feat: change all Link component to SmartLink

Close #3512
This commit is contained in:
anime
2025-07-24 15:06:39 +08:00
parent fc4817e669
commit ba951cd2aa
338 changed files with 1381 additions and 1381 deletions

View File

@@ -1,4 +1,4 @@
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import CONFIG from '../config'
import { siteConfig } from '@/lib/config'
@@ -13,22 +13,22 @@ export default function ArticleAdjacent ({ prev, next }) {
}
return (
<section className='pt-8 text-gray-800 items-center text-xs md:text-sm flex justify-between m-1 '>
<Link
<SmartLink
href={`/${prev.slug}`}
passHref
className='py-1 cursor-pointer hover:underline justify-start items-center dark:text-white flex w-full h-full duration-200'>
<i className='mr-1 fas fa-angle-left' />{prev.title}
</Link>
<Link
</SmartLink>
<SmartLink
href={`/${next.slug}`}
passHref
className='py-1 cursor-pointer hover:underline justify-end items-center dark:text-white flex w-full h-full duration-200'>
{next.title}
<i className='ml-1 my-1 fas fa-angle-right' />
</Link>
</SmartLink>
</section>
)
}

View File

@@ -1,5 +1,5 @@
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
import CONFIG from '../config'
@@ -24,9 +24,9 @@ export default function ArticleCopyright() {
<ul className='overflow-x-auto whitespace-nowrap text-sm dark:bg-gray-900 bg-gray-100 p-5 leading-8 border-l-2 border-indigo-500'>
<li>
<strong className='mr-2'>{locale.COMMON.AUTHOR}:</strong>
<Link href={'/about'} className='hover:underline'>
<SmartLink href={'/about'} className='hover:underline'>
{siteConfig('AUTHOR')}
</Link>
</SmartLink>
</li>
<li>
<strong className='mr-2'>{locale.COMMON.URL}:</strong>

View File

@@ -1,7 +1,7 @@
import LazyImage from '@/components/LazyImage'
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import CONFIG from '../config'
/**
@@ -35,7 +35,7 @@ export default function ArticleRecommend({ recommendPosts, siteInfo }) {
: siteInfo?.pageCover
return (
<Link
<SmartLink
key={post.id}
title={post.title}
href={post?.href}
@@ -57,7 +57,7 @@ export default function ArticleRecommend({ recommendPosts, siteInfo }) {
<div className='h-full w-full absolute opacity-80 group-hover:opacity-100 transition-all duration-1000 bg-gradient-to-b from-transparent to-black'></div>
</div>
</div>
</Link>
</SmartLink>
)
})}
</div>

View File

@@ -1,4 +1,4 @@
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
/**
* 博客归档列表
@@ -27,12 +27,12 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => {
<div id={post?.publishDay}>
<span className='text-gray-400'>{post.date?.start_date}</span>{' '}
&nbsp;
<Link
<SmartLink
href={post?.href}
passHref
className='dark:text-gray-400 dark:hover:text-indigo-300 overflow-x-hidden hover:underline cursor-pointer text-gray-600'>
{post.title}
</Link>
</SmartLink>
</div>
</li>
)

View File

@@ -1,6 +1,6 @@
import LazyImage from '@/components/LazyImage'
import { siteConfig } from '@/lib/config'
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import CONFIG from '../config'
import { BlogPostCardInfo } from './BlogPostCardInfo'
@@ -45,7 +45,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
{/* 图片封面 */}
{showPageCover && (
<div className='md:w-5/12 overflow-hidden'>
<Link href={post?.href}>
<SmartLink href={post?.href}>
<>
<LazyImage
priority={index === 1}
@@ -54,7 +54,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
className='h-56 w-full object-cover object-center group-hover:scale-110 duration-500'
/>
</>
</Link>
</SmartLink>
</div>
)}
</div>

View File

