Skip to content

Commit 800854e

Browse files
vredchenkoclaude
andcommitted
fix(webui): resolve index.mdx for section pages
Section index URLs like /docs/getting-started were showing "Page not found" because the router only looked for {path}.mdx but index files are stored as {path}/index.mdx. Add fallback to check for index.mdx when exact match not found, mirroring standard web server index.html behaviour. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 9bf1839 commit 800854e

File tree

1 file changed

+8
-2
lines changed
  • webui/src/routes/docs

1 file changed

+8
-2
lines changed

webui/src/routes/docs/$.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
import { Box, CircularProgress, Typography } from '@mui/material'
12
import { createFileRoute } from '@tanstack/react-router'
23
import { lazy, Suspense } from 'react'
3-
import { Box, CircularProgress, Typography } from '@mui/material'
44

55
const docModules = import.meta.glob('../../docs/**/*.mdx')
66

77
function getDocComponent(path: string) {
88
const normalizedPath = path.startsWith('/') ? path.slice(1) : path
99

10-
const matchingKey = Object.keys(docModules).find((key) => key.endsWith(`${normalizedPath}.mdx`))
10+
// Try exact match first: "{path}.mdx"
11+
let matchingKey = Object.keys(docModules).find((key) => key.endsWith(`${normalizedPath}.mdx`))
12+
13+
// If not found, try index file: "{path}/index.mdx"
14+
if (!matchingKey) {
15+
matchingKey = Object.keys(docModules).find((key) => key.endsWith(`${normalizedPath}/index.mdx`))
16+
}
1117

1218
if (!matchingKey) {
1319
return null

0 commit comments

Comments
 (0)