BookShelfPage

These templates include the full document shell. Each variant is shown in a separate frame (same URL as “open alone”).


src/ui/3_templates/BookShelfPage.astro
---
import Base from './Base.astro'
import Heading from '../0_atoms/Heading.astro'
import BookShelfRow from '../2_organisms/BookShelfRow.astro'
import type { BookShelfItem } from '../../lib/books'
interface Props {
title: string
/** Shelves in display order; sections with no books are omitted. */
shelves: { label: string; books: BookShelfItem[] }[]
canonicalHref?: string
}
const { title, shelves, canonicalHref } = Astro.props
const anyBooks = shelves.some(shelf => shelf.books.length > 0)
---
<Base title={title} canonicalHref={canonicalHref}>
<Heading class="meta mt-0 mb-6 text-xl font-semibold text-ink">Books</Heading>
{
!anyBooks && <p class="text-ink-muted mb-8">Nothing on the shelves yet.</p>
}
{
shelves.map(shelf => (
shelf.books.length ? (
<section class="mb-10">
<Heading
level="h2"
class="meta mb-4 text-sm font-semibold tracking-widest text-ink-muted"
>
{shelf.label}
</Heading>
<ul class="list-none p-0 m-0 [&>li:last-child]:border-b-0">
{shelf.books.map(book => (
<li>
<BookShelfRow book={book} />
</li>
))}
</ul>
</section>
) : null
))
}
</Base>