fix: use link component for all types of links to add proper styling to set text decoration none when external
This commit is contained in:
@@ -12,10 +12,3 @@ export interface ContentCardProps {
|
|||||||
promoText?: string
|
promoText?: string
|
||||||
className?: string
|
className?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContentCardLinkProps {
|
|
||||||
href: string
|
|
||||||
openInNewTab?: boolean
|
|
||||||
isExternal?: boolean
|
|
||||||
children: React.ReactNode
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
|||||||
|
|
||||||
import styles from "./contentCard.module.css"
|
import styles from "./contentCard.module.css"
|
||||||
|
|
||||||
import type { ContentCardLinkProps, ContentCardProps } from "./contentCard"
|
import type { ContentCardProps } from "./contentCard"
|
||||||
|
|
||||||
export default function ContentCard({
|
export default function ContentCard({
|
||||||
heading,
|
heading,
|
||||||
@@ -40,31 +40,16 @@ export default function ContentCard({
|
|||||||
|
|
||||||
if (!link) return card
|
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 = {
|
const linkProps = {
|
||||||
href,
|
...(link.openInNewTab && {
|
||||||
...(openInNewTab && {
|
|
||||||
target: "_blank",
|
target: "_blank",
|
||||||
rel: "noopener noreferrer",
|
rel: "noopener noreferrer",
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
return <Component {...linkProps}>{children}</Component>
|
return (
|
||||||
|
<Link href={link.href} {...linkProps}>
|
||||||
|
{card}
|
||||||
|
</Link>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user