From e32ca96bdbd3fe4d321fd2aa6989bf9632ed607e Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Fri, 13 Sep 2024 19:17:22 +0800 Subject: [PATCH] =?UTF-8?q?Magzine=20=E6=A0=B7=E5=BC=8F=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/magzine/components/ArticleInfo.js | 2 +- themes/magzine/components/Header.js | 4 +- themes/magzine/components/PostGroupLates.js | 66 ----------------- themes/magzine/components/PostGroupLatest.js | 71 +++++++++++++++++++ .../components/PostListSimpleHorizontal.js | 2 +- themes/magzine/index.js | 8 +-- 6 files changed, 79 insertions(+), 74 deletions(-) delete mode 100644 themes/magzine/components/PostGroupLates.js create mode 100644 themes/magzine/components/PostGroupLatest.js diff --git a/themes/magzine/components/ArticleInfo.js b/themes/magzine/components/ArticleInfo.js index 5bedfbeca8..f41654b0a3 100644 --- a/themes/magzine/components/ArticleInfo.js +++ b/themes/magzine/components/ArticleInfo.js @@ -14,7 +14,7 @@ export default function ArticleInfo(props) { return ( <> -
+
{siteConfig('MAGZINE_POST_LIST_CATEGORY') && ( diff --git a/themes/magzine/components/Header.js b/themes/magzine/components/Header.js index 73a3627bb3..a7c4afdebd 100644 --- a/themes/magzine/components/Header.js +++ b/themes/magzine/components/Header.js @@ -144,8 +144,8 @@ export default function Header(props) { {/* 桌面端顶部菜单 */}
{links && - links?.map(link => ( - + links?.map((link, index) => ( + ))}
diff --git a/themes/magzine/components/PostGroupLates.js b/themes/magzine/components/PostGroupLates.js deleted file mode 100644 index 397de79584..0000000000 --- a/themes/magzine/components/PostGroupLates.js +++ /dev/null @@ -1,66 +0,0 @@ -import LazyImage from '@/components/LazyImage' -import { siteConfig } from '@/lib/config' -import { useGlobal } from '@/lib/global' -// import Image from 'next/image' -import Link from 'next/link' -import { useRouter } from 'next/router' - -/** - * 最新文章列表 - * @param posts 所有文章数据 - * @param sliceCount 截取展示的数量 默认6 - * @constructor - */ -const PostGroupLatest = props => { - const { latestPosts } = props - // 获取当前路径 - const currentPath = useRouter().asPath - const { locale, siteInfo } = useGlobal() - if (!latestPosts) { - return <> - } - - return ( - <> -
-
{locale.COMMON.LATEST_POSTS}
-
- {latestPosts.map(post => { - const selected = - currentPath === `${siteConfig('SUB_PATH', '')}/${post.slug}` - - const headerImage = post?.pageCoverThumbnail - ? post.pageCoverThumbnail - : siteInfo?.pageCover - - return ( - -
- -
-
-
-
{post.title}
-
{post.lastEditedDay}
-
-
- - ) - })} - - ) -} -export default PostGroupLatest diff --git a/themes/magzine/components/PostGroupLatest.js b/themes/magzine/components/PostGroupLatest.js new file mode 100644 index 0000000000..8731e7d631 --- /dev/null +++ b/themes/magzine/components/PostGroupLatest.js @@ -0,0 +1,71 @@ +import LazyImage from '@/components/LazyImage' +import { siteConfig } from '@/lib/config' +import { useGlobal } from '@/lib/global' +// import Image from 'next/image' +import Link from 'next/link' +import { useRouter } from 'next/router' + +/** + * 最新文章列表 + * @param posts 所有文章数据 + * @param sliceCount 截取展示的数量 默认6 + * @constructor + */ +const PostGroupLatest = props => { + const { latestPosts } = props + // 获取当前路径 + const currentPath = useRouter().asPath + const { locale, siteInfo } = useGlobal() + if (!latestPosts) { + return <> + } + + return ( + <> + {/* 标题 */} +
+
{locale.COMMON.LATEST_POSTS}
+
+ + {/* 文章列表 */} +
+ {latestPosts.map(post => { + const selected = + currentPath === `${siteConfig('SUB_PATH', '')}/${post.slug}` + + const headerImage = post?.pageCoverThumbnail + ? post.pageCoverThumbnail + : siteInfo?.pageCover + + return ( + +
+ +
+
+
+
{post.title}
+
{post.lastEditedDay}
+
+
+ + ) + })} +
+ + ) +} +export default PostGroupLatest diff --git a/themes/magzine/components/PostListSimpleHorizontal.js b/themes/magzine/components/PostListSimpleHorizontal.js index e611f4b7a4..af1ece3a17 100644 --- a/themes/magzine/components/PostListSimpleHorizontal.js +++ b/themes/magzine/components/PostListSimpleHorizontal.js @@ -24,7 +24,7 @@ const PostSimpleListHorizontal = ({ title, href, posts }) => {
{/* 列表 */} -