移除冗余的slug转换函数

This commit is contained in:
tangly1024.com
2024-05-08 15:47:36 +08:00
parent fd3bc28216
commit 65eff434ec
41 changed files with 1076 additions and 1046 deletions

View File

@@ -1,7 +1,6 @@
import Badge from '@/components/Badge'
import NotionIcon from '@/components/NotionIcon'
import { siteConfig } from '@/lib/config'
import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
import Link from 'next/link'
import { useRouter } from 'next/router'
import CONFIG from '../config'
@@ -9,11 +8,9 @@ import CONFIG from '../config'
const BlogPostCard = ({ post, className }) => {
const router = useRouter()
const currentSelected = router.asPath.split('?')[0] === '/' + post.slug
const url = checkContainHttp(post.slug)
? sliceUrlFromHttp(post.slug)
: `${siteConfig('SUB_PATH', '')}/${post.slug}`
return (
<Link href={url} passHref>
<Link href={post?.href} passHref>
<div
key={post.id}
className={`${className} relative py-1.5 cursor-pointer px-1.5 hover:bg-gray-50 rounded-md dark:hover:bg-yellow-100 dark:hover:text-yellow-600