A question about server side rendering an <a> tag based on requestEvent.
I am looking for a way to pre-render variants og the route as
<a>
tag based on requestEvent
.
I post my implementation down bellow.4 Replies
My code implementation
Source code of LANGUAGES constant
Why i want to do this?
Cuz google SEO does not see the languages variants and it does not index it very well...
I would be blad for help 🙂
I used
createResource
but it does not seems to work.
ðŸ˜My website wich i am trying to fix: https://lisia-nora.pl/en
The Best Minecraft Texture Packs on the Web! 🦊 | Lisia-Nora.pl
Lisia-Nora.pl offers a wide selection of textures and mods for Minecraft. Download free resources to enhance your gaming experience and create unique ...
Instead of request Event you can get the current route with
useLocation
which is isomorphic.
But couldn’t you just do construct the url with string concatenation?
Also if you look for a "typesafe" file routes there’s this package which helps to create valid routes.
https://www.npmjs.com/package/solid-start-typesafe-routes-plugin
https://docs.solidjs.com/solid-router/reference/primitives/use-location#uselocation
and if you have a dynamic route that has the lang as a route param you can get this with useParams
https://docs.solidjs.com/solid-router/reference/primitives/use-paramsnpm
solid-start-typesafe-routes-plugin
Type-safe routes for solid-start file-routes. No more broken links.. Latest version: 1.1.0, last published: 2 months ago. Start using solid-start-typesafe-routes-plugin in your project by running
npm i solid-start-typesafe-routes-plugin
. There are no other projects in the npm registry using solid-start-typesafe-routes-plugin.useParams - SolidDocs
Documentation for SolidJS, the signals-powered UI framework
useLocation - SolidDocs
Documentation for SolidJS, the signals-powered UI framework
Thanks i figured that out
But thank you 🫶
Have a nice day/night! 😃