Skip to content

Commit 1922a29

Browse files
author
Chu Fan
committed
feat: 修改主题配置
1 parent 43aeaff commit 1922a29

3 files changed

Lines changed: 39 additions & 10 deletions

File tree

docs/.vuepress/config.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import pluginsConfig from "./config/plugins.config";
22
import themeConfig from "./config/theme.config";
33
import {defineUserConfig} from "vuepress";
44
import { fileURLToPath } from 'node:url'
5-
// @ts-ignore
6-
import {path} from "@vuepress/utils";
7-
// @ts-ignore
8-
const __dirname = path.dirname(fileURLToPath(import.meta.url))
5+
// // @ts-ignore
6+
// import {path} from "@vuepress/utils";
7+
// // @ts-ignore
8+
// const __dirname = path.dirname(fileURLToPath(import.meta.url))
99

1010
// 用于区分base路径,是否nginx代理
1111
const PROXY_DOMAIN=process.env.PROXY_DOMAIN||false
@@ -21,9 +21,9 @@ export default defineUserConfig({
2121
markdown: {
2222
// todo 引入代码文件时的路径替换
2323
importCode: {
24-
handleImportPath: (str) =>{
25-
return str.replace(/^@code/, path.resolve(__dirname, '../../code/'))
26-
},
24+
// handleImportPath: (str) =>{
25+
// return str.replace(/^@code/, path.resolve(__dirname, '../../code/'))
26+
// },
2727
},
2828
},
2929
// 主题配置

docs/.vuepress/config/plugins.config.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {searchProPlugin} from "vuepress-plugin-search-pro";
2-
2+
import { mdEnhancePlugin } from "vuepress-plugin-md-enhance"
3+
// @ts-ignore
4+
import {path} from "@vuepress/utils";
35
/**
46
* 使用的插件配置
57
*/
@@ -20,5 +22,15 @@ export default {
2022
},
2123
],
2224
}),
25+
mdEnhancePlugin({
26+
// your options
27+
// todo 引入代码文件时的路径替换 支持@code别名
28+
include: {
29+
resolvePath: (str) =>{
30+
console.log(2222,str,str.replace(/^@code/, path.resolve(__dirname, '../../code/')))
31+
return str.replace(/^@code/, path.resolve(__dirname, '../../code/'))
32+
}
33+
},
34+
}),
2335
]
2436
}

docs/.vuepress/config/theme.config.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
import {hopeTheme} from "vuepress-theme-hope";
21
import navbar from "./navbar";
32
import sidebar from "./sidebar";
43
import {FOOTER_HTML_INFO} from "./constant.config";
4+
import {hopeTheme} from "vuepress-theme-hope";
5+
import {fileURLToPath} from "node:url";
6+
// // @ts-ignore
7+
// import {path} from "@vuepress/utils";
8+
// // @ts-ignore
9+
// const __dirname = path.dirname(fileURLToPath(import.meta.url))
10+
// @ts-ignore
11+
import { getDirname, path } from "@vuepress/utils";
12+
// @ts-ignore
13+
const __dirname = getDirname(import.meta.url);
514

615
/**
716
* 主题相关配置
817
* 参考主题:https://theme-hope.vuejs.press/zh/config/intro.html#%E9%85%8D%E7%BD%AE%E6%A6%82%E5%BF%B5
918
*/
1019
export default {
1120
theme: hopeTheme({
21+
navbarIcon: false,
1222
darkmode: "toggle",
1323
// 支持全屏
1424
// fullscreen: true,
@@ -72,6 +82,13 @@ export default {
7282
mdEnhance: {
7383
codetabs: true,
7484
tasklist: true, // 支持任务列表
85+
// todo 引入代码文件时的路径替换 支持@code别名
86+
include: {
87+
resolvePath: (str) =>{
88+
console.log(2222,str,str.replace(/^@code/, path.resolve(__dirname, '../../code/')))
89+
return str.replace(/^@code/, path.resolve(__dirname, '../../code/'))
90+
}
91+
},
7592
// 启用 figure
7693
figure: true,
7794
// 启用图片懒加载
@@ -122,6 +139,6 @@ export default {
122139
"YouTube",
123140
],
124141
},
125-
},
142+
}
126143
})
127144
}

0 commit comments

Comments
 (0)