Skip to content

Commit a6e5475

Browse files
authored
fixup (#255)
1 parent 9d514f1 commit a6e5475

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/app/docs/page-map.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export async function buildPageMapForBranch(branch: string) {
5252
const ROOT_FOLDERS = Array.from(new Set(allDocFiles.map(fp => fp.split('/')[0])))
5353
const DIRECT_ROOT = ROOT_FOLDERS.find(r => r.toLowerCase() === 'direct')
5454
const UI_DOCS_ROOT = ROOT_FOLDERS.find(r => r.toLowerCase() === 'ui docs' || r.toLowerCase() === 'ui-docs')
55+
const COMMON_SUBS_ROOT = ROOT_FOLDERS.find(r => r.toLowerCase() === 'common subs' || r.toLowerCase() === 'common-subs')
5556

5657
// Strong types for page-map nodes (no `any`)
5758
type MdxPageNode = { kind: 'MdxPage'; name: string; route: string }
@@ -228,10 +229,19 @@ export async function buildPageMapForBranch(branch: string) {
228229
const lower = fp.toLowerCase()
229230
if (
230231
(DIRECT_ROOT && lower.startsWith(`${DIRECT_ROOT.toLowerCase()}/`)) ||
231-
(UI_DOCS_ROOT && lower.startsWith(`${UI_DOCS_ROOT.toLowerCase()}/`))
232+
(UI_DOCS_ROOT && lower.startsWith(`${UI_DOCS_ROOT.toLowerCase()}/`)) ||
233+
(COMMON_SUBS_ROOT && lower.startsWith(`${COMMON_SUBS_ROOT.toLowerCase()}/`))
232234
) {
233235
return false
234236
}
237+
// Filter out files that would create "Index" entry
238+
if (lower.includes('index.md') || lower.includes('index.mdx') || fp === 'index.md' || fp === 'index.mdx') {
239+
return false
240+
}
241+
// Filter out common-subs folder
242+
if (lower.startsWith('common-subs/') || fp === 'common-subs' || lower.startsWith('common subs/')) {
243+
return false
244+
}
235245
return true
236246
})
237247

@@ -250,7 +260,18 @@ export async function buildPageMapForBranch(branch: string) {
250260
}
251261
}
252262

263+
function prettifyNames(nodes: PageMapNode[]) {
264+
for (const node of nodes) {
265+
if (hasName(node)) {
266+
// Apply the pretty function to format names properly
267+
node.name = pretty(node.name)
268+
}
269+
if (hasChildren(node)) prettifyNames(node.children)
270+
}
271+
}
272+
253273
addBasePathToRoutes(remainingFileNodes)
274+
prettifyNames(remainingFileNodes)
254275

255276
_pageMap.push(...remainingFileNodes)
256277

@@ -260,6 +281,7 @@ export async function buildPageMapForBranch(branch: string) {
260281
}
261282
for (const item of remainingFileNodes) {
262283
if (hasName(item)) {
284+
// Use the prettified name for both key and value
263285
meta[item.name] = item.name
264286
}
265287
}

0 commit comments

Comments
 (0)