BlogCard调整,允许无封面图
This commit is contained in:
tangly1024
2021-12-16 14:40:39 +08:00
parent ae7edd80b6
commit f48d519a53
3 changed files with 35 additions and 32 deletions

View File

@@ -40,6 +40,7 @@ export default function ArticleDetail ({ post, blockMap, recommendPosts, prev, n
const url = BLOG.link + useRouter().asPath
const { locale } = useGlobal()
const date = formatDate(post?.date?.start_date || post.createdTime, BLOG.lang)
const cover = post.page_cover && post.page_cover.length > 1 ? post.page_cover : undefined
return (
<>
<Progress targetRef={targetRef} />
@@ -51,15 +52,11 @@ export default function ArticleDetail ({ post, blockMap, recommendPosts, prev, n
itemType="https://schema.org/Movie"
className="duration-300 hover:shadow-2xl pt-10 animate__fadeIn animate__animated subpixel-antialiased lg:pt-32 lg:px-52 px-5 py-2 dark:border-gray-700 bg-white dark:bg-gray-800"
>
{post.type && !post.type.includes('Page') && (
{post.type && !post.type.includes('Page') && cover && (
<>
<header className="w-full h-60 lg:h-96 transform duration-200 md:flex-shrink-0 overflow-hidden">
<Image
src={
post.page_cover && post.page_cover.length > 1
? post.page_cover
: BLOG.defaultImgCover
}
src={cover}
loading="eager"
objectFit="cover"
layout="fill"