Skip to content

Commit

Permalink
✨ feat: Add fallback language, modify React suspense settings, enable…
Browse files Browse the repository at this point in the history
… strict mode, and update dependencies

The changes include modifying the configuration file, package.json file, and several page files. The fallback language is added, React suspense is disabled, strict mode is enabled, and dependencies are updated. The getStaticProps function in index.page.tsx is replaced with getServerSideProps.
  • Loading branch information
canisminor1990 committed Jul 16, 2023
1 parent 853f18a commit 8ecd401
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
7 changes: 7 additions & 0 deletions next-i18next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ const i18n = require('./.i18nrc');
/** @type {import('next-i18next').UserConfig} */
module.exports = {
debug: process.env.NODE_ENV === 'development',
fallbackLng: {
default: ['en'],
zh_TW: ['zh_CN'],
},
i18n: {
defaultLocale: i18n.entryLocale,
locales: [i18n.entryLocale, ...i18n.outputLocales],
},
react: { useSuspense: false },
reloadOnPrerender: process.env.NODE_ENV === 'development',
strictMode: true,
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@ant-design/colors": "^7",
"@ant-design/icons": "^5",
"@commitlint/cli": "^17",
"@lobehub/ui": "^1",
"@lobehub/ui": "lastest",
"@vercel/analytics": "^1",
"ahooks": "^3",
"antd": "^5",
Expand Down
11 changes: 11 additions & 0 deletions src/pages/chat/[id].page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import isEqual from 'fast-deep-equal';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import Head from 'next/head';
import { useRouter } from 'next/router';
import { memo, useEffect } from 'react';
Expand Down Expand Up @@ -56,4 +57,14 @@ const ChatLayout = () => {
);
};

export async function getServerSideProps(context: any) {
const { locale } = context;
return {
props: {
// pass the translation props to the page component
...(await serverSideTranslations(locale)),
},
};
}

export default memo(ChatLayout);
2 changes: 1 addition & 1 deletion src/pages/chat/index.page.tsx
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from './[id].page';
export { default, getServerSideProps } from './[id].page';
14 changes: 1 addition & 13 deletions src/pages/index.page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';

export { default } from './chat/index.page';

export async function getStaticProps(context: any) {
const { locale } = context;
return {
props: {
// pass the translation props to the page component
...(await serverSideTranslations(locale)),
},
};
}
export { default, getServerSideProps } from './chat/index.page';

0 comments on commit 8ecd401

Please sign in to comment.