-
-
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
Cannot access certain imports - Overriding components #860
Comments
Adding to this, types are not exposed for the virtual module. The situation is a little different and will require documenting, but you can place this directive in your /// <reference path="../node_modules/@astrojs/starlight/virtual.d.ts"/> |
Thanks for the issue @TheOtterlord! This is partly intentional, although we should still find a way to support what you need to do. Basically one of the aims of my refactors in #709 was to move as much logic as possible up out of components so we can keep Translation stringsThe one thing I decided was out of scope there was the translation strings for a couple of reasons:
One interim solution I like the sound of more is just to pre-generate the strings as part of - import { useTranslations } from '../utils/translations';
- const t = useTranslations(Astro.props.locale);
- const label = t('page.editLink');
+ const label = Astro.props.labels['page.editLink']; This would hide our implementation methods in return for a data-only model until we have time to investigate the more complex option of a full i18n system. Other utilsWere there other things you need from ConstantsMaybe we take a similar approach and expose constants on the route data objects as well to avoid documenting the extra export? I agree that it’s useful to have this exposed — I already had to use TypesYeah, I realised this late in the day too and after trying a few things couldn’t type these automatically for people. I don’t know if we WANT those exposed though either for the same reason that the virtual module imports are kind of internal. What are you using them for? Maybe there’s another way to make sure the same data is available. |
Just posted #861 and saw right now that it shares some points with this feedback so I can answer for me regarding the last point.
So far for me, accessing
|
Most of the time, requiring either I can replace certain component imports from a virtual module with the
+1 on accessing the user config. This can be a really helpful module. |
Yeah, I like this as a temporary solution. Obviously, it would be great to have a more complete solution in the future, so this is nice for now. |
I think most of this has been addressed, so closing. We can open more specific issues if needed. Thanks again @TheOtterlord! |
Heyhey, I tried to override/customize the Page component and it just doesnt work properly without the util exports... without All the best, |
Hi @fsmeier — |
What version of
starlight
are you using?0.11.0
What version of
astro
are you using?latest
What package manager are you using?
pnpm
What operating system are you using?
Linux
What browser are you using?
Firefox
Describe the Bug
Certain imports used by overridable components are not exported.
utils
is one I find I often need to access. Either because the builtin component uses it, or I need translation strings, etc.List of missing exports I've noticed/needed so far.
utils
constants
Workaround
You can use a direct path to the
node_modules
folder to work around the missingexports
.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-bd7al8?file=src%2FTest.astro
Participation
The text was updated successfully, but these errors were encountered: