-
Notifications
You must be signed in to change notification settings - Fork 65
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
Include sidebar name in breadcrumbs #1219
Conversation
84a3b3f
to
bbcc298
Compare
I want to test this after PR #1217 merges. I can approve this based on testing, since I don't have experience with the docusaurus updates. |
|
…karound-breadcrumb-root
@ipopescu It is possible, although I had to make assumption that index page is the first item in the sidebar: https://github.com/casper-network/docs/pull/1219/files#diff-f0a13f8874197a80b860a20dab0030153554d0704e80691fa05ecd31dda8ce97R143-R150 Please try the updated version 😉, IMO it works great. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrzej-casper this is awesome, thanks! IMO, assuming the index page is the first item in the sidebar is a sound assumption.
Include sidebar name in breadcrumbs
Thank you for this, I also implemented that in our docs. Just a quick note that you can improve the code by looking up the sidebar ID in the theme config, and then get the actual navbar label from there. So instead of const label = sidebarName.charAt(0).toUpperCase() + sidebarName.slice(1); you can do: import { useThemeConfig } from '@docusaurus/theme-common';
[...]
const {
navbar: {items: navbarItems},
} = useThemeConfig();
const label = navbarItems.find((item) => item.sidebarId === sidebar.name)?.label || ""; |
What does this PR fix/introduce?
Workaround for facebook/docusaurus#6953, to include top-level section in breadcrumbs:
Additionally we detect index-like pages, and hide their breadcrumb:
Closes #1216.
Additional context
Content for
DocBreadcrumbs/styles.module.css
was copied directly from Docusaurus code.Content for
DocBreadcrumbs/index.tsx
is based on https://raw.githubusercontent.com/facebook/docusaurus/v2.4.1/packages/docusaurus-theme-classic/src/theme/DocBreadcrumbs/index.tsx with the following changes:Checklist
yarn install && yarn run build
.