hugo: generate metadata.json index

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2024-03-08 17:51:49 +01:00
parent 9ea2034b6a
commit 814e301375
3 changed files with 16 additions and 8 deletions

View File

@ -57,6 +57,11 @@ outputFormats:
isPlainText: true
mediaType: "application/json"
notAlternative: true
metadata:
baseName: metadata
isPlainText: true
mediaType: "application/json"
notAlternative: true
robots:
baseName: robots
isPlainText: true
@ -67,12 +72,8 @@ outputs:
home:
- html
- redirects
- metadata
- robots
term:
- html
- json
taxonomies:
languages:
en:

View File

@ -0,0 +1,8 @@
[
{{- range where site.Pages "Params.sitemap" "!=" false -}}
{{- $title := partialCached "utils/title.html" . . -}}
{{- $desc := partialCached "utils/description.html" . . -}}
{{- $kwd := partialCached "utils/keywords.html" . . -}}
{{- jsonify (dict "url" .Permalink "title" $title "description" $desc "keywords" $kwd) -}},
{{- end -}}
{}]

View File

@ -1,12 +1,11 @@
{{ $keywords := "" }}
{{ if .Keywords }}
{{ $keywords = .Keywords }}
{{ $keywords = strings.Split (collections.Delimit .Keywords " ") ", " }}
{{ else }}
{{ $keywords = "docker, docker open source, docker platform, distributed applications, microservices, containers, docker containers, docker software, docker virtualization" }}
{{ with .File }}
{{ with (index (site.Data.frontmatter) .Path) }}
{{ with .keywords }}
{{ $keywords = strings.Replace . "\n" " " | strings.TrimRight " " }}
{{ $keywords = strings.Split (strings.Trim . "\n") ", " }}
{{ end }}
{{ end }}
{{ end }}