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
|
|
@ -12,11 +12,13 @@ this site is very simple and i've set myself some arbitrary rules for it. i've b
|
|||
|
||||
in terms of routes: there's one massive [index](https://wynne.rs) of everything on the site, and each bit of text gets its own page
|
||||
|
||||
:right[anything that takes more than a few seconds to read gets a proper page, and the short stuff, like my [cv.txt](https://wynne.rs/cv.txt), is just a plain txt file]
|
||||
:right[anything that takes more than a few seconds to read gets a proper page, and the short stuff, like my [cv](https://wynne.rs/cv.txt), is just a plain txt file]
|
||||
|
||||
right now, *just* and *has* are params for filtering—[?just=guestbook](https://wynne.rs/?just=guestbook) hides anything not in the guestbook category, and [?has=hello](https://wynne.rs/?has=hello) hides anything not including "hello"—and *do* does some kind of one-off action, like [?do=random](https://wynne.rs/?do=random) which takes you to a random page or [?do=newest](https://wynne.rs/?do=newest) to go to the newest addition
|
||||
|
||||
:left[the [manpage](https://wynne.rs/man.txt) exists as an up-to-date reference for search params and their usage]
|
||||
|
||||
and that's it. i don't need anything else to archive things i care about
|
||||
|
||||
cheers,
|
||||
cheers,
|
||||
lewis x
|
||||
|
|
|
|||
|
|
@ -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