Skip to content

fix(nuxt): opt renderer route out of i18n localization - #208

Open
sandros94 wants to merge 3 commits into
romhml:mainfrom
sandros94:fix/i18n-route
Open

fix(nuxt): opt renderer route out of i18n localization#208
sandros94 wants to merge 3 commits into
romhml:mainfrom
sandros94:fix/i18n-route

Conversation

@sandros94

Copy link
Copy Markdown

Resolves #171

As per issue description, with @nuxtjs/i18n and strategy: 'prefix', i18n localises every page route and removes the unprefixed originals. The renderer placeholder page had no opt-out, so /__compodium__/renderer simply stopped existing: the request 404s (with X-Frame-Options: DENY) and the devtools preview iframe stays blank, which makes it look like a rendering bug instead of a routing one.

The fix is basically a one-liner: the placeholder route is now registered with meta: { i18n: false }, which i18n treats as its highest-precedence route-level opt-out (it wins over defineI18nRoute() and the pages config). No module detection needed, without i18n the meta key is just a no-op.

Also added an i18n fixture + test asserting the renderer responds on the unprefixed path with strategy: 'prefix' — that's the exact case that had no coverage. Verified it 404s without the fix and passes with it. Other strategies (prefix_except_default, no_prefix) keep an unprefixed default route so they were never affected.

Development note: @nuxtjs/i18n is only added as a devDependency of @compodium/nuxt for the fixture, nothing ships to consumers

I couldn't reproduce this issue vue side with vue-i18n, but I'm not that good on that so I prefer to limit my changes on nuxt

@sandros94

sandros94 commented Aug 1, 2026

Copy link
Copy Markdown
Author

This should also theoretically work with nuxt-i18n-micro. But if it doesn't I would honestly prefer to add meta: { i18n: false } support there instead of adding a branch here

EDIT: spaned a fable to doublecheck this, no it does not support meta: { i18n: false } but it already ignores routes that are tagged as internal paths, so no changes needed for that module

@sandros94

sandros94 commented Aug 1, 2026

Copy link
Copy Markdown
Author

Pushed two more fixes after field-testing this in the wild:

  1. the placeholder route also needs a name: i18n's localization middleware treats nameless routes as localizable and redirects /__compodium__/renderer to a prefixed variant that was never generated
  2. hookOnce('pages:extend')hook with an idempotent push: pages:extend re-runs on every pages rebuild, so adding/removing any page file mid-session silently dropped the placeholder until a dev server restart

EDIT: also noticed that ts v7 is not working, because compodium is using v5.x api, but this is a different topic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Using @nuxtjs/i18n with specific configuration makes Compodium not render components

1 participant