-
-
Notifications
You must be signed in to change notification settings - Fork 576
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
Expose FS translation system to plugins #2578
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: e80caa4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
✅ Deploy Preview for astro-starlight ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -152,7 +151,7 @@ export function getStarlightEcConfigPreprocessor({ | |||
}, | |||
...otherStyleOverrides, | |||
}, | |||
getBlockLocale: ({ file }) => pathToLocale(file.path, { starlightConfig, astroConfig }), | |||
getBlockLocale: ({ file }) => pathToLang(file.path, { astroConfig, starlightConfig }), |
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.
Expressive Code technically expects a Starlight language here so I changed it but this is not a bug fix (no changeset) as Expressive Code lower-cases the language identifier anyway.
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
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.
This looks great @HiDeoo! Left some suggestions/questions/discussions, but they’re honestly all around the “outside” of the core functionality or on the docs. I think overall this seems very solid 🚀
// strings. We let TypeScript merge them into a single union type so that plugins with a TypeScript | ||
// configuration preventing `UserI18nKeys` to be properly inferred can still get auto-completion | ||
// for built-in UI strings. | ||
export type I18nKeys = keyof BuiltInStrings | UserI18nKeys | keyof StarlightApp.I18n; |
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.
Ahhhhhh, nice fix! 🧠
Thanks for the review 🙌 Holding off on the suggested changes so I can tackle them all at once when we have a clearer idea of what we want to do regarding the name. |
* main: (27 commits) i18n(ko-KR): update `site-search.mdx` [ci] release (withastro#2590) Support passing more options to the DocSearch component (withastro#2589) [ci] release (withastro#2587) Add changeset for withastro#2252 (withastro#2588) [ci] format Update dev dependencies (withastro#2582) Build performance optimizations for projects with large sidebars (withastro#2252) Fix a11y CI workflow (withastro#2503) Update `astro-expressive-code` to v0.38 (withastro#2551) Added social icon for Nostr (withastro#2579) [ci] format docs(showcase): add docs.reactbricks.com to showcase (withastro#2586) i18n(ja): Update site-search.mdx (withastro#2577) i18n(ja): Update pages.mdx (withastro#2576) i18n(fr): Update `reference/plugins.mdx` from withastro#2549 (withastro#2574) [ci] format docs: update showcase-sites.astro (withastro#2562) Throw an error if a showcase image does not have the required dimensions (withastro#2573) i18n(ja): Update frontmatter.md (withastro#2566) ...
Co-authored-by: Chris Swithinbank <[email protected]>
Updated the branch with the changes discussed above, hope I did not forget anything:
I have a question: this PR adds multiple changesets but I think |
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.
I think this looks good! Left a few small notes, but nothing significant jumped out to me — just cleaning up the demo plugin and removing any other TODOs.
I have a question: this PR adds multiple changesets but I think
.changeset/polite-fishes-remain.md
should come first. Altho, I don't know if there is a way to enforce that from this PR, right?
Good question! I’m not 100% sure how Changesets orders them beyond the major/minor/patch subheadings. Not sure if it’s chronological by commit time or something else. I’d guess we should just tweak the CHANGELOG in the release PR when the time comes.
test.runIf(pkg.version[0] === '1')( | ||
'removes the deprecated `setup` hook in the DocSearch plugin with Starlight v1', | ||
async () => { | ||
const docSearchPlugin = starlightDocSearch({ | ||
appId: 'YOUR_APP_ID', | ||
apiKey: 'YOUR_SEARCH_API_KEY', | ||
indexName: 'YOUR_INDEX_NAME', | ||
}); | ||
expect(docSearchPlugin.hooks.setup).not.toBeDefined(); | ||
expect(docSearchPlugin.hooks['config:setup']).toBeDefined(); | ||
} | ||
); | ||
}); |
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.
FWIW, I would be happy to just change the DocSearch plugin right away, bumping the minimum supported Starlight version, and release a new minor. Can also happen in a follow-up PR though as we can release a new plugin version after this Starlight minor.
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.
Done, one more changeset it is 😅
packages/starlight/index.ts
Outdated
const integrations = pluginResult.integrations; | ||
const useTranslations = pluginResult.useTranslations; | ||
const absolutePathToLang = pluginResult.absolutePathToLang; |
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.
Should we refactor this to this?
const integrations = pluginResult.integrations; | |
const useTranslations = pluginResult.useTranslations; | |
const absolutePathToLang = pluginResult.absolutePathToLang; | |
const { integrations, useTranslations, absolutePathToLang } = pluginResult; |
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.
Yes, please ^^ I imagine I just duplicated the lines at the early stage of the code and missed the potential refactor later on 😞
Co-authored-by: Chris Swithinbank <[email protected]>
Co-authored-by: Chris Swithinbank <[email protected]>
Makes sense, that was also my guess, thanks. I added a new todo to the PR body to remember about that. |
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.
Perfect! Just noticed one detail with the DocSearch update.
Co-authored-by: Chris Swithinbank <[email protected]>
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.
Perfect! OK, should be ready to go I think! I’m thinking of trying to get Astro.locals
ready too, so that these two changes breaking plugins can go out together. I think we’re almost there.
Makes sense 👍 I already gathered some feedback/concerns regarding the route data PR to publish when it's ready for review, really excited about this one 🤩 |
I'm not 100% sure, but I think that changesets just reads the files alphabetically, which means changing the filename from Altho I have to say, I personally would also double check it in the ci PR later, so leaving the ToDo is also my recommendation. Nonetheless, trying it out would be interesting 🤔
|
Description
This plugin exposes the file system translation system to Starlight plugins throught the
setup
hook using a newuseTranslations()
callback function.This change requires the addition of a new plugin hook (currently named
init
, I picked the first thing coming to mind to get started) which now exposes theinjectTranslations()
callback function (which was previously available in thesetup
hook).The documentation so far is only a rough draft to get an idea of everything changed.
Remaining tasks
docs/astro.config.mjs
filedocs/package.json
filedocs/src/content/i18n/zh-CN.json
filepackages/demo-plugin/
directorypnpm i
to remove mention of thestarlight-demo-plugin
package in the lockfile// TODO(HiDeoo)
comments (if any).changeset/polite-fishes-remain.md
comes first (Deprecates the Starlight plugin `setup` hook in favor of the new `config:setup` hook which provides the same functionality.
)