Resolve some issues
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
25c83364d6
commit
891b6b29a8
|
@ -1,50 +1,21 @@
|
||||||
|
import { ParsedUrlQuery } from "querystring";
|
||||||
|
|
||||||
|
import { GetStaticPaths, GetStaticProps } from "next";
|
||||||
import { MDXRemote } from "next-mdx-remote";
|
import { MDXRemote } from "next-mdx-remote";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { EventCard } from "../../../../components/EventCard";
|
import { EventCard } from "@/components/EventCard";
|
||||||
import { MiniEventCard } from "../../../../components/MiniEventCard";
|
import { MiniEventCard } from "@/components/MiniEventCard";
|
||||||
import {
|
import {
|
||||||
getEventYears,
|
getEventYears,
|
||||||
getEventTermsByYear,
|
getEventTermsByYear,
|
||||||
getEventsByTerm,
|
getEventsByTerm,
|
||||||
getEventBySlug,
|
getEventBySlug,
|
||||||
Event,
|
Event,
|
||||||
} from "../../../../lib/events";
|
} from "@/lib/events";
|
||||||
|
|
||||||
import styles from "./term.module.css";
|
import styles from "./term.module.css";
|
||||||
|
|
||||||
export async function getStaticPaths(): Promise<{
|
|
||||||
paths: {
|
|
||||||
params: {
|
|
||||||
year: string;
|
|
||||||
term: string;
|
|
||||||
};
|
|
||||||
}[];
|
|
||||||
fallback: boolean;
|
|
||||||
}> {
|
|
||||||
const years = await getEventYears();
|
|
||||||
const paths = [];
|
|
||||||
for (const year of years) {
|
|
||||||
const terms = await getEventTermsByYear(year);
|
|
||||||
const yearPaths = terms.map((curTerm) => ({
|
|
||||||
params: { year: year, term: curTerm },
|
|
||||||
}));
|
|
||||||
paths.push(...yearPaths);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
paths: paths,
|
|
||||||
fallback: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Context {
|
|
||||||
params: {
|
|
||||||
year: string;
|
|
||||||
term: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
term: string;
|
term: string;
|
||||||
year: string;
|
year: string;
|
||||||
|
@ -52,41 +23,7 @@ interface Props {
|
||||||
futureEvents: Event[];
|
futureEvents: Event[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getStaticProps(context: Context): Promise<{
|
export default function Term(props: Props) {
|
||||||
props: Props;
|
|
||||||
}> {
|
|
||||||
const events = (
|
|
||||||
await Promise.all(
|
|
||||||
(
|
|
||||||
await getEventsByTerm(context.params.year, context.params.term)
|
|
||||||
).map((file: string) =>
|
|
||||||
getEventBySlug(context.params.year, context.params.term, file)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
).sort(
|
|
||||||
(a, b) =>
|
|
||||||
new Date(a.metadata.date).getTime() - new Date(b.metadata.date).getTime()
|
|
||||||
);
|
|
||||||
|
|
||||||
const pastEvents = events.filter(
|
|
||||||
(event) => new Date(event.metadata.date).getTime() < Date.now()
|
|
||||||
);
|
|
||||||
|
|
||||||
const futureEvents = events.filter(
|
|
||||||
(event) => new Date(event.metadata.date).getTime() >= Date.now()
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
term: context.params.term,
|
|
||||||
year: context.params.year,
|
|
||||||
pastEvents: pastEvents,
|
|
||||||
futureEvents: futureEvents,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const Term = (props: Props) => {
|
|
||||||
const hasPastEvents = props.pastEvents.length !== 0;
|
const hasPastEvents = props.pastEvents.length !== 0;
|
||||||
const hasFutureEvents = props.futureEvents.length !== 0;
|
const hasFutureEvents = props.futureEvents.length !== 0;
|
||||||
|
|
||||||
|
@ -140,6 +77,61 @@ const Term = (props: Props) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Params extends ParsedUrlQuery {
|
||||||
|
year: string;
|
||||||
|
term: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getStaticProps: GetStaticProps<Props, Params> = async (
|
||||||
|
context
|
||||||
|
) => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
const { year, term } = context.params!;
|
||||||
|
|
||||||
|
const eventNames = await getEventsByTerm(year, term);
|
||||||
|
|
||||||
|
const events: Event[] = (
|
||||||
|
await Promise.all(
|
||||||
|
eventNames.map((file: string) => getEventBySlug(year, term, file))
|
||||||
|
)
|
||||||
|
).sort(
|
||||||
|
(a, b) =>
|
||||||
|
new Date(a.metadata.date).getTime() - new Date(b.metadata.date).getTime()
|
||||||
|
);
|
||||||
|
|
||||||
|
const pastEvents = events.filter(
|
||||||
|
(event) => new Date(event.metadata.date).getTime() < Date.now()
|
||||||
|
);
|
||||||
|
|
||||||
|
const futureEvents = events.filter(
|
||||||
|
(event) => new Date(event.metadata.date).getTime() >= Date.now()
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
term: term,
|
||||||
|
year: year,
|
||||||
|
pastEvents: pastEvents,
|
||||||
|
futureEvents: futureEvents,
|
||||||
|
},
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Term;
|
export const getStaticPaths: GetStaticPaths<Params> = async () => {
|
||||||
|
const years = await getEventYears();
|
||||||
|
const paths = [];
|
||||||
|
for (const year of years) {
|
||||||
|
const terms = await getEventTermsByYear(year);
|
||||||
|
const yearPaths = terms.map((curTerm) => ({
|
||||||
|
params: { year: year, term: curTerm },
|
||||||
|
}));
|
||||||
|
paths.push(...yearPaths);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
paths: paths,
|
||||||
|
fallback: false,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
.main {
|
.main {
|
||||||
margin: auto;
|
margin: auto;
|
||||||
margin-top: 7rem;
|
margin-top: calc(112rem / 16);
|
||||||
margin-bottom: 14rem;
|
margin-bottom: calc(224rem / 16);
|
||||||
width: 50rem;
|
width: calc(800rem / 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
.heading2 {
|
.heading2 {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
font-size: 2.25rem;
|
|
||||||
color: var(--primary-heading);
|
color: var(--primary-heading);
|
||||||
}
|
}
|
||||||
|
|
||||||
.blue {
|
.blue {
|
||||||
color: var(--primary-accent)
|
color: var(--primary-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
.miniEventCards {
|
.miniEventCards {
|
||||||
margin-top: 30px;
|
margin-top: calc(30rem / 16);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue