diff --git a/www/src/content.config.ts b/www/src/content.config.ts index 5836c2c..a1e3299 100644 --- a/www/src/content.config.ts +++ b/www/src/content.config.ts @@ -7,6 +7,7 @@ const md = defineCollection({ loader: glob({ pattern: '**/*.md', base: './src/content/md' }), schema: z.object({ title: z.string(), + date: z.coerce.date().optional(), pinned: z.boolean().optional(), category: z.string().optional(), draft: z.boolean().optional(), diff --git a/www/src/lib/md.ts b/www/src/lib/md.ts index 4695519..da1c497 100644 --- a/www/src/lib/md.ts +++ b/www/src/lib/md.ts @@ -19,9 +19,13 @@ function getPostFilePath(post: Post): string { export function enrichPostWithDates(post: Post): PostWithDates { const filePath = getPostFilePath(post); + const gitDates = getGitDates(filePath); return { ...post, - dates: getGitDates(filePath), + dates: { + created: post.data.date ?? gitDates.created, + updated: gitDates.updated, + }, }; }