From d94384bc4015d364560de9da3c0a902093082c19 Mon Sep 17 00:00:00 2001 From: KazooTTT Date: Sat, 8 Feb 2025 17:14:24 +0800 Subject: [PATCH] feat: Enhance BaseHead and Note page metadata with Google Analytics and improved description --- src/components/BaseHead.astro | 23 ++++++++++++----------- src/pages/notes/[...slug].astro | 4 +++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/BaseHead.astro b/src/components/BaseHead.astro index a70a46e..63fcb8f 100644 --- a/src/components/BaseHead.astro +++ b/src/components/BaseHead.astro @@ -89,6 +89,18 @@ const socialImageURL = new URL(ogImage ? ogImage : "/social-card.png", Astro.url + + + + - diff --git a/src/pages/notes/[...slug].astro b/src/pages/notes/[...slug].astro index 18d81a3..4cbcdc9 100644 --- a/src/pages/notes/[...slug].astro +++ b/src/pages/notes/[...slug].astro @@ -4,6 +4,7 @@ import { getCollection } from "astro:content"; import Note from "@/components/note/Note.astro"; import PageLayout from "@/layouts/Base.astro"; import type { GetStaticPaths, InferGetStaticPropsType } from "astro"; +import { siteConfig } from "@/site.config"; // if you're using an adaptor in SSR mode, getStaticPaths wont work -> https://docs.astro.build/en/guides/routing/#modifying-the-slug-example-for-ssr export const getStaticPaths = (async () => { @@ -20,7 +21,8 @@ const { note } = Astro.props; const meta = { description: - note.data.description || `Read about my note posted on: ${note.data.date.toLocaleDateString()}`, + note.data.description || + `Read about my note posted on ${siteConfig.title} (${siteConfig.description}) at ${note.data.date.toLocaleDateString()} by ${siteConfig.author}`, title: note.data.title, tags: note.data.tags.join(", "), };