Skip to content

Commit

Permalink
fix bug in register_icons when looping through heroicon templates (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadavidthomas authored Mar 23, 2024
1 parent 2ee0717 commit 294d5d8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ and this project attempts to adhere to [Semantic Versioning](https://semver.org/

## [Unreleased]

### Fixed

- Fixed a bug where the icons being registered by the wagtail hook were not being found.

## [0.2.0]

### Added
Expand Down
4 changes: 3 additions & 1 deletion src/wagtail_heroicons/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
@hooks.register("register_icons")
def register_icons(icons):
template_dir = Path(__file__).parent / "templates" / "wagtail_heroicons"
heroicons = [file.stem for file in template_dir.glob("*.svg")]
heroicons = [
f"{file.parent.name}/{file.stem}" for file in template_dir.rglob("*.svg")
]
return icons + heroicons
5 changes: 4 additions & 1 deletion tests/test_wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ def test_register_icons():
str(filepath) for dir_ in app_template_dirs for filepath in dir_.rglob("*")
]

assert all(icon in template_files for icon in all_icons)
assert all(
any(template_file.endswith(f"{icon}.svg") for template_file in template_files)
for icon in all_icons
)

0 comments on commit 294d5d8

Please sign in to comment.