Skip to content

Commit

Permalink
fix: suppoert .html
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyi committed Jul 9, 2020
1 parent 6248982 commit aa724af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions packages/@rcpress/core/lib/node/prepare/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ exports.genRoutesFile = async function({
const file = pageFiles[index];
const filePath = path.join(docsDir, file);
let code = `
{
path: ${JSON.stringify(pagePath)},
filePath: ${JSON.stringify(filePath)},
markdown: AsyncMD$${index},
name: '${pagePath}' ,
route_component: LayoutWrapper,
exact: true
}`;
{
path: ${JSON.stringify(pagePath)},
filePath: ${JSON.stringify(filePath)},
markdown: AsyncMD$${index},
name: '${pagePath}' ,
route_component: LayoutWrapper,
exact: true
}`;

const dncodedPath = decodeURIComponent(pagePath);
if (dncodedPath !== pagePath) {
Expand All @@ -61,7 +61,7 @@ exports.genRoutesFile = async function({
} else {
code += `,
{
path: ${JSON.stringify(pagePath + '.html')},
path: ${JSON.stringify(pagePath.slice(0, pagePath.lastIndexOf('.html')))},
redirect: ${JSON.stringify(pagePath)},
exact: true
}`;
Expand Down
2 changes: 1 addition & 1 deletion packages/@rcpress/core/lib/node/prepare/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports.fileToPath = function(file) {
} else {
// foo.md -> /foo.html
// foo/bar.md -> /foo/bar.html
return `/${file.replace(extRE, '').replace(/\\/g, '/')}`;
return `/${file.replace(extRE, '.html').replace(/\\/g, '/')}`;
}
};

Expand Down

0 comments on commit aa724af

Please sign in to comment.