Skip to content

Migrate docs to MDX with self-dogfooding fingerprint + CLI rendering#37

Merged
nahiyankhan merged 2 commits intomainfrom
docs/mdx-dogfooding
Apr 20, 2026
Merged

Migrate docs to MDX with self-dogfooding fingerprint + CLI rendering#37
nahiyankhan merged 2 commits intomainfrom
docs/mdx-dogfooding

Conversation

@nahiyankhan
Copy link
Copy Markdown
Collaborator

Summary

  • Three prose pages (self-hosting, getting-started, cli-reference) migrate from handwritten JSX to MDX so the docs corpus is LLM-maintainable. Interactive pages (concepts, components, foundations) stay as React.
  • Self-dogfooding hooks: live fingerprint parse/lint in the browser via a new @ghost/core/browser subpath, and a CLI reference that renders from a codegen'd manifest walked off the cac registry — docs can't drift from CLI behavior.
  • Vocabulary stance: design systemdesign language across docs, skill bundle, types, and the review-command generator. Drift EngineDrift. Self-hosting page carries a yellow "Work in progress" banner flagging the end-to-end flow as untested.

What's new

MDX pipeline@mdx-js/rollup + remark-gfm / remark-frontmatter / remark-mdx-frontmatter + rehype-slug / rehype-autolink-headings / @shikijs/rehype. Zod-validated frontmatter at src/content/docs-frontmatter.ts drives routing via import.meta.glob. DocsMdxRoute reuses existing DocsPageLayout + AnimatedPageHeader + DocProse so there's no visual regression.

Browser-safe core — new ./browser subpath export in @ghost/core re-exports only pure modules (parse, lint, diff, reporters, types) via deep file-level imports. Node-only modules (sync.js, history.js, parent.js, writer.js) stay out of the browser bundle.

Fingerprint hooks<FingerprintPreview> / <FingerprintSample> MDX components parse and lint a real fingerprint.md inline. Sample at apps/docs/src/content/fingerprint-samples/ghost-ui.md is lint-gated in CI.

CLI manifest codegenpackages/ghost-cli/src/cli.ts now exports buildCli() (bin.ts is a 5-line runner). scripts/dump-cli-help.mjs walks the cac registry and writes apps/docs/src/generated/cli-manifest.json. <CliHelp command="…"> renders flag tables from the manifest; the CLI reference page shrinks from 539 JSX lines to ~170 MDX lines.

Validationcheck:docs validates MDX frontmatter, scans for broken internal links, and runs lintFingerprint against fingerprint samples. check:cli-manifest fails when the committed manifest drifts from the CLI. Both wired into pnpm check.

Test plan

  • pnpm check (biome + typecheck + file-sizes + docs frontmatter + CLI manifest drift)
  • pnpm test (159 tests, snapshot regenerated after design-language rename)
  • pnpm --filter @ghost/docs build clean
  • pnpm --filter @ghost/docs dev — browse /tools/drift/self-hosting (yellow banner), /tools/drift/getting-started (inline FingerprintSample), /tools/drift/cli (generated flag tables)
  • Edit apps/docs/src/content/docs/self-hosting.mdx → HMR reloads with no rebuild
  • Add a flag in packages/ghost-cli/src/cli.ts, run pnpm dump:cli-help → CLI reference picks it up

🤖 Generated with Claude Code

nahiyankhan and others added 2 commits April 20, 2026 14:45
Three prose pages (self-hosting, getting-started, cli-reference) move from
handwritten JSX to MDX so the docs corpus is LLM-maintainable and diff-friendly.
Interactive pages (concepts, components, foundations) stay as React.

Pipeline: @mdx-js/rollup + remark-gfm/remark-frontmatter + rehype-slug/autolink/shiki
wired into apps/docs. Zod-validated frontmatter drives routing via import.meta.glob;
a new DocsMdxRoute reuses the existing DocsPageLayout + AnimatedPageHeader + DocProse
so visual parity is preserved.

Self-dogfooding:
- New @ghost/core/browser subpath export re-exports only pure modules (parse,
  lint, diff, reporters, types). FingerprintPreview + FingerprintSample MDX
  components parse and lint a real fingerprint.md in the browser.
- New scripts/dump-cli-help.mjs walks the cac registry via buildCli() from the
  refactored ghost-cli/cli.ts and emits apps/docs/src/generated/cli-manifest.json.
  CliHelp MDX component renders flag tables from the manifest; CLI reference
  page collapses from 539 JSX lines to ~170 MDX lines.

Validation: check:docs lints MDX frontmatter, broken internal links, and runs
lintFingerprint against fingerprint samples. check:cli-manifest fails when the
committed CLI manifest drifts from the CLI. Both wired into pnpm check.

Design vocabulary: swapped 'design system' to 'design language' across
docs, skill bundle, types, fingerprint samples, and the review-command
generator (snapshot regenerated). Renamed 'Drift Engine' to 'Drift' and
'How Ghost Works' to 'How Ghost Drift Works'.

Self-hosting page carries a yellow Callout banner flagging the end-to-end
flow as untested; project's @theme resets the default Tailwind palette so
the callout uses the project's yellow swatches, not amber.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
scripts/check-docs-frontmatter.mjs runs from the repo root and imports
gray-matter + zod. Locally, pnpm hoisted both from workspace transitives
(apps/docs already depends on zod + gray-matter), so the script resolved
them. CI with stricter pnpm isolation (shamefully-hoist=false in .npmrc)
doesn't hoist transitively, so the script can't find them.

Also fix a biome template-literal warning in the same script.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@nahiyankhan nahiyankhan merged commit a202a08 into main Apr 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant