This commit is contained in:
tangly1024
2024-09-17 21:30:23 +08:00
2 changed files with 30 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
import LazyImage from '@/components/LazyImage'
import NotionIcon from '@/components/NotionIcon'
import NotionIcon from './NotionIcon'
import { siteConfig } from '@/lib/config'
import Link from 'next/link'
import CONFIG from '../config'
@@ -29,7 +29,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
return (
<article
className={` ${COVER_HOVER_ENLARGE} ? ' hover:scale-110 transition-all duration-150' : ''}`}>
className={` ${COVER_HOVER_ENLARGE} ? ' hover:transition-all duration-150' : ''}`}>
<div
data-wow-delay='.2s'
className={
@@ -48,7 +48,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
priority={index === 0}
src={post?.pageCoverThumbnail}
alt={post?.title}
className='h-60 w-full object-cover group-hover:scale-105 group-hover:brightness-75 transition-all duration-300'
className='h-full w-full object-cover group-hover:scale-105 group-hover:brightness-75 transition-all duration-500 ease-in-out' //宽高都调整为自适应,保证封面居中
/>
</div>
</Link>
@@ -74,7 +74,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
</div>
)}
{/* 标题 */}
{/* 标题和图标 */}
<Link
href={post?.href}
passHref
@@ -82,7 +82,10 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
' group-hover:text-indigo-700 dark:hover:text-yellow-700 dark:group-hover:text-yellow-600 text-black dark:text-gray-100 line-clamp-2 replace cursor-pointer text-xl font-extrabold leading-tight'
}>
{siteConfig('POST_TITLE_ICON') && (
<NotionIcon icon={post.pageIcon} />
<NotionIcon
icon={post.pageIcon}
className="heo-icon w-6 h-6 mr-1 align-middle transform translate-y-[-8%]" // 专门为 Heo 主题的图标设置样式
/>
)}
<span className='menu-link '>{post.title}</span>
</Link>

View File

@@ -0,0 +1,22 @@
import LazyImage from '@/components/LazyImage'
/**
* notion的图标icon
* 可能是emoji 可能是 svg 也可能是 图片
* @returns
*/
const NotionIcon = ({ icon, className = 'w-8 h-8 my-auto inline mr-1' }) => {
if (!icon) {
return <></>
}
if (icon.startsWith('http') || icon.startsWith('data:')) {
// 这里优先使用传入的 className
return <LazyImage src={icon} className={className} />
}
// 对于 emoji 或 svg设置默认 className也可以传递不同的样式
return <span className={`inline-block ${className}`}>{icon}</span>
}
export default NotionIcon