Merged in fix/use-link-component-content-card (pull request #1899)

fix: use link component for all types of links to add proper styling to set text decoration none when external

Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
Christian Andolf
2025-05-05 08:24:16 +00:00
2 changed files with 7 additions and 29 deletions

View File

@@ -12,10 +12,3 @@ export interface ContentCardProps {
promoText?: string
className?: string
}
export interface ContentCardLinkProps {
href: string
openInNewTab?: boolean
isExternal?: boolean
children: React.ReactNode
}

View File

@@ -6,7 +6,7 @@ import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
import styles from "./contentCard.module.css"
import type { ContentCardLinkProps, ContentCardProps } from "./contentCard"
import type { ContentCardProps } from "./contentCard"
export default function ContentCard({
heading,
@@ -40,31 +40,16 @@ export default function ContentCard({
if (!link) return card
return (
<ContentCardLink
href={link.href}
openInNewTab={link.openInNewTab}
isExternal={link.isExternal}
>
{card}
</ContentCardLink>
)
}
function ContentCardLink({
children,
href,
openInNewTab,
isExternal,
}: ContentCardLinkProps) {
const Component = isExternal ? "a" : Link
const linkProps = {
href,
...(openInNewTab && {
...(link.openInNewTab && {
target: "_blank",
rel: "noopener noreferrer",
}),
}
return <Component {...linkProps}>{children}</Component>
return (
<Link href={link.href} {...linkProps}>
{card}
</Link>
)
}