feat: add umami tracking code and track events
This commit is contained in:
parent
cd3581de17
commit
aaaf100d2c
8 changed files with 36 additions and 8 deletions
|
|
@ -1 +1,3 @@
|
||||||
# todo
|
## todo
|
||||||
|
|
||||||
|
[](https://app.netlify.com/sites/blog-air/deploys)
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
const currentYear = new Date().getFullYear()
|
const currentYear = new Date().getFullYear()
|
||||||
---
|
---
|
||||||
|
|
||||||
<footer class="relative z-10 my-10 flex flex-wrap items-center gap-1">
|
<footer class="relative z-10 flex flex-wrap items-center gap-1 py-10">
|
||||||
<p>© {currentYear}</p>
|
<p>© {currentYear}</p>
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -24,6 +24,7 @@ const currentYear = new Date().getFullYear()
|
||||||
<a
|
<a
|
||||||
href={item.link}
|
href={item.link}
|
||||||
class="text-blue-500 transition-colors duration-200 hover:text-blue-700"
|
class="text-blue-500 transition-colors duration-200 hover:text-blue-700"
|
||||||
|
data-umami-event={`footer-${item.label}`}
|
||||||
>
|
>
|
||||||
{item.label}
|
{item.label}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
|
|
@ -10,21 +10,26 @@ const config = lang === "zh" ? zh : en
|
||||||
---
|
---
|
||||||
|
|
||||||
<header class="flex h-24 w-full items-center justify-between">
|
<header class="flex h-24 w-full items-center justify-between">
|
||||||
<a href="/">
|
<a href="/" data-umami-event="site-name">
|
||||||
<div class="text-2xl font-semibold">{config.siteName}</div>
|
<div class="text-2xl font-semibold">{config.siteName}</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="flex items-center gap-6">
|
<div class="flex items-center gap-6">
|
||||||
{
|
{
|
||||||
config.rss && (
|
config.rss && (
|
||||||
<a href="/atom.xml" target="_blank">
|
<a href="/atom.xml" target="_blank" data-umami-event="rss">
|
||||||
<Rss />
|
<Rss />
|
||||||
</a>
|
</a>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
config.social.map((social) => (
|
config.social.map((social) => (
|
||||||
<a href={social.link} target="_blank" class="hidden md:block">
|
<a
|
||||||
|
href={social.link}
|
||||||
|
target="_blank"
|
||||||
|
class="hidden md:block"
|
||||||
|
data-umami-event={social.label}
|
||||||
|
>
|
||||||
<social.icon />
|
<social.icon />
|
||||||
</a>
|
</a>
|
||||||
))
|
))
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,11 @@ const { home, archive, custom, about } =
|
||||||
<div class="mb-10 mt-4 flex gap-4 overflow-x-auto whitespace-nowrap text-lg">
|
<div class="mb-10 mt-4 flex gap-4 overflow-x-auto whitespace-nowrap text-lg">
|
||||||
{
|
{
|
||||||
home && (
|
home && (
|
||||||
<a href={`/${lang}`} class="hover:underline hover:underline-offset-4">
|
<a
|
||||||
|
href={`/${lang}`}
|
||||||
|
class="hover:underline hover:underline-offset-4"
|
||||||
|
data-umami-event="nav-home"
|
||||||
|
>
|
||||||
<p>{t("nav.home")}</p>
|
<p>{t("nav.home")}</p>
|
||||||
</a>
|
</a>
|
||||||
)
|
)
|
||||||
|
|
@ -22,6 +26,7 @@ const { home, archive, custom, about } =
|
||||||
<a
|
<a
|
||||||
href={`/${lang}/archive`}
|
href={`/${lang}/archive`}
|
||||||
class="hover:underline hover:underline-offset-4"
|
class="hover:underline hover:underline-offset-4"
|
||||||
|
data-umami-event="nav-archive"
|
||||||
>
|
>
|
||||||
<p>{t("nav.archive")}</p>
|
<p>{t("nav.archive")}</p>
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -33,6 +38,7 @@ const { home, archive, custom, about } =
|
||||||
href={tab.link}
|
href={tab.link}
|
||||||
class="hover:underline hover:underline-offset-4"
|
class="hover:underline hover:underline-offset-4"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
data-umami-event={`nav-${tab.label}`}
|
||||||
>
|
>
|
||||||
<p>{tab.label}</p>
|
<p>{tab.label}</p>
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -43,6 +49,7 @@ const { home, archive, custom, about } =
|
||||||
<a
|
<a
|
||||||
href={`/${lang}/about`}
|
href={`/${lang}/about`}
|
||||||
class="hover:underline hover:underline-offset-4"
|
class="hover:underline hover:underline-offset-4"
|
||||||
|
data-umami-event="nav-about"
|
||||||
>
|
>
|
||||||
<p>{t("nav.about")}</p>
|
<p>{t("nav.about")}</p>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import { formatDate } from "~/utils"
|
||||||
|
|
||||||
<a
|
<a
|
||||||
href={`/${lang}/posts/${post.id}/`}
|
href={`/${lang}/posts/${post.id}/`}
|
||||||
|
data-umami-event={`post-${post.id}`}
|
||||||
class="my-3 flex visited:text-purple-500/90 md:my-2"
|
class="my-3 flex visited:text-purple-500/90 md:my-2"
|
||||||
>
|
>
|
||||||
<p
|
<p
|
||||||
|
|
|
||||||
|
|
@ -11,5 +11,11 @@ export function LanguageToggle() {
|
||||||
window.location.href = newPath
|
window.location.href = newPath
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Languages className="cursor-pointer" onClick={handleLanguageToggle} />
|
return (
|
||||||
|
<Languages
|
||||||
|
className="cursor-pointer"
|
||||||
|
data-umami-event="language-toggle"
|
||||||
|
onClick={handleLanguageToggle}
|
||||||
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ export function ThemeToggle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button onClick={handleToggleClick}>
|
<button onClick={handleToggleClick} data-umami-event="theme-toggle">
|
||||||
<Sun className="dark:hidden" />
|
<Sun className="dark:hidden" />
|
||||||
<Moon className="hidden dark:block" />
|
<Moon className="hidden dark:block" />
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,12 @@ const config = lang === "zh" ? zh.meta : en.meta
|
||||||
setTheme()
|
setTheme()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script
|
||||||
|
defer
|
||||||
|
src="https://umami.guoqi.dev/script.js"
|
||||||
|
data-website-id="3cd55e92-cb53-4254-a97d-24441b08d7c3"
|
||||||
|
data-domains="astro-air.netlify.app"></script>
|
||||||
</head>
|
</head>
|
||||||
<body
|
<body
|
||||||
class="flex min-h-screen w-full justify-center px-6 dark:bg-[#121212] dark:text-white md:px-0"
|
class="flex min-h-screen w-full justify-center px-6 dark:bg-[#121212] dark:text-white md:px-0"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue