mirror of
https://github.com/jannikmenzel/iFSR-Website.git
synced 2025-06-06 17:48:46 +02:00
improved svg rendering and prepared headline icons
This commit is contained in:
parent
fb2e61bc97
commit
7e15d46684
9 changed files with 117 additions and 62 deletions
21
layouts/_default/_markup/render-heading.html
Normal file
21
layouts/_default/_markup/render-heading.html
Normal file
|
@ -0,0 +1,21 @@
|
|||
{{- $level := .Level -}}
|
||||
{{- $text := .Text -}}
|
||||
|
||||
{{- $re := `\[(\w+)\]` -}}
|
||||
{{- $matches := findRE $re $text -}}
|
||||
|
||||
{{- if gt (len $matches) 0 -}}
|
||||
{{- range $i, $match := $matches -}}
|
||||
{{- $iconName := replaceRE `^\[(\w+)\]$` `$1` $match -}}
|
||||
{{- $iconPath := printf "icons/%s.svg" $iconName -}}
|
||||
{{- $svg := resources.Get $iconPath -}}
|
||||
{{- if $svg -}}
|
||||
{{- $svgContent := $svg.Content | safeHTML -}}
|
||||
{{- $text = replace $text $match (printf `<span class="icon">%s</span>` $svgContent) -}}
|
||||
{{- else -}}
|
||||
{{- $text = replace $text $match (printf `<span class="icon-missing">[%s]</span>` $iconName) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
<h{{ $level }}>{{ $text | safeHTML }}</h{{ $level }}>
|
Loading…
Add table
Add a link
Reference in a new issue