PR feedback
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Aditya Thakral 2021-08-27 18:13:51 -04:00
parent 4828069800
commit 7ceffc3ba0
3 changed files with 20 additions and 9 deletions

View File

@ -104,7 +104,13 @@ export async function getUpcomingEvents(): Promise<Event[]> {
});
}
export async function getProps(year: string, term: string): Promise<Props> {
export async function getEventsPageProps({
year,
term,
}: {
year: string;
term: string;
}): Promise<Props> {
const eventNames = await getEventsByTerm(year, term);
const events: Event[] = (

View File

@ -9,7 +9,7 @@ import { Link } from "@/components/Link";
import { MiniEventCard } from "@/components/MiniEventCard";
import {
Event,
getProps,
getEventsPageProps,
getEventYears,
getEventTermsByYear,
} from "@/lib/events";
@ -61,7 +61,7 @@ export default function Term(props: Props) {
key={link.year + link.term}
/>
))}
<Link href="/events/archives">Archives</Link>
<Link href="/events/archive">Archive</Link>
</div>
{hasFutureEvents && (
<>
@ -88,6 +88,14 @@ export default function Term(props: Props) {
</span>
</h2>
)}
{!hasFutureEvents && !hasPastEvents && (
<>
<h2>Events</h2>
There are no upcoming or past events for the{" "}
{`${capitalize(props.term)} ${props.year}`} term. Please check back
later!
</>
)}
<div className={styles.miniEventCards}>
{props.pastEvents.map(({ content, metadata }) => (
<MiniEventCard
@ -125,9 +133,7 @@ export const getStaticProps: GetStaticProps<Props, Params> = async (
context
) => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const { year, term } = context.params!;
return { props: await getProps(year, term) };
return { props: await getEventsPageProps(context.params!) };
};
export const getStaticPaths: GetStaticPaths<Params> = async () => {

View File

@ -1,12 +1,11 @@
import { GetStaticProps } from "next";
import { getCurrentTerm, getProps } from "@/lib/events";
import { getCurrentTerm, getEventsPageProps } from "@/lib/events";
import Term, { Props } from "./[year]/[term]/index";
export default Term;
export const getStaticProps: GetStaticProps<Props> = async () => {
const curTerm = getCurrentTerm();
return { props: await getProps(curTerm.year, curTerm.term) };
return { props: await getEventsPageProps(getCurrentTerm()) };
};