feat: Add Vercel Analytics integration and update dependencies

This commit is contained in:
2025-06-09 00:29:48 -03:00
parent 1278ac3efe
commit 486ce640b8
3 changed files with 44 additions and 30 deletions

View File

@@ -47,6 +47,7 @@
"@supabase/supabase-js": "^2.50.0", "@supabase/supabase-js": "^2.50.0",
"@types/react": "^18.3.10", "@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0", "@types/react-dom": "^18.3.0",
"@vercel/analytics": "^1.5.0",
"ai": "^4.3.16", "ai": "^4.3.16",
"astro": "^5.9.0", "astro": "^5.9.0",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",

3
pnpm-lock.yaml generated
View File

@@ -116,6 +116,9 @@ importers:
'@types/react-dom': '@types/react-dom':
specifier: ^18.3.0 specifier: ^18.3.0
version: 18.3.7(@types/react@18.3.23) version: 18.3.7(@types/react@18.3.23)
'@vercel/analytics':
specifier: ^1.5.0
version: 1.5.0(react@18.3.1)
ai: ai:
specifier: ^4.3.16 specifier: ^4.3.16
version: 4.3.16(react@18.3.1)(zod@3.23.8) version: 4.3.16(react@18.3.1)(zod@3.23.8)

View File

@@ -1,4 +1,5 @@
--- ---
import Analytics from "@vercel/analytics/astro";
interface Props { interface Props {
title: string; title: string;
} }
@@ -17,26 +18,35 @@ const { title } = Astro.props;
<title>{title}</title> <title>{title}</title>
<script is:inline> <script is:inline>
// shadcn dark mode script for Astro // shadcn dark mode script for Astro
const themeKey = 'theme'; const themeKey = "theme";
function getThemePreference() { function getThemePreference() {
if (typeof localStorage !== 'undefined' && localStorage.getItem(themeKey)) { if (
typeof localStorage !== "undefined" &&
localStorage.getItem(themeKey)
) {
return localStorage.getItem(themeKey); return localStorage.getItem(themeKey);
} }
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; return window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
} }
const isDark = getThemePreference() === 'dark'; const isDark = getThemePreference() === "dark";
document.documentElement.classList[isDark ? 'add' : 'remove']('dark'); document.documentElement.classList[isDark ? "add" : "remove"]("dark");
if (typeof localStorage !== 'undefined') { if (typeof localStorage !== "undefined") {
const observer = new MutationObserver(() => { const observer = new MutationObserver(() => {
const isDark = document.documentElement.classList.contains('dark'); const isDark = document.documentElement.classList.contains("dark");
localStorage.setItem(themeKey, isDark ? 'dark' : 'light'); localStorage.setItem(themeKey, isDark ? "dark" : "light");
});
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ["class"],
}); });
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });
} }
</script> </script>
</head> </head>
<body> <body>
<slot /> <slot />
<Analytics />
</body> </body>
</html> </html>
<style is:global> <style is:global>