pages-parser.js 450 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
module.exports = function parsePages(manifest, pages) {
  const entryPagePath = pages[0].path
  const router = {
    entry: entryPagePath.substr(0, entryPagePath.lastIndexOf('/')),
    pages: {}
  }
  pages.forEach(page => {
    const lastIndex = page.path.lastIndexOf('/')
    const key = page.path.substr(0, lastIndex)
    router.pages[key] = {
      component: page.path.substr(lastIndex + 1)
    }
  })
  manifest.router = router
}