Add a function to get sidebar data #1011
Closed
LuHugo
started this conversation in
Feature Requests
Replies: 2 comments 4 replies
-
The For example, this would find all the groups that contain links to sidebar.filter((item) => {
return (
item.type === 'group' &&
item.entries.some(
(subitem) => subitem.type === 'link' && subitem.href.startsWith('/reference/')
)
);
}); |
Beta Was this translation helpful? Give feedback.
4 replies
-
As filtering is already possible using the approach mentioned by Chris and the performance issue was a misunderstanding, I will close this discussion. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What version of
starlight
are you using?0.11.2
What is your idea?
The ability to override default components in the current version is great, but the sidebar data is still a bit annoying. There is no function to query the sidebar. It would be great if you could add a query for sidebar based on
slug
orpath
. For example:getSidebarBySlug
orgetSidebarByPath
.Or add an identification field (such as
path
ordirectory
) to the group type data of the returned sidebar data to filter the sidebar data to be displayed when rewriting the component.The above method is obviously not perfect. There may be a better way to filter out the required sidebar data.
Why is this feature necessary?
Display different sidebars according to different routes
Do you have examples of this feature in other projects?
No response
Participation
Beta Was this translation helpful? Give feedback.
All reactions