diff --git a/composables/useLocalStorage.ts b/composables/useLocalStorage.ts new file mode 100644 index 0000000..374a995 --- /dev/null +++ b/composables/useLocalStorage.ts @@ -0,0 +1,38 @@ +// composables/useLocalStorage.ts +import { ref, watchEffect } from "vue"; + +export const useLocalStorage = (key: string, defaultValue: T) => { + const state = ref(defaultValue); + + // Only run on client-side + if (process.client) { + const readValue = () => { + try { + const item = window.localStorage.getItem(key); + return item ? (JSON.parse(item) as T) : defaultValue; + } catch (error) { + console.warn(`Error reading localStorage key "${key}":`, error); + return defaultValue; + } + }; + + state.value = readValue(); + + watchEffect(() => { + try { + window.localStorage.setItem(key, JSON.stringify(state.value)); + } catch (error) { + console.warn(`Error setting localStorage key "${key}":`, error); + } + }); + + // Handle storage events from other tabs + window.addEventListener("storage", (event) => { + if (event.key === key) { + state.value = readValue(); + } + }); + } + + return state; +}; diff --git a/nuxt.config.ts b/nuxt.config.ts index 4173a0b..b653a6c 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -51,7 +51,7 @@ export default defineNuxtConfig({ nitro: { compressPublicAssets: true, prerender: { - routes: ["/haditha/about-us", "/haditha/contact-us"], // Pre-render these routes + routes: ["/haditha", "/haditha/about-us", "/haditha/contact-us"], // Pre-render these routes }, }, @@ -102,7 +102,7 @@ export default defineNuxtConfig({ dir: `./systems/${buildName.substring( 0, buildName.length - 1 - )}_ui/assets/${buildName}/font-icons`, + )}_ui/assets/${buildName}/font-icons/*.svg`, }, ], }, @@ -172,6 +172,7 @@ export default defineNuxtConfig({ "@chat": "~/systems/chat_ui", }, vite: { + assetsInclude: ['**/*.svg'], resolve: {}, // optimizeDeps: { // exclude: ["vue-demi"], diff --git a/systems/hadith_ui b/systems/hadith_ui index 05d5483..8fd63ea 160000 --- a/systems/hadith_ui +++ b/systems/hadith_ui @@ -1 +1 @@ -Subproject commit 05d548399b8d931e7e0c90abe31e96d345f01dca +Subproject commit 8fd63ea1722b6b74d6ed9472e2103eab917af6f3