Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/components/navbar/top-level-items.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
// src/components/navbar/normalize-meta-to-items.ts
import { normalizePages } from "nextra/normalize-pages"
import type { Folder, PageMapItem } from "nextra"
import meta from "../../pages/_meta"

/**
* Convert _meta.tsx format to PageMapItem[] format that normalizePages expects
*/
export function normalizeMetaToItems(meta: Record<string, any>, route = "/") {
export function normalizeMetaToItems(meta: Record<string, any>, parent = "/") {
const pageMapItems: PageMapItem[] = Object.entries(meta).map(
([name, config]) => {
const route = parent === "/" ? `/${name}` : `${parent}/${name}`

if (typeof config === "string") {
return {
kind: "MdxPage",
name,
route: `/${name}`,
route,
frontMatter: { title: config },
}
}

const item: PageMapItem = {
name,
route: config.route || `/${name}`,
route: config.route || route,
}

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

const result = normalizePages({
list: [{ data: meta }, ...pageMapItems],
route,
route: parent,
})

return result
Expand Down