Skip to content

Commit

Permalink
fix(core): fix the same page path (#175)
Browse files Browse the repository at this point in the history
* fix(core): fix the same page path

* perf(core): only one filter
  • Loading branch information
skiyee authored Jul 8, 2024
1 parent ac2f0ca commit 8549c29
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/core/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ export class PageContext {
? mergePageMetaDataArray(generatedPageMetaData.concat(customPageMetaData))
: generatedPageMetaData

return type === 'main' ? this.setHomePage(result) : result
const parseMeta = result.filter((page, index, self) =>
self.findLastIndex(item => page.path === item.path) === index,
)

return type === 'main' ? this.setHomePage(parseMeta) : parseMeta
}

/**
Expand Down Expand Up @@ -241,6 +245,7 @@ export class PageContext {

async mergePageMetaData() {
const pageMetaData = await this.parsePages(this.pagesPath, 'main', this.pagesGlobConfig?.pages)

this.pageMetaData = pageMetaData
debug.pages(this.pageMetaData)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div>Hello World</div>
</template>
3 changes: 3 additions & 0 deletions packages/playground/src/pages/index.nvue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div>Hello World</div>
</template>
1 change: 1 addition & 0 deletions test/files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('get files', () => {
"blog/index.vue",
"blog/post.vue",
"i18n.vue",
"index.nvue",
"index.vue",
"test-json.vue",
"test-yaml.vue",
Expand Down
4 changes: 2 additions & 2 deletions test/generate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ describe('generate routes', () => {
{
"path": "../packages/playground/src/pages/index",
"type": "page",
"style": {},
"middlewares": [
"auth",
"test"
],
"style": {}
]
},
{
"path": "../packages/playground/src/pages/test-json",
Expand Down

0 comments on commit 8549c29

Please sign in to comment.