11---
2- // Import the global.css file here so that it is included on
3- // all pages through the use of the <BaseHead /> component.
42import " ../styles/sparkstack_globals.css" ;
53import " @/styles/sparkstack_globals.css" ;
64import " ../env.d.ts" ;
7-
5+ import { themeScript } from " ../lib/theme-script " ;
86import { ClientRouter } from " astro:transitions" ;
7+
98interface Props {
109 title: string ;
1110 description: string ;
1211 image? : string ;
1312}
1413
1514const canonicalURL = new URL (Astro .url .pathname , Astro .site );
16-
1715const { title, description, image = " /blog-placeholder-1.jpg" } = Astro .props ;
1816---
1917
@@ -22,12 +20,13 @@ const { title, description, image = "/blog-placeholder-1.jpg" } = Astro.props;
2220<meta name =" viewport" content =" width=device-width,initial-scale=1" />
2321<link rel =" icon" type =" image/svg+xml" href =" /favicon.svg" />
2422<meta name =" generator" content ={ Astro .generator } />
23+ <ClientRouter />
2524
2625<!-- Font preloads -->
27- <!-- <link rel="preload" href="/fonts/fonts/complete/TT_Hoves_Pro_Variable.woff" as="font" type="font/woff" crossorigin /> -->
28- <!-- <link rel="preload" href="/fonts/atkinson-bold.woff" as="font" type="font/woff" crossorigin /> -->
2926<link href =" /fonts/fonts.css" type =" css/stylesheet" />
3027
28+ <script is:inline set:html ={ themeScript } ></script >
29+
3130<!-- Canonical URL -->
3231<link rel =" canonical" href ={ canonicalURL } />
3332
@@ -50,46 +49,3 @@ const { title, description, image = "/blog-placeholder-1.jpg" } = Astro.props;
5049<meta property =" twitter:description" content ={ description } />
5150<meta property =" twitter:image" content ={ new URL (image , Astro .url )} />
5251
53- <ClientRouter />
54-
55- <script is:inline >
56- // Theme handling
57- const getThemePreference = () => {
58- if (typeof localStorage !== "undefined" && localStorage.getItem("theme")) {
59- return localStorage.getItem("theme");
60- }
61- return window.matchMedia("(prefers-color-scheme: dark)").matches
62- ? "dark"
63- : "light";
64- };
65-
66- // Initialize theme
67- const isDark = getThemePreference() === "dark";
68- document.documentElement.classList[isDark ? "add" : "remove"]("dark");
69-
70- // Color scheme initialization
71- const initializeColorScheme = (attribute, defaultValue) => {
72- const stored = localStorage.getItem(attribute);
73- const value = stored || defaultValue;
74- localStorage.setItem(attribute, value);
75- document.documentElement.setAttribute(`data-${attribute}`, value);
76- };
77-
78- // Initialize all color schemes
79- initializeColorScheme("primary-color", "lime");
80- initializeColorScheme("gray-color", "olive");
81- initializeColorScheme("secondary-color", "mint");
82- initializeColorScheme("accent-color", "lime");
83-
84- // Theme observer
85- if (typeof localStorage !== "undefined") {
86- const observer = new MutationObserver(() => {
87- const isDark = document.documentElement.classList.contains("dark");
88- localStorage.setItem("theme", isDark ? "dark" : "light");
89- });
90- observer.observe(document.documentElement, {
91- attributes: true,
92- attributeFilter: ["class"],
93- });
94- }
95- </script >
0 commit comments