Skip to content

Commit 2e9ce1d

Browse files
committed
fix: updated schema for manage content
1 parent 7d77c41 commit 2e9ce1d

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

src/content.config.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,29 @@ export const seoSchemaWithoutImage = z.object({
88
type: z.string().optional(),
99
keywords: z.string().optional(),
1010
canonicalUrl: z.string().optional(),
11-
twitter: z.object({
12-
creator: z.string().optional(),
13-
}).optional(),
11+
twitter: z
12+
.object({
13+
creator: z.string().optional(),
14+
})
15+
.optional(),
1416
robots: z.string().optional(),
15-
})
17+
});
1618

1719
const seoSchema = (image: ImageFunction) =>
18-
z.object({
19-
image: image().optional(),
20-
}).merge(seoSchemaWithoutImage);
20+
z
21+
.object({
22+
image: image().optional(),
23+
})
24+
.merge(seoSchemaWithoutImage);
2125

2226
const pageCollection = defineCollection({
2327
loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: './src/content/pages' }),
24-
schema: ({ image }) => z.object({
25-
title: z.string(),
26-
seo: seoSchema(image),
27-
}),
28+
schema: ({ image }) =>
29+
z.object({
30+
title: z.string(),
31+
description: z.string().optional(),
32+
seo: seoSchema(image),
33+
}),
2834
});
2935

3036
const linkCollection = defineCollection({
@@ -61,12 +67,13 @@ const talkCollection = defineCollection({
6167

6268
const postCollection = defineCollection({
6369
loader: glob({ pattern: '**/[^_]*.{md,mdx}', base: './src/content/posts' }),
64-
schema: ({ image }) => z.object({
65-
title: z.string(),
66-
date: z.date(),
67-
image: image().optional(),
68-
seo: seoSchema(image),
69-
}),
70+
schema: ({ image }) =>
71+
z.object({
72+
title: z.string(),
73+
date: z.date(),
74+
image: image().optional(),
75+
seo: seoSchema(image),
76+
}),
7077
});
7178

7279
export const collections = {

0 commit comments

Comments
 (0)