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 (
scripts/discover-routes.ts) crawls GitHub repos during prerendering to discover all documentation pages and generate static routes. RequiresGITHUB_TOKENenvironment variable. -
Documentation API (
server/api/packages/[slug]/docs/[version]/[...path].ts) fetches Markdown files from GitHub using the Octokit client, with 24-hour caching. Files are fetched fromdocs/{path}.mdin the repository's branch corresponding to the version. -
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.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. - MDC content rendering: Uses
@nuxtjs/mdcfor Markdown rendering with custom Prose components inapp/components/prose/. - 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 MDC prose components (*.global.vue)
data/ # Package definitions (packages.ts)
layouts/ # Layout components
middleware/ # Global middleware (trailing slash redirect)
pages/ # File-based routing
assets/css/ # Global CSS (Tailwind)
server/
api/ # Nitro API routes
utils/ # Server utilities (GitHub, Packagist)
scripts/ # Build scripts (route discovery)
shared/types/ # Shared TypeScript interfaces
public/ # Static assets
- Nuxt config (
nuxt.config.ts): Configures modules (@nuxt/eslint, @nuxt/fonts, @nuxt/icon, @nuxt/image, @nuxtjs/mdc, @nuxtjs/sitemap), Tailwind via Vite plugin, MDC syntax highlighting, and prerender hooks. - ESLint (
eslint.config.mjs): Extends Nuxt's config with Prettier integration, disables multi-word component names rule. - Prettier: 4-space tabs, single quotes, 120 print width, Tailwind plugin for class sorting.
- Environment variables:
GITHUB_TOKEN(required for 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 MDC defaults) - Modify MDC config in
nuxt.config.tsfor syntax highlighting languages/themes
The main branch is production (not main or master). All PRs should target this branch.