refactor(favicon): enhance FindIcon function to support icon variants

- Updated FindIcon to accept an additional variant parameter for improved icon fetching.
- Adjusted FavIcon and GetFavIconFromAlias functions to utilize the new variant handling logic.
This commit is contained in:
yusing
2025-12-15 14:54:05 +08:00
parent baa7e72ad6
commit 31bf889d4a
3 changed files with 15 additions and 7 deletions

View File

@@ -150,9 +150,13 @@ type contextValue struct {
uri string
}
func FindIcon(ctx context.Context, r route, uri string) (FetchResult, error) {
func FindIcon(ctx context.Context, r route, uri string, variant IconVariant) (FetchResult, error) {
for _, ref := range r.References() {
result, err := fetchIcon(ctx, sanitizeName(ref))
ref = sanitizeName(ref)
if variant != IconVariantNone {
ref += "-" + string(variant)
}
result, err := fetchIcon(ctx, ref)
if err == nil {
return result, err
}