mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-20 02:35:53 +10:00
17 lines
430 B
JavaScript
17 lines
430 B
JavaScript
const { indexRE } = require('./isIndexFile')
|
|
const isIndexFile = require('./isIndexFile')
|
|
|
|
const extRE = /\.(vue|md)$/
|
|
|
|
module.exports = function fileToPath (file) {
|
|
if (isIndexFile(file)) {
|
|
// README.md -> /
|
|
// foo/README.md -> /foo/
|
|
return file.replace(indexRE, '/$1')
|
|
} else {
|
|
// foo.md -> /foo.html
|
|
// foo/bar.md -> /foo/bar.html
|
|
return `/${file.replace(extRE, '').replace(/\\/g, '/')}.html`
|
|
}
|
|
}
|