From 2f40cf3bce4924fe7e396db2830cd1a8120efd7c Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Tue, 30 Jun 2026 14:28:48 -0400 Subject: [PATCH] refactor(ui): enhance SEO metadata and structured data injection --- src/components/BaseHead.astro | 21 +++++++++++++++++++-- src/components/StreamPlayer.astro | 20 -------------------- src/components/TagList.astro | 2 +- src/components/YouTube.astro | 19 +++++++++++++++++++ src/components/blog/Masthead.astro | 2 ++ src/components/blog/PostPreview.astro | 16 +++++++++++++++- src/components/layout/Footer.astro | 3 ++- src/components/project/Project.astro | 13 +++++++++---- src/layouts/Base.astro | 13 +++++++++++-- src/layouts/BlogPost.astro | 23 ++++++++++++++++++++++- 10 files changed, 100 insertions(+), 32 deletions(-) delete mode 100644 src/components/StreamPlayer.astro create mode 100644 src/components/YouTube.astro diff --git a/src/components/BaseHead.astro b/src/components/BaseHead.astro index 0196911..01586a8 100644 --- a/src/components/BaseHead.astro +++ b/src/components/BaseHead.astro @@ -1,17 +1,21 @@ --- import { WEBMENTION_PINGBACK, WEBMENTION_URL } from "astro:env/client"; -import { siteConfig } from "@/site.config"; +import { siteConfig, socialLinks } from "@/site.config"; import type { SiteMeta } from "@/types"; import "@/styles/global.css"; type Props = SiteMeta; -const { articleDate, description, ogImage, title } = Astro.props; +const { articleDate, description, keywords, ogImage, schema, title } = Astro.props; const titleSeparator = "•"; const siteTitle = `${title} ${titleSeparator} ${siteConfig.title}`; const canonicalURL = new URL(Astro.url.pathname, Astro.site); const socialImageURL = new URL(ogImage ? ogImage : "/social-card.png", Astro.url).href; + +const xLink = socialLinks.find((s) => s.friendlyName === "X")?.link; +const twitterHandle = xLink ? `@${xLink.split("/").pop()}` : undefined; +const schemas = schema ? (Array.isArray(schema) ? schema : [schema]) : []; --- @@ -38,8 +42,15 @@ const socialImageURL = new URL(ogImage ? ogImage : "/social-card.png", Astro.url {/* Primary Meta Tags */} +{keywords && keywords.length > 0 && } +{/* Tell crawlers to index and allow full image/snippet/video previews */} + + {/* Open Graph / Facebook */} @@ -48,6 +59,7 @@ const socialImageURL = new URL(ogImage ? ogImage : "/social-card.png", Astro.url + { @@ -65,6 +77,11 @@ const socialImageURL = new URL(ogImage ? ogImage : "/social-card.png", Astro.url +{twitterHandle && } +{twitterHandle && } + +{/* Structured data (schema.org JSON-LD) */} +{schemas.map((s) =>