diff --git a/lib/prepare.js b/lib/prepare.js index 3fd7b453760bfc9491ed7d97dffac59f8b5ace1a..00c65973fe2c566a9bf05f614e34e18bd9f74c89 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -230,7 +230,7 @@ async function genRoutesFile ({ siteData: { pages }, sourceDir, pageFiles }) { function genRoute ({ path: pagePath }, index) { const file = pageFiles[index] const filePath = path.resolve(sourceDir, file) - const code = ` + let code = ` { path: ${JSON.stringify(pagePath)}, component: Theme, @@ -241,6 +241,14 @@ async function genRoutesFile ({ siteData: { pages }, sourceDir, pageFiles }) { }) } }` + + if (/\/$/.test(pagePath)) { + code += `,{ + path: ${JSON.stringify(pagePath + 'index.html')}, + redirect: ${JSON.stringify(pagePath)} + }` + } + return code }