@@ -3,7 +3,7 @@ import NotionPage from '@/components/NotionPage'
import TwikooCommentCount from '@/components/TwikooCommentCount'
import { siteConfig } from '@/lib/config'
import { formatDateFmt } from '@/lib/utils/formatDate'
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import TagItemMini from './TagItemMini'
/**
@@ -24,7 +24,7 @@ export const BlogPostCardInfo = ({
<header>
<h2>
{/* 标题 */}
<Link
<SmartLink
href={post?.href}
passHref
className={`line-clamp-2 replace cursor-pointer text-2xl ${
@@ -34,7 +34,7 @@ export const BlogPostCardInfo = ({
<NotionIcon icon={post.pageIcon} />
)}
<span className='menu-link '>{post.title}</span>
</Link>
</SmartLink>
</h2>
{/* 分类 */}
@@ -43,13 +43,13 @@ export const BlogPostCardInfo = ({
className={`flex mt-2 items-center ${
showPreview ? 'justify-center' : 'justify-start'
} flex-wrap dark:text-gray-500 text-gray-400 `}>
<Link
<SmartLink
href={`/category/${post.category}`}
passHref
className='cursor-pointer font-light text-sm menu-link hover:text-indigo-700 dark:hover:text-indigo-400 transform'>
<i className='mr-1 far fa-folder' />
{post.category}
</Link>
</SmartLink>
<TwikooCommentCount
className='text-sm hover:text-indigo-700 dark:hover:text-indigo-400'
@@ -87,13 +87,13 @@ export const BlogPostCardInfo = ({
{/* 日期标签 */}
<div className='text-gray-400 justify-between flex'>
{/* 日期 */}
<Link
<SmartLink
href={`/archive#${formatDateFmt(post?.publishDate, 'yyyy-MM')}`}
passHref
className='font-light menu-link cursor-pointer text-sm leading-4 mr-3'>
<i className='far fa-calendar-alt mr-1' />
{post?.publishDay || post.lastEditedDay}
</Link>
</SmartLink>
<div className='md:flex-nowrap flex-wrap md:justify-start inline-block'>
<div>

View File

@@ -1,4 +1,4 @@
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
const CategoryGroup = ({ currentCategory, categories }) => {
if (!categories) {
@@ -9,7 +9,7 @@ const CategoryGroup = ({ currentCategory, categories }) => {
{categories.map(category => {
const selected = currentCategory === category.name
return (
<Link
<SmartLink
key={category.name}
href={`/category/${category.name}`}
passHref
@@ -20,7 +20,7 @@ const CategoryGroup = ({ currentCategory, categories }) => {
<div> <i className={`mr-2 fas ${selected ? 'fa-folder-open' : 'fa-folder'}`} />{category.name}({category.count})</div>
</Link>
</SmartLink>
);
})}
</div>

View File

@@ -1,7 +1,7 @@
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import throttle from 'lodash.throttle'
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import { useRouter } from 'next/router'
import { useCallback, useEffect, useRef, useState } from 'react'
import CONFIG from '../config'
@@ -106,12 +106,12 @@ const Header = props => {
<i className='mr-2 fas fa-th-list' />
{locale.COMMON.CATEGORY}
</div>
<Link
<SmartLink
href={'/category'}
passHref
className='mb-3 text-gray-400 hover:text-black dark:text-gray-400 dark:hover:text-white hover:underline cursor-pointer'>
{locale.COMMON.MORE} <i className='fas fa-angle-double-right' />
</Link>
</SmartLink>
</div>
<CategoryGroup
currentCategory={currentCategory}
@@ -127,12 +127,12 @@ const Header = props => {
<i className='mr-2 fas fa-tag' />
{locale.COMMON.TAGS}
</div>
<Link
<SmartLink
href={'/tag'}
passHref
className='text-gray-400 hover:text-black dark:hover:text-white hover:underline cursor-pointer'>
{locale.COMMON.MORE} <i className='fas fa-angle-double-right' />
</Link>
</SmartLink>
</div>
<div className='p-2'>
<TagGroups tags={tags} currentTag={currentTag} />

View File

@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'
import { siteConfig } from '@/lib/config'
import Card from '@/themes/hexo/components/Card'
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import { RecentComments } from '@waline/client'
/**
@@ -36,7 +36,7 @@ const HexoRecentComments = (props) => {
{!onLoading && comments && comments.length > 0 && comments.map((comment) => <div key={comment.objectId} className='pb-2 pl-1'>
<div className='dark:text-gray-200 text-sm waline-recent-content wl-content' dangerouslySetInnerHTML={{ __html: comment.comment }} />
<div className='dark:text-gray-400 text-gray-400 text-sm text-right cursor-pointer hover:text-red-500 hover:underline pt-1 pr-2'>
<Link href={{ pathname: comment.url, hash: comment.objectId, query: { target: 'comment' } }}>--{comment.nick}</Link>
<SmartLink href={{ pathname: comment.url, hash: comment.objectId, query: { target: 'comment' } }}>--{comment.nick}</SmartLink>
</div>
</div>)}

View File

@@ -1,7 +1,7 @@
import LazyImage from '@/components/LazyImage'
import { useGlobal } from '@/lib/global'
// import Image from 'next/image'
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import { useRouter } from 'next/router'
/**
@@ -34,7 +34,7 @@ const LatestPostsGroup = ({ latestPosts, siteInfo }) => {
const selected = currentPath === post?.href
return (
<Link
<SmartLink
key={post.id}
title={post.title}
href={post?.href}
@@ -58,7 +58,7 @@ const LatestPostsGroup = ({ latestPosts, siteInfo }) => {
<div className='text-gray-500'>{post.lastEditedDay}</div>
</div>
</div>
</Link>
</SmartLink>
)
})}
</>

View File

@@ -1,5 +1,5 @@
import { siteConfig } from '@/lib/config'
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
/**
* Logo
* 实际值支持文字
@@ -9,14 +9,14 @@ import Link from 'next/link'
const Logo = props => {
const { siteInfo } = props
return (
<Link href='/' passHref legacyBehavior>
<SmartLink href='/' passHref legacyBehavior>
<div className='flex flex-col justify-center items-center cursor-pointer space-y-3'>
<div className='font-medium text-lg p-1.5 rounded dark:border-white dark:text-white menu-link transform duration-200'>
{' '}
{siteInfo?.title || siteConfig('TITLE')}
</div>
</div>
</Link>
</SmartLink>
)
}
export default Logo

View File

@@ -1,6 +1,6 @@
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import CONFIG from '../config'
const MenuGroupCard = props => {
@@ -46,7 +46,7 @@ const MenuGroupCard = props => {
{links.map(link => {
if (link.show) {
return (
<Link
<SmartLink
key={`${link.href}`}
title={link.href}
href={link.href}
@@ -58,7 +58,7 @@ const MenuGroupCard = props => {
<div className='text-center'>{link.name}</div>
<div className='text-center font-semibold'>{link.slot}</div>
</div>
</Link>
</SmartLink>
)
} else {
return null

View File

@@ -1,5 +1,5 @@
import Collapse from '@/components/Collapse'
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import { useState } from 'react'
/**
@@ -32,7 +32,7 @@ export const MenuItemCollapse = props => {
className='w-full px-8 py-3 dark:hover:bg-indigo-500 hover:bg-indigo-500 hover:text-white text-left dark:bg-hexo-black-gray'
onClick={toggleShow}>
{!hasSubMenu && (
<Link
<SmartLink
href={link?.href}
target={link?.target}
className=' font-extralight flex justify-between pl-2 pr-4 dark:text-gray-200 no-underline tracking-widest pb-1'>
@@ -40,7 +40,7 @@ export const MenuItemCollapse = props => {
{link?.icon && <i className={link.icon + ' mr-4'} />}
{link?.name}
</span>
</Link>
</SmartLink>
)}
{hasSubMenu && (
<div
@@ -64,12 +64,12 @@ export const MenuItemCollapse = props => {
<div
key={index}
className='dark:hover:bg-indigo-500 hover:bg-indigo-500 hover:text-white dark:bg-black dark:text-gray-200 text-left px-10 justify-start bg-gray-50 tracking-widest transition-all duration-200 py-3 pr-6'>
<Link href={sLink.href} target={link?.target}>
<SmartLink href={sLink.href} target={link?.target}>
<span className='text-sm ml-4 whitespace-nowrap'>
{link?.icon && <i className={sLink.icon + ' mr-2'} />}{' '}
{sLink.title}
</span>
</Link>
</SmartLink>
</div>
)
})}

View File

@@ -1,4 +1,4 @@
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import { useState } from 'react'
/**
* 支持二级展开的菜单
@@ -18,13 +18,13 @@ export const MenuItemDrop = ({ link }) => {
onMouseOver={() => changeShow(true)}
onMouseOut={() => changeShow(false)}>
{!hasSubMenu && (
<Link
<SmartLink
href={link?.href}
target={link?.target}
className=' menu-link pl-2 pr-4 no-underline tracking-widest pb-1'>
{link?.icon && <i className={link?.icon} />} {link?.name}
{hasSubMenu && <i className='px-2 fa fa-angle-down'></i>}
</Link>
</SmartLink>
)}
{hasSubMenu && (
@@ -51,12 +51,12 @@ export const MenuItemDrop = ({ link }) => {
<li
key={index}
className='cursor-pointer hover:bg-indigo-500 hover:text-white tracking-widest transition-all duration-200 dark:border-gray-800 py-1 pr-6 pl-3'>
<Link href={sLink.href} target={link?.target}>
<SmartLink href={sLink.href} target={link?.target}>
<span className='text-sm text-nowrap font-extralight'>
{link?.icon && <i className={sLink?.icon}> &nbsp; </i>}
{sLink.title}
</span>
</Link>
</SmartLink>
</li>
)
})}

View File

@@ -1,4 +1,4 @@
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
/**
* 首页导航大按钮组件
@@ -15,14 +15,14 @@ const NavButtonGroup = (props) => {
<nav id='home-nav-button' className={'w-full z-10 md:h-72 md:mt-6 xl:mt-32 px-5 py-2 mt-8 flex flex-wrap md:max-w-6xl space-y-2 md:space-y-0 md:flex justify-center max-h-80 overflow-auto'}>
{categoryOptions?.map(category => {
return (
<Link
<SmartLink
key={`${category.name}`}
title={`${category.name}`}
href={`/category/${category.name}`}
passHref
className='text-center shadow-text w-full sm:w-4/5 md:mx-6 md:w-40 md:h-14 lg:h-20 h-14 justify-center items-center flex border-2 cursor-pointer rounded-lg glassmorphism hover:bg-white hover:text-black duration-200 hover:scale-105 transform'>
{category.name}
</Link>
</SmartLink>
)
})}
</nav>

View File

@@ -1,4 +1,4 @@
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import { useRouter } from 'next/router'
/**
@@ -22,7 +22,7 @@ const PaginationNumber = ({ page, totalPage }) => {
return (
<div className='mt-10 mb-5 flex justify-center items-end font-medium text-indigo-400 duration-500 py-3 space-x-2'>
{/* 上一页 */}
<Link
<SmartLink
href={{
pathname:
currentPage === 2
@@ -33,12 +33,12 @@ const PaginationNumber = ({ page, totalPage }) => {
rel='prev'
className={`${currentPage === 1 ? 'invisible' : 'block'} pb-0.5 hover:bg-indigo-400 hover:text-white w-6 text-center cursor-pointer duration-200 hover:font-bold`}>
<i className='fas fa-angle-left' />
</Link>
</SmartLink>
{pages}
{/* 下一页 */}
<Link
<SmartLink
href={{
pathname: `${pagePrefix}/page/${currentPage + 1}`,
query: router.query.s ? { s: router.query.s } : {}
@@ -46,7 +46,7 @@ const PaginationNumber = ({ page, totalPage }) => {
rel='next'
className={`${+showNext ? 'block' : 'invisible'} pb-0.5 hover:bg-indigo-400 hover:text-white w-6 text-center cursor-pointer duration-200 hover:font-bold`}>
<i className='fas fa-angle-right' />
</Link>
</SmartLink>
</div>
)
}
@@ -61,7 +61,7 @@ const PaginationNumber = ({ page, totalPage }) => {
function getPageElement(page, currentPage, pagePrefix) {
const selected = page + '' === currentPage + ''
return (
<Link
<SmartLink
href={page === 1 ? `${pagePrefix}/` : `${pagePrefix}/page/${page}`}
key={page}
passHref
@@ -74,7 +74,7 @@ function getPageElement(page, currentPage, pagePrefix) {
cursor-pointer pb-0.5 w-6 text-center
`}>
{page}
</Link>
</SmartLink>
)
}

View File

@@ -3,7 +3,7 @@ import NotionIcon from '@/components/NotionIcon'
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import { formatDateFmt } from '@/lib/utils/formatDate'
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import TagItemMini from './TagItemMini'
/**
@@ -38,14 +38,14 @@ export default function PostHero({ post, siteInfo }) {
<div className='mb-3 flex justify-center'>
{post.category && (
<>
<Link
<SmartLink
href={`/category/${post.category}`}
passHref
legacyBehavior>
<div className='cursor-pointer px-2 py-1 mb-2 border rounded-sm dark:border-white text-sm font-medium hover:underline duration-200 shadow-text-md text-white'>
{post.category}
</div>
</Link>
</SmartLink>
</>
)}
</div>
@@ -62,12 +62,12 @@ export default function PostHero({ post, siteInfo }) {
<div className='flex justify-center dark:text-gray-200 text-opacity-70'>
{post?.type !== 'Page' && (
<>
<Link
<SmartLink
href={`/archive#${formatDateFmt(post?.publishDate, 'yyyy-MM')}`}
passHref
className='pl-1 mr-2 cursor-pointer hover:underline'>
{locale.COMMON.POST_TIME}: {post?.publishDay}
</Link>
</SmartLink>
</>
)}
<div className='pl-1 mr-2'>

View File

@@ -1,5 +1,5 @@
import { useGlobal } from '@/lib/global'
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
import { useEffect, useRef } from 'react'
import Card from './Card'
import SearchInput from './SearchInput'
@@ -31,7 +31,7 @@ export default function SearchNav(props) {
<div id="category-list" className="duration-200 flex flex-wrap mx-8">
{categoryOptions?.map(category => {
return (
<Link
<SmartLink
key={category.name}
href={`/category/${category.name}`}
passHref
@@ -44,7 +44,7 @@ export default function SearchNav(props) {
<i className="mr-4 fas fa-folder" />
{category.name}({category.count})
</div>
</Link>
</SmartLink>
)
})}
</div>

View File

@@ -1,4 +1,4 @@
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
/**
* 博客列表上方嵌入条
@@ -10,10 +10,10 @@ export default function SlotBar(props) {
if (tag) {
return <div className="cursor-pointer px-3 py-2 mb-2 font-light hover:text-indigo-700 dark:hover:text-indigo-400 transform dark:text-white">
<Link key={tag} href={`/tag/${encodeURIComponent(tag)}`} passHref
<SmartLink key={tag} href={`/tag/${encodeURIComponent(tag)}`} passHref
className={'cursor-pointer inline-block rounded duration-200 mr-2 py-0.5 px-1 text-xl whitespace-nowrap '}>
<div className='font-light dark:text-gray-400 dark:hover:text-white'> #{tag} </div>
</Link>
</SmartLink>
</div>
} else if (category) {
return <div className="cursor-pointer text-lg px-5 py-1 mb-2 font-light hover:text-indigo-700 dark:hover:text-indigo-400 transform dark:text-white">

View File

@@ -1,8 +1,8 @@
import Link from 'next/link'
import SmartLink from '@/components/SmartLink'
const TagItemMini = ({ tag, selected = false }) => {
return (
<Link
<SmartLink
key={tag}
href={selected ? '/' : `/tag/${encodeURIComponent(tag.name)}`}
passHref
@@ -14,7 +14,7 @@ const TagItemMini = ({ tag, selected = false }) => {
<div className='font-light'>{selected && <i className='mr-1 fa-tag'/>} {tag.name + (tag.count ? `(${tag.count})` : '')} </div>
</Link>
</SmartLink>
);
}