-
Notifications
You must be signed in to change notification settings - Fork 0
docs: add Cloudflare Nimbus documentation site #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dc7b6e4
docs: add Cloudflare Nimbus documentation site under docs/
amondnet 07724fe
chore(docs): apply AI code review suggestions
amondnet 74ae305
ci(codacy): exclude the docs/ Nimbus scaffold from analysis
amondnet c6f32a3
chore: apply AI code review suggestions
amondnet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| name: Docs | ||
|
|
||
| # Builds the Nimbus docs site (docs/) on every PR that touches it, and | ||
| # deploys it to Cloudflare (Workers static assets, docs/wrangler.jsonc) on main. | ||
| # | ||
| # Deploy needs two repository secrets: | ||
| # CLOUDFLARE_API_TOKEN — "Edit Cloudflare Workers" template. The custom | ||
| # domain route in wrangler.jsonc also needs | ||
| # Zone:DNS:Edit on the pleaseai.dev zone. | ||
| # CLOUDFLARE_ACCOUNT_ID | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'docs/**' | ||
| - .github/workflows/docs.yml | ||
| pull_request: | ||
| paths: | ||
| - 'docs/**' | ||
| - .github/workflows/docs.yml | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: docs-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| # CI runs no git hooks, so skip the cargo:hk source build (matches ci.yml). | ||
| MISE_DISABLE_TOOLS: cargo:hk | ||
| defaults: | ||
| run: | ||
| working-directory: docs | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup mise (node, bun) | ||
| uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0 | ||
|
|
||
| - name: Install dependencies | ||
| run: bun install --frozen-lockfile | ||
|
|
||
| - name: Typecheck | ||
| run: bun run typecheck | ||
|
|
||
| - name: Build | ||
| run: bun run build | ||
|
|
||
| - name: Nimbus preflight | ||
| run: bun run check | ||
|
|
||
| - name: Upload site | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: docs-dist | ||
| path: docs/dist | ||
| retention-days: 7 | ||
|
|
||
| deploy: | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| environment: | ||
| name: docs | ||
| url: https://code-search.pleaseai.dev | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Download site | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| name: docs-dist | ||
| path: docs/dist | ||
|
|
||
| - name: Deploy to Cloudflare | ||
| uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0 | ||
| with: | ||
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| workingDirectory: docs | ||
| command: deploy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| node_modules/ | ||
| dist/ | ||
| .astro/ | ||
| .wrangler/ | ||
|
|
||
| .env | ||
| .env.local | ||
| .env.*.local | ||
| .env.production | ||
| .dev.vars | ||
| .dev.vars.* | ||
|
|
||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| pnpm-debug.log* | ||
|
|
||
| .DS_Store | ||
| .idea/ | ||
| .vscode/* | ||
| !.vscode/extensions.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| # This Nimbus docs site | ||
|
|
||
| Astro-based docs. The `nimbus-docs` package handles content schemas, sidebar/TOC, MDX→markdown, build hooks, and the `nimbus` CLI. Everything in `src/` is yours to edit. | ||
|
|
||
| ## File layout | ||
|
|
||
| ``` | ||
| astro.config.ts # imports nimbus + defineNimbusConfig | ||
| src/ | ||
| ├── components.ts # MDX globals registry — every component used in .mdx must be listed | ||
| ├── components/ # AgentDirective, Header, Render + ui/<slug>/ | ||
| ├── content/ | ||
| │ ├── docs/*.mdx | ||
| │ └── partials/*.mdx # referenced via <Render file="..." /> | ||
| ├── content.config.ts # registers docsCollection() + partialsCollection() | ||
| ├── layouts/ # BaseLayout (NimbusHead), DocsLayout (sidebar/TOC/breadcrumbs) | ||
| ├── lib/cn.ts # Tailwind className merger | ||
| ├── pages/ | ||
| │ ├── [...slug].astro | ||
| │ ├── [...slug]/index.md.ts # per-page markdown alternate | ||
| │ ├── llms.txt.ts | ||
| │ ├── og.png.ts # site-level OG card | ||
| │ ├── og/ | ||
| │ │ ├── _og-card-config.ts # shared OG theme tokens (underscore = not a route) | ||
| │ │ └── [...slug].ts # per-page OG cards | ||
| │ └── robots.txt.ts | ||
| └── styles/ # globals.css, prose.css | ||
| ``` | ||
|
|
||
| Cloudflare deploys also have `wrangler.jsonc` at the project root. | ||
|
|
||
| ## Writing docs | ||
|
|
||
| Frontmatter validates against `docsSchema` (`nimbus-docs/schemas`). Required: `title`. | ||
|
|
||
| ```mdx | ||
| --- | ||
| title: My page | ||
| description: One-line summary. | ||
| --- | ||
|
|
||
| Content here. The page H1 comes from `title` — don't repeat it in the body. | ||
|
|
||
| ## Section heading | ||
| ``` | ||
|
|
||
| Rules: | ||
|
|
||
| - **Components must be PascalCase and registered in `src/components.ts`.** A pre-build validator catches typos with a "did you mean" hint. | ||
| - **Partials use `<Render file="..." />`.** Don't import `.mdx` directly. Shared content lives in `src/content/partials/<slug>.mdx`. | ||
| - **Icons use `astro-icon` + Phosphor.** `<Icon name="ph:<glyph>" class="w-4 h-4" />` from `astro-icon/components`. Glyphs: [phosphoricons.com](https://phosphoricons.com). | ||
| - **Don't remove `<AgentDirective />` from `BaseLayout.astro`.** It points agents at `/llms.txt`. | ||
|
|
||
| ## Adding things | ||
|
|
||
| | Goal | Action | | ||
| |---|---| | ||
| | New doc page | Create `src/content/docs/<slug>.mdx`. Sidebar picks it up. | | ||
| | New partial | Create `src/content/partials/<slug>.mdx`. Use via `<Render file="<slug>" />`. | | ||
| | UI from registry | `bun run nimbus-docs add <slug>`. Register in `src/components.ts` if used in MDX. | | ||
| | Feature recipe | `bun run nimbus-docs add <feature-slug>`. Pipe the printed brief to your agent. | | ||
| | Check it builds | `bun run nimbus-docs check` — build-free preflight (env + structure + authoring + types). `--json` for an agent loop, `--fix` to repair what's safe. | | ||
| | Custom page route | Add a file under `src/pages/`. | | ||
| | Custom OG style | Edit `src/pages/og/_og-card-config.ts`. | | ||
| | Check for updates | `bun run nimbus-docs outdated` — starter files behind their tag + registry components behind. | | ||
| | Upgrade a starter file | `bun run nimbus-docs diff <file>` to review, `diff --apply <file>` to pull a clean upstream change. | | ||
| | Upgrade a registry component | `bun run nimbus-docs add <slug> --overwrite`, then review with `git diff`. | | ||
|
|
||
| List installable items: `bun run nimbus-docs list`. | ||
|
|
||
| ## Audit this site | ||
|
|
||
| Start with `bun run nimbus-docs check --json`. It runs the environment, structural, authoring, and type checks build-free — config validity, `site` placeholder, route collisions, MDX component resolution, the lint rules, and a `tsc` type-check — and returns three top-level signals plus per-scope detail: | ||
|
|
||
| - **`status`** (`passed` | `failed` | `partial`) and **`readiness`** (`buildable` | `blocked` | `unknown`) are the primary signals. `status` is the whole-run verdict; `readiness` answers "does env + structure say it builds?". `ok` (=== zero errors) is kept for back-compat only. | ||
| - **`findings[{scope,code,severity,file,line,message,fixable,fix}]`** are problems we evaluated. Apply each `fix` (or `check --fix`). | ||
| - **`scopes[].notes[{code,reason,requiresBuild?,requiresInput?}]`** are checks we *couldn't* evaluate yet (e.g. types before a build). A note is never a finding and never carries a `fix` — you resolve it by making the missing thing exist (usually a build), not by `--fix`. `summary.notes` counts them. | ||
|
|
||
| Loop terminates on `status !== "failed" && summary.fixable === 0` — a `partial` run with nothing left to fix is a **stop** (optionally build, then re-check), not a `--fix` retry. Exit is `1` only when `status` is `"failed"`. For full coverage (types + link-checking) run a build first, then `check` again. | ||
|
|
||
| Then walk the categories below for what `check` doesn't cover yet — route-file existence, registry hygiene, the AI surface, post-build search, and Cloudflare config. Emit findings as: | ||
|
|
||
| ``` | ||
| - [error|warn|info] FILE:LINE — what + why + fix. | ||
| ``` | ||
|
|
||
| End with `Summary: N errors, N warnings.` | ||
|
|
||
| - **Config** — `astro.config.ts` calls `nimbus(defineNimbusConfig({ ... }))`; `site` is set; `editPattern` (if set) contains `{path}`; `output:` matches the deploy target. | ||
| - **Content** — `content.config.ts` registers `docsCollection()` (and `partialsCollection()` if used); every `.mdx` is inside a registered collection; frontmatter validates. | ||
| - **Sidebar** — every sidebar ref resolves to a content entry; no orphans; no slug collisions. | ||
| - **MDX** — every PascalCase component in `*.mdx` is registered; every `<Render file=...>` resolves; code-fence languages are valid. | ||
| - **Routes** — `llms.txt.ts`, `robots.txt.ts`, `[...slug]/index.md.ts`, `og.png.ts`, `og/[...slug].ts` all exist. | ||
| - **Registry hygiene** — every `src/components/ui/<slug>/` is either MDX-registered or imported in `src/`; transitive deps (`lib/cn.ts`, etc.) exist. | ||
| - **AI surface** — `<AgentDirective />` renders in `BaseLayout.astro`; doc `<head>` has `<link rel="alternate" type="text/markdown" ...>`. | ||
| - **Search** — `data-pagefind-body` is on the docs main wrapper; after `bun run build`, `dist/pagefind/` exists with ≥1 indexed page. | ||
| - **Cloudflare** (if applicable) — `wrangler.jsonc` has `name`, `compatibility_date`, `assets.directory = "./dist"`, `not_found_handling`. | ||
|
|
||
| ## Don't | ||
|
|
||
| - Hand-add components under `src/components/ui/` that exists in the nimbus-docs registry — use `nimbus-docs add` so deps resolve. | ||
| - Import `.mdx` files directly — use `<Render file="..." />`. | ||
| - Attach remark/rehype plugins via `mdx({ remarkPlugins })` — Sätteri silently drops them. Framework-side transformations run as content passes. | ||
| - Remove `<AgentDirective />` unless asked. | ||
| - Edit `src/components.ts` to bypass registration — if a component is used in `.mdx`, register it. | ||
|
|
||
| ## Project home | ||
|
|
||
| [nimbus-docs.com](https://nimbus-docs.com) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import { defineConfig } from "astro/config"; | ||
| import tailwindcss from "@tailwindcss/vite"; | ||
| import nimbus, { | ||
| defineConfig as defineNimbusConfig, | ||
| } from "@cloudflare/nimbus-docs"; | ||
| import { tableScroll } from "@cloudflare/nimbus-docs/markdown"; | ||
|
|
||
| const nimbusConfig = defineNimbusConfig({ | ||
| // Canonical origin — the repository homepage. Drives canonical URLs, | ||
| // absolute OG image URLs, robots.txt, sitemap, and the links in /llms.txt. | ||
| site: "https://code-search.pleaseai.dev", | ||
| title: "csp", | ||
| description: | ||
| "Code Search Please — fast and accurate hybrid code search for agents. A Rust port of MinishLab/semble.", | ||
| locale: "en", | ||
| github: "https://github.com/pleaseai/code-search", | ||
| editPattern: "https://github.com/pleaseai/code-search/edit/main/docs/{path}", | ||
| socialImageAlt: "csp — Code Search Please documentation", | ||
| sidebar: { | ||
| // The content directory is flat (clean URLs like /installation); the | ||
| // rail is grouped here instead. Array position is the rail order. | ||
| items: [ | ||
| { | ||
| label: "Get started", | ||
| items: ["introduction", "installation", "quickstart"], | ||
| }, | ||
| { | ||
| label: "Agent setup", | ||
| items: ["mcp-server", "plugin", "agents-md", "sub-agent"], | ||
| }, | ||
| { | ||
| label: "Reference", | ||
| items: ["cli", "library", "how-it-works", "development"], | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
|
|
||
| export default defineConfig({ | ||
| // nimbus:adapter | ||
| output: "static", | ||
| // Tailwind v4 via its Vite plugin (the integration Astro recommends for | ||
| // Tailwind v4 — replaces the PostCSS plugin, which doesn't build under | ||
| // Astro 7's Vite 8 bundler). | ||
| vite: { | ||
| plugins: [tailwindcss()], | ||
| }, | ||
| // Hover-prefetch link targets so full-page navigations feel instant without | ||
| // a client-side router. | ||
| prefetch: { | ||
| prefetchAll: true, | ||
| defaultStrategy: "hover", | ||
| }, | ||
| integrations: [ | ||
| nimbus(nimbusConfig, { | ||
| // Authoring rules are opt-in by design — your repo, your taste. The | ||
| // two below are the load-bearing pair: frontmatter has to validate | ||
| // against the content schema for the page to render properly, and | ||
| // broken internal links are 404s for your readers. Add the others | ||
| // (heading hierarchy, code-block language, style, etc.) when you're | ||
| // ready to enforce them — see `nimbus-docs lint --help`. | ||
| rules: { | ||
| "nimbus/frontmatter-shape": "error", | ||
| "nimbus/internal-link": "error", | ||
| }, | ||
| // Wrap wide tables so they scroll instead of overflowing the page | ||
| // (styled by `.nb-table-scroll` in src/styles/prose.css). | ||
| markdown: { | ||
| hastPlugins: [tableScroll()], | ||
| }, | ||
| }), | ||
| ], | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.