-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from JohnsonMao/feature/posts-page
✨ add posts page
- Loading branch information
Showing
5 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const common = { | ||
home: 'Home', | ||
posts: 'Posts', | ||
about: 'About', | ||
tags: 'Tags', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const common = { | ||
home: '首頁', | ||
posts: '文章', | ||
about: '關於', | ||
tags: '標籤', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Metadata> { | ||
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 ( | ||
<Container as="main"> | ||
<p className="my-12 text-center text-3xl dark:text-white"> | ||
{metadata.title} | ||
</p> | ||
<List Item={Card} items={posts} /> | ||
</Container> | ||
); | ||
} | ||
|
||
export default RootPage; |