-
-
Notifications
You must be signed in to change notification settings - Fork 585
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
Ability to customise Starlight’s components #415
Comments
Thanks for the issue! We’d like to enable this all over the layout, not just in the header, so yes, consider this on the roadmap 🥳 (Bear in mind though that while the header may seem underutilised on wider screens, it is less clear cut on narrow viewports like on mobile.) |
Yes, I agree that the current header works very well on mobile and the mobile version is by far the best I've seen in a docs theme so kudos! I'm excited to see how this will be implemented and hopefully I can contribute in some way. |
I'm also very interested in these possible changes :)! @delucis are there ways for people to contribute to this functionality by any chance? |
Just for information, there is also a Discord thread where we started talking about possible APIs, different use-cases, what would be supported at first, what would not, etc. if some people are interested. |
Thank you @HiDeoo and thanks for your interest @khendrikse! This is a good push for me to bring some of my notes from that thread over here for those who aren’t on Discord. Would love to hear people’s thoughts, if this aligns with what you want and expect, and if there are use cases you have that this would or wouldn’t solve! The idea
There are two use cases the system should support ideally:
It’s possible the best approach for the latter is just to let people import and wrap our built-in components, but I’d like to check that’s true, because really the nicest for “slotting” things in is just to write your component and not need to worry about that. Some API sketchesThe API could maybe look something like this: // astro.config.mjs
starlight({
components: {
// Component for a dedicated template area that is empty currently:
SidebarFooter: './src/components/SidebarFooter.astro',
// Component that overrides a built-in component:
SocialIcons: './src/components/SocialIcons.astro',
},
}) A user component could import a ---
// src/components/SocialIcons.astro
import {
SocialIcons,
type StarlightComponentProps
} from '@astrojs/starlight/layout-components';
type Props = StarlightComponentProps;
---
<SocialIcons {...Astro.props}>
<ExtraIconAtStart slot="before" />
<ExtraIconAtEnd slot="after" />
</SocialIcons> Q&A
Example uses
|
This looks awesome! |
Yes. That will be out of scope for now. But one argument in favour of the config in this form is that we want to enable Starlight “plugins” further down the road and one thing they could do is provide component overrides via this. (Would be harder to do if component overrides were added via some naming convention or “magic” folder.) |
@delucis This sounds really good. Especially because if I understand correctly it would also support anyone wishing to just extend the existing components. Especially the footer feedback mechanism I think (and in a sense, any footer changes) will be a use case I imagine will be seen a lot. |
Any news about this topic? |
Related to sidebar issues:
what if instead extending config with attributes allow to generate sidebar based on collection: const blogEntries = await getCollection('blog');
blogEntries.sort(...) then people can add any metadata to collection and use it for sorting of for showing custom icons etc. |
What version of
starlight
are you using?0.5.2
What is your idea?
The header of my docs site looks pretty sparse. I would like to add some glanceable information to it, like the latest release, GitHub stars etc., similar to this feature in the
Mkdocs/Material theme.
Why is this feature necessary?
The header is currently underutilised space. Top-level menus or custom widgets could make use of that space.
Do you have examples of this feature in other projects?
Material theme for Mkdocs https://squidfunk.github.io/mkdocs-material/
Participation
The text was updated successfully, but these errors were encountered: