nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.65k stars 465 forks source link

pages:extend pages i18n remove layout from extend pages #2956

Closed nonehub closed 1 month ago

nonehub commented 1 month ago

Environment


Reproduction

https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-jskhtw?file=pages%2Ftest.vue

Describe the bug

When I add a page using hooks pages:extend:

  hooks: {
    'pages:extend'(pages) {
      pages.push({
        name: `testExtend`,
        path: `/testExtend`,
        file: '~/pages/test.vue',
      });
    },
  },

i18n changes the layout to the default, even though on the same page it was not the default..

try open /test and /testExtend They are the same file https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-jskhtw?file=pages%2Ftest.vue

/test : image

/testExtend image

Additional context

No response

Logs

No response

BobbieGoede commented 1 month ago

This happens without i18n as well, you'll have to pass meta like so:

    'pages:extend'(pages) {
      pages.push({
        name: `testExtend`,
        path: `/testExtend`,
        meta: { layout: 'trans' },
        file: '~/pages/test.vue',
      });
    },

Not sure if definePageMeta should work on pages added this way, I suggest opening an issue on the Nuxt repo if that is the expected behavior.

nonehub commented 1 month ago

This happens without i18n as well, you'll have to pass meta like so:

    'pages:extend'(pages) {
      pages.push({
        name: `testExtend`,
        path: `/testExtend`,
        meta: { layout: 'trans' },
        file: '~/pages/test.vue',
      });
    },

Not sure if definePageMeta should work on pages added this way, I suggest opening an issue on the Nuxt repo if that is the expected behavior.

sorry, thanks