File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use client' ;
2+
3+ import { useCallback } from 'react' ;
14import Link from 'next/link' ;
25
36import { ExternalLink } from './externalLink' ;
@@ -27,6 +30,13 @@ export function SmartLink({
2730} : Props ) {
2831 const realTo = to || href || '' ;
2932
33+ const handleAutolinkClick = useCallback ( ( e : React . MouseEvent ) => {
34+ const link = e . currentTarget as HTMLAnchorElement ;
35+ if ( link . classList . contains ( 'autolink-heading' ) ) {
36+ navigator . clipboard . writeText ( link . href ) ;
37+ }
38+ } , [ ] ) ;
39+
3040 if ( remote || realTo ?. indexOf ( '://' ) !== - 1 ) {
3141 return (
3242 < ExternalLink href = { realTo } className = { className } { ...props } >
@@ -38,6 +48,7 @@ export function SmartLink({
3848 return (
3949 < Link
4050 href = { to || href || '' }
51+ onClick = { handleAutolinkClick }
4152 className = { `${ isActive ? activeClassName : '' } ${ className } ` }
4253 { ...props }
4354 >
You can’t perform that action at this time.
0 commit comments