diff --git a/docs/pages/docs/routing.mdx b/docs/pages/docs/routing.mdx index 3fa949854..ca73c0dea 100644 --- a/docs/pages/docs/routing.mdx +++ b/docs/pages/docs/routing.mdx @@ -240,41 +240,6 @@ Localized pathnames map to a single internal pathname that is created via the fi APIs](/docs/routing/navigation). -
-How do I integrate with an external system like a CMS to localize pathnames? - -In case you're using a system like a CMS to configure localized pathnames, you'll typically implement this with a dynamic segment that catches all localized pathnames _instead_ of using the `pathnames` configuration from `next-intl`. - -**Examples:** - -1. All pathnames are handled by your CMS: `[locale]/[[...slug]]/page.tsx` -2. Some pathnames are handled by your CMS: `[locale]/blog/[...slug]/page.tsx` - -```tsx filename="page.tsx" -import {notFound} from 'next'; -import {fetchContent} from './cms'; - -type Props = { - params: { - locale: string; - slug: Array; - }; -}; - -export default async function CatchAllPage({params}: Props) { - const content = await fetchContent(params.locale, params.slug); - if (!content) notFound(); - - // ... -} -``` - -In this case, you'll likely want to disable [alternate links](/docs/routing/middleware#alternate-links) and provide your own implementation instead. - -Furthermore, in case you provide a locale switcher, it might require special care to be able to switch between localized pathnames of the same page. A simplified implementation might always redirect to the home page instead. - -
-
How can I revalidate localized pathnames? @@ -296,11 +261,11 @@ import createMiddleware from 'next-intl/middleware'; export default createMiddleware({ defaultLocale: 'en', - locales: ['en', 'fr'], + locales: ['en', 'de'], pathnames: { '/news/[slug]': { en: '/news/[slug]', - fr: '/infos/[slug]' + de: '/neuigkeiten/[slug]' } } }); @@ -310,10 +275,10 @@ Depending on whether `some-article` was included in [`generateStaticParams`](htt ```tsx // Statically generated at build time -revalidatePath('/fr/news/some-article'); +revalidatePath('/de/news/some-article'); // Dynamically generated at runtime: -revalidatePath('/fr/infos/some-article'); +revalidatePath('/de/neuigkeiten/some-article'); ``` When in doubt, you can revalidate both paths to be on the safe side. @@ -340,6 +305,41 @@ If you localize the values for dynamic segments, you might want to turn off [alt
+
+How do I integrate with an external system like a CMS that provides localized pathnames? + +In case you're using a system like a CMS to configure localized pathnames, you'll typically implement this with a dynamic segment that catches all localized pathnames _instead_ of using the `pathnames` configuration from `next-intl`. + +**Examples:** + +1. All pathnames are handled by your CMS: `[locale]/[[...slug]]/page.tsx` +2. Some pathnames are handled by your CMS: `[locale]/blog/[...slug]/page.tsx` + +```tsx filename="page.tsx" +import {notFound} from 'next'; +import {fetchContent} from './cms'; + +type Props = { + params: { + locale: string; + slug: Array; + }; +}; + +export default async function CatchAllPage({params}: Props) { + const content = await fetchContent(params.locale, params.slug); + if (!content) notFound(); + + // ... +} +``` + +In this case, you'll likely want to disable [alternate links](/docs/routing/middleware#alternate-links) and provide your own implementation instead. + +Furthermore, in case you provide a locale switcher, it might require special care to be able to switch between localized pathnames of the same page. A simplified implementation might always redirect to the home page instead. + +
+ ### Domains If you want to serve your localized content based on different domains, you can provide a list of mappings between domains and locales via the `domains` setting.