prev-cli 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -5
- package/package.json +1 -2
- package/src/theme/Layout.tsx +36 -2
package/dist/cli.js
CHANGED
|
@@ -12,7 +12,6 @@ import tailwindcss from "@tailwindcss/vite";
|
|
|
12
12
|
import mdx from "@mdx-js/rollup";
|
|
13
13
|
import remarkGfm from "remark-gfm";
|
|
14
14
|
import rehypeHighlight from "rehype-highlight";
|
|
15
|
-
import rehypeMermaid from "rehype-mermaid";
|
|
16
15
|
import path4 from "path";
|
|
17
16
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
18
17
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
@@ -319,10 +318,7 @@ async function createViteConfig(options) {
|
|
|
319
318
|
plugins: [
|
|
320
319
|
mdx({
|
|
321
320
|
remarkPlugins: [remarkGfm],
|
|
322
|
-
rehypePlugins: [
|
|
323
|
-
rehypeHighlight,
|
|
324
|
-
[rehypeMermaid, { strategy: "pre-mermaid" }]
|
|
325
|
-
]
|
|
321
|
+
rehypePlugins: [rehypeHighlight]
|
|
326
322
|
}),
|
|
327
323
|
react(),
|
|
328
324
|
tailwindcss(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prev-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Transform MDX directories into beautiful documentation websites",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"react-dom": "^19.0.0",
|
|
53
53
|
"react-router-dom": "^7.0.0",
|
|
54
54
|
"rehype-highlight": "^7.0.0",
|
|
55
|
-
"rehype-mermaid": "^3.0.0",
|
|
56
55
|
"remark-gfm": "^4.0.0",
|
|
57
56
|
"rolldown-vite": "^7.3.0",
|
|
58
57
|
"tailwind-merge": "^2.5.0",
|
package/src/theme/Layout.tsx
CHANGED
|
@@ -1,9 +1,43 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { Outlet } from 'react-router-dom'
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
2
|
+
import { Outlet, useLocation } from 'react-router-dom'
|
|
3
3
|
import { Sidebar } from './Sidebar'
|
|
4
4
|
import './styles.css'
|
|
5
5
|
|
|
6
|
+
// Lazy-load and render mermaid diagrams
|
|
7
|
+
async function renderMermaidDiagrams() {
|
|
8
|
+
const codeBlocks = document.querySelectorAll('code.language-mermaid')
|
|
9
|
+
if (codeBlocks.length === 0) return
|
|
10
|
+
|
|
11
|
+
const mermaid = await import('mermaid')
|
|
12
|
+
mermaid.default.initialize({ startOnLoad: false, theme: 'neutral' })
|
|
13
|
+
|
|
14
|
+
for (const block of codeBlocks) {
|
|
15
|
+
const pre = block.parentElement
|
|
16
|
+
if (!pre || pre.dataset.mermaidRendered) continue
|
|
17
|
+
|
|
18
|
+
const code = block.textContent || ''
|
|
19
|
+
const container = document.createElement('div')
|
|
20
|
+
container.className = 'mermaid-diagram'
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const { svg } = await mermaid.default.render(`mermaid-${Math.random().toString(36).slice(2)}`, code)
|
|
24
|
+
container.innerHTML = svg
|
|
25
|
+
pre.replaceWith(container)
|
|
26
|
+
} catch (e) {
|
|
27
|
+
console.error('Mermaid render error:', e)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
6
32
|
export function Layout() {
|
|
33
|
+
const location = useLocation()
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
// Render mermaid after content loads
|
|
37
|
+
const timer = setTimeout(renderMermaidDiagrams, 100)
|
|
38
|
+
return () => clearTimeout(timer)
|
|
39
|
+
}, [location.pathname])
|
|
40
|
+
|
|
7
41
|
return (
|
|
8
42
|
<div className="min-h-screen bg-background text-foreground">
|
|
9
43
|
<div className="flex">
|