Skip to content

Commit 3c41a72

Browse files
committed
wip
1 parent f51b39d commit 3c41a72

File tree

7 files changed

+89
-6
lines changed

7 files changed

+89
-6
lines changed

src/components/LinkCard2.astro

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
import { z } from "astro:schema";
3+
import ReactLinkCard2 from "./LinkCard2.tsx";
4+
5+
const props = z.object({
6+
title: z.string(),
7+
description: z.string(),
8+
href: z.string(),
9+
icon: z.string(),
10+
});
11+
12+
const { title, description, href, icon } = props.parse(Astro.props);
13+
14+
const images = import.meta.glob<string>("/src/icons/*.svg", {
15+
query: "?raw",
16+
import: "default",
17+
});
18+
19+
const image = images[`/src/icons/${icon}.svg`];
20+
21+
if (!image) {
22+
throw new Error(`[LinkCard2]: Icon ${icon} not found in /src/icons/`);
23+
}
24+
25+
const svg = await image();
26+
---
27+
28+
<ReactLinkCard2 title={title} description={description} href={href} svg={svg} />

src/components/LinkCard2.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import Markdown from "react-markdown";
2+
3+
type Props = {
4+
title: string;
5+
description: string;
6+
href: string;
7+
svg: string;
8+
};
9+
10+
export default function LinkCard2({ title, description, href, svg }: Props) {
11+
return (
12+
<a
13+
href={href}
14+
className="not-content flex flex-col gap-4 rounded border border-cl1-gray-8 bg-cl1-white p-6 no-underline dark:border-cl1-gray-2 dark:bg-cl1-gray-0"
15+
>
16+
<div>
17+
{svg && (
18+
<div
19+
className="flex h-10 w-10 items-center justify-center rounded bg-cl1-orange-9 fill-cl1-brand-orange dark:bg-cl1-orange-0"
20+
dangerouslySetInnerHTML={{ __html: svg }}
21+
/>
22+
)}
23+
</div>
24+
<div className="flex flex-col gap-2 text-black">
25+
<p className="font-semibold">{title}</p>
26+
<div className="text-sm">
27+
<Markdown disallowedElements={["a"]} unwrapDisallowed={true}>
28+
{description}
29+
</Markdown>
30+
</div>
31+
</div>
32+
</a>
33+
);
34+
}
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,43 @@
11
---
2+
import LinkCard2 from "../LinkCard2.astro";
3+
24
const topCards = [
35
{
46
label: "Fundamentals",
57
href: "/fundamentals/",
68
description: "How Cloudflare works and how to get started.",
9+
icon: "growth-outline",
710
},
811
{
912
label: "Docs directory",
1013
href: "/products/",
1114
description: "How to use specific Cloudflare products.",
15+
icon: "documentation-outline",
1216
},
1317
{
1418
label: "Learning paths",
1519
href: "/learning-paths/",
1620
description: "Step-by-step walkthroughs on a variety of concepts.",
21+
icon: "cloudflare-ruleset-engine-outline",
1722
},
1823
{
1924
label: "Reference architectures",
2025
href: "/reference-architecture/",
2126
description: "How our products are designed and architected.",
27+
icon: "code-branch-outline",
2228
},
2329
];
2430
---
2531

2632
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4">
2733
{
2834
topCards.map((card) => (
29-
<a
35+
<LinkCard2
36+
title={card.label}
37+
description={card.description}
3038
href={card.href}
31-
class="rounded-md border border-solid border-gray-200 p-6 !text-inherit no-underline hover:bg-gray-50 dark:border-gray-700 dark:hover:bg-gray-800"
32-
>
33-
<p class="!mt-0 font-semibold">{card.label}</p>
34-
<div class="leading-2 !mt-1 text-sm">{card.description}</div>
35-
</a>
39+
icon={card.icon}
40+
/>
3641
))
3742
}
3843
</div>
Lines changed: 5 additions & 0 deletions
Loading

src/icons/code-branch-outline.svg

Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading

src/icons/growth-outline.svg

Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)