mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 23:16:49 +00:00
55 lines
2.5 KiB
JavaScript
55 lines
2.5 KiB
JavaScript
import { siteConfig } from '@/lib/config'
|
|
import CONFIG from '../config'
|
|
import Link from 'next/link'
|
|
import TwikooCommentCount from '@/components/TwikooCommentCount'
|
|
import LazyImage from '@/components/LazyImage'
|
|
import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
|
|
|
|
const BlogPostCard = ({ post }) => {
|
|
const showPageCover = siteConfig('EXAMPLE_POST_LIST_COVER', null, CONFIG) && post?.pageCoverThumbnail
|
|
const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
|
|
|
|
return <article className={`${showPageCover ? 'flex md:flex-row flex-col-reverse' : ''} replace mb-12 `}>
|
|
<div className={`${showPageCover ? 'md:w-7/12' : ''}`}>
|
|
<h2 className="mb-4">
|
|
<Link
|
|
href={`/${post.slug}`}
|
|
className="text-black dark:text-gray-100 text-xl md:text-2xl no-underline hover:underline">
|
|
{post?.title}
|
|
</Link>
|
|
</h2>
|
|
|
|
<div className="mb-4 text-sm text-gray-700 dark:text-gray-300">
|
|
by <a href="#" className="text-gray-700 dark:text-gray-300">{siteConfig('AUTHOR')}</a> on {post.date?.start_date || post.createdTime}
|
|
<TwikooCommentCount post={post} className='pl-1'/>
|
|
<span className="font-bold mx-1"> | </span>
|
|
<Link href={`/category/${post.category}`} className="text-gray-700 dark:text-gray-300 hover:underline">{post.category}</Link>
|
|
{/* <span className="font-bold mx-1"> | </span> */}
|
|
{/* <a href="#" className="text-gray-700">2 Comments</a> */}
|
|
</div>
|
|
|
|
{!post.results && <p className="line-clamp-3 text-gray-700 dark:text-gray-400 leading-normal">
|
|
{post.summary}
|
|
</p>}
|
|
{/* 搜索结果 */}
|
|
{post.results && (
|
|
<p className="line-clamp-3 mt-4 text-gray-700 dark:text-gray-300 text-sm font-light leading-7">
|
|
{post.results.map((r, index) => (
|
|
<span key={index}>{r}</span>
|
|
))}
|
|
</p>
|
|
)}
|
|
</div>
|
|
{/* 图片封面 */}
|
|
{showPageCover && (
|
|
<div className="md:w-5/12 w-full h-44 overflow-hidden p-1">
|
|
<Link href={url} passHref legacyBehavior>
|
|
<LazyImage src={post?.pageCoverThumbnail} className='w-full bg-cover hover:scale-110 duration-200' />
|
|
</Link>
|
|
</div>
|
|
)}
|
|
</article>
|
|
}
|
|
|
|
export default BlogPostCard
|