This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
- Dev server:
npm run dev(starts Astro dev server on localhost:4321) - Build:
npm run build(fetches GitHub stars, then generates static site indist/) - Preview:
npm run preview(serves built site for testing) - Tests:
npm run test:e2e(runs Playwright E2E tests) - Single test:
npx playwright test tests/specific-test.spec.ts - Format:
npx prettier --write . - Fetch GitHub stars:
npm run fetch-stars(updates cached star data from GitHub REST API)
- Secrets are expected via local environment variables
- Admin authentication uses Astro's server-only env support
This is a personal blog/portfolio website built with Astro as the primary framework, using selective hydration with React and Svelte components.
- Framework: Astro 5.x (static site generation with hybrid SSR)
- UI Libraries: React 18, Svelte 5, TypeScript
- Content: Astro Content Collections with Zod schema validation
- Styling: SCSS with CSS custom properties, dark/light theme support
- Testing: Playwright for E2E tests
- Deployment: Netlify (static hosting with serverless functions)
- Authentication: Single-user admin system with HTTPOnly cookies and session tokens
-
src/content/: Content Collectionsblog/- Blog posts in MDX format organized by yearsketch/- Creative coding projects/sketches- Content schema defined in
src/content.config.tswith Zod validation
-
src/components/: Mixed component architecture.astrofiles for static/server-rendered componentsreact/subdirectory for React components requiring client-side interactivityml/subdirectory for TensorFlow.js machine learning demos
-
src/sketches/: Canvas-based generative art using canvas-sketch library- Each sketch has corresponding
.ts/.tsxfile and MDX content file - Uses Two.js, canvas-sketch, and custom Vector utilities
- Each sketch has corresponding
-
src/layouts/: Astro layout componentsBlogPost.astro- Blog post template with comments integrationSketch.astro- Creative coding project template
-
src/pages/: File-based routing- Dynamic routes using
[...id].astropattern - RSS feed generation in
rss.xml.js - GitHub Stars: Paginated by year at
/stars/[year]/(e.g.,/stars/2025/,/stars/2024/)/stars/redirects to current year- Data cached in
src/data/github-stars.jsonat build time - Fetched via REST API using
scripts/fetch-github-stars.js
- Authentication:
/login/- Admin login page with form-based authentication/admin/- Protected admin dashboard (requires authentication)/api/logout/- Logout endpoint supporting both GET and POST requests
- Dynamic routes using
Content is managed through Astro Content Collections with strict TypeScript schemas:
// Blog posts require: title, description, pubDate, tags
// Optional: updatedDate, showDate, isDraft, cardImage- Files starting with
_are ignored by the content loader - Blog posts support both
.mdand.mdxformats - Sketches have additional
previewImagefield for gallery display
- Most components are static Astro components for performance
- Client-side interactivity uses Astro hydration directives where needed
- Svelte components for specific interactive elements
- TensorFlow.js demos use selective hydration for performance
- Authentication pages use
export const prerender = falsefor server-side rendering
- Global styles in
src/styles/global.scss - CSS Modules for component-specific styling (
.module.cssfiles) - CSS custom properties for theming
- Modern-normalize for consistent cross-browser styling
- Fira Code font for code blocks
Single-user admin authentication with the following components:
-
Middleware (
src/middleware.ts): Route protection for/admin/*paths- Session token validation using secure hash comparison
- Redirects unauthenticated users to login with return URL
- Adds auth context to
Astro.localsfor use in pages
-
Login (
src/pages/login.astro): Form-based authentication- Simple credential validation using
astro:env/server(appropriate for single-user system) - Generates session tokens with format:
username|timestamp|hash - Sets HTTPOnly cookies for security (secure in production)
- Simple credential validation using
-
Session Management:
- Session tokens use SHA-256 hash with secret and timestamp
- 1 month token expiration
- URL-safe delimiter (
|) to handle email addresses in usernames
-
Environment Variables: Uses Astro 5.x
astro:envsystem- Type-safe server environment variables with schema validation
- Required variables:
ADMIN_USERNAME,ADMIN_PASSWORD,ADMIN_SECRET
-
Rate Limiting: Expected to be handled at the hosting or edge layer
Playwright E2E tests configured to:
- Test against Chromium, Firefox, and WebKit
- Run against dev server (
npm run dev) for authentication testing - Generate HTML reports in
playwright-report/ - Retry failed tests on CI environments
- Includes authentication, search, index, and visual regression coverage in
tests/
- TypeScript: Strict mode enabled, prefer interfaces over types
- Imports: External packages first, then internal utilities/components
- Components: Functional components with destructured props
- Naming: PascalCase for components, camelCase for utilities, kebab-case for content files
- Formatting: Prettier with single quotes, no semicolons, trailing commas
- Module System:
package.jsoncontains "type": "module", so useimport, notrequire, when writing node scripts
- All URLs have a trailing slash