From 9777d996d172755472dd8127ff9b7a3c579cf454 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 14 Jun 2025 11:01:42 +0000 Subject: refactor: enhance PostElement structure and update blog schema - Wrapped the post link in an
tag for improved semantic structure. - Updated blogSchema to include posts for better structured data representation. - Adjusted the blog index to utilize the new posts parameter for enhanced SEO. --- src/utils/schemas/blogSchema.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/utils') diff --git a/src/utils/schemas/blogSchema.ts b/src/utils/schemas/blogSchema.ts index 7ff84d8..54e2fca 100644 --- a/src/utils/schemas/blogSchema.ts +++ b/src/utils/schemas/blogSchema.ts @@ -1,13 +1,24 @@ -import type { WithContext, Blog } from "schema-dts"; +import type { WithContext, CollectionPage } from "schema-dts"; +import type { CollectionEntry } from "astro:content"; export type BlogSchemaParams = { readonly siteUrl: string; readonly title: string; + readonly posts: CollectionEntry<"blog">[]; }; -export default ({ siteUrl, title }: BlogSchemaParams): WithContext => ({ +export default ({ siteUrl, title, posts }: BlogSchemaParams): WithContext => ({ "@context": "https://schema.org", - "@type": "Blog", + "@type": "CollectionPage", "url": new URL("/blog/", siteUrl).toString(), "name": title, + "mainEntity": { + "@type": "ItemList", + "itemListElement": posts.map((post, index) => ({ + "@type": "ListItem", + "position": index + 1, + "url": new URL(`/blog/${post.slug}`, siteUrl).toString(), + "name": post.data.title, + })), + }, }); -- cgit v1.2.3