diff --git a/internal/homepage/list_icons.go b/internal/homepage/list_icons.go index 367fc2ae..5b131114 100644 --- a/internal/homepage/list_icons.go +++ b/internal/homepage/list_icons.go @@ -219,8 +219,7 @@ func HasIcon(icon *IconURL) bool { if common.IsTest { return true } - key := NewIconKey(icon.IconSource, icon.Extra.Ref) - meta, ok := ListAvailableIcons()[key] + meta, ok := ListAvailableIcons()[icon.Extra.Key] if !ok { return false } @@ -332,6 +331,10 @@ func UpdateWalkxCodeIcons(m IconMap) error { if isLight { f = strings.TrimSuffix(f, "-light") } + isDark := strings.HasSuffix(f, "-dark") + if isDark { + f = strings.TrimSuffix(f, "-dark") + } key := NewIconKey(IconSourceWalkXCode, f) icon, ok := m[key] if !ok { @@ -342,6 +345,9 @@ func UpdateWalkxCodeIcons(m IconMap) error { if isLight { icon.Light = true } + if isDark { + icon.Dark = true + } } } return nil diff --git a/internal/homepage/list_icons_test.go b/internal/homepage/list_icons_test.go index d22e8704..4ca215a2 100644 --- a/internal/homepage/list_icons_test.go +++ b/internal/homepage/list_icons_test.go @@ -10,16 +10,22 @@ const walkxcodeIcons = `{ "png": [ "app1.png", "app1-light.png", - "app2.png" + "app2.png", + "karakeep.png", + "karakeep-dark.png" ], "svg": [ "app1.svg", - "app1-light.svg" + "app1-light.svg", + "karakeep.svg", + "karakeep-dark.svg" ], "webp": [ "app1.webp", "app1-light.webp", - "app2.webp" + "app2.webp", + "karakeep.webp", + "karakeep-dark.webp" ] }` @@ -98,8 +104,8 @@ func TestListWalkxCodeIcons(t *testing.T) { if err := UpdateWalkxCodeIcons(m); err != nil { t.Fatal(err) } - if len(m) != 2 { - t.Fatalf("expect 2 icons, got %d", len(m)) + if len(m) != 3 { + t.Fatalf("expect 3 icons, got %d", len(m)) } test := []testCases{ { @@ -118,6 +124,15 @@ func TestListWalkxCodeIcons(t *testing.T) { WebP: true, }, }, + { + Key: NewIconKey(IconSourceWalkXCode, "karakeep"), + IconMeta: IconMeta{ + SVG: true, + PNG: true, + WebP: true, + Dark: true, + }, + }, } runTests(t, m, test) }