-
From this PR #1798, which solved issue #280 , I know I could rewrite ONE export default {
rewrites: {
'dir/README.md': 'dir/index.md',
}
} What if I have so many Can anyone provide an example for this case? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Hi, @brc-dd , If I have a deeper directory structure, I have to respectively write mappings for each depth as below: {
rewrites: {
'README.md': 'index.md',
':a*/README.md': ':a*/index.md',
':a*/:b*/README.md': ':a*/:b*/index.md',
// deeper directories, more mappings...
},
} This is acceptable for now, but I wonder if there is a better way to do that. Could there be a configurable entry filename for this purpose? I have also done some searching in path-to-regexp. And have tried to modify VitePress's relevant source code in Lines 434 to 440 in 5c9b75e This worked functionally, but took an intolerable time to finish the function rewrite(src: string, from: string, to: string) {
// remove '/' which is a delimiter by default ('/#?'), so it could match any depth of path.
const options = { delimiter: '#?' }
const urlMatch = match(from, options)
const res = urlMatch(src)
if (!res) return false
const toPath = compile(to, options)
return toPath(res.params)
} |
Beta Was this translation helpful? Give feedback.
':foo*/README.md': ':foo*/index.md'