MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / Link

Function Link

apps/web/ui/Message/Link/index.tsx:19–63  ·  view source on GitHub ↗
({
  url,
  title,
  onClick,
  onImageClick,
  onLoad,
}: Props)

Source from the content-addressed store, hash-verified

17}
18
19export default function Link({
20 url,
21 title,
22 onClick,
23 onImageClick,
24 onLoad,
25}: Props) {
26 if (isImage(url)) {
27 return (
28 <Accordion header={title}>
29 <Image src={url} onLoad={onLoad} onClick={onImageClick} />
30 </Accordion>
31 );
32 }
33
34 if (isVideo(url)) {
35 return (
36 <Accordion header={title}>
37 <Video src={url} onLoad={onLoad} />
38 </Accordion>
39 );
40 }
41
42 if (isMail(url)) {
43 return <Mail url={url} title={title} />;
44 }
45
46 const isHrefInvalid = !isUrlValid(url);
47 const isExternalLink = !url.startsWith('https://linen.dev/');
48
49 return (
50 <a
51 className={classNames(styles.link, {
52 [styles.line]: isHrefInvalid,
53 })}
54 href={url}
55 title={isHrefInvalid ? 'Invalid link' : ''}
56 rel="noreferrer ugc"
57 target={isExternalLink ? '_blank' : undefined}
58 onClick={onClick}
59 >
60 {title}
61 </a>
62 );
63}

Callers

nothing calls this directly

Calls 4

isImageFunction · 0.90
isVideoFunction · 0.90
isMailFunction · 0.90
isUrlValidFunction · 0.90

Tested by

no test coverage detected