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 (
)
}
const { name, links } = category;
if (links.length === 0) {
return ()
}
return (
{name} — {links.length}
{links.map((link, key) => (
))}
);
}
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}
)
}
}