{{/* Return the requested SVG icon */}} {{/* Search for the icon in the Hugo Blox Builder icon library, falling back to user's icon library */}} {{ $dirFile := path.Split .name }} {{ $pack := .pack | default (strings.Replace $dirFile.Dir "/" "") | default "hero" }} {{ $name := $dirFile.File }} {{- $icon_pack := index site.Data.icons $pack -}} {{- $icon := index (index $icon_pack "icons") $name -}} {{ if $icon }} {{ if in (slice "hb" "brands") $pack }} {{/* Pass */}} {{ else }} {{ $icon_body := index $icon "body" }} {{ $icon_size := index $icon_pack "height" }} {{ $icon = printf `%s` (cast.ToString $icon_size) (cast.ToString $icon_size) $icon_body }} {{ end }} {{ else }} {{ with index (index site.Data.icons.hb "icons") $name -}} {{ $icon = . }} {{ else }} {{- $prefix := printf "media/icons/%s/" $pack -}} {{- $icon_path := printf "%s%s.svg" $prefix $name -}} {{- if not (fileExists (printf "assets/%s" $icon_path)) -}} {{ $pageRef := "unknown location" }} {{ if .Page }} {{ if .Page.File }} {{ if .Page.File.Path }} {{ $pageRef = .Page.File.Path }} {{ else if .Page.RelPermalink }} {{ $pageRef = .Page.RelPermalink }} {{ end }} {{ else if .Page.RelPermalink }} {{ $pageRef = .Page.RelPermalink }} {{ end }} {{ end }} {{ partial "functions/logger" (dict "page" .Page "level" "warn" "id" (printf "missing-icon-%s-%s" $pack $name) "message" (printf "The icon `%s` was not found in `assets/media/icons/%s/`. Referenced in: %s" $name $pack $pageRef) ) }} {{- end -}} {{- $icon := resources.Get $icon_path -}} {{ if $icon }} {{ $icon = .Content }} {{ else }} {{ $icon = index (index site.Data.icons.brands "icons") "hugo" }} {{ end }} {{ end }} {{ end }} {{ if .attributes }} {{ $icon = replaceRE "