HiDeoo / starlight-versions

Starlight plugin to version documentation pages
https://starlight-versions.vercel.app
MIT License
24 stars 1 forks source link

Versions working with utils #4

Closed DefinitelyMaybe closed 4 months ago

DefinitelyMaybe commented 4 months ago

Is your feature request related to a problem?

Hey! thank you again for your work on this project 😄

I'm currently playing around with trying to get both starlight-versions and starlight-utils to work together. I've gone down the route of making my own custom sidebar which is a copy|paste of starlight-utils component and am now trying to make it fit with starlight-versions as the only integration. Thing is that in your sidebar component you've done:

import starlightConfig from 'virtual:starlight/user-config'
import starlightVersionsConfig from 'virtual:starlight-versions-config'

and I can't seem to find out how or where or what I can replace these imports with in my component.

Any help or advice on this is appreciated 👍

Describe the solution you'd like

unsure. need advice.

Describe alternatives you've considered

option 2 is not including this as a feature of the website. It'd be a nice to have tho 😄

Additional Context

I have a deployed repo here if you'd like to check it out

HiDeoo commented 4 months ago

Thanks for the feedback.

Regarding the specific imports you mention, those should work out of the box in your custom component but would trigger some TS errors as TypeScript would have no knowledge of their content. This is something that can be easily workaround by providing some definitions for them, e.g. like this is done in https://github.com/HiDeoo/starlight-versions/blob/main/packages/starlight-versions/virtual.d.ts.

Altho, I'm not sure fixing these imports would fix the underlying issue as you would still not have access to some functions like getVersionFromSlug() and getVersionSidebar() which are not exported. There are some plans in Starlight to move route data (like the sidebar) away from being props and making them available everywhere. When such changes are made in Starlight, this plugin will be refactored to use such approach and would make it easier for such use cases.

There is also a last consideration to take into account in this case, which is the fact that the sidebar are versioned in this plugin but the configuration of the Multi-Sidebar of starlight-utils is not which could lead to some mismatches in the sidebar data in different versions preventing the starlight-utils plugin to work as expected.

It is definitely too early imo for this plugin to try to address composition with other plugin/component overrides and even more how the versioning of other plugins configuration could be addressed. The next major step would be when possible to no longer use route data from props and re-evaulate at that point.

DefinitelyMaybe commented 4 months ago

Thank you 🙏 the TS errors were getting to me 😅

I've copied the getVersionFromSlug() and getVersionSidebar() functions so no worries there. Hoping I can wrangle it together now.

Ah, makes sense re future plans for the prop/route data. Looking forward to it 😄