Context with Meta
Hi there! ๐
I have a problem. It seems that when I try to create a custom MetaTitle with SolidMeta, the language context is not being accessed in SSR. Here is my implementation:
ERROR:
this is the context for paraglide:
https://github.com/thetarnav/paraglide-solidstart-hackernews/blob/main/src/i18n/adapter.ts
GitHub
paraglide-solidstart-hackernews/src/i18n/adapter.ts at main ยท theta...
Example hackernews app built with SolidStart and Paraglide-js for i18n. - thetarnav/paraglide-solidstart-hackernews
5 Replies
First thing I'd check is whether adapter.createI18n() is actually executed in your server side implementation.
And given the source is in your project find out if/when the initialization goes off the rails.
GitHub
paraglide-solidstart-hackernews/src/i18n/index.tsx at b3b28ff610f61...
Example hackernews app built with SolidStart and Paraglide-js for i18n. - thetarnav/paraglide-solidstart-hackernews
One thing I'd note is that this import is probably the one responsible for loading the module on the server for the first time.
GitHub
paraglide-solidstart-hackernews/src/entry-server.tsx at b3b28ff610f...
Example hackernews app built with SolidStart and Paraglide-js for i18n. - thetarnav/paraglide-solidstart-hackernews
This is running on the server. If I remove the MetaTitle, it works. I'm not sure what could be wrong with the Title component from SolidMeta.
i found this issue in solid-meta:
https://github.com/solidjs/solid-meta/issues/41
GitHub
[Bug?]: Cannot access context when read in Meta content prop. ยท Iss...
If you try to read context inside content prop of Meta component provided by start, the context will not be available, which is not expected as it's used directly under the provider. <Ctx.Pr...
Based on that issue, this crashes:
But this works:
Only you know how you plan to use your
MetaTitle
. Perhaps you can construct it in such a way that the context is accessed outside of useHead()
.