fix: make schema(s) strict (#23)

If schema(s) are made with strict, it will disallow extra keys in the markdown frontmatter.
This commit is contained in:
Sha Mwe La
2023-02-01 12:13:41 +06:30
committed by GitHub
parent 920046f389
commit dc026b38de
+13 -11
View File
@@ -1,15 +1,17 @@
import { z } from "astro:content";
export const blogSchema = z.object({
author: z.string().optional(),
pubDatetime: z.date(),
title: z.string(),
postSlug: z.string().optional(),
featured: z.boolean().optional(),
draft: z.boolean().optional(),
tags: z.array(z.string()).default(["others"]),
ogImage: z.string().optional(),
description: z.string(),
});
export const blogSchema = z
.object({
author: z.string().optional(),
pubDatetime: z.date(),
title: z.string(),
postSlug: z.string().optional(),
featured: z.boolean().optional(),
draft: z.boolean().optional(),
tags: z.array(z.string()).default(["others"]),
ogImage: z.string().optional(),
description: z.string(),
})
.strict();
export type BlogFrontmatter = z.infer<typeof blogSchema>;