mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
♻️ refactor: Simplify index page component and remove internationalization configuration
- Remove debugging and fallback language settings from `next-i18next.config.js` - Conditionally set `localePath` based on the environment - Simplify `index.page.tsx` by removing unused imports and consolidating code - Update `getStaticProps` to pass translation props to the page component These changes were made to improve code readability and remove unnecessary configuration settings related to internationalization.
This commit is contained in:
@@ -2,14 +2,8 @@ const i18n = require('./.i18nrc');
|
||||
|
||||
/** @type {import('next-i18next').UserConfig} */
|
||||
module.exports = {
|
||||
debug: false,
|
||||
fallbackLng: {
|
||||
default: ['zh_CN'],
|
||||
},
|
||||
i18n: {
|
||||
defaultLocale: i18n.entryLocale,
|
||||
locales: [i18n.entryLocale, ...i18n.outputLocales],
|
||||
},
|
||||
localePath:
|
||||
typeof window === 'undefined' ? require('node:path').resolve('./public/locales') : '/locales',
|
||||
};
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
import type { GetStaticProps, InferGetStaticPropsType } from 'next';
|
||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
||||
import { memo } from 'react';
|
||||
|
||||
import Chat from './chat/index.page';
|
||||
export { default } from './chat/index.page';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const Index = (_props: InferGetStaticPropsType<typeof getStaticProps>) => {
|
||||
return <Chat />;
|
||||
};
|
||||
|
||||
export const getStaticProps: GetStaticProps = async ({ locale }) => ({
|
||||
props: {
|
||||
...(await serverSideTranslations(locale ?? 'zh_CN', ['common'])),
|
||||
},
|
||||
});
|
||||
|
||||
export default memo(Index);
|
||||
export async function getStaticProps(context: any) {
|
||||
const { locale } = context;
|
||||
return {
|
||||
props: {
|
||||
// pass the translation props to the page component
|
||||
...(await serverSideTranslations(locale)),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user