This file provides guidance to Claude Code when working with this repository.
This is a Docusaurus plugin that exposes documentation as raw markdown files for AI/LLM access. It's a fork of docusaurus-markdown-source-plugin by Nader Jaber (FlyNumber).
docusaurus-plugin-ai-docs/
├── index.js # Main plugin (postBuild hook, sitemap generation)
├── theme/Root.js # React wrapper that injects dropdown into pages
├── components/MarkdownActionsDropdown/ # Dropdown UI component
│ └── index.js
├── package.json
├── README.md
└── LICENSE
postBuildhook: Processes all.mdand.mdxfiles after Docusaurus buildcleanMarkdownForDisplay(): Converts MDX to clean markdown (strips React components, imports, JSX)generateSitemap(): Creates_sitemap.mdfollowing Docusaurus sidebar hierarchyparseSidebars(): Readssidebars.tsorsidebars.jsfrom the projectextractSlug(): Parses frontmatterslugfor custom URL pathsgetThemePath(): Registers the theme component
- Wraps the app and injects dropdown into
article .markdown headerelements - Uses
MutationObserverto handle client-side navigation - Works with docs at root path (no
/docs/prefix requirement)
Dropdown with 5 options:
- Ask ChatGPT - Opens ChatGPT with page pre-loaded
- Ask Claude - Opens Claude with page pre-loaded
- Copy URL for AI Agent - Copies markdown URL to clipboard
- View as Markdown - Opens raw markdown in new tab
- Copy as Markdown - Copies markdown content to clipboard
{
projectName: 'My Project', // Used in AI prompts (default: site title)
rootDocId: 'introduction', // Document ID for root slug "/" (default: 'introduction')
}- During
postBuild, plugin reads all docs fromdocs/directory - MDX files are converted to clean markdown (removing imports, JSX, etc.)
- Files are output to build directory respecting frontmatter
slug _sitemap.mdis generated fromsidebars.tsstructure- Theme component injects dropdown into each page header at runtime
To test locally in a Docusaurus project:
# In the Docusaurus project
npm install ../path/to/docusaurus-plugin-ai-docs
npm run build
npm run serveThen verify:
- Dropdown appears on doc pages
.mdURLs return clean markdown/_sitemap.mdshows correct hierarchy- ChatGPT/Claude links work with correct prompts
- Plugin uses vanilla JavaScript (no TypeScript, no build step)
- React components use Docusaurus theme components (
@theme/Layout, etc.) - All file operations use
fs-extrafor consistency - Icons are inline SVGs (ChatGPT from simpleicons.org, Claude from uxwing.com)