|
1 | 1 | import { useState, type ChangeEvent } from "react"; |
2 | | -import { getIconData, iconToSVG } from "@iconify/utils"; |
3 | | -// @ts-ignore virtual module |
4 | | -import iconCollection from "virtual:astro-icon"; |
5 | | -import { type CollectionEntry } from "astro:content"; |
| 2 | +import type { CollectionEntry } from "astro:content"; |
| 3 | +import type { IconifyIconBuildResult } from "@iconify/utils"; |
6 | 4 |
|
7 | 5 | const ProductCatalog = ({ |
8 | 6 | products, |
9 | 7 | }: { |
10 | | - products: CollectionEntry<"products">[]; |
| 8 | + products: (CollectionEntry<"products"> & { |
| 9 | + icon: IconifyIconBuildResult; |
| 10 | + groups: string[]; |
| 11 | + })[]; |
11 | 12 | }) => { |
12 | 13 | const [filters, setFilters] = useState<{ |
13 | 14 | search: string; |
@@ -94,29 +95,24 @@ const ProductCatalog = ({ |
94 | 95 | </p> |
95 | 96 | </div> |
96 | 97 | )} |
97 | | - {productList.map((product, idx) => { |
98 | | - const iconData = getIconData(iconCollection.local, product.id); |
99 | | - let icon = null; |
100 | | - if (iconData) { |
101 | | - icon = iconToSVG(iconData); |
102 | | - } |
| 98 | + {productList.map((product) => { |
103 | 99 | return ( |
104 | 100 | <a |
105 | 101 | href={product.data.product.url} |
106 | 102 | className="self-stretch p-3 border-gray-200 dark:border-gray-700 border-solid border rounded-md block !text-inherit no-underline hover:bg-gray-50 dark:hover:bg-black" |
107 | 103 | > |
108 | 104 | <div className="flex items-center"> |
109 | | - {icon && ( |
| 105 | + {product.icon && ( |
110 | 106 | <div className="rounded-full p-2 bg-orange-50 mr-2 text-orange-500"> |
111 | 107 | <svg |
112 | | - {...icon.attributes} |
| 108 | + {...product.icon.attributes} |
113 | 109 | width={28} |
114 | 110 | height={28} |
115 | | - dangerouslySetInnerHTML={{ __html: icon.body }} |
| 111 | + dangerouslySetInnerHTML={{ __html: product.icon.body }} |
116 | 112 | /> |
117 | 113 | </div> |
118 | 114 | )} |
119 | | - {!icon && ( |
| 115 | + {!product.icon && ( |
120 | 116 | <div className="flex items-center justify-center leading-none rounded-full p-2 bg-orange-50 mr-2 text-[color:var(--orange-accent-200)] text-xl font-bold w-11 h-11"> |
121 | 117 | {product.data.name.substr(0, 1)} |
122 | 118 | </div> |
|
0 commit comments