Skip to content

Commit

Permalink
Match v0 name behavior for local icons (#179)
Browse files Browse the repository at this point in the history
* fix(#178): match v0 name behavior for local icons

* chore: add changeset

* chore(lint): Prettier fix

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
natemoo-re and github-actions[bot] authored Jan 2, 2024
1 parent 580b5cd commit b55cd5f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
21 changes: 21 additions & 0 deletions .changeset/hungry-steaks-relax.md
Original file line number Diff line number Diff line change
@@ -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
<Icon name="astro" />
```

**After**

```jsx
<Icon name="logos/astro" />
```
8 changes: 4 additions & 4 deletions demo/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const icon = "adjustment";
<Icon size={24} name="adjustment" />
<Icon size={24} name={icon} />
<Icon size={24} name="annotation" />
<Icon size={24} name="deno" />
<Icon name="deno" />
<Icon width={75} name="alpine" />
<Icon name="alpine-multi-color" />
<Icon size={24} name="logos/deno" />
<Icon name="logos/deno" />
<Icon width={75} name="logos/alpine" />
<Icon name="logos/alpine-multi-color" />
</article>

<article>
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/loaders/loadLocalCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit b55cd5f

@vercel
Copy link

@vercel vercel bot commented on b55cd5f Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on b55cd5f Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

api-astroicon – ./packages/service

api-astroicon-git-main-nmoo.vercel.app
api.astroicon.dev
api-astroicon-nmoo.vercel.app

Please sign in to comment.