diff --git a/.gitignore b/.gitignore index 238e770b..73b8ad4b 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,6 @@ # debug npm-debug.log* yarn-debug.log* -yarn-error.log* \ No newline at end of file +yarn-error.log* + +content/events \ No newline at end of file diff --git a/pages/events/[year]/index.tsx b/pages/events/[year]/index.tsx new file mode 100644 index 00000000..cbc33aa0 --- /dev/null +++ b/pages/events/[year]/index.tsx @@ -0,0 +1,68 @@ +import React from "react"; +import { getYears, getTermsByYear } from "../../../lib/events"; +import styles from "./year.module.css"; +import { Link } from "../../../components/Link"; + +export async function getStaticPaths(): Promise<{ + paths: { + params: { + year: string; + }; + }[]; + fallback: boolean; +}> { + const years = await getYears(); + const paths = years.map((curYear) => ({ + params: { year: curYear }, + })); + console.log(paths); + return { + paths: paths, + fallback: false, + }; +} + +interface Context { + params: { + year: string; + }; +} + +export async function getStaticProps(context: Context): Promise<{ + props: { + year: string; + terms: string[]; + }; +}> { + return { + props: { + year: context.params.year, + terms: await getTermsByYear(context.params.year), + }, + }; +} + +interface Props { + year: string; + terms: string[]; +} + +const Year = (props: Props) => { + return ( +