{{ $item := "" }} {{ $theme := "" }} {{ $class := "" }} {{ $href := "" }} {{ $title := "" }} {{ if reflect.IsMap . }} {{ $item = .icon }} {{ $theme = .theme }} {{ $class = .class }} {{/* {{ warnf "themeInsideMap: %s" $theme }} */}} {{ $title = .title }} {{ else }} {{ $item = . }} {{ end }} {{ $theme := $theme | default "default" }} {{ $classes := "" }} {{/* {{ warnf "themeAfterLoop: %s" $theme }} */}} {{ $file := "" }} {{/* ?? Check data type ? See https://www.brijumaquio.com/get-data-type-in-hugo-framework */}} {{ if eq (printf "%T" $item) "*resources.resourceAdapter" }} {{ $file = $item }} {{ else if eq (printf "%T" $item) "string" }} {{ $folder := $theme }} {{/* {{ warnf "themeToFolder: %s" $theme }} */}} {{/* {{ warnf "folderFromTheme : %s" $folder }} */}} {{ $classes = printf "%v%v%v%v%v" $theme " ico ico-" $item " " $class }} {{ $path := printf "svg/%s/%s.svg" $folder $item }} {{ $file = resources.Get $path }} {{/* {{ warnf "Loading icon from ico.html shortcode: %s" $item }} */}} {{/* {{ warnf "theme: %s" $theme }} */}} {{ else }} {{/* Get the filename, remove extension, add custom classes */}} {{ $classes = print (replace (path.Base $item) ".svg" "" | anchorize) " ico " }} {{ $file = resources.Get $item }} {{ end }} {{ if eq $file nil }} {{ warnf "Error detected in ico shortcode: Icon not found: %s" $file }} {{ return }} {{ end }} {{- $content := replaceRE "" "" $file.Content -}} {{ $pattern := `[\s\S]*?([\s\S]*)([\s\S]*)?([\s\S]*)([\s\S]*)?` }} {{ $replaceWith := "" }} {{ with $title }} {{ $replaceWith = printf `` $classes . }} {{ else }} {{ $replaceWith = printf `` $classes }} {{ end }} {{- return ($content | replaceRE $pattern $replaceWith | safeHTML) -}}