0
mirror of https://github.com/valentineus/popov.link.git synced 2025-07-04 00:20:26 +03:00
Files
popov.link/src/utils/schemas/blogPostSchema.ts

31 lines
843 B
TypeScript
Raw Normal View History

import type { WithContext, BlogPosting } from "schema-dts";
export type BlogPostSchemaParams = {
readonly siteUrl: string;
readonly title: string;
readonly description: string;
readonly slug: string;
readonly datePublished: string;
readonly author: string;
readonly lang: string;
};
export default ({ siteUrl, title, description, slug, datePublished, author, lang }: BlogPostSchemaParams): WithContext<BlogPosting> => ({
"@context": "https://schema.org",
"@type": "BlogPosting",
"url": new URL(`/blog/${slug}`, siteUrl).toString(),
"headline": title,
"description": description,
"datePublished": datePublished,
"dateModified": datePublished,
"inLanguage": lang,
"author": {
"@type": "Person",
"name": author,
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": new URL(`/blog/${slug}`, siteUrl).toString(),
},
});