@yl_lowcode/docs-theme 0.0.2 → 0.0.3
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/package.json +1 -1
- package/plugins/shiki-raw.js +7 -0
package/package.json
CHANGED
package/plugins/shiki-raw.js
CHANGED
|
@@ -10,6 +10,11 @@ function getMd(srcDir, options) {
|
|
|
10
10
|
return mdPromise;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
// 配置文件变更时 VitePress 会重新加载插件,重置单例避免引用已销毁的 Shiki 实例
|
|
14
|
+
export function resetMd() {
|
|
15
|
+
mdPromise = null;
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
export function shikiRawPlugin(options) {
|
|
14
19
|
let srcDir = process.cwd();
|
|
15
20
|
|
|
@@ -18,6 +23,8 @@ export function shikiRawPlugin(options) {
|
|
|
18
23
|
enforce: "pre",
|
|
19
24
|
configResolved(config) {
|
|
20
25
|
srcDir = config.root;
|
|
26
|
+
// 每次配置重新解析时重置 markdown renderer,避免 Shiki disposed 错误
|
|
27
|
+
resetMd();
|
|
21
28
|
},
|
|
22
29
|
async load(id) {
|
|
23
30
|
if (!id.endsWith("?raw")) return null;
|