Skip to content

Commit

Permalink
theme-hexo seo
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed May 17, 2024
1 parent 89d3858 commit 45009c9
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 65 deletions.
76 changes: 46 additions & 30 deletions themes/hexo/components/BlogPostCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (

<div className={`${siteConfig('HEXO_POST_LIST_COVER_HOVER_ENLARGE', null, CONFIG) ? ' hover:scale-110 transition-all duration-150' : ''}`} >
<div key={post.id}
data-aos="fade-up"
data-aos-easing="ease-in-out"
data-aos-duration="800"
data-aos-once="false"
data-aos-anchor-placement="top-bottom"
id='blog-post-card'
className={`group md:h-56 w-full flex justify-between md:flex-row flex-col-reverse ${siteConfig('HEXO_POST_LIST_IMG_CROSSOVER', null, CONFIG) && index % 2 === 1 ? 'md:flex-row-reverse' : ''}
<div
className={`${siteConfig('HEXO_POST_LIST_COVER_HOVER_ENLARGE', null, CONFIG) ? ' hover:scale-110 transition-all duration-150' : ''}`}>
<div
key={post.id}
data-aos='fade-up'
data-aos-easing='ease-in-out'
data-aos-duration='800'
data-aos-once='false'
data-aos-anchor-placement='top-bottom'
id='blog-post-card'
className={`group md:h-56 w-full flex justify-between md:flex-row flex-col-reverse ${siteConfig('HEXO_POST_LIST_IMG_CROSSOVER', null, CONFIG) && index % 2 === 1 ? 'md:flex-row-reverse' : ''}
overflow-hidden border dark:border-black rounded-xl bg-white dark:bg-hexo-black-gray`}>

{/* 文字内容 */}
<BlogPostCardInfo index={index} post={post} showPageCover={showPageCover} showPreview={showPreview} showSummary={showSummary} />

{/* 图片封面 */}
{showPageCover && (
<div className="md:w-5/12 overflow-hidden">
<Link href={post?.href} passHref legacyBehavior>
<LazyImage priority={index === 1} src={post?.pageCoverThumbnail} className='h-56 w-full object-cover object-center group-hover:scale-110 duration-500' />
</Link>
</div>
)}

</div>

</div>

{/* 文字内容 */}
<BlogPostCardInfo
index={index}
post={post}
showPageCover={showPageCover}
showPreview={showPreview}
showSummary={showSummary}
/>

{/* 图片封面 */}
{showPageCover && (
<div className='md:w-5/12 overflow-hidden'>
<Link href={post?.href} passHref legacyBehavior>
<LazyImage
priority={index === 1}
alt={post?.title}
src={post?.pageCoverThumbnail}
className='h-56 w-full object-cover object-center group-hover:scale-110 duration-500'
/>
</Link>
</div>
)}
</div>
</div>
)
}

Expand Down
1 change: 1 addition & 0 deletions themes/hexo/components/Hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const Hero = props => {

<LazyImage
id='header-cover'
alt={siteInfo?.title}
src={siteInfo?.pageCover}
className={`header-cover w-full h-screen object-cover object-center ${siteConfig('HEXO_HOME_NAV_BACKGROUND_IMG_FIXED', null, CONFIG) ? 'fixed' : ''}`}
/>
Expand Down
1 change: 1 addition & 0 deletions themes/hexo/components/LatestPostsGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const LatestPostsGroup = ({ latestPosts, siteInfo }) => {
className={'my-3 flex'}>
<div className='w-20 h-14 overflow-hidden relative'>
<LazyImage
alt={post?.title}
src={`${headerImage}`}
className='object-cover w-full h-full'
/>
Expand Down
68 changes: 33 additions & 35 deletions themes/hexo/components/PaginationNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="mt-10 mb-5 flex justify-center items-end font-medium text-black duration-500 dark:text-gray-300 py-3 space-x-2">
{/* 上一页 */}
<Link
href={{
pathname: currentPage === 2
<div className='mt-10 mb-5 flex justify-center items-end font-medium text-black duration-500 dark:text-gray-300 py-3 space-x-2'>
{/* 上一页 */}
<Link
href={{
pathname:
currentPage === 2
? `${pagePrefix}/`
: `${pagePrefix}/page/${currentPage - 1}`,
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`}>
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`}>
<i className='fas fa-angle-left' />
</Link>

<i className="fas fa-angle-left" />
{pages}

</Link>

{pages}

{/* 下一页 */}
<Link
href={{
pathname: `${pagePrefix}/page/${currentPage + 1}`,
query: router.query.s ? { s: router.query.s } : {}
}}
rel="next"
className={`${+showNext ? 'block' : 'invisible'} pb-0.5 border-b border-indigo-300 dark:border-indigo-700 hover:border-indigo-400 dark:hover:border-indigo-400 w-6 text-center cursor-pointer duration-500 hover:font-bold`}>

<i className="fas fa-angle-right" />

</Link>
{/* 下一页 */}
<Link
href={{
pathname: `${pagePrefix}/page/${currentPage + 1}`,
query: router.query.s ? { s: router.query.s } : {}
}}
rel='next'
className={`${+showNext ? 'block' : 'invisible'} pb-0.5 border-b border-indigo-300 dark:border-indigo-700 hover:border-indigo-400 dark:hover:border-indigo-400 w-6 text-center cursor-pointer duration-500 hover:font-bold`}>
<i className='fas fa-angle-right' />
</Link>
</div>
)
}

function getPageElement(page, currentPage, pagePrefix) {
return (
(<Link
<Link
href={page === 1 ? `${pagePrefix}/` : `${pagePrefix}/page/${page}`}
key={page}
passHref
className={
(page + '' === currentPage + ''
? 'font-bold bg-indigo-400 dark:bg-indigo-500 text-white '
: 'border-b duration-500 border-indigo-300 hover:border-indigo-400 ') +
' border-white dark:border-indigo-700 dark:hover:border-indigo-400 cursor-pointer pb-0.5 w-6 text-center font-light hover:font-bold'
(page + '' === currentPage + ''
? 'font-bold bg-indigo-400 dark:bg-indigo-500 text-white '
: 'border-b duration-500 border-indigo-300 hover:border-indigo-400 ') +
' border-white dark:border-indigo-700 dark:hover:border-indigo-400 cursor-pointer pb-0.5 w-6 text-center font-light hover:font-bold'
}>

{page}

</Link>)
</Link>
)
}

Expand Down

0 comments on commit 45009c9

Please sign in to comment.