commerce/components/layout/search/collection-link.tsx
Chloe 6729bbd80c
add check for collection link
Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
2024-07-04 09:15:57 +07:00

28 lines
591 B
TypeScript

import { getCollection } from 'lib/shopify';
import { cn } from 'lib/utils';
import Link from 'next/link';
const CollectionLink = async ({
collectionLinkId,
anchorText,
className
}: {
collectionLinkId?: string;
anchorText: string;
className?: string;
}) => {
if (!collectionLinkId) return null;
const collection = await getCollection({ id: collectionLinkId });
if (!collection) return null;
return (
<Link href={collection.path} className={cn('border p-2 text-sm text-gray-600', className)}>
{anchorText}
</Link>
);
};
export default CollectionLink;