import { LinkIncludingShortenedCollectionAndTags } from "@/types/global"; import Image from "next/image"; import isValidUrl from "@/lib/shared/isValidUrl"; import React from "react"; import Link from "next/link"; export default function LinkGroupedIconURL({ link, }: { link: LinkIncludingShortenedCollectionAndTags; }) { const url = isValidUrl(link.url || "") && link.url ? new URL(link.url) : undefined; const [showFavicon, setShowFavicon] = React.useState(true); let shortendURL; try { shortendURL = new URL(link.url || "").host.toLowerCase(); } catch (error) { console.log(error); } return (
{link.url && url && showFavicon ? ( { setShowFavicon(false); }} /> ) : showFavicon === false ? ( ) : link.type === "pdf" ? ( ) : link.type === "image" ? ( ) : undefined}

{shortendURL}

); }