選項
首頁首頁 Skill 文件 wiki-vitepress

wiki-vitepress

microsoft/skills microsoft/skills

此套件可將 Wiki Markdown 內容建構為採用深色主題的 VitePress 靜態網站,並包含支援點擊放大功能的深色模式 Mermaid 圖表,以及正式發布版本的建構輸出。

...展開全部
0
更新時間 2026-09-11

Wiki VitePress 打包工具

將生成的維基 Markdown 檔案轉化為採用深色主題並包含互動式 Mermaid 圖表的精緻 VitePress 靜態網站。

何時啟用

  • 使用者要求「建立網站」或「封裝為 VitePress」
  • 使用者執行/deep-wiki:build指令
  • 使用者希望將生成的維基頁面輸出為可供瀏覽的 HTML 檔案

VitePress 框架搭建

wiki-site/目錄中產生以下結構:

wiki-site/
├── .vitepress/
│   ├── config.mts
│   └── theme/
│       ├── index.ts
│       └── custom.css
├── public/
├── [生成的 .md 頁面]
├── package.json
└── index.md

設定要求 (config.mts)

  • 請搭配使用vitepress-plugin-mermaid提供的withMermaid封裝函式
  • 若要設定為僅支援深色模式的主題請將appearance設為'dark'
  • 根據目錄結構設定themeConfig.navthemeConfig.sidebar
  • Mermaid 設定中必須設定暗色主題變數:
mermaid: {
  theme: 'dark',
  themeVariables: {
    primaryColor: '#1e3a5f',
    primaryTextColor: '#e0e0e0',
    primaryBorderColor: '#4a9eed',
    lineColor: '#4a9eed',
    secondaryColor: '#2d4a3e',
    tertiaryColor: '#2d2d3d',
    background: '#1a1a2e',
    主背景色: '#1e3a5f',
    節點邊框色: '#4a9eed',
    叢集背景色: '#16213e',
    標題色: '#e0e0e0',
    邊緣標籤背景色: '#1a1a2e'
  }
}

深色模式 Mermaid:三層修正方案

第 1 層:主題變數(位於 config.mts 中)

如上所示,透過mermaid.themeVariables進行設定。

第二層:CSS 覆寫(custom.css

使用!important 針對 Mermaid 的 SVG 元素進行覆寫:

.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; }

第 3 層:內聯樣式替換 (theme/index.ts)

Mermaid 的內聯樣式屬性會覆寫所有設定。請使用onMounted搭配輪詢機制來替換它們:

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)
})

請在onMounted 中使用setup(),而非enhanceApp()— 伺服器端渲染 (SSR) 期間尚不存在 DOM。

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); }

後處理規則

在 VitePress 建置之前,掃描所有.md檔案並修正:

  • 替換

    (Vue 模板編譯器相容性)
  • 將裸露的 泛型參數以反引號包圍,並置於程式碼圍欄之外
  • 確保每個頁面皆含包含標題描述的YAML 前置元資料

建置

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

輸出結果將存放在wiki-site/.vitepress/dist/ 目錄中。

已知注意事項

  • Mermaid 採用非同步渲染 — 當onMounted觸發時,SVG 檔案尚未生成。必須進行輪詢。
  • 編譯器選項isCustomElement對於裸 會導致更嚴重的當機 — 請勿使用此選項
  • Mermaid 中的 Node 文字會使用特異性最高的內嵌樣式— 僅靠 CSS 無法解決此問題
  • enhanceApp()會在 SSR 期間執行,此時document尚不存在 — 請僅使用setup()
在 GitHub 上查看
---
name: wiki-vitepress
description: Packages generated wiki Markdown into a VitePress static site with dark theme, dark-mode Mermaid diagrams with click-to-zoom, and production build output.
license: MIT
---

# Wiki VitePress Packager

Transform generated wiki Markdown files into a polished VitePress static site with dark theme and interactive Mermaid diagrams.

## When to Activate

- User asks to "build a site" or "package as VitePress"
- User runs the `/deep-wiki:build` command
- User wants a browsable HTML output from generated wiki pages

## VitePress Scaffolding

Generate the following structure in a `wiki-site/` directory:

```
wiki-site/
├── .vitepress/
│   ├── config.mts
│   └── theme/
│       ├── index.ts
│       └── custom.css
├── public/
├── [generated .md pages]
├── package.json
└── index.md
```

## Config Requirements (`config.mts`)

- Use `withMermaid` wrapper from `vitepress-plugin-mermaid`
- Set `appearance: 'dark'` for dark-only theme
- Configure `themeConfig.nav` and `themeConfig.sidebar` from the catalogue structure
- Mermaid config must set dark theme variables:

```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'
  }
}
```

## Dark-Mode Mermaid: Three-Layer Fix

### Layer 1: Theme Variables (in config.mts)
Set via `mermaid.themeVariables` as shown above.

### Layer 2: CSS Overrides (`custom.css`)
Target Mermaid SVG elements with `!important`:

```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; }
```

### Layer 3: Inline Style Replacement (`theme/index.ts`)
Mermaid inline `style` attributes override everything. Use `onMounted` + polling to replace them:

```typescript
import { onMounted } from 'vue'

// In 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)
})
```

Use `setup()` with `onMounted`, NOT `enhanceApp()` — DOM doesn't exist during SSR.

## Click-to-Zoom for Mermaid Diagrams

Wrap each `.mermaid` container in a clickable wrapper that opens a fullscreen modal:

```typescript
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)
  })
})
```

Modal CSS:
```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); }
```

## Post-Processing Rules

Before VitePress build, scan all `.md` files and fix:
- Replace `<br/>` with `<br>` (Vue template compiler compatibility)
- Wrap bare `<T>` generic parameters in backticks outside code fences
- Ensure every page has YAML frontmatter with `title` and `description`

## Build

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

Output goes to `wiki-site/.vitepress/dist/`.

## Known Gotchas

- Mermaid renders async — SVGs don't exist when `onMounted` fires. Must poll.
- `isCustomElement` compiler option for bare `<T>` causes worse crashes — do NOT use it
- Node text in Mermaid uses inline `style` with highest specificity — CSS alone won't fix it
- `enhanceApp()` runs during SSR where `document` doesn't exist — use `setup()` only

所有檔案

0 個檔案

安裝 wiki-vitepress

請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。

下載 ZIP

複製儲存庫並將技能檔案複製到您的專案中。

git clone https://github.com/microsoft/skills/tree/main/.github/plugins/deep-wiki/skills/wiki-vitepress # Copy SKILL.md to your .claude/skills/ directory

複製 複製
快速設定: 將技能資料夾複製到 .claude/skills/ Claude 會自動偵測並使用該技能
儲存庫 microsoft/skills

相關技能

golang-dependency-injection
更新時間 2026-06-29
nuxthub
更新時間 2026-08-23
tc-tracker
更新時間 2026-08-27
code-quality
更新時間 2026-08-22
OR