diff --git a/blog.config.js b/blog.config.js index 7e9f8d3e..a2a96ecd 100644 --- a/blog.config.js +++ b/blog.config.js @@ -7,7 +7,6 @@ const BLOG = { lang: 'zh-CN', // ['zh-CN','en-US'] default lang => see /lib/lang.js for more. notionPageId: process.env.NOTION_PAGE_ID || 'bee1fccfa3bd47a1a7be83cc71372d83', // Important page_id!!! notionAccessToken: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public - defaultImgCover: 'https://avatars.githubusercontent.com/u/15920488', // default image cover appearance: 'auto', // ['light', 'dark', 'auto'], font: 'font-sans tracking-wider subpixel-antialiased', // 文章字体 ['font-sans', 'font-serif', 'font-mono'] @see https://www.tailwindcss.cn/docs/font-family lightBackground: '#ffffff', // use hex value, don't forget '#' e.g #fffefc diff --git a/components/ArticleDetail.js b/components/ArticleDetail.js index cbcc3713..c97568b4 100644 --- a/components/ArticleDetail.js +++ b/components/ArticleDetail.js @@ -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 ( <> @@ -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 && ( <> 1 - ? post.page_cover - : BLOG.defaultImgCover - } + src={cover} loading="eager" objectFit="cover" layout="fill" diff --git a/components/BlogPostCard.js b/components/BlogPostCard.js index ccce55fa..cf776e62 100644 --- a/components/BlogPostCard.js +++ b/components/BlogPostCard.js @@ -1,46 +1,53 @@ import BLOG from '@/blog.config' -import TagItemMini from '@/components/TagItemMini' import Link from 'next/link' import React from 'react' import Image from 'next/image' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faFolder } from '@fortawesome/free-solid-svg-icons' +import TagItemMini from './TagItemMini' const BlogPostCard = ({ post, tags }) => { + const cover = (post.page_cover && post.page_cover.length > 1) ? post.page_cover : undefined + // const cover = undefined return ( - - - - 1) ? post.page_cover : BLOG.defaultImgCover} alt={post.title} layout='fill' objectFit='cover' loading='lazy' /> - - - - - - - - {post.category} - - - | - - {post.date.start_date} - - + + - + {post.title} - {post.summary} + {post.summary} - - {post.tagItems.map(tag => ())} + + + + + {post.category} + + + | + + {post.date.start_date} + + + + {post.tagItems.map(tag => ())} + + + + {cover && ( + + + + + + )} ) }
{post.summary}