Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions i18n.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const locales = ["en", "zh"] as const;
export const defaultLocale = "en";

export const i18n = {
locales,
defaultLocale,
} as const;

export type Locale = (typeof locales)[number];
4 changes: 3 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// next.config.mjs
import { createMDX } from "fumadocs-mdx/next";
import createNextIntlPlugin from "next-intl/plugin";

const withMDX = createMDX();
const withNextIntl = createNextIntlPlugin("./i18n.ts");

/** @type {import('next').NextConfig} */
const config = {
Expand All @@ -10,4 +12,4 @@ const config = {
images: { unoptimized: true }, // 避免使用 Next Image 优化服务
};

export default withMDX(config);
export default withNextIntl(withMDX(config));
Comment on lines 12 to +15

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Enable next-intl plugin without locale-aware routes

Wrapping the Next.js config with createNextIntlPlugin('./i18n.ts') configures the app to rewrite requests to locale-prefixed paths (e.g. /en, /zh). The current app directory only contains root-level routes (app/page.tsx, app/docs/...) and does not provide a [locale] segment or locale-aware layouts. After this change, users will be redirected to locale-prefixed URLs that have no matching pages, leading to 404s for every request. The locale directory structure and layouts need to be added before enabling the plugin.

Useful? React with 👍 / 👎.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dependencies": {
"@orama/orama": "^3.1.13",
"@orama/tokenizers": "^3.1.13",
"@radix-ui/react-slot": "^1.2.3",
"@types/mdx": "^2.0.13",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
Expand All @@ -22,13 +23,13 @@
"fumadocs-ui": "^15.7.11",
"lucide-react": "^0.544.0",
"next": "^15.5.3",
"next-intl": "^4.3.8",
"react": "^19.1.1",
"react-dom": "^19.1.1",
"rehype-autolink-headings": "^7.1.0",
"rehype-slug": "^6.0.0",
"remark-gfm": "^4.0.1",
"tailwind-merge": "^3.3.1",
"@radix-ui/react-slot": "^1.2.3"
"tailwind-merge": "^3.3.1"
},
"devDependencies": {
"@tailwindcss/postcss": "^4.1.13",
Expand Down
126 changes: 126 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.