diff --git a/i18n/locales/en/common.ts b/i18n/locales/en/common.ts index 4ba7121d..532deca2 100644 --- a/i18n/locales/en/common.ts +++ b/i18n/locales/en/common.ts @@ -1,4 +1,5 @@ const common = { + home: 'Home', posts: 'Posts', about: 'About', tags: 'Tags', diff --git a/i18n/locales/zh-TW/common.ts b/i18n/locales/zh-TW/common.ts index 5a329a04..0554f8f8 100644 --- a/i18n/locales/zh-TW/common.ts +++ b/i18n/locales/zh-TW/common.ts @@ -1,4 +1,5 @@ const common = { + home: '首頁', posts: '文章', about: '關於', tags: '標籤', diff --git a/src/app/[lang]/layout.tsx b/src/app/[lang]/layout.tsx index 0d756525..c002735d 100644 --- a/src/app/[lang]/layout.tsx +++ b/src/app/[lang]/layout.tsx @@ -44,9 +44,13 @@ async function I18nLayout({ }; const menu: HeaderProps['menu'] = [ { - text: common.posts, + text: common.home, href: '/', }, + { + text: common.posts, + href: '/posts', + }, ]; return ( diff --git a/src/app/[lang]/page.tsx b/src/app/[lang]/page.tsx index 86e423be..f6c48fad 100644 --- a/src/app/[lang]/page.tsx +++ b/src/app/[lang]/page.tsx @@ -1,5 +1,4 @@ import type { Metadata } from 'next'; -import { notFound } from 'next/navigation'; import { getDictionary } from '~/i18n'; import Card from '@/components/Card'; @@ -11,8 +10,6 @@ import type { RootParams } from './layout'; export async function generateMetadata({ params: { lang }, }: RootParams): Promise { - if (!lang) notFound(); - const { common } = await getDictionary(lang); return { @@ -21,8 +18,6 @@ export async function generateMetadata({ } async function RootPage({ params: { lang } }: RootParams) { - if (!lang) notFound(); - const posts = await getAllDataFrontmatter('posts'); const { metadata } = await getDictionary(lang); diff --git a/src/app/[lang]/posts/page.tsx b/src/app/[lang]/posts/page.tsx new file mode 100644 index 00000000..a8ecceee --- /dev/null +++ b/src/app/[lang]/posts/page.tsx @@ -0,0 +1,34 @@ +import type { Metadata } from 'next'; + +import { getDictionary } from '~/i18n'; +import Card from '@/components/Card'; +import Container from '@/components/Container'; +import List from '@/components/List'; +import { getAllDataFrontmatter } from '@/utils/mdx'; +import type { RootParams } from '../layout'; + +export async function generateMetadata({ + params: { lang }, +}: RootParams): Promise { + const { common } = await getDictionary(lang); + + return { + title: common.posts, + }; +} + +async function RootPage({ params: { lang } }: RootParams) { + const posts = await getAllDataFrontmatter('posts'); + const { metadata } = await getDictionary(lang); + + return ( + +

+ {metadata.title} +

+ +
+ ); +} + +export default RootPage;