docusaurus-plugin-dev
Helps develop and build Docusaurus plugins using this starter template
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Helps develop and build Docusaurus plugins using this starter template
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when working with docusaurus-plugin-glossary to configure, manage glossary terms, troubleshoot issues, and explain features
Use when working with docusaurus.config.js/ts files to validate or modify Docusaurus configuration
Use when creating Docusaurus plugins (remark, rehype, theme, content, lifecycle) to extend markdown, modify HTML, or add custom functionality
Use when swizzling Docusaurus theme components and editing theme elements
| name | docusaurus-plugin-dev |
| description | Helps develop and build Docusaurus plugins using this starter template |
// src/plugin.ts - Register client module with getClientModules()
export default function myPlugin(context, options): Plugin {
return {
name: 'my-plugin',
getClientModules() {
return [require.resolve('./client')];
},
};
}
// src/client/index.ts - Enhance DOM automatically on every page
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
export default (function () {
if (!ExecutionEnvironment.canUseDOM) return null;
return {
onRouteUpdate({ location }) {
// Runs on every route change - enhance elements automatically
document.querySelectorAll('.markdown img').forEach(img => {
img.style.cursor = 'zoom-in';
img.addEventListener('click', () => console.log('Image clicked'));
});
},
};
})();
getClientModules() run on every page automatically—no manual imports needed in content filesExecutionEnvironment.canUseDOM before using browser APIs to prevent SSR errorsonRouteUpdate for DOM manipulation that needs to reinitialize on every SPA navigation.markdown img, pre code) and enhance themsrc/plugin.ts, browser code in src/client/ - never mix themUse onRouteUpdate with DOM selectors to enhance elements automatically without imports.
Initialize third-party libraries (medium-zoom, highlight.js) and reinitialize on route changes.
Attach keyboard shortcuts or scroll handlers once, persist across routes using initialization flags.
Pass configuration from plugin to client via setGlobalData or inline during build.
For detailed documentation:
Plugin Hooks (src/plugin.ts):
loadContent() - Load/process data at build timecontentLoaded() - Inject global data with setGlobalData() or add routesgetClientModules() - Return array of client module paths (runs in browser)Client Lifecycle (src/client/index.ts):
onRouteUpdate() - During navigation (use for DOM manipulation)onRouteDidUpdate() - After navigation completes (use for analytics)Critical Guardrails:
fs, path) in src/client/*ExecutionEnvironment.canUseDOM checksetTimeout(() => {}, 0) if DOM elements not immediately available