mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-11-20 19:20:50 -05:00
fs -> fs/promises -> asyncify all note parsing
This commit is contained in:
@@ -98,7 +98,7 @@ const incrementPageHits = async (slug: string | string[], client: faunadb.Client
|
||||
};
|
||||
|
||||
const getSiteStats = async (client: faunadb.Client) => {
|
||||
const notes = getAllNotes();
|
||||
const notes = await getAllNotes();
|
||||
const q = faunadb.query;
|
||||
|
||||
const { data: pages }: { data: PageStats[] } = await client.query(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||
];
|
||||
|
||||
// push notes separately and use their metadata
|
||||
const notes = getAllNotes();
|
||||
const notes = await getAllNotes();
|
||||
notes.map((note) =>
|
||||
pages.push({
|
||||
loc: urlJoin("/notes/", note.slug, "/"),
|
||||
|
||||
Reference in New Issue
Block a user