New post in drafts and almost ready. Also on a new computer, so had to re-download all the theme and submodules. Thinking of just converting the box submodule to be native to my blog for easier maintenence. Need to proof this last post on google sheets and publish tomorrow morning.
This commit is contained in:
@ -0,0 +1,48 @@
|
||||
{{ $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 "<!--[\\s\\S]*-->" "" $file.Content -}}
|
||||
{{ $pattern := `[\s\S]*?<svg([\s\S]*)?>([\s\S]*)(<title>[\s\S]*</title>)?([\s\S]*)</svg>([\s\S]*)?` }}
|
||||
{{ $replaceWith := "" }}
|
||||
{{ with $title }}
|
||||
{{ $replaceWith = printf `<svg aria-hidden="true" class="%s" ${1}>${2}<title>%s</title>${4}</svg>` $classes . }}
|
||||
{{ else }}
|
||||
{{ $replaceWith = printf `<svg aria-hidden="true" class="%s" ${1}>${2}${3}${4}</svg>` $classes }}
|
||||
{{ end }}
|
||||
{{- return ($content | replaceRE $pattern $replaceWith | safeHTML) -}}
|
||||
Reference in New Issue
Block a user