Skip to content

Commit

Permalink
fix: redirect */index.html to */ (close #83)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 16, 2018
1 parent 4e72ba8 commit 52e04c4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}

Expand Down

0 comments on commit 52e04c4

Please sign in to comment.