src/pages/

Responsibility

SSR route layer for the Knowledge Garden. Every page sets prerender = false (implicit in output: "server" mode) and fetches content at request time from R2 via getLiveCollection / getLiveEntry. Top-level pages handle the home view (index.astro), full-page search (search.astro), graph placeholder (graph.astro), and error states (404.astro, 500.astro). Subdirectories implement content type listings, doc navigation, tag browsing, API endpoints, attachment serving, and legacy redirects.

Design Patterns

Data & Control Flow

Requests hit Astro’s server-side router on Cloudflare Workers. Pages call getLiveCollection("knowledge") to list entries (body omitted for performance) or getLiveEntry("knowledge", key) to fetch a single entry with its full markdown body. Collection data is adapted via fromCollectionEntry() into Document objects, then filtered by type, path prefix, or tag. For docs and content detail pages, markdown bodies are rendered at request time through the unified pipeline (renderMarkdown), and headings are extracted for the table of contents sidebar. The attachments/[...path].ts endpoint reads binary assets directly from the KNOWLEDGE_BUCKET R2 binding with appropriate MIME types and caching headers.

Integration Points