Skip to content

Commit

Permalink
Execute check for sidebar links only on server (#585)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri POSTOLOV authored Jan 17, 2024
1 parent 08de422 commit c494a9c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/nextra-theme/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,12 @@ export default function NextraLayout({ children, pageOpts, pageProps }: NextraTh
defaultLocale,
route: fsPath,
})
for (const item of result.flatDocsDirectories) {
if (!item.route) {
throw new Error(`Route "${item.name}" is not exist. Remove this field from _meta.js file`)
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}" is not exist. Remove this field from _meta.js file`)
}
}
}
return result
Expand Down

0 comments on commit c494a9c

Please sign in to comment.