Skip to content

Commit 695fcf7

Browse files
committed
fixed borken test, and failing link.
1 parent ce4583d commit 695fcf7

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/pages/api/[version]/icons/[iconName].ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const prerender = false
1313
* Returns actual SVG markup for the icon.
1414
* Icon name: React component name (e.g., FaCircle, MdHome)
1515
*/
16-
export const GET: APIRoute = async ({ params, url }) => {
16+
export const GET: APIRoute = async ({ params, url, locals }) => {
1717
const { version, iconName: reactName } = params
1818

1919
if (!version) {
@@ -48,7 +48,12 @@ export const GET: APIRoute = async ({ params, url }) => {
4848
)
4949
}
5050

51-
const svgs = await fetchIconSvgs(url, version, 'pf', assetsFetch)
51+
const svgs = await fetchIconSvgs(
52+
url,
53+
version,
54+
'pf',
55+
(locals as any)?.runtime?.env?.ASSETS?.fetch,
56+
)
5257
const svg = svgs?.[reactName] ?? null
5358

5459
if (!svg) {

src/utils/icons/fetch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ export async function fetchIconSvgs(
4040
url: URL,
4141
version: string,
4242
setId: string,
43+
assetsFetch?: (input: Request) => Promise<Response>,
4344
): Promise<Record<string, string> | null> {
44-
const iconsSvgsUrl = new URL(`/api/${version}/icons/${setId}`, url.origin)
45+
const iconsSvgsUrl = new URL(`/api/${version}/icons/${setId}.json`, url.origin)
4546
const response = assetsFetch
4647
? await assetsFetch(new Request(iconsSvgsUrl))
4748
: await fetch(iconsSvgsUrl)

0 commit comments

Comments
 (0)