File tree 2 files changed +20
-7
lines changed
2 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -57,21 +57,33 @@ export async function createMarkdownToVueRenderFn(
57
57
base ,
58
58
siteConfig ?. logger
59
59
)
60
+
60
61
pages = pages . map ( ( p ) => slash ( p . replace ( / \. m d $ / , '' ) ) )
61
62
63
+ const dynamicRoutes = new Map (
64
+ siteConfig ?. dynamicRoutes ?. routes . map ( ( r ) => [
65
+ r . fullPath ,
66
+ path . join ( srcDir , r . route )
67
+ ] ) || [ ]
68
+ )
69
+
70
+ const rewrites = new Map (
71
+ Object . entries ( siteConfig ?. rewrites . map || { } ) . map ( ( [ key , value ] ) => [
72
+ path . join ( srcDir , key ) ,
73
+ path . join ( srcDir , value ! )
74
+ ] ) || [ ]
75
+ )
76
+
62
77
return async (
63
78
src : string ,
64
79
file : string ,
65
80
publicDir : string
66
81
) : Promise < MarkdownCompileResult > => {
67
- const fileOrig = file
68
- const alias =
69
- siteConfig ?. rewrites . map [ file ] || // virtual dynamic path file
70
- siteConfig ?. rewrites . map [ file . slice ( srcDir . length + 1 ) ]
71
- file = alias ? path . join ( srcDir , alias ) : file
82
+ const fileOrig = dynamicRoutes . get ( file ) || file
83
+ file = rewrites . get ( file ) || file
72
84
const relativePath = slash ( path . relative ( srcDir , file ) )
73
- const cacheKey = JSON . stringify ( { src, file : fileOrig } )
74
85
86
+ const cacheKey = JSON . stringify ( { src, file : relativePath } )
75
87
if ( isBuild || options . cache !== false ) {
76
88
const cached = cache . get ( cacheKey )
77
89
if ( cached ) {
Original file line number Diff line number Diff line change @@ -402,8 +402,9 @@ export async function createVitePressPlugin(
402
402
config . publicDir
403
403
)
404
404
405
+ const relativePath = slash ( path . relative ( srcDir , file ) )
405
406
const payload : PageDataPayload = {
406
- path : `/${ slash ( path . relative ( srcDir , file ) ) } ` ,
407
+ path : `/${ siteConfig . rewrites . map [ relativePath ] || relativePath } ` ,
407
408
pageData
408
409
}
409
410
You can’t perform that action at this time.
0 commit comments