mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-13 23:16:47 +00:00
feat: add DOM props filtering for SmartLink component
- Introduce filterDOMProps utility to exclude Next.js specific props - Apply filtering to external links to ensure clean DOM attributes - Maintain consistent prop passing for internal Next.js links
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import Link from 'next/link'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
|
||||
// 保留允许传给 <a> 的属性
|
||||
const filterDOMProps = (props) => {
|
||||
const {
|
||||
passHref,
|
||||
legacyBehavior,
|
||||
...rest
|
||||
} = props;
|
||||
return rest;
|
||||
};
|
||||
const SmartLink = ({ href, children, ...rest }) => {
|
||||
const LINK = siteConfig('LINK')
|
||||
const isExternal = href.startsWith('http') && !href.startsWith(LINK)
|
||||
@@ -11,14 +20,14 @@ const SmartLink = ({ href, children, ...rest }) => {
|
||||
href={href}
|
||||
target='_blank'
|
||||
rel='noopener noreferrer'
|
||||
{...rest}>
|
||||
{...filterDOMProps(rest)}>
|
||||
{children}
|
||||
</a>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Link href={href} {...rest}>
|
||||
<Link href={href} {...rest} >
|
||||
{children}
|
||||
</Link>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user