Merge pull request #957 from umihico/patch-1

Allow line breaks for <a> tags to keep body width on mobile
This commit is contained in:
Timothy 2024-07-10 21:38:27 +08:00 committed by GitHub
commit c97f7f076e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,14 +8,16 @@ const CustomLink = ({ href, ...rest }: LinkProps & AnchorHTMLAttributes<HTMLAnch
const isAnchorLink = href && href.startsWith('#')
if (isInternalLink) {
return <Link href={href} {...rest} />
return <Link className="break-words" href={href} {...rest} />
}
if (isAnchorLink) {
return <a href={href} {...rest} />
return <a className="break-words" href={href} {...rest} />
}
return <a target="_blank" rel="noopener noreferrer" href={href} {...rest} />
return (
<a className="break-words" target="_blank" rel="noopener noreferrer" href={href} {...rest} />
)
}
export default CustomLink