Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions sites/mainweb/app/(portal)/hacklytics/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ORG_NAME, SITE_ORIGIN } from "@query/core";
import { VENUE_TZ } from "@/lib/venue-time";
import "./fonts.generated.css";
import { FONT_PRELOADS } from "@/lib/fonts.generated";
import { firstParagraph } from "@/lib/first-paragraph";

// The Hacklytics site's own faces (sites/hacklytics2027): Silkscreen for
// headings, Instrument Sans for text. Scoped to this route by .hl-theme, and
Expand Down Expand Up @@ -89,7 +90,7 @@ export async function generateMetadata(): Promise<Metadata> {

const dates = formatRange(edition.startDate, edition.endDate);
const description =
edition.description ??
firstParagraph(edition.description) ??
"Georgia Tech's data science hackathon, open to students nationwide.";
const title = `${edition.name} | ${dates}`;

Expand Down Expand Up @@ -157,7 +158,7 @@ async function EventJsonLd() {
eventStatus: "https://schema.org/EventScheduled",
eventAttendanceMode: "https://schema.org/OfflineEventAttendanceMode",
description:
edition.description ??
firstParagraph(edition.description) ??
"Georgia Tech's data science hackathon, open to students nationwide.",
url: URL,
image: [`${SITE_ORIGIN}/logo512.png`],
Expand Down
3 changes: 2 additions & 1 deletion sites/mainweb/app/(portal)/hacklytics/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { FlowerBed } from "@/components/hackathon/FlowerBed";
import { MyRegistration } from "./MyRegistration";
import { RetryButton } from "./RetryButton";
import { hlSectionTitle } from "./styles";
import { firstParagraph } from "@/lib/first-paragraph";

/**
* The public landing page for an edition that has been announced but is not yet
Expand Down Expand Up @@ -239,7 +240,7 @@ export default async function HacklyticsPage() {
<h1 className={`mt-1 ${pageTitle}`}>{event.name}</h1>

{event.description ? (
<p className={pageDek}>{event.description}</p>
<p className={pageDek}>{firstParagraph(event.description)}</p>
) : null}
</header>

Expand Down
19 changes: 19 additions & 0 deletions sites/mainweb/lib/first-paragraph.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, expect, it } from "vitest";
import { firstParagraph } from "./first-paragraph";

describe("firstParagraph", () => {
it("takes the text before the first blank line", () => {
expect(firstParagraph("Intro line.\n\nMore detail.\n\nEven more.")).toBe(
"Intro line.",
);
});

it("keeps a single paragraph whole", () => {
expect(firstParagraph("One paragraph only.")).toBe("One paragraph only.");
});

it("returns null for nothing", () => {
expect(firstParagraph(null)).toBeNull();
expect(firstParagraph(" ")).toBeNull();
});
});
9 changes: 9 additions & 0 deletions sites/mainweb/lib/first-paragraph.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* The first paragraph of an edition's description. The full text is the About
* section on the application page; the summary under a title and the link
* preview take only its opening paragraph.
*/
export function firstParagraph(text: string | null | undefined) {
const first = text?.split(/\n\s*\n/)[0]?.trim();
return first || null;
}
Loading