|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project overview |
| 6 | + |
| 7 | +Adapty documentation site (codename Cassiopeia). Built with **Astro 5 + MDX + React + Tailwind CSS 4**. Covers 7 SDK platforms: iOS, Android, React Native, Flutter, Unity, Kotlin Multiplatform, Capacitor. |
| 8 | + |
| 9 | +Deployed to **https://adapty.io/docs** via AWS S3 + CloudFront. GitHub Actions deploy `develop` → staging, `main` → production. |
| 10 | + |
| 11 | +## Commands |
| 12 | + |
| 13 | +```bash |
| 14 | +npm run dev # Dev server at localhost:4321 (runs prebuild + build:md first) |
| 15 | +npm run build # Production build → ./build/ |
| 16 | +npm run preview # Serve production build locally |
| 17 | +``` |
| 18 | + |
| 19 | +No test suite or linter is configured. Package manager: **Yarn 1.22**. |
| 20 | + |
| 21 | +## Content architecture |
| 22 | + |
| 23 | +All articles live in `src/content/docs` as `.mdx` files. Subdirectories are for organization only — **URLs are derived from filename alone**, not folder path (e.g., `version-3.0/ios/sdk-installation-ios.mdx` → `/docs/sdk-installation-ios`). |
| 24 | + |
| 25 | +### Frontmatter schema |
| 26 | + |
| 27 | +```yaml |
| 28 | +title: "Required display title" |
| 29 | +description: "SEO description" |
| 30 | +metadataTitle: "Browser tab title | Adapty Docs" |
| 31 | +keywords: ['array', 'of', 'keywords'] |
| 32 | +rank: 100 # Sort priority, default 50 |
| 33 | +customSlug: "override-url" # Optional URL override |
| 34 | +``` |
| 35 | +
|
| 36 | +### Navigation |
| 37 | +
|
| 38 | +Sidebars are defined per platform in `src/data/sidebars/*.json` (ios, android, react-native, flutter, unity, kmp, capacitor, tutorial, api). Each entry references an article by its filename-based `id`. To add an article to navigation, add its id to the appropriate sidebar JSON. |
| 39 | + |
| 40 | +### Images |
| 41 | + |
| 42 | +- Article-specific: `src/assets/{article-name}/image.png` |
| 43 | +- Shared: `src/assets/shared/image.png` |
| 44 | +- Use `<ZoomImage id="image.png" width="700px" alt="desc" />` (preferred) |
| 45 | +- Legacy `<Zoom><img src={require(...)}/></Zoom>` still works |
| 46 | + |
| 47 | +### Path aliases |
| 48 | + |
| 49 | +- `@site` → repo root |
| 50 | +- `@components` → `src/components/` |
| 51 | + |
| 52 | +## Key components |
| 53 | + |
| 54 | +| Component | Import required? | Usage | |
| 55 | +|-----------|-----------------|-------| |
| 56 | +| `ZoomImage` | Yes | `<ZoomImage id="file.png" width="700px" alt="..." />` | |
| 57 | +| `Tabs`/`TabItem` | Yes | `<Tabs groupId="platform"><TabItem value="ios" label="iOS">...</TabItem></Tabs>` | |
| 58 | +| `Details` | Yes | `<Details summary="Title">content</Details>` | |
| 59 | +| `InlineTooltip` | Yes | `<InlineTooltip tooltip="hover text">[link](page.md)</InlineTooltip>` | |
| 60 | +| `CustomDocCardList` | Yes | `<CustomDocCardList ids={['id1','id2']} />` or `<CustomDocCardList />` for auto | |
| 61 | +| `Button` | **No** (auto-registered) | `<Button id="page-id">Text</Button>` or `<Button href="url">Text</Button>` | |
| 62 | +| `Callout` | **No** (remark plugin) | `:::note`, `:::tip`, `:::info`, `:::warning`, `:::danger`, `:::important`, `:::link` | |
| 63 | + |
| 64 | +Import path pattern: `import Component from '@site/src/components/Component.astro';` |
| 65 | + |
| 66 | +## Reusable content snippets |
| 67 | + |
| 68 | +`src/components/reusable/` contains MDX snippets that can be imported into multiple articles to avoid content duplication. |
| 69 | + |
| 70 | +## Remark/Rehype plugins (`src/plugins/`) |
| 71 | + |
| 72 | +- `remark-aside` — converts `:::note`/`:::tip`/etc. fenced directives into `<Callout>` components |
| 73 | +- `remark-transform-links` — strips `.md`/`.mdx` extensions from internal links |
| 74 | +- `remark-transform-require` — handles legacy `require()` image imports |
| 75 | +- `remark-transform-details` — processes `<Details>` components |
| 76 | +- `remark-heading-id` — auto-generates heading anchors |
| 77 | +- `remark-strip-imports` — removes imports during markdown export |
| 78 | +- `remark-strip-highlight-comments` — cleans highlight syntax |
| 79 | + |
| 80 | +## Code blocks |
| 81 | + |
| 82 | +````markdown |
| 83 | +```swift title="MyApp.swift" {2,4-6} |
| 84 | +// Line highlighting and title supported via Shiki transformers |
| 85 | +``` |
| 86 | +```` |
| 87 | + |
| 88 | +## Learning and Memory Management |
| 89 | + |
| 90 | +- YOU MUST use the journal tool frequently to capture technical insights, failed approaches, and user preferences |
| 91 | +- Before starting complex tasks, search the journal for relevant past experiences and lessons learned |
| 92 | +- Document architectural decisions and their outcomes for future reference |
| 93 | +- Track patterns in user feedback to improve collaboration over time |
| 94 | +- When you notice something that should be fixed but is unrelated to your current task, document it in your journal rather than fixing it immediately |
| 95 | + |
| 96 | +## Styling architecture |
| 97 | + |
| 98 | +### CSS files |
| 99 | + |
| 100 | +| File | Role | |
| 101 | +|------|------| |
| 102 | +| `src/styles/global.css` | **Primary stylesheet.** Tailwind import, theme variables (`@theme`), light/dark CSS custom properties, all design block styles (code blocks, details, callouts, tables, zoom images, heading anchors, task lists, highlight lines) | |
| 103 | +| `src/css/custom.css` | Legacy Docusaurus-era variables (`--purplePrimary`, `--ifm-*`). Still loaded via `src/css/custom.scss` but superseded by `global.css` for new work | |
| 104 | +| `src/css/api-reference.css` | Styles for the Stoplight API reference pages | |
| 105 | +| `src/css/fonts/fonts.css` | `@font-face` declarations for Inter, Roboto, Fira Code | |
| 106 | + |
| 107 | +### Theme system |
| 108 | + |
| 109 | +- Light/dark mode toggled via `.dark` class on `<html>` (persisted in `localStorage`) |
| 110 | +- All design tokens are CSS custom properties defined in `:root` (light) and `.dark` (dark) blocks in `global.css` |
| 111 | +- Key tokens: `--bg-primary`, `--bg-secondary`, `--text-primary`, `--text-secondary`, `--accent-primary` (`#5c13ff` light / `#a78bfa` dark), `--border-primary`, `--shadow-sm/md/lg` |
| 112 | +- Brand color: `--color-primary-500: #6720ff` |
| 113 | +- Fonts: Inter (body), Fira Code (code blocks) |
| 114 | +- Tailwind 4 configured in `global.css` via `@theme` block (custom font sizes, line heights, brand colors) |
| 115 | + |
| 116 | +### Design blocks in `global.css` |
| 117 | + |
| 118 | +These are the styled visual blocks that articles use — their CSS lives entirely in `global.css`: |
| 119 | + |
| 120 | +- **Code blocks** (`.code-block-wrapper`) — title bar, copy button, Shiki syntax highlighting, dark mode color inversion, diff styling, line highlighting (`.highlight-line`) |
| 121 | +- **Callouts** — rendered by remark-aside plugin into `<Callout>` (note/tip/info/warning/danger/important/link) |
| 122 | +- **Details/Accordion** (`details`/`summary`) — collapsible sections with chevron animation |
| 123 | +- **Ordered lists** (`.docs-prose ol`) — circular step-number bullets (Mintlify-inspired) |
| 124 | +- **Zoom images** (`.zoom-wrapper`, `.zoom-image`) — bordered, shadowed, hover-scale images |
| 125 | +- **Tables** — word-break handling, code wrapping within cells |
| 126 | +- **Heading anchors** (`.heading-anchor`) — hover-revealed link icon |
| 127 | +- **Task lists** (`li:has(input[type="checkbox"])`) — checkbox styling |
| 128 | + |
| 129 | +### Layout |
| 130 | + |
| 131 | +- Single layout: `src/layouts/DocsLayout.astro` — assembles Header, Sidebar, Breadcrumbs, article content, TableOfContents, FeedbackForm, Footer |
| 132 | +- Layout applies Tailwind prose classes (`.docs-prose`) to article content |
| 133 | +- Right column (ToC + feedback) visible at `xl:` (1280px+), sidebar at `lg:` (1024px+) |
| 134 | +- API reference pages use `isFullWidth` mode (no sidebar/ToC) |
| 135 | + |
| 136 | +### Page routing |
| 137 | + |
| 138 | +- `src/pages/[...slug].astro` — main catch-all route for doc articles |
| 139 | +- `src/pages/[slug].astro` + `src/pages/[slug]/[...rest].astro` — API reference pages |
| 140 | + |
| 141 | +### UI components (non-content) |
| 142 | + |
| 143 | +These are layout/interactive components in `src/components/`, not imported by article authors: |
| 144 | + |
| 145 | +- `Header.astro` — top nav with platform switcher, search, theme toggle |
| 146 | +- `Sidebar.astro` / `SidebarItem.astro` — left navigation tree |
| 147 | +- `PlatformSwitcher.astro` — SDK platform selector in header |
| 148 | +- `Search.astro` — Algolia-powered search |
| 149 | +- `ThemeToggle.astro` — light/dark mode switch |
| 150 | +- `TableOfContents.astro` — right-column heading navigation |
| 151 | +- `FeedbackForm.astro` — page feedback widget |
| 152 | +- `Breadcrumbs.astro` — breadcrumb trail |
| 153 | +- `Footer.astro` — page footer |
| 154 | +- `ZoomLightbox.astro` — fullscreen image lightbox overlay |
| 155 | +- `Calculator.tsx` — interactive React calculator widget |
| 156 | +- `ApiReferencePage.astro` — Stoplight Elements API docs wrapper |
| 157 | + |
| 158 | +## Build pipeline details |
| 159 | + |
| 160 | +- `prebuild` copies shared assets (images, API specs) to `public/` |
| 161 | +- `build:md` generates plain markdown exports and LLM-optimized files (`scripts/generate-md.mjs`, `generate-llms.mjs`, `generate-platform-llms-full.mjs`) |
| 162 | +- Production build runs `astro build` then `build:md:prod` (outputs to `./build/`) |
| 163 | + |
| 164 | +## Reference |
| 165 | + |
| 166 | +Comprehensive component examples and writing guidelines: `TECH_WRITERS_README.md` |
0 commit comments