BookDetailPage
These templates include the full document shell. Each variant is shown in a separate frame (same URL as “open alone”).
---import type { BacklinkSource } from '../../lib/internal-links/backlink-graph'import type { BookLink } from '../../lib/books'import type { BlogBlock } from '../../lib/markdown/block-types'import '../../styles/link-open-graph-preview.css'import '../../styles/blog-chart.css'import Base from './Base.astro'import LinkButton from '../0_atoms/LinkButton.astro'import Prose from '../0_atoms/Prose.astro'import ProseDocument from '../2_organisms/ProseDocument.astro'import Backlinks from '../2_organisms/Backlinks.astro'
interface OpenGraphProps { url: string imageUrl: string imageAlt: string ogTitle: string ogDescription?: string}
interface Props { title: string author: string description?: string noindex: boolean canonicalHref?: string copyablePostId?: string githubEditHref?: string /** Rich social preview (book pages set this only when a cover exists). */ openGraph?: OpenGraphProps /** Real pages use `Date` from content; story fixtures may use ISO strings. */ startedAt?: Date | string finishedAt?: Date | string /** Labeled external links (Bookshop.org, Amazon, …) rendered as buttons below the author. */ links: BookLink[] coverUrl?: string postId: string backlinks: BacklinkSource[] markdownBlocks?: BlogBlock[]}
const { title, author, description, noindex, canonicalHref, copyablePostId, githubEditHref, openGraph, startedAt, finishedAt, links, coverUrl, postId, backlinks, markdownBlocks,} = Astro.props
const dateFmt = new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'short', day: 'numeric' })function formatDay(value: Date | string | undefined): string | undefined { if (!value) return undefined const date = value instanceof Date ? value : new Date(value) return Number.isNaN(date.getTime()) ? undefined : dateFmt.format(date)}const startedLabel = formatDay(startedAt)const finishedLabel = formatDay(finishedAt)---
<Base title={title} description={description} noindex={noindex} canonicalHref={canonicalHref} copyablePostId={copyablePostId} githubEditHref={githubEditHref} openGraph={openGraph}> <article> <header class="mb-6"> {coverUrl && ( <img src={coverUrl} alt={`Cover of ${title}`} class="mb-4 w-full max-w-[240px] border border-border" /> )} <h1 class="font-serif text-3xl font-medium leading-tight text-ink mb-2">{title}</h1> <div class="text-sm text-ink-muted mb-2">by {author}</div> {links.length > 0 && ( <div class="flex flex-wrap items-center gap-2 mb-2"> {links.map(link => ( <LinkButton label={link.label} href={link.url} external aria-label={`${link.label} (opens in a new tab)`} /> ))} </div> )} {(startedLabel || finishedLabel) && ( <div class="text-sm text-ink-muted"> {startedLabel && <span>Started {startedLabel}</span>} {startedLabel && finishedLabel && <span> · </span>} {finishedLabel && <span>Finished {finishedLabel}</span>} </div> )} </header> { markdownBlocks ? ( <ProseDocument blocks={markdownBlocks} /> ) : ( <Prose> <slot /> </Prose> ) } <Backlinks sources={backlinks} /> </article></Base>