hugo: improve templating for keywords and descriptions

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2024-05-08 20:06:24 +02:00
parent 0ca7526092
commit a56d652fdd
2 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{{ $desc := "" }} {{ $desc := "" }}
{{ if .Description }} {{ if .Description }}
{{ $desc = .Description }} {{ $desc = strings.Replace .Description "\n" " " }}
{{ else }} {{ else }}
{{ with .File }} {{ with .File }}
{{ with (index (site.Data.frontmatter) .Path) }} {{ with (index (site.Data.frontmatter) .Path) }}

View File

@ -1,11 +1,11 @@
{{ $keywords := "" }} {{ $keywords := "" }}
{{ if .Keywords }} {{ if .Keywords }}
{{ $keywords = strings.Split (collections.Delimit .Keywords " ") ", " }} {{ $keywords = delimit .Keywords " " }}
{{ else }} {{ else }}
{{ with .File }} {{ with .File }}
{{ with (index (site.Data.frontmatter) .Path) }} {{ with (index (site.Data.frontmatter) .Path) }}
{{ with .keywords }} {{ with .keywords }}
{{ $keywords = strings.Split (strings.Trim . "\n") ", " }} {{ $keywords = strings.Replace (strings.Trim . "\n") "\n" " " }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}