File tree Expand file tree Collapse file tree 2 files changed +70
-2
lines changed Expand file tree Collapse file tree 2 files changed +70
-2
lines changed Original file line number Diff line number Diff line change 11import { LucideIcon } from 'lucide-react'
22import Prism from 'prismjs'
33import { PropsWithChildren , useEffect } from 'react'
4+ import Link from './Link'
45
56const CodeBlock = ( {
67 children,
@@ -31,9 +32,9 @@ const CodeBlock = ({
3132 }
3233 >
3334 { Icon && < Icon size = { 14 } strokeWidth = { 2 } /> }
34- { /* <Link href={linkHref} target={'_blank'} borderWidth={'narrow'}>
35+ < Link href = { linkHref } target = { '_blank' } borderWidth = { 'narrow' } >
3536 { linkText ? linkText : linkHref }
36- </Link> */ }
37+ </ Link >
3738 </ div >
3839 ) }
3940 </ div >
Original file line number Diff line number Diff line change 1+ import { PropsWithChildren } from 'react'
2+ import { LucideIcon } from 'lucide-react'
3+
4+ const Link = ( {
5+ borderWidth = undefined ,
6+ children,
7+ className,
8+ href,
9+ Icon = undefined ,
10+ iconSize = 16 ,
11+ iconStrokeWidth = 1.65 ,
12+ inline = false ,
13+ target,
14+ } : PropsWithChildren < LinkProps > ) => {
15+ return (
16+ < a
17+ href = { href }
18+ target = { target }
19+ className = {
20+ ( inline ? 'inline ' : 'inline-flex items-center gap-1 ' ) +
21+ 'relative bg-gradient-to-r from-fuchsia-400 to-violet-800 bg-[length:200%_100%] bg-clip-text text-transparent ' +
22+ 'group whitespace-normal transition-[background-size] duration-700 hover:bg-[length:500%_1000%] dark:to-violet-700 ' +
23+ ( className ? ` ${ className } ` : '' )
24+ }
25+ >
26+ < span > { children } </ span >
27+ { Icon ? (
28+ < Icon
29+ size = { iconSize }
30+ absoluteStrokeWidth = { true }
31+ strokeWidth = { iconStrokeWidth }
32+ className = {
33+ 'stroke-violet-600 ease-bounce group-hover:max-w-full group-hover:animate-bounce-bottom'
34+ }
35+ />
36+ ) : (
37+ ''
38+ ) }
39+ < span
40+ className = {
41+ ( borderWidth === 'narrow'
42+ ? 'h-px'
43+ : borderWidth === 'none'
44+ ? 'hidden'
45+ : borderWidth === 'huge'
46+ ? 'h-1'
47+ : 'h-[2px]' ) +
48+ ' absolute -bottom-px left-0 w-full max-w-0 bg-gradient-to-r from-fuchsia-400 to-violet-800 transition-[max-width] duration-500 ease-line group-hover:max-w-full'
49+ }
50+ > </ span >
51+ </ a >
52+ )
53+ }
54+
55+ export interface LinkProps {
56+ children : PropsWithChildren
57+ href : string
58+ target : string
59+ borderWidth ?: undefined | 'narrow' | 'none' | 'huge'
60+ className ?: string
61+ Icon ?: LucideIcon | undefined
62+ iconSize ?: number | 16
63+ iconStrokeWidth ?: number | 2
64+ inline ?: boolean
65+ }
66+
67+ export default Link
You can’t perform that action at this time.
0 commit comments