From 9069348fd7b710888442b1c415087f6c8d1c81f6 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 1 Jan 2025 15:32:08 +0800 Subject: [PATCH] =?UTF-8?q?card=E7=BB=84=E4=BB=B6=E5=A4=9A=E4=BD=99=20?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E7=A7=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/heo/components/HexoCard.js | 10 ---- themes/heo/components/HexoRecentComments.js | 62 ++++++++++++++------- 2 files changed, 41 insertions(+), 31 deletions(-) delete mode 100644 themes/heo/components/HexoCard.js diff --git a/themes/heo/components/HexoCard.js b/themes/heo/components/HexoCard.js deleted file mode 100644 index 0806dc28..00000000 --- a/themes/heo/components/HexoCard.js +++ /dev/null @@ -1,10 +0,0 @@ -const Card = ({ children, headerSlot, className }) => { - return
- <>{headerSlot} -
- {children} -
-
-} -export default Card - diff --git a/themes/heo/components/HexoRecentComments.js b/themes/heo/components/HexoRecentComments.js index 661654dc..354e2182 100644 --- a/themes/heo/components/HexoRecentComments.js +++ b/themes/heo/components/HexoRecentComments.js @@ -1,16 +1,15 @@ -import Card from '@./HexoCard' -import { useGlobal } from '@/lib/global' -import Link from 'next/link' -import { RecentComments } from '@waline/client' -import { useEffect, useState } from 'react' import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' +import { RecentComments } from '@waline/client' +import Link from 'next/link' +import { useEffect, useState } from 'react' /** * @see https://waline.js.org/guide/get-started.html * @param {*} props * @returns */ -const HexoRecentComments = (props) => { +const HexoRecentComments = props => { const [comments, updateComments] = useState([]) const { locale } = useGlobal() const [onLoading, changeLoading] = useState(true) @@ -25,22 +24,43 @@ const HexoRecentComments = (props) => { }, []) return ( - -
- - {locale.COMMON.RECENT_COMMENTS} +
+
+ + {locale.COMMON.RECENT_COMMENTS} +
+ + {onLoading && ( +
+ Loading... + +
+ )} + {!onLoading && comments && comments.length === 0 && ( +
No Comments
+ )} + {!onLoading && + comments && + comments.length > 0 && + comments.map(comment => ( +
+
+
+ + --{comment.nick} +
- - {onLoading &&
Loading...
} - {!onLoading && comments && comments.length === 0 &&
No Comments
} - {!onLoading && comments && comments.length > 0 && comments.map((comment) =>
-
-
- --{comment.nick} -
-
)} - - +
+ ))} +
) }