shuding / nextra

Simple, powerful and flexible site generation framework with everything you love from Next.js.
https://nextra.site
MIT License
11.87k stars 1.28k forks source link

Nextra 3 uses i18n structure, and the MDX file in pages root fails to load. #3121

Open bazijun opened 3 months ago

bazijun commented 3 months ago

Description

I'm experiencing issues with Nextra 3<3.0.0-alpha.31> when using the i18n directory structure. MDX files in the root pages directory are not loading properly.

├─ pages │ ├─ en/ │ ├─ zh/ │ ├─ es/ │ ├─ ru/ │ ├─ test.mdx ❌

Error Message

./src/pages/test.mdx:2:1

Module not found: Can't resolve 'E:/code/capsolver-docs-v3/.next/static/chunks/nextra-page-map-test.mdx.mjs'
  1 | import { HOC_MDXWrapper } from 'nextra/setup-page'
> 2 | import { pageMap } from 'E:/code/capsolver-docs-v3/.next/static/chunks/nextra-page-map-test.mdx.mjs'
    | ^
  3 |
  4 |
  5 | import 'nextra-theme-docs/style.css'

https://nextjs.org/docs/messages/module-not-found

theme.config.tsx

export default {
  i18n: [
    { locale: "en", name: "English" },
    { locale: "zh", name: "简体中文" },
    { locale: "es", name: "Español" },
    { locale: "ru", name: "Россия" },
    { locale: "vi", name: "Tiếng Việt" },
    { locale: "de", name: "Deutsch" },
    { locale: "jp", name: "日本語" },
    { locale: "hi", name: "हिन्दी" },
    { locale: "fr", name: "Français" },
    { locale: "id", name: "Bahasa Indonesia" },
    { locale: "pt", name: "Português" },
  ]
}
dimaMachina commented 3 months ago

unfortunately this will be not fixed, until Nextra v4

bazijun commented 3 months ago

@dimaMachina But I really need to have a 404 page with Nav and Footer under the root path of pages. Can you give me some suggestions to achieve this requirement? Thank you very much

dimaMachina commented 1 month ago

@bazijun Hi there, would you want to try Nextra 4 with app router support and server side i18n? How to do it I described in https://github.com/shuding/nextra/issues/2600#issuecomment-2385107206

dimaMachina commented 1 month ago

Also cc @arno-fukuda

arno-fukuda commented 3 weeks ago

Is there any workaround that can serve the /en/ content without locale in url and without a redirect? Google Search Console indexing doesn't like the 307 redirect, but we don't want to change our sitemap to use /en/ as default.