From ae0a7f72358dee39a133663423b499e4525c06cb Mon Sep 17 00:00:00 2001 From: Herman Z <2526045+germanz@users.noreply.github.com> Date: Thu, 20 Oct 2022 19:42:37 +0200 Subject: [PATCH] feat: pass props to custom resolver (#42) Co-authored-by: Nate Moore --- .changeset/green-camels-teach.md | 5 +++++ demo/src/icons/custom.ts | 6 ++++++ demo/src/pages/index.astro | 12 +++++++++--- packages/core/lib/utils.ts | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 .changeset/green-camels-teach.md create mode 100644 demo/src/icons/custom.ts diff --git a/.changeset/green-camels-teach.md b/.changeset/green-camels-teach.md new file mode 100644 index 00000000..6405db4a --- /dev/null +++ b/.changeset/green-camels-teach.md @@ -0,0 +1,5 @@ +--- +"astro-icon": minor +--- + +Pass props to custom resolvers diff --git a/demo/src/icons/custom.ts b/demo/src/icons/custom.ts new file mode 100644 index 00000000..6732a2ef --- /dev/null +++ b/demo/src/icons/custom.ts @@ -0,0 +1,6 @@ +export default async (name: string, { size }): Promise => { + return ` + + + `; +}; diff --git a/demo/src/pages/index.astro b/demo/src/pages/index.astro index b78a0a22..f624a2fd 100644 --- a/demo/src/pages/index.astro +++ b/demo/src/pages/index.astro @@ -28,7 +28,7 @@ import { Icon } from 'astro-icon';

The Icon component will optimize and inline any SVG file inside of src/icons/

Alternatively, see the Sprite method.

- +

Local

@@ -39,9 +39,15 @@ import { Icon } from 'astro-icon';

Custom remote source

- + +
+ +
+

Custom SVG resolver

+ +
- +

Local dependencies

diff --git a/packages/core/lib/utils.ts b/packages/core/lib/utils.ts index 0a4280da..daa2485d 100644 --- a/packages/core/lib/utils.ts +++ b/packages/core/lib/utils.ts @@ -170,7 +170,7 @@ export default async function load( if (typeof get === "undefined") { get = getFromService.bind(null, pack); } - const contents = await get(name); + const contents = await get(name, inputProps); if (!contents) { throw new Error( ` did not return an icon!`