From 0d43186a8ed3d83e6d8a13227afa7a3d197ae684 Mon Sep 17 00:00:00 2001 From: Johnson Mao Date: Mon, 26 Feb 2024 21:59:00 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20add=20button=20component?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/[lang]/(home)/Article.tsx | 2 +- src/app/[lang]/(home)/page.tsx | 11 ++++++-- src/app/[lang]/layout.tsx | 8 +----- src/app/[lang]/posts/InfiniteList.tsx | 14 +++++++--- src/components/Button.tsx | 39 +++++++++++++++++++++++++++ src/components/Link.tsx | 2 +- src/components/ThemeSwitcher.tsx | 21 ++++----------- types/link.d.ts | 4 ++- 8 files changed, 69 insertions(+), 32 deletions(-) create mode 100644 src/components/Button.tsx diff --git a/src/app/[lang]/(home)/Article.tsx b/src/app/[lang]/(home)/Article.tsx index 236f8878..d9cd2889 100644 --- a/src/app/[lang]/(home)/Article.tsx +++ b/src/app/[lang]/(home)/Article.tsx @@ -32,7 +32,7 @@ function Article({ /> )} -
+

{title}

diff --git a/src/app/[lang]/(home)/page.tsx b/src/app/[lang]/(home)/page.tsx index 2959bfaa..d22555b8 100644 --- a/src/app/[lang]/(home)/page.tsx +++ b/src/app/[lang]/(home)/page.tsx @@ -2,7 +2,8 @@ import type { Metadata } from 'next'; import { getDictionary } from '~/data/i18n'; import Container from '@/components/Container'; -import { H1 } from '@/components/Heading'; +import { H1, H2 } from '@/components/Heading'; +import Button from '@/components/Button'; import List from '@/components/List'; import { getAllDataFrontmatter } from '@/utils/mdx'; @@ -22,6 +23,7 @@ export async function generateMetadata({ async function RootPage({ params: { lang } }: RootParams) { const posts = await getAllDataFrontmatter('posts'); const { homePage, common } = await getDictionary(lang); + const nextPostId = posts.at(4)?.id || ''; return ( <> @@ -30,8 +32,13 @@ async function RootPage({ params: { lang } }: RootParams) {

{homePage.description}

-

{common.latestPosts}

+

{common.latestPosts}

+
+ +
); diff --git a/src/app/[lang]/layout.tsx b/src/app/[lang]/layout.tsx index ebe90438..3bbcf986 100644 --- a/src/app/[lang]/layout.tsx +++ b/src/app/[lang]/layout.tsx @@ -5,7 +5,6 @@ import ThemeSwitcher from '@/components/ThemeSwitcher'; import Header, { Avatar } from './Header'; import Footer from './Footer'; import Menu, { MenuProps } from './Menu'; -import cn from '@/utils/cn'; export async function generateStaticParams() { return locales.map((lang) => ({ lang })); @@ -60,12 +59,7 @@ async function I18nLayout({ <>
}> - +
{children}