add order

This commit is contained in:
Jared He 2021-08-16 22:43:02 -05:00
parent c4a8ccf68d
commit cbbd5d4ad5
3 changed files with 9 additions and 6 deletions

View File

@ -6,15 +6,19 @@ import { MDXRemoteSerializeResult } from "next-mdx-remote";
import { serialize } from "next-mdx-remote/serialize";
const EVENTS_PATH = path.join("content", "events");
const TERMS = ["winter", "spring", "fall"];
export async function getYears(): Promise<string[]> {
return (await fs.readdir(EVENTS_PATH, { withFileTypes: true }))
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
.map((dirent) => dirent.name)
.sort();
}
export async function getTermsByYear(year: string): Promise<string[]> {
return await fs.readdir(path.join(EVENTS_PATH, year));
return (await fs.readdir(path.join(EVENTS_PATH, year))).sort(
(a, b) => TERMS.indexOf(a) - TERMS.indexOf(b)
);
}
interface Metadata {

View File

@ -15,7 +15,6 @@ export async function getStaticPaths(): Promise<{
const paths = years.map((curYear) => ({
params: { year: curYear },
}));
console.log(paths);
return {
paths: paths,
fallback: false,
@ -56,7 +55,7 @@ const Year = (props: Props) => {
<hr />
<div className={styles.links}>
{props.terms.map((term) => (
<Link key={term} href={`./${props.year}/${term}`}>
<Link key={term} href={`events/${props.year}/${term}`}>
{`${term.charAt(0).toUpperCase()}${term.slice(1)}`}
</Link>
))}

View File

@ -8,11 +8,11 @@
.heading2 {
font-weight: 700;
font-size: 2.25rem;
color: var(--purple-2);
color: var(--primary-heading);
}
.blue {
color: var(--blue-2)
color: var(--primary-accent)
}
.links {