From 45009c94c7273fc6661277f28b362ffad7f1c9de Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Fri, 17 May 2024 18:17:16 +0800 Subject: [PATCH] theme-hexo seo --- themes/hexo/components/BlogPostCard.js | 76 +++++++++++++--------- themes/hexo/components/Hero.js | 1 + themes/hexo/components/LatestPostsGroup.js | 1 + themes/hexo/components/PaginationNumber.js | 68 ++++++++++--------- 4 files changed, 81 insertions(+), 65 deletions(-) diff --git a/themes/hexo/components/BlogPostCard.js b/themes/hexo/components/BlogPostCard.js index 10a47726ac5..bcaf44d682f 100644 --- a/themes/hexo/components/BlogPostCard.js +++ b/themes/hexo/components/BlogPostCard.js @@ -5,42 +5,58 @@ import CONFIG from '../config' import { BlogPostCardInfo } from './BlogPostCardInfo' const BlogPostCard = ({ index, post, showSummary, siteInfo }) => { - const showPreview = siteConfig('HEXO_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap - if (post && !post.pageCoverThumbnail && siteConfig('HEXO_POST_LIST_COVER_DEFAULT', null, CONFIG)) { + const showPreview = + siteConfig('HEXO_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap + if ( + post && + !post.pageCoverThumbnail && + siteConfig('HEXO_POST_LIST_COVER_DEFAULT', null, CONFIG) + ) { post.pageCoverThumbnail = siteInfo?.pageCover } - const showPageCover = siteConfig('HEXO_POST_LIST_COVER', null, CONFIG) && post?.pageCoverThumbnail && !showPreview + const showPageCover = + siteConfig('HEXO_POST_LIST_COVER', null, CONFIG) && + post?.pageCoverThumbnail && + !showPreview // const delay = (index % 2) * 200 return ( - -
-
+
- - {/* 文字内容 */} - - - {/* 图片封面 */} - {showPageCover && ( -
- - - -
- )} - -
- -
- + {/* 文字内容 */} + + + {/* 图片封面 */} + {showPageCover && ( +
+ + + +
+ )} +
+ ) } diff --git a/themes/hexo/components/Hero.js b/themes/hexo/components/Hero.js index 91059205ea7..7e1cdc9d645 100644 --- a/themes/hexo/components/Hero.js +++ b/themes/hexo/components/Hero.js @@ -92,6 +92,7 @@ const Hero = props => { diff --git a/themes/hexo/components/LatestPostsGroup.js b/themes/hexo/components/LatestPostsGroup.js index 6254def8f57..5a0a0161b7f 100644 --- a/themes/hexo/components/LatestPostsGroup.js +++ b/themes/hexo/components/LatestPostsGroup.js @@ -42,6 +42,7 @@ const LatestPostsGroup = ({ latestPosts, siteInfo }) => { className={'my-3 flex'}>
diff --git a/themes/hexo/components/PaginationNumber.js b/themes/hexo/components/PaginationNumber.js index 42281b93542..2cbbb69c998 100644 --- a/themes/hexo/components/PaginationNumber.js +++ b/themes/hexo/components/PaginationNumber.js @@ -12,60 +12,58 @@ const PaginationNumber = ({ page, totalPage }) => { const router = useRouter() const currentPage = +page const showNext = page < totalPage - const pagePrefix = router.asPath.split('?')[0].replace(/\/page\/[1-9]\d*/, '').replace(/\/$/, '') + const pagePrefix = router.asPath + .split('?')[0] + .replace(/\/page\/[1-9]\d*/, '') + .replace(/\/$/, '') const pages = generatePages(pagePrefix, page, currentPage, totalPage) return ( -
- {/* 上一页 */} - + {/* 上一页 */} + + query: router.query.s ? { s: router.query.s } : {} + }} + rel='prev' + className={`${currentPage === 1 ? 'invisible' : 'block'} pb-0.5 border-white dark:border-indigo-700 hover:border-indigo-400 dark:hover:border-indigo-400 w-6 text-center cursor-pointer duration-200 hover:font-bold`}> + + - + {pages} - - - {pages} - - {/* 下一页 */} - - - - - + {/* 下一页 */} + + +
) } function getPageElement(page, currentPage, pagePrefix) { return ( - ( - {page} - - ) + ) }