import Link from "next/link"
import PropTypes from "prop-types"
import { linkPropTypes } from "utils/types"
const CustomLink = ({ link, children }) => {
const isInternalLink = link.url.startsWith("/")
// For internal links, use the Next.js Link component
if (isInternalLink) {
return (
{children}
)
}
// Plain tags for external links
if (link.newTab) {
return (
{children}
)
}
return (
{children}
)
}
CustomLink.propTypes = {
link: linkPropTypes,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
]).isRequired,
}
export default CustomLink