移除冗余的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

@@ -2,7 +2,6 @@ import LazyImage from '@/components/LazyImage'
import NotionIcon from '@/components/NotionIcon'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import { siteConfig } from '@/lib/config'
import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
import Link from 'next/link'
import CONFIG from '../config'
@@ -15,9 +14,6 @@ const BlogItem = ({ 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
@@ -25,7 +21,7 @@ const BlogItem = ({ post }) => {
<div className={`${showPageCover ? 'md:w-7/12' : ''}`}>
<h2 className='mb-4'>
<Link
href={`/${post.slug}`}
href={post?.href}
className='text-black dark:text-gray-100 text-xl md:text-2xl no-underline hover:underline'>
{siteConfig('POST_TITLE_ICON') && (
<NotionIcon icon={post.pageIcon} />
@@ -72,7 +68,7 @@ const BlogItem = ({ post }) => {
{/* 图片封面 */}
{showPageCover && (
<div className='md:w-5/12 w-full h-44 overflow-hidden p-1'>
<Link href={url} passHref legacyBehavior>
<Link href={post?.href} passHref legacyBehavior>
<LazyImage
src={post?.pageCoverThumbnail}
className='w-full bg-cover hover:scale-110 duration-200'