fix: corrects git date fetching after moving content location

This commit is contained in:
Lewis Wynne 2026-03-26 19:19:31 +00:00
parent 077cbf2e75
commit 705a5a39f3
3 changed files with 10 additions and 5 deletions

View file

@ -15,17 +15,19 @@ export function getSlug(postId: string): string {
}
function getPostFilePath(post: Post): string {
return path.join(process.cwd(), 'src/content/md', `${post.id}.md`);
return path.join(process.cwd(), 'content', `${post.id}.md`);
}
export function enrichPostWithDates(post: Post): PostWithDates {
const filePath = getPostFilePath(post);
const gitDates = getGitDates(filePath);
const created = post.data.date ?? gitDates.created;
const updated = post.data.updated ?? gitDates.updated;
return {
...post,
dates: {
created: post.data.date ?? gitDates.created,
updated: gitDates.updated,
created,
updated: updated && updated.getTime() !== created.getTime() ? updated : null,
},
};
}

View file

@ -3,6 +3,7 @@ body {
max-width: 38rem;
margin: 0 auto;
padding: 1rem;
text-align: justify;
}
img {