import Link from "next/link"; import React from "react"; import { Page } from "../../payload-types"; import { Button } from "../Button"; type CMSLinkType = { type?: "custom" | "reference"; url?: string; newTab?: boolean; reference?: { value: string | Page; relationTo: "pages"; }; label?: string; appearance?: "default" | "primary" | "secondary"; children?: React.ReactNode; className?: string; }; export const CMSLink: React.FC = ({ type, url, newTab, reference, label, appearance, children, className, }) => { const href = type === "reference" && typeof reference?.value === "object" && reference.value.slug ? `/${reference.value.slug}` : url; if (!appearance) { const newTabProps = newTab ? { target: "_blank", rel: "noopener noreferrer" } : {}; if (type === "custom") { return ( {label && label} {children && children} ); } if (href) { return ( {label && label} {children && children} ); } } const buttonProps = { newTab, href, appearance, label, }; return