Hexo: 背景图

This commit is contained in:
tangly1024
2022-03-31 11:30:19 +08:00
parent 6bfe030ead
commit 418dc38de6
4 changed files with 7 additions and 8 deletions

View File

@@ -8,7 +8,7 @@ import { useGlobal } from '@/lib/global'
* @param {prev,next} param0
* @returns
*/
export default function ArticleRecommend ({ recommendPosts }) {
export default function ArticleRecommend ({ recommendPosts, siteInfo }) {
if (!CONFIG_HEXO.ARTICLE_RECOMMEND || !recommendPosts || recommendPosts.length === 0) {
return <></>
}
@@ -25,7 +25,7 @@ export default function ArticleRecommend ({ recommendPosts }) {
{recommendPosts.map(post => {
const headerImage = post?.page_cover
? `url("${post.page_cover}")`
: `url("/${BLOG.HOME_BANNER_IMAGE}")`
: `url("${siteInfo?.pageCover}")`
return (
<Link key={post.id} title={post.title} href={`${BLOG.PATH}/article/${post.slug}`} passHref>

View File

@@ -2,10 +2,9 @@ import Link from 'next/link'
import { useGlobal } from '@/lib/global'
import formatDate from '@/lib/formatDate'
import { useEffect } from 'react'
import BLOG from '@/blog.config'
export default function HeaderArticle ({ post }) {
const headerImage = post?.page_cover ? `url("${post.page_cover}")` : `url("/${BLOG.HOME_BANNER_IMAGE}")`
export default function HeaderArticle ({ post, siteInfo }) {
const headerImage = post?.page_cover ? `url("${post.page_cover}")` : `url("${siteInfo?.pageCover}")`
const { isDarkMode } = useGlobal()
const { locale } = useGlobal()

View File

@@ -9,7 +9,7 @@ import { useRouter } from 'next/router'
* @param sliceCount 截取展示的数量 默认6
* @constructor
*/
const LatestPostsGroup = ({ posts }) => {
const LatestPostsGroup = ({ posts, siteInfo }) => {
if (!posts) {
return <></>
}
@@ -29,7 +29,7 @@ const LatestPostsGroup = ({ posts }) => {
const selected = currentPath === `${BLOG.PATH}/article/${post.slug}`
const headerImage = post?.page_cover
? `url("${post.page_cover}")`
: `url("/${BLOG.HOME_BANNER_IMAGE}")`
: `url("${siteInfo?.pageCover}")`
return (
<Link

View File

@@ -34,7 +34,7 @@ export default function SideRight (props) {
</Card>
)}
{CONFIG_HEXO.WIDGET_LATEST_POSTS && latestPosts && latestPosts.length > 0 && <Card>
<LatestPostsGroup posts={latestPosts} />
<LatestPostsGroup posts={latestPosts} {...props} />
</Card>}
<div className='sticky top-20'>