-
-
Notifications
You must be signed in to change notification settings - Fork 544
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
Initial Starlight Plugins support #942
Conversation
🦋 Changeset detectedLatest commit: 1016921 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This comment was marked as outdated.
This comment was marked as outdated.
Super exciting to see this! Will make sure to get you a thorough review ASAP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super exciting work @HiDeoo! Left a few initial thoughts and questions.
Thanks a lot for the initial feedback and discussions. I think all of the points raised are now actionable and I can get back to it and prepare an updated version including all the suggested changes for further review 👍 |
* main: (103 commits) i18n(fr): update `guides/sidebar.mdx` (withastro#1033) i18n(fr): update `reference/configuration.mdx` (withastro#1034) i18n(fr): update `reference/frontmatter.md` (withastro#1035) Fix docs component details (withastro#1031) Overhaul getting started guide (withastro#1026) i18n(zh-cn): Update sidebar.mdx & configuration.mdx (withastro#1022) i18n(es): Update `configuration` & `sidebar` (withastro#1029) [ci] format i18n(zh-cn): Update frontmatter.md (withastro#1020) i18n(zh-cn): Update overrides.md (withastro#1021) i18n(zh-cn): Update i18n.mdx (withastro#1019) fix(docs-i18n-tracker): update `translations` import (withastro#1025) [ci] format i18n(zh-cn): Update css-and-tailwind.mdx (withastro#1018) [ci] format i18n(zh-cn): Update authoring-content.md (withastro#1016) i18n(ko-KR): update `configuration.mdx` (withastro#1015) i18n(ko-KR): update `sidebar.mdx` (withastro#1014) i18n(ko-KR): update `i18n.mdx` (withastro#1013) [ci] format ...
Turns out this one is a little bit "annoying" due to the recursive types (a user config including plugins which contains a function that pass down a user config that contains plugins…) and our tranforms. I've setup a small repro in the TS playground of the issue. I've found so far 1 workaround that I describe in the playground but imo this is pretty ugly I'll continue to explore this as I may be missing something obvious or a better way to do this but so far, no luck. |
Just pushed a few changes relative to the first review:
If I did not miss anything, this should covers all the feedback from the first review except the one about adding |
Updated the PR with the following changes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really excited we’re getting so close!
I’ve left a last pass of comments on the docs & changeset, but then I think we should be good to go. 🚀
Co-authored-by: Chris Swithinbank <[email protected]>
Huh, not sure why CI started failing 🤔 |
Co-authored-by: Chris Swithinbank <[email protected]>
The CI failure is very odd — just ran the build with no issues locally. |
Same, working fine locally 🤔 |
From the stack trace it’s almost like it’s complaining about this: starlight/packages/starlight/index.ts Line 80 in 00d101b
But that’s not merged into this PR yet 🤔 |
Yeah I'm a bit confused as there is no |
Merged and fixed that to see if it helps! |
Looks like that worked? I guess somehow there was some weird code in the CI job? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
STAMP OF APPROVAL! ✅
Yeah, I was afraid to try this, see it works and have no clue on why 🤣 I do not have a better explanation ^^ |
Well, here goes nothing… 🤞 |
What kind of changes does this PR include?
Description
Starlight plugins proposal #753Starlight plugins proposal #962.This pull request is the beginning of the implementation of a Starlight Plugin API. A lot of details and discussions are available in
#753#962.The following features are implemented in this first PR:
config
updateConfig()
addIntegration()
logger
I tried to comment various implementation details, specially around Zod, like why the plugin API is using a totally different schema than the configuration one, why the configuration and configuration updates flowing through the plugin API are not validated (but still properly typed for user convenience) and only the final configuration is validated, etc. but if you have any questions/suggestions, please let me know.
Plugin Example
This PR adds a temporary
@astrojs/starlight-search-demo
plugin that demonstrates the various features of the plugin API and see how it can be used.This example is obviously a reference to a potential
starlight-algolia
kind of plugin that has been requested multiple times on Discord and would also be needed for the Astro docs site. The idea was to see the code required to implement such a plugin and having a custom search bar by only adding the following lines to theastro.config.mjs
file:Note that this plugin is only meant for demo purposes. It does nothing and even tho we briefly discussed the idea of having official plugins and if we ever decide to make an official Algolia plugin, it feels like this should be done in a separate PR or maybe even a separate repository with all expected features from such a plugin (proper CSS styling, pagefind disabled, tests, etc.).
Note: I think my personal important takeaway from this example is that the
injectSettings()
API discussed in #753 (and potentially in #861 too for some API changes) could be really useful.Documentation
This PR adds a "Plugins Reference" page inspired by the Astro Integration API documentation page.
I'm not sure if a guide is needed for the plugin API at this point, as the "use a plugin" section would be pretty much a repeat of the
plugins
section of the Configuration Reference and may change between plugins and a "create a plugin" section, which I think does not exist for the Astro Integration API, would be pretty much merging the various examples from the "Plugins Reference" page.I also suggested a change to the showcase to add a new section dedicated for plugins so it can be linked from various places. Obviously, we would need to wait for the first plugin to be published before doing that if we decide to go that way.
Remaining tasks
These tasks should be completed before merging this PR:
TODO(HiDeoo)
references.