1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-03 14:26:41 -04:00

fs -> fs/promises -> asyncify all note parsing

This commit is contained in:
2022-04-26 17:22:44 -04:00
parent 36e0835947
commit a3870a15db
6 changed files with 31 additions and 21 deletions

View File

@ -86,7 +86,8 @@ export const getStaticProps: GetStaticProps = async ({ params }: { params: Pick<
};
export const getStaticPaths: GetStaticPaths = async () => {
const paths = getNoteSlugs().map((slug) => ({ params: { slug } }));
const slugs = await getNoteSlugs();
const paths = slugs.map((slug) => ({ params: { slug } }));
return {
paths,

View File

@ -22,9 +22,10 @@ const Notes = ({ notesByYear }: NotesListProps) => (
export const getStaticProps: GetStaticProps = async () => {
// parse the year of each note and group them together
const notes = await getAllNotes();
const notesByYear: NotesListProps["notesByYear"] = {};
getAllNotes().map((note) => {
notes.map((note) => {
const year = new Date(note.date).getUTCFullYear();
(notesByYear[year] || (notesByYear[year] = [])).push(note);
});