Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polish(theme): better error messages on navbar item rendering failures + ErrorCauseBoundary API #8735

Merged
merged 6 commits into from
Mar 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/docusaurus-theme-common/src/utils/docsUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,9 @@ export function useLayoutDoc(
throw new Error(
`DocNavbarItem: couldn't find any doc with id "${docId}" in version${
versions.length > 1 ? 's' : ''
} ${versions.map((version) => version.name).join(', ')}".
} "${versions.map((version) => version.name).join(', ')}".
Check themeConfig.navbar.items in your Docusaurus config to make sure
navbar items aren't attempting to reference a non-existent doc.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works but this assumes useLayoutDoc will always be used inside the theme navbar, which may not always be the case in the future.

I'd really prefer if you used error cause, as explained here: #8696 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha! That makes sense. I've updated things to reflect your suggestions from #8696 (comment)

Available doc ids are:
- ${uniq(allDocs.map((versionDoc) => versionDoc.id)).join('\n- ')}`,
);
Expand Down