Merge branch 'main' into pr/emengweb/1575

This commit is contained in:
tangly1024.com
2024-01-30 18:53:11 +08:00
397 changed files with 4357 additions and 3222 deletions

View File

@@ -1,17 +1,15 @@
import BLOG from '@/blog.config'
import Link from 'next/link'
import NotionIcon from './NotionIcon'
import { useRouter } from 'next/router'
import React from 'react'
const BlogPostCard = ({ post, className }) => {
const router = useRouter()
const currentSelected = router.asPath.split('?')[0] === '/' + post.slug
let pageIcon = post.pageIcon !== '' ? post.pageIcon : BLOG.IMG_LAZY_LOAD_PLACEHOLDER
pageIcon = post.pageIcon.indexOf("amazonaws.com")!=-1 ? post.pageIcon+"&width=88" : post.pageIcon
pageIcon = post.pageIcon.indexOf('amazonaws.com') !== -1 ? post.pageIcon + '&width=88' : post.pageIcon
return (
<Link href={`${removeHttp(post.slug)}`} target={(checkRemoveHttp(post.slug) ? '_blank' : '_self')} passHref>
<div key={post.id} className={`${className} h-full rounded-lg p-4 dark:bg-neutral-800 cursor-pointer bg-white hover:bg-white rounded-2xl dark:hover:bg-gray-800 ${currentSelected ? 'bg-green-50 text-green-500' : ''}`}>
<div key={post.id} className={`${className} h-full rounded-2xl p-4 dark:bg-neutral-800 cursor-pointer bg-white hover:bg-white dark:hover:bg-gray-800 ${currentSelected ? 'bg-green-50 text-green-500' : ''}`}>
<div className="stack-entry w-full flex space-x-3 select-none dark:text-neutral-200">
<NotionIcon icon={pageIcon} size='10' className='text-6xl w-11 h-11 mx-1 my-0 flex-none' />
<div className="stack-comment flex-auto">
@@ -24,9 +22,9 @@ const BlogPostCard = ({ post, className }) => {
)
function removeHttp(str) {
// 检查字符串是否包含http
if (str.includes("http")) {
if (str.includes('http')) {
// 如果包含找到http的位置
let index = str.indexOf("http");
const index = str.indexOf('http');
// 返回http之后的部分
return str.slice(index, str.length);
} else {
@@ -36,11 +34,9 @@ const BlogPostCard = ({ post, className }) => {
}
function checkRemoveHttp(str) {
// 检查字符串是否包含http
if (str.includes("http")) {
if (str.includes('http')) {
// 如果包含找到http的位置
let index = str.indexOf("http");
// 包含
return true;
return str.indexOf('http') > -1
} else {
// 不包含
return false;