Merge branch 'feat/events-year' into feat/events-term

This commit is contained in:
Jared He 2021-08-18 10:37:51 -05:00
commit e0c446b747
5 changed files with 97 additions and 1 deletions

2
.gitignore vendored
View File

@ -22,4 +22,4 @@
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn-error.log*

View File

View File

View File

@ -0,0 +1,69 @@
import React from "react";
import { Link } from "../../../components/Link";
import { getEventYears, getEventTermsByYear } from "../../../lib/events";
import styles from "./year.module.css";
export async function getStaticPaths(): Promise<{
paths: {
params: {
year: string;
};
}[];
fallback: boolean;
}> {
const years = await getEventYears();
const paths = years.map((curYear) => ({
params: { year: curYear },
}));
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 getEventTermsByYear(context.params.year),
},
};
}
interface Props {
year: string;
terms: string[];
}
const Year = (props: Props) => {
return (
<div className={styles.main}>
<h2 className={styles.heading2}>
Events Archive:<span className={styles.blue}>{` ${props.year}`}</span>
</h2>
<hr />
<div className={styles.links}>
{props.terms.map((term) => (
<Link key={term} href={`/events/${props.year}/${term}`}>
{`${term.charAt(0).toUpperCase()}${term.slice(1)}`}
</Link>
))}
</div>
</div>
);
};
export default Year;

View File

@ -0,0 +1,27 @@
.main {
margin: auto;
margin-top: 7rem;
margin-bottom: 14rem;
width: 50rem;
}
.heading2 {
font-weight: 700;
font-size: 2.25rem;
color: var(--primary-heading);
}
.blue {
color: var(--primary-accent)
}
.links {
display: flex;
flex-direction: column;
}
.links > * {
font-weight: 400;
font-size: 16px;
margin-top: 30px;
}