Fetch upcoming events and recent news on home page #162
No reviewers
Labels
No Label
a11y
Backlog
Blocked
Bug
Content
Dependencies
Design
Feature Request
Good First Issue
In Progress
Performance
Priority - High
Priority - Low
Priority - Medium
Untriaged
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: www/www-new#162
Loading…
Reference in New Issue
No description provided.
Delete Branch "feat/upcoming-events-recent-news"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #149
@ -95,0 +114,4 @@
export const getStaticProps: GetStaticProps<Props, Params> = async () => {
const events = await getUpcomingEvents();
const news = await getRecentNews();
return { props: { events, news } };
You should slice these arrays here, if you don't that will make the HTML pages gigantic, as all the events and news will be serialized in HTML.
@ -95,0 +111,4 @@
type Params = ParsedUrlQuery;
export const getStaticProps: GetStaticProps<Props, Params> = async () => {
Just
GetStaticProps<Props>
is fine, you can omit Params here.@ -29,1 +19,3 @@
];
interface Props {
events: Event[];
news: News[];
We only need the first news, so we should only pass 1 news item, instead of an array.
@ -55,3 +49,3 @@
<div className={styles.cardsBackground}>
<div className={styles.cards}>
{/* TODO: add links to past events and past news */}
{/* TODO: add links to past/upcoming events and past news */}
links:
/events
/events/archive
/news/archive
note that we will never have upcoming news.
LGTM after comments are addressed!
@ -65,0 +80,4 @@
const eventsInTerm = await getEventsByTerm(year, TERMS[term]);
return await Promise.all(
eventsInTerm.map(
async (slug) => await getEventBySlug(year, TERMS[term], slug)
no need to use async and await if the thing you're returning from your function is a promise.
so:
async (slug) => await getEventBySlug(year, TERMS[term], slug)
is the same as
(slug) => getEventBySlug(year, TERMS[term], slug)
@ -28,2 +18,2 @@
{ Content: AltTab, metadata: altTabEventMetadata },
];
interface Props {
numberOfEvents: number; // total number of upcoming events
this seems redundant, why can't we just use events.length?
Currently, we're displaying a link to the upcoming events page iff there are more than 2 upcoming events, however we are only passing up to 2 events in the events array (that is, 0 <= events.length <= 2).
oh, I see. In that case, you should pass in a boolean prop (eg
moreUpcomingEvents
) instead ofnumberOfEvents
.@ -61,1 +57,4 @@
</Link>
</p>
<hr className={styles.cardsDividingLine} />
{props.numberOfEvents == 0 ? (
Use
===
. Only use==
for null checks.🚢