import LinkTag from 'next/link'; import { Category, Link } from '../../types'; import EditSVG from '../../public/icons/edit.svg'; import RemoveSVG from '../../public/icons/remove.svg'; import styles from '../../styles/home/links.module.scss'; export default function Links({ category }: { category: Category; }) { if (category === null) { return (

Veuillez séléctionner une categorié

ou en créer une
) } const { name, links } = category; if (links.length === 0) { return (

Aucun lien pour {category.name}

Créer un lien
) } return (

{name} — {links.length}

); } function LinkItem({ link }: { link: Link; }) { const { id, name, url, category } = link; return (
  • {name} — {category.name}
  • ); } function LinkItemURL({ url }: { url: string; }) { try { const { origin, pathname, search } = new URL(url); let text = ''; if (pathname !== '/') { text += pathname; } if (search !== '') { if (text === '') { text += '/'; } text += search; } return ( {origin}{text} ) } catch (error) { console.error('error', error); return ( {url} ) } }