import { LinkIncludingShortenedCollectionAndTags } from "@/types/global"; import Image from "next/image"; import isValidUrl from "@/lib/shared/isValidUrl"; import React from "react"; export default function LinkIcon({ link, width, }: { link: LinkIncludingShortenedCollectionAndTags; width?: string; }) { const url = isValidUrl(link.url || "") && link.url ? new URL(link.url) : undefined; const iconClasses: string = "bg-white shadow rounded-md border-[2px] flex item-center justify-center border-white select-none z-10" + " " + (width || "w-12"); const [showFavicon, setShowFavicon] = React.useState(true); return ( <> {link.url && url && showFavicon ? ( { setShowFavicon(false); }} /> ) : showFavicon === false ? (
) : link.type === "pdf" ? ( ) : link.type === "image" ? ( ) : undefined} ); }