- header.ts now imports and re-exports functions from search.ts and theme.ts for use in the header template - Functions available via x-data=header: - initializeSearch - initializeTheme - changeTheme - changeWoodPaneling - loadWoodPaneling - updateWoodPanelingIndicators - header.templ x-init calls these functions directly - Enables proper SSR-first pattern with x-init for setup only
30 lines
569 B
TypeScript
30 lines
569 B
TypeScript
// Header functionality
|
|
|
|
import { Alpine } from "./alpine";
|
|
import { initializeSearch } from "./search";
|
|
import {
|
|
initializeTheme,
|
|
changeTheme,
|
|
changeWoodPaneling,
|
|
loadWoodPaneling,
|
|
updateWoodPanelingIndicators,
|
|
} from "./theme";
|
|
|
|
const logout = (): void => {
|
|
localStorage.removeItem("token");
|
|
localStorage.removeItem("user");
|
|
window.location.href = "/";
|
|
};
|
|
|
|
export { logout };
|
|
|
|
Alpine.data("header", () => ({
|
|
logout,
|
|
initializeSearch,
|
|
initializeTheme,
|
|
changeTheme,
|
|
changeWoodPaneling,
|
|
loadWoodPaneling,
|
|
updateWoodPanelingIndicators,
|
|
}));
|