-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
front matter option "displayed_sidebar" & "hide_sidebar" #5686
Comments
So you mean the home doc would display a sidebar and a next button, but there wouldn't be a "home" link in the sidebar? I'm not against this, just wondering how useful it would be and if people will be understand this feature. (Refs are already not widely used afaik, and our doc about them was a bit confusing) Some questions to figure out if we really need this:
|
Me, plus three users on Discord.
It's hard to describe. Look at this page: https://docs.luxalgo.com/ The need is that:
Therefore, this page has to be part of the docs plugin (which I implemented by importing a React component into the MD page), or else it won't know about the docs sidebar. On the other hand, it should do absolutely nothing with that sidebar—the only thing it should do is getting itself registered. I don't see how this use-case can be realized without sufficient hacking (I hope I'm already one of the guys most familiar with the internal details). Currently I swizzled
|
I'm just asking because I don't like adding features without understanding better the use-case :) This use-case seems reasonable to me and we should try to support this. What I don't like:
What about adding We could deprecate the ref type, add a more powerful/generic API that solves all the use-cases at once?
|
Yeah, my use-case may not be the best to illustrate this API. So adding a doc in a sidebar creates a two-way binding: sidebar includes the doc link, doc page renders the sidebar.
I thought about that, but this means the sidebar keys are no-longer irrelevant on the user side. But it certainly makes sense 👍
Won't that create two sidebar associations, just like declaring the same doc in two sidebars? What's the use case? |
Oh, and I think your API would also handle autogenerated items pretty nicely. I like the |
I don't understand this, can you explain?
For me, it would add a link to the parent sidebar, and bind to the So, if I understand we agree on:
Your use-case would be solved by:
right? |
Now they do matter :P And yes, your summary is what I'm thinking of—using front matter to create associations-only, and use |
Mmmm, const sidebars = {
sidebarA: [
{type: 'doc', id: 'my-doc'},
],
sidebarB: [
{type: 'doc', id: 'doc2', sidebar: 'sidebarA'},
],
}; From your description, you are saying that
I don't have much objection to that API, but it's pretty confusing IMO, and doesn't look like a natural derivative of the |
yes 🤪
👍 better I'm saying: const sidebars = {
sidebarA: [
{type: 'doc', id: 'my-doc', sidebar: "sidebarB"},
],
sidebarB: [
],
}; Would be the same as: const sidebars = {
sidebarA: [
{type: 'ref', id: 'my-doc'},
],
sidebarB: [
{type: 'association', id: 'my-doc'},
],
}; And it would only be a shortcut for a use-case that does not really make much sense in the first place, so I'd rather not do this (and I think we agree that Eventually, we could have a more convenient md frontmatter syntax: ---
sidebar: sidebarA
--- or ---
sidebar:
mobile: sidebarA
desktop: null
--- I don't think many will want to hide the sidebar just on desktop (like you do) so maybe we shouldn't complicate the API for the most common use-case and just provide a |
Actually, I think there are many other layout-related metadata that can accept However, as I looked through relevant source code, I think it'll make more sense if we make two front matter options: |
You mean Can this make sense for any use-case? ---
sidebar:
mobile: sidebarA
desktop: sidebarB
--- |
I mean, ---
sidebar: sidebarA
hide_sidebar:
mobile: true
desktop: false
--- Or: ---
sidebar: sidebarA
hide_sidebar: true
--- Assigning different sidebars on desktop and mobile makes navigation quite confusing IMO, and it also makes the doc's metadata unnecessarily different from before. |
Agree. Also the concept of "mobile/destop" is theme-specific (another theme might decide to use 3 breakpoints). I wonder if it's a good idea to include this notion inside docs plugin core: it may be better to handle this frontmatter only inside the theme (which can be annoying for |
Yes, we are. Once we split the front matter into |
🚀 Feature
Have you read the Contributing Guidelines on issues?
Yes
Has this been requested on Canny?
No
Motivation
We have two item types:
doc
which creates both the sidebar association and the link,ref
which creates just the link but not association (the sidebar will not show up on that page). We naturally want a third:association
that creates the association but not the actual link.Use-case: home pages of docs sites would use the sidebar as navigation, but itself shouldn't necessarily appear in that sidebar (typically we go back by clicking the logo or using a navbar link).
API Design
A new sidebar item type
association
would be sufficient. It might still take all the props ofdoc
orref
for uniformity (we won't throw during validation), but they don't do anything.The
association
item can be declared anywhere in the sidebar, because it doesn't go into the rendered structure.Have you tried building it?
It would literally be just 20 lines of code in the doc metadata generation logic. But I'll be implementing this after the category index page thing (or at least after #5678)
The text was updated successfully, but these errors were encountered: