Skip to content

Commit 52e04c4

Browse files
committed
fix: redirect */index.html to */ (close #83)
1 parent 4e72ba8 commit 52e04c4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/prepare.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ async function genRoutesFile ({ siteData: { pages }, sourceDir, pageFiles }) {
230230
function genRoute ({ path: pagePath }, index) {
231231
const file = pageFiles[index]
232232
const filePath = path.resolve(sourceDir, file)
233-
const code = `
233+
let code = `
234234
{
235235
path: ${JSON.stringify(pagePath)},
236236
component: Theme,
@@ -241,6 +241,14 @@ async function genRoutesFile ({ siteData: { pages }, sourceDir, pageFiles }) {
241241
})
242242
}
243243
}`
244+
245+
if (/\/$/.test(pagePath)) {
246+
code += `,{
247+
path: ${JSON.stringify(pagePath + 'index.html')},
248+
redirect: ${JSON.stringify(pagePath)}
249+
}`
250+
}
251+
244252
return code
245253
}
246254

0 commit comments

Comments
 (0)