From b55cd5f92da8988467e86cb2a45d3dfa82ef3ffa Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 2 Jan 2024 14:49:12 -0600 Subject: [PATCH] Match v0 name behavior for local icons (#179) * fix(#178): match v0 name behavior for local icons * chore: add changeset * chore(lint): Prettier fix --------- Co-authored-by: github-actions[bot] --- .changeset/hungry-steaks-relax.md | 21 +++++++++++++++++++ demo/src/pages/index.astro | 8 +++---- .../core/src/loaders/loadLocalCollection.ts | 2 ++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 .changeset/hungry-steaks-relax.md diff --git a/.changeset/hungry-steaks-relax.md b/.changeset/hungry-steaks-relax.md new file mode 100644 index 00000000..5d507178 --- /dev/null +++ b/.changeset/hungry-steaks-relax.md @@ -0,0 +1,21 @@ +--- +"astro-icon": patch +--- + +**BREAKING**: Requires subdirectory prefixes for local icons. + +This fixes a regression introduced in v1 and matches the previous v0 `name` behavior. + +As an example, the `src/icons/logos/astro.svg` file could previously be referenced by the name `astro`. It should correctly be referenced as `logos/astro`. + +**Before** + +```jsx + +``` + +**After** + +```jsx + +``` diff --git a/demo/src/pages/index.astro b/demo/src/pages/index.astro index caaafeee..1076e708 100644 --- a/demo/src/pages/index.astro +++ b/demo/src/pages/index.astro @@ -19,10 +19,10 @@ const icon = "adjustment"; - - - - + + + +
diff --git a/packages/core/src/loaders/loadLocalCollection.ts b/packages/core/src/loaders/loadLocalCollection.ts index 557cda29..5dd7a268 100644 --- a/packages/core/src/loaders/loadLocalCollection.ts +++ b/packages/core/src/loaders/loadLocalCollection.ts @@ -16,6 +16,8 @@ export default async function createLocalCollection( const local = await importDirectory(dir, { prefix: "local", keepTitles: true, + includeSubDirs: true, + keyword: (file) => file.subdir + file.file, }); // Validate, clean up, fix palette and optimize