Skip to content

Commit 6ae6c00

Browse files
authored
Fix the navbar submenu in 404 page (#2222)
## Description Currently, we render only the last segment of path in `href` in navbar submenu links. mea culpa, I tested if it opens, and I tested the other links, but I didn't notice until I went back to work on `/community/events` page :/ This is currently only broken in 404 page, so it's not huge, but it can be pretty frustrating to click a link and try to get out and land on 404 page again.
1 parent 8846229 commit 6ae6c00

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/components/navbar/top-level-items.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
// src/components/navbar/normalize-meta-to-items.ts
21
import { normalizePages } from "nextra/normalize-pages"
32
import type { Folder, PageMapItem } from "nextra"
43
import meta from "../../pages/_meta"
54

65
/**
76
* Convert _meta.tsx format to PageMapItem[] format that normalizePages expects
87
*/
9-
export function normalizeMetaToItems(meta: Record<string, any>, route = "/") {
8+
export function normalizeMetaToItems(meta: Record<string, any>, parent = "/") {
109
const pageMapItems: PageMapItem[] = Object.entries(meta).map(
1110
([name, config]) => {
11+
const route = parent === "/" ? `/${name}` : `${parent}/${name}`
12+
1213
if (typeof config === "string") {
1314
return {
1415
kind: "MdxPage",
1516
name,
16-
route: `/${name}`,
17+
route,
1718
frontMatter: { title: config },
1819
}
1920
}
2021

2122
const item: PageMapItem = {
2223
name,
23-
route: config.route || `/${name}`,
24+
route: config.route || route,
2425
}
2526

2627
if (config.title) {
@@ -40,7 +41,7 @@ export function normalizeMetaToItems(meta: Record<string, any>, route = "/") {
4041

4142
const result = normalizePages({
4243
list: [{ data: meta }, ...pageMapItems],
43-
route,
44+
route: parent,
4445
})
4546

4647
return result

0 commit comments

Comments
 (0)