Skip to content

Commit de00407

Browse files
committed
Fix CTA + double <a> tag on homepage cards
1 parent 17d2eea commit de00407

File tree

2 files changed

+48
-13
lines changed

2 files changed

+48
-13
lines changed

docusaurus/src/components/Card/Card.jsx

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,50 @@ export function CardCta({
103103
text,
104104
color = '#000',
105105
withArrow,
106+
asPlainContent = false,
106107
...rest
107108
}) {
108-
return (
109-
<Link
110-
className={className}
111-
to={to}
112-
style={{
113-
color: color,
114-
paddingTop: '15px',
115-
paddingBottom: '50px',
116-
}}>
109+
const contentJSX = (
110+
<>
117111
{text}
118112
{withArrow && (
119113
<span className={styles.card__title__arrow}>
120114
<IconArrow />
121115
</span>
122116
)}
117+
</>
118+
);
119+
120+
if (asPlainContent) {
121+
return (
122+
<div
123+
className={className}
124+
style={{
125+
color: color,
126+
paddingTop: '15px',
127+
paddingBottom: '50px',
128+
}}
129+
{...rest}
130+
>
131+
{contentJSX}
132+
</div>
133+
);
134+
}
135+
136+
return (
137+
<Link
138+
className={className}
139+
to={to}
140+
style={{
141+
color: color,
142+
paddingTop: '15px',
143+
paddingBottom: '50px',
144+
}}
145+
{...rest}
146+
>
147+
{contentJSX}
123148
</Link>
124-
)
149+
);
125150
}
126151

127152
export function Card({

docusaurus/src/pages/home/Home.jsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,21 @@ export default function PageHome() {
154154
styles.home__categories__item,
155155
)}
156156
>
157-
<Card categoryType={categoryType} asCallToAction>
157+
<Card categoryType={categoryType} href={categoryItemCardLink} asCallToAction>
158158
{categoryItemCardIconName && <CardIcon name={categoryItemCardIconName} color={categoryItemCardIconColor}/>}
159-
{categoryItemCardTitle && <CardTitle >{categoryItemCardTitle}</CardTitle>}
159+
{categoryItemCardTitle && <CardTitle>{categoryItemCardTitle}</CardTitle>}
160160
{categoryItemCardDescription && <CardDescription>{categoryItemCardDescription}</CardDescription>}
161-
{categoryItemCardLink && <CardCta withArrow to={categoryItemCardLink} text={categoryItemCardCtaText} color={categoryItemCardIconColor} className="category-card-cta" />}
161+
{/* Use asPlainContent=true when parent Card already has asCallToAction */}
162+
{categoryItemCardLink &&
163+
<CardCta
164+
asPlainContent={true}
165+
withArrow={true}
166+
to={categoryItemCardLink}
167+
text={categoryItemCardCtaText}
168+
color={categoryItemCardIconColor}
169+
className="category-card-cta"
170+
/>
171+
}
162172
{categoryItemCardImgSrc && <CardImg src={categoryItemCardImgSrc} />}
163173
</Card>
164174
{/* {categoryItem.links && (

0 commit comments

Comments
 (0)