1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-10-23 08:04:28 -04:00

v5: Revenge of the JavaScript 🦸 (#711)

Hugo ➡️ Next.js
This commit is contained in:
2021-12-30 08:18:41 -05:00
committed by GitHub
parent b7505fa260
commit 9979e1bf3f
577 changed files with 8019 additions and 11864 deletions

32
pages/notes/index.tsx Normal file
View File

@@ -0,0 +1,32 @@
import { format, parseISO } from "date-fns";
import groupBy from "lodash.groupby";
import Layout from "../../components/Layout";
import Container from "../../components/Container";
import List from "../../components/notes/List";
import { getAllNotes } from "../../lib/parseNotes";
import type { GetStaticProps } from "next";
export default function Notes({ allNotes }) {
return (
<>
<Layout>
<Container title="Notes" description="Recent posts by Jake Jarvis.">
<List allNotes={allNotes} />
</Container>
</Layout>
</>
);
}
export const getStaticProps: GetStaticProps = async () => {
const allNotes = getAllNotes(["date", "slug", "title"]);
// parse year of each note
allNotes.map((note: any) => (note.year = parseInt(format(parseISO(note.date), "yyyy"))));
return {
props: {
allNotes: groupBy(allNotes, "year"),
},
};
};