Skip to content

Commit 441f023

Browse files
shigmaulivz
authored andcommitted
feat($core): prevent duplicate route (#1525)
1 parent 9efc678 commit 441f023

File tree

1 file changed

+8
-1
lines changed
  • packages/@vuepress/core/lib/node

1 file changed

+8
-1
lines changed

packages/@vuepress/core/lib/node/App.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,14 @@ module.exports = class App {
348348
computed: new this.ClientComputedMixinConstructor(),
349349
enhancers: this.pluginAPI.getOption('extendPageData').items
350350
})
351-
this.pages.push(page)
351+
const index = this.pages.findIndex(({ path }) => path === page.path)
352+
if (index >= 0) {
353+
// Override a page if corresponding path already exists
354+
logger.warn(`Override existing page ${chalk.yellow(page.path)}.`)
355+
this.pages.splice(index, 1, page)
356+
} else {
357+
this.pages.push(page)
358+
}
352359
}
353360

354361
/**

0 commit comments

Comments
 (0)