Dynamic permalinks
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Aditya Thakral 2021-09-12 01:59:10 -04:00
parent bed40fe10e
commit f2df7541c0
5 changed files with 16 additions and 14 deletions

View File

@ -7,7 +7,7 @@ import { Link } from "./Link";
import styles from "./EventCard.module.css";
interface BaseProps {
interface EventCardProps {
name: string;
short: string;
date: Date;
@ -15,15 +15,13 @@ interface BaseProps {
location: string;
poster?: string;
registerLink?: string;
permaLink: string;
showDescription?: boolean;
children: ReactNode;
}
type EventCardProps =
| (BaseProps & { showDescription?: false; link: string })
| (BaseProps & { showDescription: true; link?: string });
export function EventCard({
link,
permaLink,
name,
date,
online,
@ -60,8 +58,8 @@ export function EventCard({
<h2>
<EventSetting date={date} online={online} location={location} />
</h2>
{!showDescription && link && (
<Link href={link}>
{!showDescription && (
<Link href={permaLink}>
<span className={styles.mobileLearnMore}>Learn more</span>
</Link>
)}

View File

@ -16,7 +16,7 @@ interface Props {
date: Date;
poster?: string;
registerLink?: string;
permaLink?: string;
permaLink: string;
}
/**
@ -51,7 +51,7 @@ export function EventDescriptionCard({
<EventSetting date={date} online={online} location={location} />
</h2>
<p className={styles.desc}>{short}</p>
{permaLink && <Link href={permaLink}>Learn more</Link>}
<Link href={permaLink}>Learn more</Link>
<footer>
{registerLink && (

View File

@ -6,7 +6,6 @@ online: true
location: 'Twitch'
poster: 'images/events/2021/fall/BOT.png'
registerLink: https://bit.ly/csc-bot-event-signup-form
permaLink: /events/2021/fall/BOT/
---
Kick off the fall term with CS Clubs BOT event! 🍂 Interested in attending upcoming CSC events? Want to meet others in the CS community?

View File

@ -27,13 +27,14 @@ export async function getEventTermsByYear(year: string): Promise<string[]> {
}
interface Metadata {
slug: string;
// slug: string;
name: string;
poster?: string;
short: string;
date: string;
online: boolean;
location: string;
permaLink: string;
registerLink?: string;
}
@ -55,7 +56,12 @@ export async function getEventBySlug(
return {
content: await serialize(content),
metadata: { ...metadata, slug } as Metadata,
metadata: {
...metadata,
// slug,
// permaLink is based on the directory structure in /pages
permaLink: `/events/${year}/${term}/${slug}`,
} as Metadata,
};
}

View File

@ -75,7 +75,6 @@ export default function Term(props: Props) {
{...metadata}
date={new Date(metadata.date)}
key={metadata.name + metadata.date.toString()}
link={`/events/${props.year}/${props.term}/${metadata.slug}`}
>
<MDXRemote {...content} />
</EventCard>