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 &&