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

Is it possible that adding customized attribute to sidebar item in order to group different item by this attribute? #3868

Closed
ReginaLiang opened this issue Dec 3, 2020 · 7 comments
Labels
proposal This issue is a proposal, usually non-trivial change

Comments

@ReginaLiang
Copy link

ReginaLiang commented Dec 3, 2020

💥 Proposal

such as:
sidebar item config is below:

{
  type: 'doc', 
  id: 'pageId',
  isNeedMenu: true
},

and I can get this config in DocPage's props, then do something according isNeedMenu.

Is it possible?

Look forward to your reply.

Thanks.

version: 2.0.0-alpha.68

@ReginaLiang ReginaLiang added status: needs triage This issue has not been triaged by maintainers proposal This issue is a proposal, usually non-trivial change labels Dec 3, 2020
@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Dec 3, 2020
@slorber
Copy link
Collaborator

slorber commented Dec 3, 2020

Hi,

Currently, it's not possible to assign unknown attributes to the sidebar, because the shape of the sidebar items is validated quite aggressively to avoid typos.

But we may allow this, as it's the 2nd time something similar is requested (#3787)

Can you explain me better what you are trying to achieve exactly?
Like showing me a design or something ?

You have swizzled the DocPage, and want to use additional custom attributes in your custom DocPage comp right?

@slorber
Copy link
Collaborator

slorber commented Dec 3, 2020

Would this work for your usecase?

Putting custom attributes under "data" make sure we can still detect sidebars typos and validate the other attributes

{
  type: 'doc', 
  id: 'pageId',
  data: {isNeedMenu: true},
},

cc @justinryder

@oriooctopus
Copy link
Contributor

@slorber we also have a need for this on our project. We pass in all custom attributes within an object called extra. I have already written this locally by modifying the sidebar plugin, would you mind if I put up a small PR that added this functionality that you could review?

@ReginaLiang
Copy link
Author

Hi,

Currently, it's not possible to assign unknown attributes to the sidebar, because the shape of the sidebar items is validated quite aggressively to avoid typos.

But we may allow this, as it's the 2nd time something similar is requested (#3787)

Can you explain me better what you are trying to achieve exactly?
Like showing me a design or something ?

You have swizzled the DocPage, and want to use additional custom attributes in your custom DocPage comp right?

Hi, @slorber,

yes, I have swizzled DocPage, so I want to use additional custom attributes to judge something in my comp. About my usage situation, all sidebar menus separated into two categories: A(--> need to redirect to original DocPage), B(--> need to redirect to my customized DocPage), so for convenience I want to config one attributes to judge current item is A or B into sidebar item. so that I don't need to add extra config file to judge it.

Thanks sincerely for your reply.

@slorber
Copy link
Collaborator

slorber commented Dec 4, 2020

Thanks @ReginaLiang

@oriooctopus yes a PR is welcome for this thanks.

@ReginaLiang
Copy link
Author

Hi, @slorber,
I saw this PR have merged, Could you mind to tell me when the newer version will release? ^v^

Thanks sincerely.

@slorber
Copy link
Collaborator

slorber commented Dec 14, 2020

Hi, probably later this week or early next week.
In the meantime you can use the @canary dist tag (sync with master)

@slorber slorber closed this as completed Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This issue is a proposal, usually non-trivial change
Projects
None yet
Development

No branches or pull requests

3 participants