import { ParsedUrlQuery } from "querystring";
import { GetStaticPaths, GetStaticProps } from "next";
import React from "react";
import { Link } from "@/components/Link";
import { Title } from "@/components/Title";
import { getEventYears, getEventTermsByYear } from "@/lib/events";
import { Term } from "@/utils";
import styles from "./index.module.css";
interface Props {
year: string;
terms: Term[];
}
export default function Year(props: Props) {
return (
{["Events", props.year]}
Events Archive:{` ${props.year}`}
{props.terms.map((term) => (
-
{`${term.charAt(0).toUpperCase()}${term.slice(1)}`}
))}
);
}
interface Params extends ParsedUrlQuery {
year: string;
}
export const getStaticProps: GetStaticProps = async (
context
) => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const { year } = context.params!;
return {
props: {
year: year,
terms: await getEventTermsByYear(year),
},
};
};
export const getStaticPaths: GetStaticPaths = async () => {
const years = await getEventYears();
const paths = years.map((curYear) => ({
params: { year: curYear },
}));
return {
paths: paths,
fallback: false,
};
};