2025-06-11 23:20:36 +00:00
|
|
|
import type { WithContext, BlogPosting } from "schema-dts";
|
|
|
|
|
|
|
|
export type BlogPostSchemaParams = {
|
|
|
|
readonly author: string;
|
2025-06-14 11:25:17 +00:00
|
|
|
readonly dateModified: string;
|
|
|
|
readonly datePublished: string;
|
|
|
|
readonly description: string;
|
2025-06-14 11:09:34 +00:00
|
|
|
readonly lang: string;
|
2025-06-14 11:25:17 +00:00
|
|
|
readonly siteUrl: string;
|
|
|
|
readonly slug: string;
|
|
|
|
readonly title: string;
|
2025-06-11 23:20:36 +00:00
|
|
|
};
|
|
|
|
|
2025-06-14 11:25:17 +00:00
|
|
|
export default ({ siteUrl, slug, title, description, datePublished, dateModified, author, lang }: BlogPostSchemaParams): WithContext<BlogPosting> => ({
|
2025-06-11 23:20:36 +00:00
|
|
|
"@context": "https://schema.org",
|
|
|
|
"@type": "BlogPosting",
|
|
|
|
"url": new URL(`/blog/${slug}`, siteUrl).toString(),
|
|
|
|
"headline": title,
|
2025-06-14 11:09:34 +00:00
|
|
|
"description": description,
|
2025-06-11 23:20:36 +00:00
|
|
|
"datePublished": datePublished,
|
2025-06-14 11:25:17 +00:00
|
|
|
"dateModified": dateModified,
|
2025-06-14 11:09:34 +00:00
|
|
|
"inLanguage": lang,
|
2025-06-11 23:20:36 +00:00
|
|
|
"author": {
|
|
|
|
"@type": "Person",
|
|
|
|
"name": author,
|
|
|
|
},
|
2025-06-14 11:09:34 +00:00
|
|
|
"mainEntityOfPage": {
|
|
|
|
"@type": "WebPage",
|
|
|
|
"@id": new URL(`/blog/${slug}`, siteUrl).toString(),
|
|
|
|
},
|
2025-06-11 23:20:36 +00:00
|
|
|
});
|