2021-08-23 14:56:11 -04:00
|
|
|
import { GetStaticProps } from "next";
|
|
|
|
import { MDXRemote } from "next-mdx-remote";
|
2021-07-27 02:13:34 -04:00
|
|
|
import React from "react";
|
|
|
|
|
2021-08-13 04:16:37 -04:00
|
|
|
import { ConnectWithUs } from "@/components/ConnectWithUs";
|
|
|
|
import { DefaultLayout } from "@/components/DefaultLayout";
|
|
|
|
import { EmailSignup } from "@/components/EmailSignup";
|
|
|
|
import { EventDescriptionCard } from "@/components/EventDescriptionCard";
|
|
|
|
import { Image } from "@/components/Image";
|
2021-08-23 14:56:11 -04:00
|
|
|
import { Link } from "@/components/Link";
|
2021-08-13 04:16:37 -04:00
|
|
|
import { NewsCard } from "@/components/NewsCard";
|
|
|
|
import { SocialLinks } from "@/components/SocialLinks";
|
2021-08-23 14:56:11 -04:00
|
|
|
import { Event, getUpcomingEvents } from "@/lib/events";
|
|
|
|
import { News, getRecentNews } from "@/lib/news";
|
2021-07-27 02:13:34 -04:00
|
|
|
|
2021-08-13 04:16:37 -04:00
|
|
|
import styles from "./index.module.css";
|
|
|
|
|
2021-08-23 14:56:11 -04:00
|
|
|
interface Props {
|
|
|
|
moreEvents: boolean; // true if there are more than 2 upcoming events
|
|
|
|
events: Event[]; // array of 0 - 2 events
|
|
|
|
news: News;
|
|
|
|
}
|
2021-07-27 02:13:34 -04:00
|
|
|
|
2021-08-23 14:56:11 -04:00
|
|
|
export default function Home(props: Props) {
|
2021-07-27 02:13:34 -04:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<DefaultLayout>
|
|
|
|
<header className={styles.intro}>
|
|
|
|
<div className={styles.introTop} />
|
|
|
|
<div className={styles.introContent}>
|
|
|
|
<div className={styles.clubTitleWrapper}>
|
|
|
|
<Image src="/images/logo-icon.svg" alt="CSC Logo" />
|
|
|
|
<h1 className={styles.clubTitle}>Computer Science Club</h1>
|
|
|
|
</div>
|
|
|
|
<p className={styles.clubDescription}>
|
|
|
|
University of Waterloo's <br />
|
|
|
|
student computing community
|
|
|
|
</p>
|
|
|
|
<SocialLinks color="gradient" size="big" />
|
|
|
|
</div>
|
|
|
|
<div className={styles.introBottom} />
|
|
|
|
<Image
|
|
|
|
className={styles.codey}
|
|
|
|
src="/images/home/codey_sitting.svg"
|
|
|
|
alt="CSC mascot Codey, a blue shiba with circular glasses"
|
|
|
|
/>
|
|
|
|
</header>
|
|
|
|
</DefaultLayout>
|
|
|
|
<div className={styles.cardsBackground}>
|
|
|
|
<div className={styles.cards}>
|
|
|
|
<section className={styles.events}>
|
|
|
|
<h1 className={styles.cardsHeading}>Upcoming Events</h1>
|
2021-08-23 14:56:11 -04:00
|
|
|
<p className={styles.cardsDescription}>
|
|
|
|
See past events{" "}
|
|
|
|
<Link href="/events/archive">
|
|
|
|
<a title="Events Archive">here</a>
|
|
|
|
</Link>
|
|
|
|
</p>
|
2021-07-27 02:13:34 -04:00
|
|
|
<hr className={styles.cardsDividingLine} />
|
2021-08-23 14:56:11 -04:00
|
|
|
{props.events.length === 0 ? (
|
|
|
|
<p>
|
|
|
|
There are no upcoming events right now. Please check back later!
|
|
|
|
</p>
|
|
|
|
) : null}
|
2021-07-27 02:13:34 -04:00
|
|
|
<div className={styles.eventCards}>
|
2021-08-23 14:56:11 -04:00
|
|
|
{props.events.length > 0
|
|
|
|
? props.events.map((event) => (
|
|
|
|
<EventDescriptionCard
|
|
|
|
{...event.metadata}
|
|
|
|
date={new Date(event.metadata.date)}
|
|
|
|
key={event.metadata.name + event.metadata.date.toString()}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
: null}
|
2021-07-27 02:13:34 -04:00
|
|
|
</div>
|
2021-08-23 14:56:11 -04:00
|
|
|
{props.moreEvents ? (
|
|
|
|
<p>
|
|
|
|
See more upcoming events{" "}
|
|
|
|
<Link href="/events">
|
|
|
|
<a title="Events">here</a>
|
|
|
|
</Link>
|
|
|
|
</p>
|
|
|
|
) : null}
|
2021-07-27 02:13:34 -04:00
|
|
|
</section>
|
2021-08-23 11:11:42 -04:00
|
|
|
<section className={styles.news} id="news">
|
2021-07-27 02:13:34 -04:00
|
|
|
<h1 className={styles.cardsHeading}>News</h1>
|
|
|
|
<p className={styles.cardsDescription}>
|
|
|
|
Updates from our execs! <br />
|
2021-08-23 14:56:11 -04:00
|
|
|
See past news{" "}
|
|
|
|
<Link href="/news/archive">
|
|
|
|
<a title="News Archive">here</a>
|
|
|
|
</Link>
|
2021-07-27 02:13:34 -04:00
|
|
|
</p>
|
|
|
|
<hr className={styles.cardsDividingLine} />
|
2021-08-23 14:56:11 -04:00
|
|
|
{
|
|
|
|
<NewsCard
|
|
|
|
{...props.news.metadata}
|
|
|
|
date={new Date(props.news.metadata.date)}
|
|
|
|
>
|
|
|
|
<MDXRemote {...props.news.content} />
|
|
|
|
</NewsCard>
|
|
|
|
}
|
2021-07-27 02:13:34 -04:00
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<DefaultLayout>
|
|
|
|
<ConnectWithUs />
|
|
|
|
<EmailSignup />
|
|
|
|
</DefaultLayout>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Home.Layout = function HomeLayout(props: { children: React.ReactNode }) {
|
|
|
|
return <div className={styles.page}>{props.children}</div>;
|
|
|
|
};
|
2021-08-23 14:56:11 -04:00
|
|
|
|
|
|
|
export const getStaticProps: GetStaticProps<Props> = async () => {
|
|
|
|
const upcomingEvents = await getUpcomingEvents();
|
|
|
|
const recentNews = await getRecentNews();
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
moreEvents: upcomingEvents.length > 2,
|
|
|
|
events: upcomingEvents.slice(0, 2),
|
|
|
|
news: recentNews[0],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|