1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-27 17:30:28 -04:00
jarv.is/pages/notes/index.tsx

37 lines
841 B
TypeScript

import { NextSeo } from "next-seo";
import { format } from "date-fns";
import List from "../../components/notes/List";
import { getAllNotes } from "../../lib/parse-notes";
import type { GetStaticProps } from "next";
const Notes = ({ notesByYear }) => (
<>
<NextSeo
title="Notes"
description="Recent posts by Jake Jarvis."
openGraph={{
title: "Notes",
}}
/>
<List notesByYear={notesByYear} />
</>
);
export const getStaticProps: GetStaticProps = async () => {
// parse the year of each note and group them together
const notesByYear = {};
getAllNotes().map((note) => {
const year = parseInt(format(new Date(note.date), "yyyy"));
(notesByYear[year] || (notesByYear[year] = [])).push(note);
});
return {
props: {
notesByYear,
},
};
};
export default Notes;