Link from [term] to [term]/[event] (#412)
continuous-integration/drone/push Build is passing Details

Closes #189

https://csclub.uwaterloo.ca/~a3thakra/csc/j285he-term-to-term-event/events/

Co-authored-by: Jared He <66887902+jaredjhe@users.noreply.github.com>
Reviewed-on: #412
Reviewed-by: n3parikh <n3parikh@csclub.uwaterloo.ca>
This commit is contained in:
Jared He 2022-03-23 20:23:21 -04:00
parent b0ca27416c
commit 0f1e8b7e81
7 changed files with 41 additions and 4 deletions

View File

@ -31,6 +31,10 @@
margin-bottom: 0; margin-bottom: 0;
} }
.content > h1 a {
color: var(--primary-heading);
}
.content, .content,
.content > h2 { .content > h2 {
font-weight: 400; font-weight: 400;

View File

@ -18,6 +18,10 @@ interface EventCardProps {
permaLink: string; permaLink: string;
showDescription?: boolean; showDescription?: boolean;
children: ReactNode; children: ReactNode;
year: string;
term: string;
slug: string;
titleLinked: boolean;
} }
export function EventCard({ export function EventCard({
@ -30,6 +34,10 @@ export function EventCard({
registerLink, registerLink,
children, children,
showDescription = false, showDescription = false,
year,
term,
slug,
titleLinked,
}: EventCardProps) { }: EventCardProps) {
return ( return (
<article className={styles.card}> <article className={styles.card}>
@ -54,7 +62,13 @@ export function EventCard({
showDescription ? styles.mobileShowDescriptionContent : "", showDescription ? styles.mobileShowDescriptionContent : "",
].join(" ")} ].join(" ")}
> >
<h1>{name}</h1> <h1>
{titleLinked ? (
<Link href={`/events/${year}/${term}/${slug}`}>{name}</Link>
) : (
name
)}
</h1>
<h2> <h2>
<EventSetting date={date} online={online} location={location} /> <EventSetting date={date} online={online} location={location} />
</h2> </h2>

View File

@ -14,6 +14,10 @@
margin: 0; margin: 0;
} }
.name a {
color: var(--primary-heading);
}
.nameSpacer { .nameSpacer {
width: calc(140rem / 16); width: calc(140rem / 16);
} }

View File

@ -1,32 +1,39 @@
import React, { ReactNode } from "react"; import React, { ReactNode } from "react";
import { EventSetting } from "./EventSetting"; import { EventSetting } from "./EventSetting";
import { Link } from "./Link";
import styles from "./MiniEventCard.module.css"; import styles from "./MiniEventCard.module.css";
interface Props { interface MiniEventCardProps {
name: string; name: string;
description: ReactNode; description: ReactNode;
short: string; short: string;
online: boolean; online: boolean;
location: string; location: string;
date: Date; date: Date;
year: string;
term: string;
slug: string;
} }
export const MiniEventCard: React.FC<Props> = ({ export const MiniEventCard: React.FC<MiniEventCardProps> = ({
name, name,
short, short,
description, description,
location, location,
date, date,
online, online,
year,
term,
slug,
}) => { }) => {
return ( return (
<details className={styles.card}> <details className={styles.card}>
<summary> <summary>
<div onClick={(event) => event.preventDefault()}> <div onClick={(event) => event.preventDefault()}>
<h2 className={styles.name}> <h2 className={styles.name}>
<div>{name}</div> <Link href={`/events/${year}/${term}/${slug}`}>{name}</Link>
<div className={styles.nameSpacer}></div> <div className={styles.nameSpacer}></div>
</h2> </h2>
<div className={styles.info}> <div className={styles.info}>

View File

@ -53,6 +53,9 @@ interface Metadata {
location: string; location: string;
permaLink: string; permaLink: string;
registerLink?: string; registerLink?: string;
year: string;
term: string;
slug: string;
} }
export interface Event { export interface Event {
@ -82,6 +85,9 @@ export async function getEventBySlug(
).toString(), ).toString(),
// permaLink is based on the directory structure in /pages // permaLink is based on the directory structure in /pages
permaLink: `/events/${year}/${term}/${slug}`, permaLink: `/events/${year}/${term}/${slug}`,
year: year,
term: term,
slug: slug,
} as Metadata, } as Metadata,
}; };
} }

View File

@ -28,6 +28,7 @@ export default function EventInfoPage({ year, term, event }: Props) {
{...event.metadata} {...event.metadata}
date={new Date(event.metadata.date)} date={new Date(event.metadata.date)}
showDescription showDescription
titleLinked={false}
> >
<MDXRemote {...event.content} /> <MDXRemote {...event.content} />
</EventCard> </EventCard>

View File

@ -75,6 +75,7 @@ export default function TermPage(props: Props) {
{...metadata} {...metadata}
date={new Date(metadata.date)} date={new Date(metadata.date)}
key={metadata.name + metadata.date.toString()} key={metadata.name + metadata.date.toString()}
titleLinked={true}
> >
<MDXRemote {...content} /> <MDXRemote {...content} />
</EventCard> </EventCard>