Skip to content
Open
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
43 changes: 42 additions & 1 deletion src/pages/speaker/[slug].astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
import fs from "node:fs";
import { getCollection, getEntries } from "astro:content";
import Layout from "@layouts/Layout.astro";
import Prose from "@ui/Prose.astro";
Expand All @@ -20,6 +21,22 @@ const { entry } = Astro.props;

const sessions = await getEntries(entry.data.submissions);

// Social cards generated by scripts/download_social_speakers.cjs;
// multi-session speakers have one card per session, suffixed with the
// session code (social-<slug>-<CODE>.png), single-session speakers just
// social-<slug>.png.
const CARDS_DIR = "public/media/speakers";
const cardFiles = fs.existsSync(CARDS_DIR) ? fs.readdirSync(CARDS_DIR) : [];
const speakerCards = cardFiles
.filter(
(f) =>
f === `social-${entry.id}.png` ||
new RegExp(`^social-${entry.id}-[A-Z0-9]+\\.png$`).test(f),
)
.sort()
.map((f) => `/media/speakers/${f}`);
const socialCard = speakerCards[0];

function isUrl(str: string): boolean {
str = ensureHttps(str);
const regex = /^(https?:\/\/)?([a-zA-Z0-9.-]+)\.([a-zA-Z]{2,6})([\/\w@.-]*)$/;
Expand Down Expand Up @@ -83,7 +100,11 @@ function getGitHosting(url: string): string | undefined {
}
---

<Layout title={entry.data.name} description={`Profile of ${entry.data.name}`}>
<Layout
title={entry.data.name}
description={`Profile of ${entry.data.name}`}
image={socialCard}
>
<Section2 variant="dark" id="speaker-page">
<Title id="speaker" as="h1">{entry.data.name}</Title>

Expand Down Expand Up @@ -268,6 +289,26 @@ function getGitHosting(url: string): string | undefined {
))
}
</ul>

{
speakerCards.length > 0 && (
<p class="mb-4 text-xl">
<span class="font-bold">
Social media card{speakerCards.length > 1 ? "s" : ""}:
</span>
{speakerCards.map((card, index) => (
<a
class="text-white/80 hover:text-accent underline ml-2"
href={card}
target="_blank"
set:text={
speakerCards.length > 1 ? `Card ${index + 1}` : "Download"
}
/>
))}
</p>
)
}
</Section2>
</Layout>

Expand Down
Loading