From 3ed545b9ca5956d13f3d60ef841d3e803950cbea Mon Sep 17 00:00:00 2001 From: babayaga Date: Thu, 21 Aug 2025 23:06:47 +0200 Subject: [PATCH] site2 refactor --- .../components/ArticleStructuredData.astro | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 packages/polymech/src/components/ArticleStructuredData.astro diff --git a/packages/polymech/src/components/ArticleStructuredData.astro b/packages/polymech/src/components/ArticleStructuredData.astro new file mode 100644 index 0000000..f7adcce --- /dev/null +++ b/packages/polymech/src/components/ArticleStructuredData.astro @@ -0,0 +1,43 @@ +--- +import config from "@/app/config.json" +import { get } from "@/model/registry.js" +import { default_image } from "@/app/config.js" + +const { frontmatter } = Astro.props +const title = frontmatter?.title || config.site.title +const pageUrl = new URL(Astro.url.pathname, Astro.site) +const image = frontmatter ? frontmatter.image || default_image() : default_image() + +const itemData = frontmatter ? await get("json-ld", {} as any, frontmatter, +{ + url: pageUrl.href, +}) : null + +const meta = config.metadata || { } + +let data = itemData || { + "@context": "https://schema.org", + "@type": "Article", + headline: title, + description: frontmatter?.description || meta.description, + //datePublished: createdAt?.toISOString(), + //dateModified: updatedAt?.toISOString() ?? undefined, + url: pageUrl, + thumbnailUrl: image, + image: { + "@type": "ImageObject", + url: image.src || "", + caption: image.alt, + width: image.width, + height: image.height, + }, + author: { + "@type": "Person", + name: meta.author, + description: meta.author_bio, + url: meta.author_url + } +} +--- + +