feat: manual date takes precedence over git date

This commit is contained in:
Lewis Wynne 2026-01-31 23:59:24 +00:00
parent 97bfb2c3a6
commit 23d34ae3ab
2 changed files with 6 additions and 1 deletions

View file

@ -7,6 +7,7 @@ const md = defineCollection({
loader: glob({ pattern: '**/*.md', base: './src/content/md' }), loader: glob({ pattern: '**/*.md', base: './src/content/md' }),
schema: z.object({ schema: z.object({
title: z.string(), title: z.string(),
date: z.coerce.date().optional(),
pinned: z.boolean().optional(), pinned: z.boolean().optional(),
category: z.string().optional(), category: z.string().optional(),
draft: z.boolean().optional(), draft: z.boolean().optional(),

View file

@ -19,9 +19,13 @@ function getPostFilePath(post: Post): string {
export function enrichPostWithDates(post: Post): PostWithDates { export function enrichPostWithDates(post: Post): PostWithDates {
const filePath = getPostFilePath(post); const filePath = getPostFilePath(post);
const gitDates = getGitDates(filePath);
return { return {
...post, ...post,
dates: getGitDates(filePath), dates: {
created: post.data.date ?? gitDates.created,
updated: gitDates.updated,
},
}; };
} }