Root > src > pages

Pages and routes

Changelog

Module responsibilities

This module defines the public HTTP surface through Astro file-based routing. It renders portfolio pages, prerenders content detail pages, emits RSS, and serves the Anthropic chat endpoint.

Entry and startup

Astro discovers files under this directory. src/middleware.ts runs before routes and can return a maintenance response. All visual pages compose src/layouts/BaseLayout.astro.

External interfaces

Method and route File Rendering and responsibility
GET / index.astro Server page; featured projects from Django, recent posts, hero, and about summary
GET /about about.astro Server page; biography, education, skills, and contact links
GET /projects projects/index.astro Server page; serializes published Django projects into an idle-hydrated filter
GET /projects/[slug] projects/[slug].astro Runtime Django metadata detail with optional MDX body, headings, reading time, and API-related projects
GET /blog blog/index.astro Server page; published posts in an idle-hydrated filter
GET /blog/[slug] blog/[slug].astro Prerendered, non-draft MDX detail with headings and reading time
GET /til til/index.astro Server page; published short notes with search and topic filtering
GET /til/[slug] til/[slug].astro Prerendered, non-draft MDX detail with headings and reading time
GET /rss.xml rss.xml.ts RSS for non-draft posts
GET /404 404.astro Custom not-found presentation
POST /api/chat api/chat.ts Server API for the visitor assistant

POST /api/chat expects JSON with messages as an array and optional currentPath. It loads published project metadata from PROJECT_API_URL, keeps non-draft blog context from MDX, adds static skills, education, and contact data, caches the base prompt per server cold start, adds page context, and returns { message }. Missing credentials, unavailable project API data, and runtime errors deliberately return friendly JSON messages without inventing project details.

Key dependencies and configuration

Data models

Page props are derived from content entry schemas. Lists serialize Dates to ISO strings where client components need them. The chat route accepts message objects with role and content, then narrows roles for the Anthropic client; no database or server session is used.

Testing and quality

No route/API unit-test framework exists. Run npm run check, npm run build, and npm run smoke:chat against a running standalone server. Manually verify route generation for all MDX slugs, draft exclusion, RSS links, 404 behavior, maintenance 503 headers, chat responses with and without credentials, Django catalog fallback behavior, and that no secret enters client bundles.

FAQ

Where should a new page be added?

Add it under this directory following Astro filename routing, and wrap visual pages in BaseLayout. Add navigation in src/lib/constants.ts only when the page belongs in global navigation.

Why are detail routes prerendered in a server-output app?

Their slugs and bodies are known from local content at build time. Prerendering avoids a server lookup on every detail request while leaving /api/chat and general server output available.

How should the chat API evolve?

Keep the Anthropic SDK and key server-only. If the public request contract changes, update ChatWidget.tsx at the same time and add validation/rate-limit tests when a test harness is introduced.