Skip to content

Commit

Permalink
fix: custom paths pages config should use route name as key
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede committed Dec 27, 2024
1 parent 757195a commit 4ae5fee
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type AnalyzedNuxtPageMeta = {
* Analyzed path used to retrieve configured custom paths
*/
path: string
name?: string
}

export type NuxtPageAnalyzeContext = {
Expand Down Expand Up @@ -233,6 +234,8 @@ export function analyzeNuxtPages(ctx: NuxtPageAnalyzeContext, pages?: NuxtPage[]

ctx.pages.set(page, {
path: analyzePagePath(filePath, ctx.stack.length),
// if route has an index child the parent will not have a name
name: page.name ?? page.children?.find(x => x.path.endsWith('/index'))?.name,
inRoot: ctx.stack.length === 0
})

Expand Down Expand Up @@ -296,7 +299,8 @@ function getRouteOptionsFromPages(
return options
}

const pageOptions = pageMeta.path ? pages[pageMeta.path] : undefined
const valueByName = pageMeta.name ? pages[pageMeta.name] : undefined
const pageOptions = valueByName ?? pages[pageMeta.path]

// routing disabled
if (pageOptions === false) {
Expand Down

0 comments on commit 4ae5fee

Please sign in to comment.