Skip to content

Commit

Permalink
feat($core): prevent duplicate route (#1525)
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma authored and ulivz committed Apr 14, 2019
1 parent 9efc678 commit 441f023
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/@vuepress/core/lib/node/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,14 @@ module.exports = class App {
computed: new this.ClientComputedMixinConstructor(),
enhancers: this.pluginAPI.getOption('extendPageData').items
})
this.pages.push(page)
const index = this.pages.findIndex(({ path }) => path === page.path)
if (index >= 0) {
// Override a page if corresponding path already exists
logger.warn(`Override existing page ${chalk.yellow(page.path)}.`)
this.pages.splice(index, 1, page)
} else {
this.pages.push(page)
}
}

/**
Expand Down

0 comments on commit 441f023

Please sign in to comment.