Skip to content

Commit 21bed8a

Browse files
authored
Merge pull request #754 from jerensl/learning-card
refactor: make the link tag optional on learning card
2 parents e427107 + 20983da commit 21bed8a

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/custom/LearningCard/LearningCard.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,19 @@ interface Tutorial {
2525

2626
interface Props {
2727
tutorial: Tutorial;
28-
path: string;
28+
path?: string;
2929
courseCount: number;
3030
courseType: string;
3131
}
3232

33+
const OptionalLink: React.FC<React.PropsWithChildren<{ path?: string }>> = ({ path, children }) => {
34+
if (!path) {
35+
return <>{children}</>;
36+
}
37+
38+
return <CardLink href={path}>{children}</CardLink>;
39+
};
40+
3341
const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType }) => {
3442
return (
3543
<CardWrapper>
@@ -57,7 +65,7 @@ const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType
5765
</CardParent>
5866
</Card2>
5967
) : (
60-
<CardLink href={path}>
68+
<OptionalLink path={path}>
6169
<CardActive>
6270
<CardParent style={{ borderTop: `5px solid ${tutorial.frontmatter.themeColor}` }}>
6371
<div>
@@ -88,7 +96,7 @@ const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType
8896
</div>
8997
</CardParent>
9098
</CardActive>
91-
</CardLink>
99+
</OptionalLink>
92100
)}
93101
</CardWrapper>
94102
);

0 commit comments

Comments
 (0)