Skip to content

Commit 2f1b6f9

Browse files
committed
feat(nx-dev): allow link-card components to take an image URL
1 parent 781b300 commit 2f1b6f9

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

nx-dev/ui-markdoc/src/lib/tags/cards.component.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export function LinkCard({
117117
}: {
118118
title: string;
119119
type: string;
120-
icon: string; // `icon` is the link to the SVG file
120+
icon: string; // Can be either a component name or a direct image URL
121121
url: string;
122122
appearance?: 'default' | 'small';
123123
}): JSX.Element {
@@ -138,13 +138,20 @@ export function LinkCard({
138138
}
139139
)}
140140
>
141-
{icon &&
142-
(frameworkIcons[icon as Framework]?.image ||
143-
callIfFunction(nxDevIcons[icon as keyof typeof nxDevIcons]) ||
144-
callIfFunction(
145-
(heroIcons[icon as keyof typeof heroIcons] as any)?.render,
146-
{ className: 'w-full h-full' }
147-
))}
141+
{icon.startsWith('/') ? (
142+
<img
143+
src={icon}
144+
alt={title}
145+
className="h-full w-full object-contain"
146+
/>
147+
) : (
148+
frameworkIcons[icon as Framework]?.image ||
149+
callIfFunction(nxDevIcons[icon as keyof typeof nxDevIcons]) ||
150+
callIfFunction(
151+
(heroIcons[icon as keyof typeof heroIcons] as any)?.render,
152+
{ className: 'w-full h-full' }
153+
)
154+
)}
148155
</div>
149156
)}
150157
<div

0 commit comments

Comments
 (0)