diff --git a/lib/prepare.js b/lib/prepare.js index 3fd7b45376..00c65973fe 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 }