mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-24 14:36:59 +02:00
fix: use exact path & handle non-index pages
This commit is contained in:
parent
0fcad83410
commit
d9def2865a
2 changed files with 4 additions and 2 deletions
|
@ -7,6 +7,7 @@ async function genRoutesConfig({docsData, docsDir, pagesData}) {
|
||||||
return `
|
return `
|
||||||
{
|
{
|
||||||
path: ${JSON.stringify(docsPath)},
|
path: ${JSON.stringify(docsPath)},
|
||||||
|
exact: true,
|
||||||
component: () => <Docs><${componentName} /></Docs>
|
component: () => <Docs><${componentName} /></Docs>
|
||||||
}`;
|
}`;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +23,7 @@ async function genRoutesConfig({docsData, docsDir, pagesData}) {
|
||||||
return `
|
return `
|
||||||
{
|
{
|
||||||
path: ${JSON.stringify(pagesPath)},
|
path: ${JSON.stringify(pagesPath)},
|
||||||
|
exact: true,
|
||||||
component: ${componentName}
|
component: ${componentName}
|
||||||
}`;
|
}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,13 +14,13 @@ async function generate(file, content) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const indexRE = /(^|.*\/)index\.(md|js)$/i;
|
const indexRE = /(^|.*\/)index\.(md|js)$/i;
|
||||||
const mdRE = /\.md$/;
|
const extRE = /\.(md|js)$/;
|
||||||
|
|
||||||
function fileToPath(file) {
|
function fileToPath(file) {
|
||||||
if (indexRE.test(file)) {
|
if (indexRE.test(file)) {
|
||||||
return file.replace(indexRE, '/$1');
|
return file.replace(indexRE, '/$1');
|
||||||
}
|
}
|
||||||
return `/${file.replace(mdRE, '').replace(/\\/g, '/')}`;
|
return `/${file.replace(extRE, '').replace(/\\/g, '/')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function encodePath(userpath) {
|
function encodePath(userpath) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue