feat: add next-intl, supports en/zh/de languages

This commit is contained in:
javayhu 2025-03-02 01:33:56 +08:00
parent a4e7a59e17
commit 72005865f3
19 changed files with 24 additions and 24 deletions

View File

@ -4,15 +4,17 @@ import { withContentCollections } from "@content-collections/next";
/**
* https://next-intl.dev/docs/getting-started/app-router/with-i18n-routing#next-config
*
* Explicitly specify the path to the request config file
*/
const withNextIntl = createNextIntlPlugin();
module.exports = {
experimental: {
// https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout
missingSuspenseWithCSRBailout: false,
},
}
// module.exports = {
// experimental: {
// // https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout
// missingSuspenseWithCSRBailout: false,
// },
// }
/**
* https://nextjs.org/docs/app/api-reference/config/next-config-js

View File

@ -32,8 +32,6 @@ export default async function HomePage(props: HomePageProps) {
return (
<>
{/* <PromotekitScript /> */}
<div className="mt-12 flex flex-col gap-16">
<div className="text-center">

View File

@ -21,18 +21,18 @@ interface LocaleLayoutProps {
params: Promise<{ locale: string }>;
};
export function generateStaticParams() {
return routing.locales.map((locale) => ({ locale }));
}
// export function generateStaticParams() {
// return routing.locales.map((locale) => ({ locale }));
// }
export async function generateMetadata(props: Omit<LocaleLayoutProps, 'children'>) {
const { locale } = await props.params;
const t = await getTranslations({ locale, namespace: 'LocaleLayout' });
// export async function generateMetadata(props: Omit<LocaleLayoutProps, 'children'>) {
// const { locale } = await props.params;
// const t = await getTranslations({ locale, namespace: 'LocaleLayout' });
return {
title: t('title')
};
}
// return {
// title: t('title')
// };
// }
export default async function LocaleLayout({ children, params }: LocaleLayoutProps) {
const { locale } = await params;

View File

@ -67,11 +67,11 @@ export async function generateMetadata(
};
}
export async function generateStaticParams() {
return allPosts.map((post) => ({
slug: post.slugAsParams.split('/')
}));
}
// export async function generateStaticParams() {
// return allPosts.map((post) => ({
// slug: post.slugAsParams.split('/')
// }));
// }
export default async function BlogPostPage(props: NextPageProps) {
const post = await getBlogPostFromParams(props);

View File

@ -10,7 +10,7 @@ export const config = {
// Set a cookie to remember the previous locale for
// all requests that have a locale prefix
'/(de|en)/:path*',
'/(zh|de|en)/:path*',
// Enable redirects that add missing locales
// (e.g. `/pathnames` -> `/en/pathnames`)