File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
packages/vuepress/src/core Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -3,11 +3,16 @@ import type { NavbarOptions, SidebarOptions } from 'vuepress-theme-hope'
3
3
import { navbar , sidebar } from 'vuepress-theme-hope'
4
4
import { getVipViteBundler } from './bundler'
5
5
6
+ /**
7
+ * 用户配置
8
+ */
9
+ export type VipVuepressUserConfig = UserConfig
10
+
6
11
/**
7
12
* 定义 vuepress 配置
8
13
* @param config 配置
9
14
*/
10
- export function defineVipVuepressConfig ( config : UserConfig ) : UserConfig {
15
+ export function defineVipVuepressConfig ( config : VipVuepressUserConfig ) : VipVuepressUserConfig {
11
16
// 默认vite编译
12
17
if ( config . bundler == null ) {
13
18
config . bundler = getVipViteBundler ( )
Original file line number Diff line number Diff line change 1
1
import type { ThemeOptions } from 'vuepress-theme-hope'
2
2
import path from 'node:path'
3
- import { fileURLToPath } from 'node:url'
4
3
import { hopeTheme } from 'vuepress-theme-hope'
5
4
import { i18n } from './i18n'
6
5
import { baseThemePluginOptions } from './theme-plugins'
@@ -143,19 +142,17 @@ export function getVipHopeTheme(userConfig: ThemeOptions) {
143
142
* https://vuejs.press/zh/guide/markdown.html#%E5%AF%BC%E5%85%A5%E4%BB%A3%E7%A0%81%E5%9D%97
144
143
* - 例如:引入的路径中包含@code,会替换为当前目录下的code目录
145
144
* @param pathArray 路径规则,旧路径,新路径
145
+ * @param cwd 文件目录,默认当前目录
146
146
* @returns 新路径
147
147
*/
148
- export function handleImportCodePath ( pathArray : Array < [ oldPath : string , newPath : string ] > ) {
148
+ export function handleImportCodePath ( pathArray : Array < [ oldPath : string , newPath : string ] > , cwd ?: string ) {
149
149
return ( str : string ) : string => {
150
150
// 当前目录名
151
- const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
152
-
153
151
for ( const [ oldPath , newPath ] of pathArray ) {
154
152
if ( str . includes ( oldPath ) ) {
155
- return str . replace ( `/^ ${ oldPath } /` , path . resolve ( __dirname , newPath ) )
153
+ return str . replace ( oldPath , path . resolve ( cwd ?? process . cwd ( ) , newPath ) )
156
154
}
157
155
}
158
-
159
156
// 原路径
160
157
return str
161
158
}
You can’t perform that action at this time.
0 commit comments