mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
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:
+13
-11
@@ -1,15 +1,17 @@
|
|||||||
import { z } from "astro:content";
|
import { z } from "astro:content";
|
||||||
|
|
||||||
export const blogSchema = z.object({
|
export const blogSchema = z
|
||||||
author: z.string().optional(),
|
.object({
|
||||||
pubDatetime: z.date(),
|
author: z.string().optional(),
|
||||||
title: z.string(),
|
pubDatetime: z.date(),
|
||||||
postSlug: z.string().optional(),
|
title: z.string(),
|
||||||
featured: z.boolean().optional(),
|
postSlug: z.string().optional(),
|
||||||
draft: z.boolean().optional(),
|
featured: z.boolean().optional(),
|
||||||
tags: z.array(z.string()).default(["others"]),
|
draft: z.boolean().optional(),
|
||||||
ogImage: z.string().optional(),
|
tags: z.array(z.string()).default(["others"]),
|
||||||
description: z.string(),
|
ogImage: z.string().optional(),
|
||||||
});
|
description: z.string(),
|
||||||
|
})
|
||||||
|
.strict();
|
||||||
|
|
||||||
export type BlogFrontmatter = z.infer<typeof blogSchema>;
|
export type BlogFrontmatter = z.infer<typeof blogSchema>;
|
||||||
|
|||||||
Reference in New Issue
Block a user