Skip to content

Commit

Permalink
feat: add month / year support for ad page (#310)
Browse files Browse the repository at this point in the history
<!-- 👋 Hi, thanks for sending a PR to boston-ts-website! 💖.
Please fill out all fields below and make sure each item is true and [x]
checked.
Otherwise we may not be able to review your PR. -->

## PR Checklist

- [x] Addresses an existing open issue: fixes
#45
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/boston-ts-website/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/boston-ts-website/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

<!-- Description of what is changed and how the code change does that.
-->
  • Loading branch information
SeanSanker authored Sep 13, 2024
1 parent e175f7b commit aa67ec4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
11 changes: 9 additions & 2 deletions app/components/AdGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import * as styles from "./AdGrid.css";
import { AdLogo } from "./AdLogo";

export function AdGrid() {
export interface AdGridProps {
month: string;
year: number;
}

export function AdGrid({ month, year }: AdGridProps) {
return (
<main className={styles.adGrid}>
<div className={styles.imageArea}>
Expand All @@ -11,7 +16,9 @@ export function AdGrid() {
<h1 className={styles.h1}>
Boston <span className={styles.together}>TS Club</span>
</h1>
<p className={styles.p}>June 2024</p>
<p className={styles.p}>
{month} {year}
</p>
</div>
</main>
);
Expand Down
23 changes: 22 additions & 1 deletion app/routes/ad.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
import { MetaFunction } from "@remix-run/node";
import { useSearchParams } from "@remix-run/react";

import { AdGrid } from "~/components/AdGrid";
import { createMeta } from "~/config";

export const meta: MetaFunction = () => createMeta({ page: "Ad" });

function useYearAndMonth() {
const [searchParams] = useSearchParams();

const currentDate = new Date();

const month =
searchParams.get("month") ??
currentDate.toLocaleString("default", { month: "long" });

const paramYear = searchParams.get("year");
const parsedYear = paramYear ? parseInt(paramYear, 10) : null;

const currentYear = currentDate.getFullYear();
const year = !parsedYear || isNaN(parsedYear) ? currentYear : parsedYear;

return { month, year };
}

export default function Ad() {
return <AdGrid />;
const { month, year } = useYearAndMonth();

return <AdGrid month={month} year={year} />;
}

0 comments on commit aa67ec4

Please sign in to comment.