mirror of
https://github.com/valentineus/popov.link.git
synced 2025-07-03 16:10:26 +03:00
- Added optional `basedOn` field to blog post schema for better content attribution. - Updated blog post markdown to include `basedOn` reference for improved context. - Refactored page schema to replace deprecated website schema, enhancing structured data representation. - Adjusted 404 and index pages to utilize the new page schema for consistency and SEO improvements.
27 lines
816 B
TypeScript
27 lines
816 B
TypeScript
import type { WithContext, CollectionPage } from "schema-dts";
|
|
import type { CollectionEntry } from "astro:content";
|
|
|
|
export type BlogSchemaParams = {
|
|
readonly posts: CollectionEntry<"blog">[];
|
|
readonly siteUrl: string;
|
|
readonly title: string;
|
|
};
|
|
|
|
export default ({ siteUrl, title, posts }: BlogSchemaParams): WithContext<CollectionPage> => ({
|
|
"@context": "https://schema.org",
|
|
"@type": "CollectionPage",
|
|
"url": new URL("/blog/", siteUrl).toString(),
|
|
"name": title,
|
|
"mainEntity": {
|
|
"@type": "ItemList",
|
|
"itemListOrder": "https://schema.org/ItemListOrderDescending",
|
|
"numberOfItems": posts.length,
|
|
"itemListElement": posts.map((post, index) => ({
|
|
"@type": "ListItem",
|
|
"position": index + 1,
|
|
"url": new URL(`/blog/${post.slug}`, siteUrl).toString(),
|
|
"name": post.data.title,
|
|
})),
|
|
},
|
|
});
|