Skip to content

Commit

Permalink
Improve error message + fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
benface committed Dec 4, 2024
1 parent 06948c7 commit d258329
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 11 additions & 3 deletions packages/nextra-theme/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,19 @@ export default function NextraLayout({ children, pageOpts, pageProps }: NextraTh
})
if (typeof window === 'undefined') {
// Execute this check for sidebar links only on server, will be stripped from client build
for (const item of result.flatDocsDirectories) {
if (!item.route) {
throw new Error(`Route "${item.name}" does not exist. Remove this field from _meta.js file`)
const checkIfRouteExists = (item: (typeof result.docsDirectories)[number], baseRoute = '') => {
const expectedRoute = `${baseRoute}/${item.name}`
// TODO: When a page doesn't exist in languages other than English, `item.route` is `#` for some reason
if (item.type === 'doc' && !item.route) {
throw new Error(`Route "${expectedRoute}" does not exist. Remove this field from _meta.js file`)
}
if (item.children) {
for (const child of item.children) {
checkIfRouteExists(child, item.route)
}
}
}
result.docsDirectories.forEach((item) => checkIfRouteExists(item))
}
return result
}, [defaultLocale, fsPath, locale, pageMap])
Expand Down
1 change: 0 additions & 1 deletion website/pages/en/developing/creating-a-subgraph/_meta.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export default {
'creating-a-subgraph': '',
'install-the-cli': '',
'subgraph-manifest': '',
'ql-schema': '',
Expand Down

0 comments on commit d258329

Please sign in to comment.