Support embed icons on bookmarks URLs

This commit is contained in:
Hítalo Silva 2025-04-12 19:48:09 -03:00
parent eeda2104a6
commit 90254b92d2
No known key found for this signature in database
GPG Key ID: 72B5E5625EC6EE91
2 changed files with 3 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"html/template" "html/template"
"math" "math"
"strconv" "strconv"
"strings"
"golang.org/x/text/language" "golang.org/x/text/language"
"golang.org/x/text/message" "golang.org/x/text/message"
@ -53,6 +54,7 @@ var globalTemplateFunctions = template.FuncMap{
return template.HTML(value + ` <span class="color-base size-h5">` + label + `</span>`) return template.HTML(value + ` <span class="color-base size-h5">` + label + `</span>`)
}, },
"hasPrefix": strings.HasPrefix,
} }
func mustParseTemplate(primary string, dependencies ...string) *template.Template { func mustParseTemplate(primary string, dependencies ...string) *template.Template {

View File

@ -13,7 +13,7 @@
<div class="flex items-center gap-10"> <div class="flex items-center gap-10">
{{- if ne "" .Icon.URL }} {{- if ne "" .Icon.URL }}
<div class="bookmarks-icon-container"> <div class="bookmarks-icon-container">
<img class="bookmarks-icon{{ if .Icon.IsFlatIcon }} flat-icon{{ end }}" src="{{ .Icon.URL }}" alt="" loading="lazy"> <img class="bookmarks-icon{{ if .Icon.IsFlatIcon }} flat-icon{{ end }}" src="{{ if hasPrefix .Icon.URL "data:image/" }}{{ .Icon.URL | safeURL }}{{ else }}{{ .Icon.URL }}{{ end }}" alt="" loading="lazy">
</div> </div>
{{- end }} {{- end }}
<a href="{{ .URL | safeURL }}" class="bookmarks-link {{ if .HideArrow }}bookmarks-link-no-arrow {{ end }}color-highlight size-h4" {{ if .Target }}target="{{ .Target }}"{{ end }} rel="noreferrer">{{ .Title }}</a> <a href="{{ .URL | safeURL }}" class="bookmarks-link {{ if .HideArrow }}bookmarks-link-no-arrow {{ end }}color-highlight size-h4" {{ if .Target }}target="{{ .Target }}"{{ end }} rel="noreferrer">{{ .Title }}</a>