# CLAUDE.md

Development guidance for this Astro template repository.

## Commands

### Core Development
```bash
pnpm dev              # Development server
pnpm build            # Build for production
pnpm preview          # Preview build with Wrangler
pnpm deploy           # Deploy to Cloudflare Pages
```

### Utilities
```bash
pnpm commit           # AI-powered commit messages
pnpm convert:avif:all # Convert all images to AVIF
pnpm convert:avif:jpeg
pnpm convert:avif:png
pnpm cf-typegen       # Generate Cloudflare types
```

## Change Documentation

**IMPORTANT**: Update `dev/continuity.md` when making changes to document:
- What changed and why
- Decisions made
- Next steps

## Architecture

Minimal Astro template with content-driven architecture:

### Content Layer (`src/content/`)
- **blog/** - MDX blog posts with schema validation
- **sections/** - Homepage sections (hero, experience, skills, featured-project)
- **pages/** - Page-specific content (contact)

Schema defined in `src/content.config.ts`

### Component Layer
- **Core UI**: BlogCard, FormattedDate, Navigation, Footer, GridOverlay
- **Blog**: BlogFilters, ReadingProgress, TableOfContents, PostNavigation, RelatedPosts
- **Sections**: Hero, Experience, Skills, FeaturedProject

### Routes
- Static routes in `src/pages/`
- Dynamic blog routes via `[...slug].astro`
- Layouts in `src/layouts/`

## Data Flow

**Blog Index** (`src/pages/blog/index.astro`):
1. Fetch all posts via `getCollection('blog')`
2. Sort by pubDate (newest first)
3. Identify featured post (first with `featured: true`)
4. Render featured hero + filterable grid
5. Extract categories for filter UI

**Individual Posts** (`src/pages/blog/[...slug].astro`):
1. `getStaticPaths()` generates routes
2. Calculate previous/next posts (by date)
3. Find related posts (matching category/tags, limit 3)
4. Calculate reading time (200 wpm)
5. Pass to `BlogPost` layout

## Image Handling
- `src/assets/` - Processed by Astro (relative paths)
- `public/media/` - Served as-is (absolute paths like `/media/file.mp4`)
- AVIF conversion utility available

## Deployment
- Cloudflare Pages adapter configured
- Image service: "compile" mode
- Platform proxy enabled for development

## Utility Scripts

- **`src/utils/convert-to-avif.js`** - Image optimization
- **`src/utils/git-commit.js`** - AI commit message generation (requires OpenRouter API key in `src/utils/.env`)
