A workaround solution for displaying sidebar on custom pages. #8267
mvsantos013
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
😅 a bit hacky but yes, for sure it's possible to do that In the future we'll probably use React Server Components to give you the ability to query arbitrary data (ie docs sidebar data) directly from the homepage. That would be much simpler and officially supported |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If you are creating a custom react page and want to display the default sidebar on left this guide is for you.
Recently, I wanted to include a sidebar on a react page but that's not possible with official tools, unfortunately. Then I found this article from Mark Needham showing how to add a sidebar to a custom page, but since it requires you to manually register the pages and breadcrumbs I decided to extend it with dynamic filling of pages/breadcrumbs. The only disadvantage of my solution is that you need to register all the pages in sidebars.js, i.e, auto generation of sidebar content is not possible but you will have a single source of truth, which for me is not a big problem, but it depends on you.
All you need to do is to add the CustomPageContainer.jsx component to your src folder:
To use the above component all you have to do is to create your own custom react page and import the component:
Beta Was this translation helpful? Give feedback.
All reactions