hugo/docs/layouts/_partials/helpers/validation/validate-keywords.html
Bjørn Erik Pedersen 61a286595e
Some checks are pending
Test / test (1.23.x, ubuntu-latest) (push) Waiting to run
Test / test (1.23.x, windows-latest) (push) Waiting to run
Test / test (1.24.x, ubuntu-latest) (push) Waiting to run
Test / test (1.24.x, windows-latest) (push) Waiting to run
Merge commit 'b3d87dd0fd'
2025-04-24 10:23:16 +02:00

22 lines
886 B
HTML

{{/* prettier-ignore-start */ -}}
{{- /*
We use the front matter keywords field to determine related content. To ensure
consistency, during site build we validate each keyword against the entries in
data/keywords.yaml.
As of March 5, 2025, this feature is experimental, pending usability
assessment. We anticipate that the number of additions to data/keywords.yaml
will decrease over time, though the initial implementation will require some
effort.
*/}}
{{/* prettier-ignore-end */ -}}
{{- $t := debug.Timer "validateKeywords" }}
{{- $allowedKeywords := collections.Apply site.Data.keywords "strings.ToLower" "." }}
{{- range $p := site.Pages }}
{{- range .Params.keywords }}
{{- if not (in $allowedKeywords (lower .)) }}
{{- warnf "The word or phrase %q is not in the keywords data file. See %s." . $p.Page.String }}
{{- end }}
{{- end }}
{{- end }}
{{- $t.Stop }}