This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Nuxt 4 application that powers the BabDev website (https://www.babdev.com), showcasing open-source PHP packages (Laravel, Symfony, Sylius) with integrated documentation.
pnpm install # Install dependencies
pnpm dev # Start dev server on http://localhost:3000
pnpm build # Build for production
pnpm preview # Preview production build locally
pnpm generate # Generate static sitepnpm lint # Run ESLint
pnpm lint:fix # Fix ESLint issues automatically
pnpm format # Format code with Prettier
pnpm format:check # Check Prettier formattingThe site fetches and displays documentation from GitHub repositories at build time:
-
Package definitions are centralized in
app/data/packages.ts- this is the single source of truth for all packages, their versions, GitHub repos, and metadata. -
Build-time route discovery:
discoverDocsRoutes()inserver/utils/docs.tswalks each repo'sdocs/tree on GitHub, and one list feeds both the prerenderer and the sitemap. The Nitroprerender:routeshook innuxt.config.tsadds those routes plus each page's/rawMarkdown twin and the redirect-source routes (package/docsindexes, renamed-slug URLs);server/api/__sitemap__/docs.get.tsserves the same list to the sitemap.crawlLinkspicks up everything else. Both need theGITHUB_TOKENenvironment variable. -
Documentation API (
server/api/packages/[slug]/docs/[version]/[...path].get.ts) resolves a route todocs/{path}.mdon the version's branch throughresolveDoc()inserver/utils/docSource.ts, which caches the GitHub fetch for 24 hours, then applies rendering-only workarounds to the Markdown. The raw twin (server/routes/raw/open-source/packages/[slug]/docs/[version]/[...path].get.ts, advertised byserver/routes/llms.txt.get.ts) serves the same file verbatim throughresolveDoc()for AI agents, so rendering workarounds stay out of that path. -
GitHub utilities (
server/utils/github.ts) provide a singleton Octokit client and helpers for fetching repository metadata and file contents. -
Package data enrichment (
server/api/packages.get.ts) fetches GitHub stars/topics and Packagist download counts to enrich package metadata.
- Static site generation (SSG): The site is fully prerendered with
nitro.static: trueandautoSubfolderIndex: false(no trailing slashes in URLs). - Trailing slash middleware:
app/middleware/redirect-trailing-slash.global.tsenforces no trailing slashes with 301 redirects. - Comark content rendering: Uses
@comark/nuxt(the<Markdown>component, taking raw Markdown via:value) for Markdown rendering with custom Prose components inapp/components/prose/. Syntax highlighting is configured per-page via Comark'sshikiplugin, passed through the:pluginsprop. - Cached API handlers: Documentation endpoints use
defineCachedEventHandlerwith 24-hour cache TTL. - Type safety: Shared TypeScript types in
shared/types/define the package data structure used across client and server.
app/
components/ # Vue components
prose/ # Custom Comark prose components (*.global.vue)
composables/ # Composables (canonical + Markdown alternate links)
data/ # Package definitions (packages.ts)
middleware/ # Global middleware (trailing slash redirect)
pages/ # File-based routing
assets/css/ # Global CSS (Tailwind)
server/
api/ # Nitro API routes (incl. __sitemap__ source)
routes/ # Non-API routes (llms.txt, /raw Markdown twins)
utils/ # Server utilities (GitHub, Packagist)
shared/types/ # Shared TypeScript interfaces
shared/utils/ # Shared helpers (auto-imported on client + server)
public/ # Static assets
- Nuxt config (
nuxt.config.ts): Configures modules (@nuxt/eslint, @nuxt/fonts, @nuxt/icon, @nuxt/image, @comark/nuxt, @nuxtjs/sitemap, reka-ui/nuxt), Tailwind via Vite plugin, static prerendering (nitro.static,crawlLinks,autoSubfolderIndex: false), route rules (redirects + prerender), fonts, and sitemap. - ESLint (
eslint.config.mjs): Extends Nuxt's config with Prettier integration, disables the multi-word component names and single-root template rules. - Prettier: 4-space tabs, single quotes, 120 print width, Tailwind plugin for class sorting.
- Environment variables:
GITHUB_TOKEN(needed for build; the build does not fail without it: GitHub errors, including unauthenticated rate limits, are logged and the affected docs pages are skipped, so check the prerender output — locally,GITHUB_TOKEN="$(gh auth token)" pnpm build),NUXT_PUBLIC_SITE_URL(defaults to localhost:3000).
To add a new package:
- Add entry to
app/data/packages.tswith all required metadata - Ensure the GitHub repo has a
docs/directory in the specified branch - The documentation will be automatically discovered and prerendered on next build
To modify documentation rendering:
- Edit Prose components in
app/components/prose/(these override Comark's default element rendering) - Adjust the Comark
shikiplugin config in the docs page (app/pages/open-source/packages/[slug]/docs/[version]/[...path].vue) for syntax highlighting languages/themes
The main branch is production (not main or master). All PRs should target this branch.