mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 15:09:22 +00:00
21 lines
733 B
JavaScript
21 lines
733 B
JavaScript
import BLOG from '@/blog.config'
|
|
import Link from 'next/link'
|
|
import { useRouter } from 'next/router'
|
|
import React from 'react'
|
|
|
|
const BlogPostCard = ({ post, className }) => {
|
|
const router = useRouter()
|
|
const currentSelected = router.asPath.split('?')[0] === '/' + post.slug
|
|
return (
|
|
<div key={post.id} className={`${className} py-1 cursor-pointer px-2 hover:bg-gray-50 rounded-md dark:hover:bg-gray-600 ${currentSelected ? 'bg-green-50 text-green-500' : ''}`}>
|
|
<div className="flex flex-col w-full">
|
|
<Link href={`${BLOG.SUB_PATH}/${post.slug}`} passHref>
|
|
<a>{post.title}</a>
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default BlogPostCard
|