From 679ffbce742fd08e96b7e2c46011b2605541bdfa Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 6 Feb 2023 11:03:29 +0800 Subject: [PATCH] =?UTF-8?q?hexo=20=E9=BB=98=E8=AE=A4=E5=B0=81=E9=9D=A2?= =?UTF-8?q?=E5=9B=BE=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/LayoutPage.js | 3 +-- themes/hexo/components/BlogPostCard.js | 5 ++++- themes/hexo/components/BlogPostListPage.js | 4 ++-- themes/hexo/components/BlogPostListScroll.js | 4 ++-- themes/hexo/config_hexo.js | 3 ++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/themes/hexo/LayoutPage.js b/themes/hexo/LayoutPage.js index d4ab7079..b0841c1c 100644 --- a/themes/hexo/LayoutPage.js +++ b/themes/hexo/LayoutPage.js @@ -2,8 +2,7 @@ import BlogPostListPage from './components/BlogPostListPage' import LayoutBase from './LayoutBase' export const LayoutPage = (props) => { - const { page, posts, postCount } = props return - + } diff --git a/themes/hexo/components/BlogPostCard.js b/themes/hexo/components/BlogPostCard.js index 819363fa..9688268c 100644 --- a/themes/hexo/components/BlogPostCard.js +++ b/themes/hexo/components/BlogPostCard.js @@ -5,8 +5,11 @@ import TagItemMini from './TagItemMini' import CONFIG_HEXO from '../config_hexo' import NotionPage from '@/components/NotionPage' -const BlogPostCard = ({ post, showSummary, index }) => { +const BlogPostCard = ({ post, showSummary, index, siteInfo }) => { const showPreview = CONFIG_HEXO.POST_LIST_PREVIEW && post.blockMap + if (post && !post.page_cover && CONFIG_HEXO.POST_LIST_COVER_DEFAULT) { + post.page_cover = siteInfo?.pageCover + } const showPageCover = CONFIG_HEXO.POST_LIST_COVER && post?.page_cover return (
{ +const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => { const totalPage = Math.ceil(postCount / BLOG.POSTS_PER_PAGE) const showPagination = postCount >= BLOG.POSTS_PER_PAGE if (!posts || posts.length === 0 || page > totalPage) { @@ -22,7 +22,7 @@ const BlogPostListPage = ({ page = 1, posts = [], postCount }) => { {/* 文章列表 */}
{posts.map(post => ( - + ))}
{showPagination && } diff --git a/themes/hexo/components/BlogPostListScroll.js b/themes/hexo/components/BlogPostListScroll.js index c846b83a..a65eb4ee 100644 --- a/themes/hexo/components/BlogPostListScroll.js +++ b/themes/hexo/components/BlogPostListScroll.js @@ -14,7 +14,7 @@ import { getListByPage } from '@/lib/utils' * @returns {JSX.Element} * @constructor */ -const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG_HEXO.POST_LIST_SUMMARY }) => { +const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG_HEXO.POST_LIST_SUMMARY, siteInfo }) => { const postsPerPage = BLOG.POSTS_PER_PAGE const [page, updatePage] = React.useState(1) const postsToShow = getListByPage(posts, page, postsPerPage) @@ -58,7 +58,7 @@ const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG_HE {/* 文章列表 */}
{postsToShow.map(post => ( - + ))}
diff --git a/themes/hexo/config_hexo.js b/themes/hexo/config_hexo.js index abe30c40..feb6dbd8 100644 --- a/themes/hexo/config_hexo.js +++ b/themes/hexo/config_hexo.js @@ -10,7 +10,8 @@ const CONFIG_HEXO = { MENU_ARCHIVE: true, // 显示归档 MENU_SEARCH: true, // 显示搜索 - POST_LIST_COVER: true, // 文章封面 + POST_LIST_COVER: true, // 列表显示文章封面 + POST_LIST_COVER_DEFAULT: true, // 封面为空时用站点背景做默认封面 POST_LIST_SUMMARY: true, // 文章摘要 POST_LIST_PREVIEW: true, // 读取文章预览