From 0ef916bf56d2e4aefca20c4c90f1a75a6e1a7be4 Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Sun, 2 Aug 2026 17:23:32 -0500 Subject: [PATCH] feat: add structured product metadata --- src/layouts/Base.astro | 39 ++++++++++++++++++++++++++++++++++++--- src/pages/index.astro | 32 +++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index 1028aca..d2e9c43 100644 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -3,20 +3,40 @@ import Header from '../components/Header.astro'; import Footer from '../components/Footer.astro'; import '../styles/global.css'; +type OpenGraphType = 'website' | 'article'; +type StructuredData = Record; + interface Props { title?: string; description?: string; image?: string; + ogType?: OpenGraphType; + robots?: string; + publishedTime?: Date; + updatedTime?: Date; + author?: string; + tags?: string[]; + structuredData?: StructuredData; } const { title = 'Green Tea — A zen, type-safe graph-pipeline HTTP framework', description = 'Green Tea is a graph-pipeline HTTP framework: declare what you need, not the order to build it. Runtime-agnostic, type-safe, calm by design.', image = '/og.png', + ogType = 'website', + robots = 'index, follow', + publishedTime, + updatedTime, + author, + tags, + structuredData, } = Astro.props; -const canonicalURL = new URL(Astro.url.pathname, Astro.site); -const ogImageURL = new URL(image, Astro.site); +const canonicalURL = new URL(Astro.url.pathname, Astro.site).toString(); +const ogImageURL = new URL(image, Astro.site).toString(); +const serializedStructuredData = structuredData + ? JSON.stringify(structuredData).replace(/ @@ -29,13 +49,24 @@ const ogImageURL = new URL(image, Astro.site); {title} + - + + { + ogType === 'article' && ( + <> + {publishedTime && } + {updatedTime && } + {author && } + {tags?.map((tag) => )} + + ) + } @@ -43,6 +74,8 @@ const ogImageURL = new URL(image, Astro.site); + {serializedStructuredData &&