/* ═══════════════════════════════════════════════════════════════ BLOG POST: /blog/:id One of our own posts: cover, date and tags, the content-block body, then its authors as person tiles. Authors are published people (linked to their pages) and, when the post names one, a guest with no people record (a tile that links nowhere). There's no /blog index on purpose: the Community page's blog section is where posts are listed, so "back" goes there. ═══════════════════════════════════════════════════════════════ */ import { Link, useParams } from "react-router-dom" import PageShell, { type ShellSection } from "../components/PageShell.tsx" import PageState from "../components/PageState.tsx" import ContentBlocks from "../components/ContentBlocks.tsx" import PeopleTiles from "../components/PeopleTiles.tsx" import { mediaUrl } from "../lib/media.ts" import { postDate, useBlogPost } from "../lib/useBlog.ts" import { accentText, BRAND } from "../lib/color.ts" import PostContents from "../components/PostContents.tsx" import { headingAnchors } from "../lib/contents.ts" import QrCode from "../components/QrCode.tsx" import RequestLink from "../components/RequestLink.tsx" import { siteUrl } from "../lib/site.ts" import { FilePdf } from "@phosphor-icons/react" const BODY = "var(--color-muted)" /* Where "back" goes: the section on the Community page. */ const BACK = { to: "/community#blog", label: "Community Blog" } export default function BlogPost() { const { id } = useParams() const { data: post, loading, error, notFound, reload } = useBlogPost(id) if (!post) { return ( ) } // Two headings or more make a list worth showing. const contents = post.show_contents ? headingAnchors(post.blocks).entries : [] const withContents = contents.length >= 2 const postUrl = siteUrl(`/blog/${post.id}`) const date = postDate(post.published_on) const cover = mediaUrl(post.cover_image) const byline = [ ...post.authors.map((author) => author.name), ...(post.guest ? [post.guest.name] : []), ].join(", ") const authors = [ ...post.authors.map((author) => ({ id: author.id, name: author.name, tagline: author.tagline, pronouns: author.pronouns, photo: mediaUrl(author.photo), })), ...(post.guest ? [ { name: post.guest.name, title: "Guest author", photo: mediaUrl(post.guest.photo), }, ] : []), ] const sections: ShellSection[] = [ { id: "post", title: "Post", accent: BRAND, background: "var(--color-surface)", content: (
{withContents && }
{date && ( )} {byline && By {byline}} {post.tags.map((tag) => ( {tag} ))} {BACK.label}
{cover && ( {post.cover_alt )}
Have a story to share?
{/* Only on paper (Download PDF): where the post lives online, as a link and as a code to scan. */}

Read this post online at
{postUrl}

), }, ] if (authors.length > 0) { sections.push({ id: "authors", title: authors.length === 1 ? "About the author" : "About the authors", accent: BRAND, background: "var(--color-tint)", content: (
), }) } return ( ) }