Wiki to vitepress site

From findscripter/everything-skills · View interactive version

Wiki to vitepress site is an AI agent skill from the GitHub repository findscripter/everything-skills. 当已有一批 Markdown wiki/文档页、需打包成可浏览的 VitePress 静态站点(暗色主题 + 可交互 Mermaid 图)时使用;脚手架 wiki-site/、写 config.mts/custom.css/theme,做暗色 Mermaid 三层修复与点击放大,npm run docs:build 产出 dist/;不适用于撰写文档内容本身、单文件转换或 MkDocs/Docusaurus 等其他生成器。触发词:build a site、打包成 VitePress、静态文档站、Mermaid 暗色、/deep-wiki:build

How to use this skill

Skill file

何时使用

已经有一批生成好的 Markdown 页面(如 deep-wiki 产出、知识库导出),想把它们打包成一个可浏览、带导航与暗色主题、内嵌可交互 Mermaid 图的 VitePress 静态站点时使用。典型触发:

不该用的边界:

步骤

  1. 建脚手架:在 wiki-site/ 下生成标准结构:

```

wiki-site/

├── .vitepress/

│ ├── config.mts

│ └── theme/

│ ├── index.ts

│ └── custom.css

├── public/

├── [拷入的 .md 页面]

├── package.json

└── index.md

```

  1. 写 config.mts:用 vitepress-plugin-mermaid 的 withMermaid 包裹配置;设 appearance: 'dark'(纯暗色);据目录结构填 themeConfig.nav 与 themeConfig.sidebar;并配置 Mermaid 暗色主题变量(见示例)。
  2. 做暗色 Mermaid 三层修复(关键,缺一层就显示异常,见下)。
  3. 加 Mermaid 图点击放大(可选增强)。
  4. 构建前后处理:扫描所有 .md,把 <br/> 改成 <br>(Vue 模板编译器兼容);代码块外裸露的泛型参数 <T> 用反引号包起来;确保每页都有含 title、description 的 YAML frontmatter。
  5. 构建:

```bash

cd wiki-site && npm install && npm run docs:build

```

产物在 wiki-site/.vitepress/dist/。

指令

暗色 Mermaid 三层修复——内联 style 优先级最高,只靠 CSS 治不住,必须三层叠加:

```typescript

mermaid: {

theme: 'dark',

themeVariables: {

primaryColor: '#1e3a5f',

primaryTextColor: '#e0e0e0',

primaryBorderColor: '#4a9eed',

lineColor: '#4a9eed',

secondaryColor: '#2d4a3e',

tertiaryColor: '#2d2d3d',

background: '#1a1a2e',

mainBkg: '#1e3a5f',

nodeBorder: '#4a9eed',

clusterBkg: '#16213e',

titleColor: '#e0e0e0',

edgeLabelBackground: '#1a1a2e'

}

}

```

```css

.mermaid .node rect,

.mermaid .node circle,

.mermaid .node polygon { fill: #1e3a5f !important; stroke: #4a9eed !important; }

.mermaid .edgeLabel { background-color: #1a1a2e !important; color: #e0e0e0 !important; }

.mermaid text { fill: #e0e0e0 !important; }

.mermaid .label { color: #e0e0e0 !important; }

```

```typescript

import { onMounted } from 'vue'

// 在 setup() 内

onMounted(() => {

let attempts = 0

const fix = setInterval(() => {

document.querySelectorAll('.mermaid svg [style]').forEach(el => {

const s = (el as HTMLElement).style

if (s.fill && !s.fill.includes('#1e3a5f')) s.fill = '#1e3a5f'

if (s.stroke && !s.stroke.includes('#4a9eed')) s.stroke = '#4a9eed'

if (s.color) s.color = '#e0e0e0'

})

if (++attempts >= 20) clearInterval(fix)

}, 500)

})

```

示例

Mermaid 图点击放大:给每个 .mermaid 容器套可点击壳,点开全屏模态:

document.querySelectorAll('.mermaid').forEach(el => {
  el.style.cursor = 'zoom-in'
  el.addEventListener('click', () => {
    const modal = document.createElement('div')
    modal.className = 'mermaid-zoom-modal'
    modal.innerHTML = el.outerHTML
    modal.addEventListener('click', () => modal.remove())
    document.body.appendChild(modal)
  })
})

配套模态 CSS:

.mermaid-zoom-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; cursor: zoom-out;
}
.mermaid-zoom-modal .mermaid { transform: scale(1.5); }

注意事项

互见


采编自 sickn33/antigravity-awesome-skills(MIT)。

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.