Fixed external link icon

This commit is contained in:
HangerThem 2026-08-04 10:39:52 +02:00
parent 7b0ab11425
commit a771755907
2 changed files with 8 additions and 4 deletions

View file

@ -1,3 +1,4 @@
import { ExternalLinkIcon } from 'lucide-react'
import type { AnchorHTMLAttributes } from 'react' import type { AnchorHTMLAttributes } from 'react'
type ExternalLinkProps = Omit< type ExternalLinkProps = Omit<
@ -7,6 +8,11 @@ type ExternalLinkProps = Omit<
href: string href: string
} }
export function ExternalLink(props: ExternalLinkProps) { export function ExternalLink({ children, ...props }: ExternalLinkProps) {
return <a {...props} target="_blank" rel="noopener noreferrer" /> return (
<a {...props} target="_blank" rel="noopener noreferrer">
{children}
<ExternalLinkIcon className="inline-block w-3 h-3 ml-1 mb-2" />
</a>
)
} }

View file

@ -26,7 +26,6 @@ import { rehypeDefinition } from '@/lib/rehype-definition'
import { slugify } from '@/utils/slug' import { slugify } from '@/utils/slug'
import { PostMeta } from '@/types/Post.type' import { PostMeta } from '@/types/Post.type'
import Link from 'next/link' import Link from 'next/link'
import { ExternalLinkIcon } from 'lucide-react'
const postsDirectory = path.join(process.cwd(), 'content/posts') const postsDirectory = path.join(process.cwd(), 'content/posts')
@ -102,7 +101,6 @@ export async function getPostBySlug(slug: string, postDirectory: string = postsD
href?.startsWith('http') ? ( href?.startsWith('http') ? (
<ExternalLink href={href}> <ExternalLink href={href}>
{children} {children}
<ExternalLinkIcon className="inline-block w-3 h-3 ml-1" />
</ExternalLink> </ExternalLink>
) : ( ) : (
<Link href={href}>{children}</Link> <Link href={href}>{children}</Link>