fix: use exact path & handle non-index pages

This commit is contained in:
endiliey 2018-08-08 14:45:54 +08:00
parent 0fcad83410
commit d9def2865a
2 changed files with 4 additions and 2 deletions

View file

@ -14,13 +14,13 @@ async function generate(file, content) {
}
const indexRE = /(^|.*\/)index\.(md|js)$/i;
const mdRE = /\.md$/;
const extRE = /\.(md|js)$/;
function fileToPath(file) {
if (indexRE.test(file)) {
return file.replace(indexRE, '/$1');
}
return `/${file.replace(mdRE, '').replace(/\\/g, '/')}`;
return `/${file.replace(extRE, '').replace(/\\/g, '/')}`;
}
function encodePath(userpath) {