nuxt-modules / i18n

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

Nuxt generate #171

Closed Frankwarnaar closed 5 years ago

Frankwarnaar commented 5 years ago

Version

4.0.0

Reproduction link

https://deploy-preview-81--miele-laundry-club.netlify.com/nl/

Steps to reproduce

Enter a postalCode (for instance 2011JJ) in the input. You will be redirected to another sub route of the index page.

What is expected ?

When you refresh, the page should be found.

What is actually happening?

A 404 is thrown.

Additional comments?

I'm running a static website, using nuxt generate. On the index page, I'm using child routes. My page structure is as the following: index.vue index/ index.vue afspraak-plannen.vue nog-niet-actief.vue

For the afspraak-plannen.vue and the nog-niet-actief.vue pages, the page is not being generated. Because of this, client side navigating to the child page does work, but the server side (static) version is not found, because it's not generated. While generating I see the following errors:

 Error generating /nl//nog-niet-actief
 Error generating /nl//afspraak-plannen  

It looks like the index folder is not being removed properly from the generated output, causing a duplicate / in the path.

This bug report is available on Nuxt community (#c181)
michaelwnyc commented 5 years ago

Can you post your configuration? Including the path definition in case it's done in-component.

Frankwarnaar commented 5 years ago

My nuxt-i18n config, where defaultLocale is nl and locales is:

[
  {
    "code": "nl",
    "name": "Nederlands"
  },
  {
    "code": "en",
    "name": "English"
  }
]
const { locales } = require('../lib/data')
const defaultLocale = locales[0]

/**
 * @see https://nuxt-community.github.io/nuxt-i18n/
 */
module.exports = [
  'nuxt-i18n',
  {
    defaultLocale,
    detectBrowserLanguage: {
      useCookie: true,
      cookieKey: 'i18n_redirected'
    },
    lazy: true,
    langDir: 'static/data/',
    locales: locales.map(locale => ({
      code: locale.code,
      file: `${locale.code}/messages.json`,
      iso: locale.code,
      name: locale.name,
    })),
    rootRedirect: defaultLocale,
    strategy: 'prefix',
    vueI18n: {
      fallbackLocale: defaultLocale,
    }
  }
]

The paths are defined by my folder structure.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

rchl commented 5 years ago

@Frankwarnaar have you fixed it or maybe new version fixed it for you?