You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context
I'm currently trying to create a multilingual static documentation website. I'm using Nextra 4 and followed the doc using the docs theme and this example to get everything working properly. The only issue I encounter is that all navigation links do not have the language prefix in it.
I cannot use the middleware system since i'm in a static context, do you have any alternative for a static i18n website ?
You can probably reproduce my current situation using the next option output: 'export' on the swr-site example. It's not a static example, but it was my starting point.
Alternatives considered
As of today, i tried to adjust the getPageMap result to force a prefix for every route
Here is an example of the code:
functionlocalizePagemap(config,lang){returnconfig.map(page=>{constlocalizedPage={...page}if(page.route){localizedPage.route=`/${lang}${page.route}`}if(page.children){localizedPage.children=localizePagemap(localizedPage.children,lang)}returnlocalizedPage})}...exportdefaultasyncfunctionRootLayout({ children, params }){const{ lang }=awaitparamsconstnativePageMap=awaitgetPageMap(`/${lang}`)constlocalizedPageMap=localizePagemap(nativePageMap,lang)...}
Unfortunately, this breaks sidebars since they seems to be generated using route parts.
I'm currently considering replacing both sidebar and navbar components with custom ones (ie copy and paste the docs theme components) to alter the route path at the latest possible step.
The solution i'd like
My ideal solution should be an option in components or the nextra plugin to generate links with the current language part directly in it.
I founded multiple warnings in using i18n routing and static generation, both in nextra and next documentation, and I was wondering if I missed something reading the doc or if there is a better approach to implement my use case.
Anyway, thank you for this great project 👌
The text was updated successfully, but these errors were encountered:
Context
I'm currently trying to create a multilingual static documentation website. I'm using Nextra 4 and followed the doc using the
docs
theme and this example to get everything working properly. The only issue I encounter is that all navigation links do not have the language prefix in it.I cannot use the middleware system since i'm in a static context, do you have any alternative for a static i18n website ?
You can probably reproduce my current situation using the next option
output: 'export'
on theswr-site
example. It's not a static example, but it was my starting point.Alternatives considered
As of today, i tried to adjust the
getPageMap
result to force a prefix for every routeHere is an example of the code:
Unfortunately, this breaks sidebars since they seems to be generated using
route
parts.I'm currently considering replacing both
sidebar
andnavbar
components with custom ones (ie copy and paste thedocs
theme components) to alter the route path at the latest possible step.The solution i'd like
My ideal solution should be an option in components or the nextra plugin to generate links with the current language part directly in it.
I founded multiple warnings in using i18n routing and static generation, both in nextra and next documentation, and I was wondering if I missed something reading the doc or if there is a better approach to implement my use case.
Anyway, thank you for this great project 👌
The text was updated successfully, but these errors were encountered: