From b4536650174ed11ce82b7e519e4573e770f36291 Mon Sep 17 00:00:00 2001 From: mereith Date: Sat, 25 Feb 2023 11:58:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=20nextjs=2013=20?= =?UTF-8?q?=E5=90=8E=E6=8C=89=E7=85=A7=E6=96=B0=E8=A7=84=E8=8C=83=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20Link=20=E6=A0=87=E7=AD=BE=E7=9A=84=E4=BD=BF?= =?UTF-8?q?=E7=94=A8"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../website/components/ArticleList/index.tsx | 13 +++------- .../website/components/AuthorCard/index.tsx | 17 ++++++------ packages/website/components/Link/index.tsx | 13 ---------- packages/website/components/NavBar/index.tsx | 2 +- packages/website/components/NavBar/item.tsx | 2 +- .../website/components/NavBarMobile/index.tsx | 4 +-- .../website/components/PageNav/render.tsx | 23 ++++++++-------- .../website/components/PostCard/bottom.tsx | 26 +++++++------------ .../website/components/PostCard/index.tsx | 10 +++---- .../website/components/PostCard/title.tsx | 23 +++++++--------- packages/website/pages/404.tsx | 4 +-- packages/website/pages/tag.tsx | 15 +++++------ 12 files changed, 59 insertions(+), 93 deletions(-) delete mode 100644 packages/website/components/Link/index.tsx diff --git a/packages/website/components/ArticleList/index.tsx b/packages/website/components/ArticleList/index.tsx index 990c1fe07..2d65cb796 100644 --- a/packages/website/components/ArticleList/index.tsx +++ b/packages/website/components/ArticleList/index.tsx @@ -1,6 +1,6 @@ import { Article } from "../../types/article"; import dayjs from "dayjs"; -import Link from "../Link"; +import Link from "next/link"; import { getTarget } from "../Link/tools"; export default function (props: { articles: Article[]; @@ -15,14 +15,9 @@ export default function (props: { - +
{props.showYear ? dayjs(article.createdAt).format("YYYY-MM-DD") @@ -31,7 +26,7 @@ export default function (props: {
{article.title}
-
+
); })} diff --git a/packages/website/components/AuthorCard/index.tsx b/packages/website/components/AuthorCard/index.tsx index 75f517e85..9a1925221 100644 --- a/packages/website/components/AuthorCard/index.tsx +++ b/packages/website/components/AuthorCard/index.tsx @@ -37,9 +37,8 @@ export default function (props: { option: AuthorCardProps }) { if (el) { const headroom = new Headroom(el, { classes: { - initial: `side-bar${ - props.option.showSubMenu == "true" ? "" : " no-submenu" - }`, + initial: `side-bar${props.option.showSubMenu == "true" ? "" : " no-submenu" + }`, pinned: "side-bar-pinned", unpinned: "side-bar-unpinned", top: "side-bar-top", @@ -69,34 +68,34 @@ export default function (props: { option: AuthorCardProps }) {
- +
{props.option.postNum}
日志
-
+
- +
{props.option.catelogNum}
分类
-
+
- +
{props.option.tagNum}
标签
-
+
diff --git a/packages/website/components/Link/index.tsx b/packages/website/components/Link/index.tsx deleted file mode 100644 index 8d3dee581..000000000 --- a/packages/website/components/Link/index.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import Link from "next/link"; - -export default function (props: { - children: any; - href: string; - newTab?: boolean; -}) { - if (props.newTab) { - return props.children; - } else { - return {props.children}; - } -} diff --git a/packages/website/components/NavBar/index.tsx b/packages/website/components/NavBar/index.tsx index 7523d57b9..e2c0a62c7 100644 --- a/packages/website/components/NavBar/index.tsx +++ b/packages/website/components/NavBar/index.tsx @@ -183,7 +183,7 @@ export default function (props: { className="flex items-center h-full md:px-2 hover:text-gray-900 dark:hover:text-dark-hover transform hover:scale-110 cursor-pointer transition-all" > - {catelog} +
{catelog}
); diff --git a/packages/website/components/NavBar/item.tsx b/packages/website/components/NavBar/item.tsx index 7e8fc135b..4a267d8f1 100644 --- a/packages/website/components/NavBar/item.tsx +++ b/packages/website/components/NavBar/item.tsx @@ -40,7 +40,7 @@ function LinkItemAtom(props: { className={props.cls ? props.cls : cls} > - {item.name} +
{item.name}
); diff --git a/packages/website/components/NavBarMobile/index.tsx b/packages/website/components/NavBarMobile/index.tsx index 3bc3f964a..9a2c05a3f 100644 --- a/packages/website/components/NavBarMobile/index.tsx +++ b/packages/website/components/NavBarMobile/index.tsx @@ -32,9 +32,9 @@ export default function (props: { key={item.id} > - +
{item.name} - +
); diff --git a/packages/website/components/PageNav/render.tsx b/packages/website/components/PageNav/render.tsx index aa8edea5f..aedc4e83a 100644 --- a/packages/website/components/PageNav/render.tsx +++ b/packages/website/components/PageNav/render.tsx @@ -17,16 +17,15 @@ const renderLink = (item: PageItem, isCur: boolean) => { href={item.href} key={`LinkItem-${item.page}-${item.type}-${item.href}`} > - {item.page} - + ); }; @@ -35,14 +34,14 @@ const renderBtn = (item: PageItem, disable: boolean, isNext: boolean) => { - {isNext ? "›" : "‹"} - + ); }; @@ -52,9 +51,9 @@ const renderMore = (item: PageItem, isNext: boolean) => { href={item.href} key={`pagenav-more-${item.page}-${item.href}-${isNext}`} > - +
••• - +
); }; diff --git a/packages/website/components/PostCard/bottom.tsx b/packages/website/components/PostCard/bottom.tsx index c083f5eef..bedb47797 100644 --- a/packages/website/components/PostCard/bottom.tsx +++ b/packages/website/components/PostCard/bottom.tsx @@ -1,4 +1,4 @@ -import Link from "../Link"; +import Link from "next/link"; import { useMemo } from "react"; import { encodeQuerystring } from "../../utils/encode"; import { getTarget } from "../Link/tools"; @@ -25,13 +25,11 @@ export function PostBottom(props: {
- {`${tag}`} + >{`${tag}`}
))} @@ -43,14 +41,12 @@ export function PostBottom(props: { {props.pre?.id && ( - {`< ${props.pre?.title}`} + >{`< ${props.pre?.title}`} )} @@ -58,14 +54,12 @@ export function PostBottom(props: { {props.next?.id && ( - {`${props.next?.title} >`} + >{`${props.next?.title} >`} )} diff --git a/packages/website/components/PostCard/index.tsx b/packages/website/components/PostCard/index.tsx index 9b89a2f30..482c9c40e 100644 --- a/packages/website/components/PostCard/index.tsx +++ b/packages/website/components/PostCard/index.tsx @@ -1,4 +1,4 @@ -import Link from "../Link"; +import Link from "next/link"; import { useMemo, useState } from "react"; import AlertCard from "../AlertCard"; import CopyRight from "../CopyRight"; @@ -132,15 +132,13 @@ export default function (props: {
- 阅读全文 - +
)} diff --git a/packages/website/components/PostCard/title.tsx b/packages/website/components/PostCard/title.tsx index 1a888b1b8..535f0da38 100644 --- a/packages/website/components/PostCard/title.tsx +++ b/packages/website/components/PostCard/title.tsx @@ -1,5 +1,5 @@ import dayjs from "dayjs"; -import Link from "../Link"; +import Link from "next/link"; import { useMemo } from "react"; import { encodeQuerystring } from "../../utils/encode"; import PostViewer from "../PostViewer"; @@ -20,16 +20,13 @@ export function Title(props: { return (
{props.type != "about" ? ( - - +
{props.title} - +
) : (
- {`${props.catelog}`} + >{`${props.catelog}`}
)} diff --git a/packages/website/pages/404.tsx b/packages/website/pages/404.tsx index 15e288b7d..e8ee3f9f9 100644 --- a/packages/website/pages/404.tsx +++ b/packages/website/pages/404.tsx @@ -22,9 +22,9 @@ export default function (props: { name?: string }) { {`此${props?.name ? props.name : "页面"}不存在`}
- +
返回主页 - +
diff --git a/packages/website/pages/tag.tsx b/packages/website/pages/tag.tsx index ad052256e..fdc0dbfa0 100644 --- a/packages/website/pages/tag.tsx +++ b/packages/website/pages/tag.tsx @@ -1,4 +1,4 @@ -import Link from "../components/Link"; +import Link from "next/link"; import AuthorCard, { AuthorCardProps } from "../components/AuthorCard"; import Layout from "../components/Layout"; import { encodeQuerystring } from "../utils/encode"; @@ -28,15 +28,14 @@ const TagPage = (props: TagPageProps) => { - {`${tag}`} + >{`${tag}`} ))}