mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 19:41:02 +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:
@@ -1,6 +1,7 @@
|
|||||||
import { z } from "astro:content";
|
import { z } from "astro:content";
|
||||||
|
|
||||||
export const blogSchema = z.object({
|
export const blogSchema = z
|
||||||
|
.object({
|
||||||
author: z.string().optional(),
|
author: z.string().optional(),
|
||||||
pubDatetime: z.date(),
|
pubDatetime: z.date(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
@@ -10,6 +11,7 @@ export const blogSchema = z.object({
|
|||||||
tags: z.array(z.string()).default(["others"]),
|
tags: z.array(z.string()).default(["others"]),
|
||||||
ogImage: z.string().optional(),
|
ogImage: z.string().optional(),
|
||||||
description: z.string(),
|
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