diff --git a/lib/load/routes.js b/lib/load/routes.js index f4ca448c05..fdc8af9b06 100644 --- a/lib/load/routes.js +++ b/lib/load/routes.js @@ -7,6 +7,7 @@ async function genRoutesConfig({docsData, docsDir, pagesData}) { return ` { path: ${JSON.stringify(docsPath)}, + exact: true, component: () => <${componentName} /> }`; } @@ -22,6 +23,7 @@ async function genRoutesConfig({docsData, docsDir, pagesData}) { return ` { path: ${JSON.stringify(pagesPath)}, + exact: true, component: ${componentName} }`; } diff --git a/lib/load/utils.js b/lib/load/utils.js index 052f7b24b6..2080afbefa 100644 --- a/lib/load/utils.js +++ b/lib/load/utils.js @@ -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) {