fix: corrects git date fetching after moving content location
This commit is contained in:
parent
077cbf2e75
commit
705a5a39f3
3 changed files with 10 additions and 5 deletions
|
|
@ -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,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ body {
|
|||
max-width: 38rem;
|
||||
margin: 0 auto;
|
||||
padding: 1rem;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
img {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue