home / skills / linehaul-ai / linehaulai-claude-marketplace / wiki-vitepress

This skill packages wiki Markdown into a VitePress site with dark theme, Mermaid diagrams, and production output for browsable pages.

npx playbooks add skill linehaul-ai/linehaulai-claude-marketplace --skill wiki-vitepress

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
4.4 KB
---
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. Use when the user wants to create a browsable website from generated wiki pages.
---

# 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

Overview

This skill packages generated wiki Markdown into a ready-to-build VitePress static site. It scaffolds a dark-only theme, configures dark-mode Mermaid diagrams, and produces a production build output ready for deployment. Use it to convert a collection of wiki pages into a browsable HTML site with click-to-zoom diagram support.

How this skill works

The packager creates a wiki-site/ directory with VitePress config, a theme extension, public assets, and the generated .md pages. It injects a config.mts that uses the withMermaid wrapper, sets appearance: 'dark', and applies specific Mermaid themeVariables for consistent dark rendering. It also adds CSS overrides and a client-side setup script that patches inline Mermaid styles and enables click-to-zoom modals for diagrams. Finally, it runs a pre-build pass to fix Markdown issues and ensures frontmatter before producing .vitepress/dist.

When to use it

  • You want a browsable static site from generated wiki Markdown.
  • You need dark-mode-first presentation with consistent Mermaid diagrams.
  • You require click-to-zoom interactive diagrams for documentation.
  • You plan to deliver a production-ready build folder for deployment.
  • You run the /deep-wiki:build command or ask to "build a site".

Best practices

  • Ensure each page has YAML frontmatter with title and description before packaging.
  • Run the Markdown post-processing to replace <br/> with <br> and backtick bare <T> generics.
  • Use setup() with onMounted and a short polling loop to patch Mermaid inline styles (avoid enhanceApp()).
  • Keep Mermaid themeVariables and CSS overrides in sync to avoid visual drift.
  • Test builds locally (npm install && npm run docs:build) and inspect .vitepress/dist before deploy.

Example use cases

  • Convert an internal wiki export into a public documentation site with dark theme.
  • Produce a documentation site for an API that includes Mermaid diagrams and flowcharts.
  • Deliver a browsable knowledge base for a team with click-to-zoom visuals for complex diagrams.
  • Automate nightly builds of updated wiki content into a static site for stakeholders.

FAQ

Why do Mermaid nodes still use light colors after CSS overrides?

Mermaid sets inline style attributes at render time with highest specificity. The skill uses a polling patch in setup() to replace inline fill/stroke/color values after SVGs are available.

Can I use enhanceApp() for the DOM fixes instead of setup()?

No. enhanceApp() can run during SSR where document is undefined. Use setup() with onMounted and a limited interval to safely modify DOM after client render.