feat: 新增分类

This commit is contained in:
KazooTTT
2025-02-05 21:30:41 +08:00
parent 1f239d3205
commit fc91e1e390
12 changed files with 323 additions and 108 deletions

View File

@ -6,7 +6,7 @@ function removeDupsAndLowerCase(array: string[]) {
}
const baseSchema = z.object({
title: z.string()
title: z.string(),
});
const post = defineCollection({
@ -20,6 +20,8 @@ const post = defineCollection({
categories: z.array(z.string()).default([]).transform(removeDupsAndLowerCase),
date: z.union([z.string(), z.date()]).transform((val) => new Date(val)),
date_modified: z.date().optional(),
data_created: z.date().optional(),
category: z.string().optional().nullable(),
}),
});
@ -28,9 +30,10 @@ const note = defineCollection({
schema: baseSchema.extend({
description: z.string().optional().nullable(),
date: z.union([z.string(), z.date()]).transform((val) => new Date(val)),
date_modified: z.date().optional(),
data_created: z.date().optional(),
tags: z.array(z.string()).default([]).transform(removeDupsAndLowerCase),
}),
});
export const collections = { post, note };