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

22 lines
583 B
TypeScript
Raw Normal View History

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