|
| 1 | +# AI agent guide for this repo |
| 2 | + |
| 3 | +This repo is an Astro 5 + MDX site with optional React "islands," Tailwind CSS v4, math rendered through KaTeX, and a small PDF→image pipeline. It renders a single-page research project site from `src/paper.mdx` using `src/pages/index.astro` as the layout and a curated set of components. |
| 4 | + |
| 5 | +## Architecture and key files |
| 6 | + |
| 7 | +- Astro + MDX content |
| 8 | + - Entry content: `src/paper.mdx` (MDX with YAML frontmatter). Frontmatter keys: `title`, `authors`, `conference`, `notes`, `links`, `description`, `favicon`, `thumbnail`, `theme`. |
| 9 | + - Layout: `src/pages/index.astro` imports the content and frontmatter from `src/paper.mdx`, sets `<html data-theme>`, OpenGraph tags, favicon, and uses `import.meta.env.BASE_URL` to prefix public assets for GitHub Pages. |
| 10 | +- Components (examples) |
| 11 | + - `Figure.astro` provides a consistent figure/caption pattern via named slots `figure` and `caption`. |
| 12 | + - `Picture.astro` wraps `astro:assets` with PDF support via `src/lib/render-pdf.ts`. `src` accepts either an `ImageMetadata` import or a string path ending with `.pdf` (path is resolved relative to `./src/pages/`). |
| 13 | + - `Video.astro`, `YouTubeVideo.astro`, `ModelViewer.astro` (`<model-viewer>`), `Carousel.astro`/`CarouselSlide.astro`, `Comparison.tsx` (React compare slider). React components require a `client:*` hydration directive when used inside MDX/`.astro`. |
| 14 | + - Math is rendered with `remark-math` + `rehype-katex`, so just write inline `$...$` or block `$$...$$` expressions inside MDX—no dedicated component is needed. |
| 15 | +- Styling |
| 16 | + - Tailwind v4 via `@tailwindcss/vite`; global styles in `src/styles/global.css` with a custom `dark` variant keyed off `data-theme`. |
| 17 | + - Code blocks themed with `astro-expressive-code` (see `astro.config.ts` styleOverrides and theme selector). |
| 18 | +- TypeScript & paths |
| 19 | + - TS strict config with JSX set to React; alias `@/*` → `./src/*` in `tsconfig.json`. |
| 20 | + |
| 21 | +## Developer workflows |
| 22 | + |
| 23 | +- Node.js: Local docs recommend Node 24+. CI uses Node 20 (see `.github/workflows/astro.yml`). If you adopt Node 24-only features, update the workflow accordingly. |
| 24 | +- Install & run |
| 25 | + - `npm install` |
| 26 | + - `npm run dev` → http://localhost:4321 |
| 27 | + - `npm run build` runs typecheck (`astro check`) then `astro build` |
| 28 | + - `npm run preview` serves the built site |
| 29 | +- Lint/format (configured but no npm scripts): |
| 30 | + - ESLint: `eslint.config.ts` covers JS/TS/TSX, Astro, JSON, Markdown, and CSS (Tailwind v4 syntax). Run with `npx eslint .`. |
| 31 | + - Prettier: `prettier.config.ts` with `prettier-plugin-astro` and `prettier-plugin-tailwindcss`. Run with `npx prettier -w .`. |
| 32 | +- Deploy |
| 33 | + - GitHub Pages is the default. Pushing to `main` builds and deploys via `.github/workflows/astro.yml`. The workflow passes `--site`/`--base`, so use `import.meta.env.BASE_URL` for public URLs (the layout in `src/pages/index.astro` already handles favicon/OG). Vercel/Netlify buttons also exist in `README.md`. |
| 34 | + |
| 35 | +## Project-specific conventions |
| 36 | + |
| 37 | +- Content lives in `src/paper.mdx`; import components at top and optionally map MD elements (e.g., `export const components = { table: Table }`). |
| 38 | +- Layout logic lives in `src/pages/index.astro`, which imports the content and frontmatter from `src/paper.mdx` using `import { Content, frontmatter } from "../paper.mdx"`. |
| 39 | +- Use the provided components for consistent layout: |
| 40 | + - Wrap visuals in `<Figure>` with slots: `<slot name="figure"/>` and `<slot name="caption"/>`. |
| 41 | + - Prefer `<Picture>` for images. It accepts: |
| 42 | + - imported images (Astro's `ImageMetadata`) for optimized images; or |
| 43 | + - a relative PDF path like `"../assets/plot.pdf"` to auto-render page 1 to PNG during build/dev. |
| 44 | + - `Carousel` expects `CarouselSlide` children to render each slide; place any markup inside each slide and the component handles pagination buttons, swipe, and keyboard focus states for you. |
| 45 | + - For React, import the component and add a hydration directive where used, e.g., `<Comparison client:idle>…</Comparison>`. |
| 46 | +- Theme handling |
| 47 | + - Set `theme` in frontmatter to `device | light | dark`. The layout in `src/pages/index.astro` writes `data-theme` and Tailwind's custom `dark` variant reads it. Use class `dark:*` utilities as needed; you can invert images in dark mode via `<Picture invertInDarkMode />`. |
| 48 | +- Assets & paths |
| 49 | + - Public assets in `public/` are served at the base URL; when constructing absolute URLs in the layout (`src/pages/index.astro`) or components, prefix with `import.meta.env.BASE_URL` (the layout already exposes `prefix`). |
| 50 | + - PDF conversion reads from `./src/pages/<path>` and writes to `dist/_astro/<name>.png`. In dev, `Picture.astro` points to `../dist/_astro/...`; in prod it points to `_astro/...`. Only the first page is rendered at 4× scale. |
| 51 | + |
| 52 | +## Integration points and examples |
| 53 | + |
| 54 | +- Icons via `astro-icon` using Iconify sets (see dependencies `@iconify-json/academicons`, `@iconify-json/ri`). Example: frontmatter `links` items include `icon: academicons:arxiv`. |
| 55 | +- Code blocks are styled by `astro-expressive-code`; don't manually theme them—follow the existing configuration in `astro.config.ts`. |
| 56 | +- To add a new interactive component: |
| 57 | + 1. Create it under `src/components/` (Astro or React). |
| 58 | + 1. Import it in `src/paper.mdx`. |
| 59 | + 1. For React, add `client:*` (e.g., `client:idle`) at the usage site. |
| 60 | + |
| 61 | +If anything here seems off or incomplete (tests aren’t defined, additional pages, alt deploys), tell me what’s missing and I’ll refine these instructions. |
0 commit comments