docusaurus-plugins
Use when creating Docusaurus plugins (remark, rehype, theme, content, lifecycle) to extend markdown, modify HTML, or add custom functionality
When & Why to Use This Skill
This Claude skill streamlines the development of Docusaurus plugins by providing structured guidance and code patterns for Remark, Rehype, lifecycle hooks, and theme customization. It helps developers extend Markdown functionality, manipulate HTML AST, and integrate custom logic into the Docusaurus build process efficiently, ensuring high-quality documentation site extensions.
Use Cases
- Developing custom Remark plugins to transform Markdown AST, such as automatically adding custom CSS classes to specific link patterns.
- Implementing Rehype plugins for post-compilation HTML processing, allowing for advanced DOM manipulations and SEO optimizations.
- Creating Docusaurus lifecycle plugins to hook into the build process for custom data loading, route generation, or post-build scripts.
- Customizing documentation UI and functionality through theme plugins and component swizzling to match specific brand requirements.
- Building content plugins to integrate external data sources or non-standard file formats into the Docusaurus content ecosystem.
| name | docusaurus-plugins |
|---|---|
| # IMPORTANT | Keep description on ONE line for Claude Code compatibility |
| description | Use when creating Docusaurus plugins (remark, rehype, theme, content, lifecycle) to extend markdown, modify HTML, or add custom functionality |
Docusaurus Plugin Guide
Quick Start
// Remark plugin - transforms markdown AST
module.exports = function remarkPlugin(options = {}) {
return async function transformer(ast, vfile) {
const { visit } = require("unist-util-visit");
visit(ast, "link", (node) => {
// Transform nodes
node.data = node.data || {};
node.data.hProperties = { className: "custom" };
});
return ast;
};
};
// In docusaurus.config.js:
// remarkPlugins: [require('./plugins/my-plugin')]
Core Principles
- 5 Plugin Types: Remark (markdown), Rehype (HTML), Lifecycle (routes/webpack), Theme (components), Content (custom data)
- Remark: Transforms markdown before HTML conversion, use
unist-util-visitfor AST traversal - Rehype: Transforms HTML after compilation, processes HAST (HTML AST)
- Lifecycle: Most flexible, implements hooks like
loadContent(),contentLoaded(),postBuild() - Export function: Returns transformer (remark/rehype) or plugin object (lifecycle)
Reference Files
Detailed guides for each plugin type:
- references/remark-plugins.md - Markdown transformation
- references/rehype-plugins.md - HTML processing
- references/lifecycle-plugins.md - Routes, webpack, global data
- references/theme-plugins.md - Themes and swizzling
- references/content-plugins.md - Custom content types
- references/package-structure.md - Publishing and config