diff options
Diffstat (limited to 'src/utils/schemas/blogPostSchema.ts')
-rw-r--r-- | src/utils/schemas/blogPostSchema.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/utils/schemas/blogPostSchema.ts b/src/utils/schemas/blogPostSchema.ts new file mode 100644 index 0000000..b20f248 --- /dev/null +++ b/src/utils/schemas/blogPostSchema.ts @@ -0,0 +1,21 @@ +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, + }, +}); |