mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
feat: add image validation to schema
This commit is contained in:
+17
-12
@@ -2,18 +2,23 @@ import { defineCollection, z } from "astro:content";
|
|||||||
|
|
||||||
const blog = defineCollection({
|
const blog = defineCollection({
|
||||||
type: "content",
|
type: "content",
|
||||||
schema: z.object({
|
schema: ({ image }) =>
|
||||||
author: z.string().optional(),
|
z.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: image()
|
||||||
canonicalURL: z.string().optional(),
|
.refine(img => img.width >= 1200 && img.height >= 630, {
|
||||||
}),
|
message: "OpenGraph image must be at least 1200 X 630 pixels!",
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
description: z.string(),
|
||||||
|
canonicalURL: z.string().optional(),
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const collections = { blog };
|
export const collections = { blog };
|
||||||
|
|||||||
Reference in New Issue
Block a user