diff --git a/content/en/functions/math/Acos.md b/content/en/functions/math/Acos.md index 32537e2dd..9a953788d 100644 --- a/content/en/functions/math/Acos.md +++ b/content/en/functions/math/Acos.md @@ -2,7 +2,7 @@ title: math.Acos description: Returns the arccosine, in radians, of the given number. categories: [] -keywords: [] +keywords: [trigonometry] params: functions_and_methods: aliases: [] diff --git a/content/en/functions/math/Asin.md b/content/en/functions/math/Asin.md index 76114a72e..45ff754f5 100644 --- a/content/en/functions/math/Asin.md +++ b/content/en/functions/math/Asin.md @@ -2,7 +2,7 @@ title: math.Asin description: Returns the arcsine, in radians, of the given number. categories: [] -keywords: [] +keywords: [trigonometry] params: functions_and_methods: aliases: [] diff --git a/content/en/functions/math/Atan.md b/content/en/functions/math/Atan.md index 5c8268b47..a98171e4b 100644 --- a/content/en/functions/math/Atan.md +++ b/content/en/functions/math/Atan.md @@ -2,7 +2,7 @@ title: math.Atan description: Returns the arctangent, in radians, of the given number. categories: [] -keywords: [] +keywords: [trigonometry] params: functions_and_methods: aliases: [] diff --git a/content/en/functions/math/Atan2.md b/content/en/functions/math/Atan2.md index 942fffdf8..fd37903b1 100644 --- a/content/en/functions/math/Atan2.md +++ b/content/en/functions/math/Atan2.md @@ -2,7 +2,7 @@ title: math.Atan2 description: Returns the arctangent, in radians, of the given number pair, determining the correct quadrant from their signs. categories: [] -keywords: [] +keywords: [trigonometry] params: functions_and_methods: aliases: [] diff --git a/content/en/functions/math/Cos.md b/content/en/functions/math/Cos.md index 249a064bb..bb0f3b9b2 100644 --- a/content/en/functions/math/Cos.md +++ b/content/en/functions/math/Cos.md @@ -2,7 +2,7 @@ title: math.Cos description: Returns the cosine of the given radian number. categories: [] -keywords: [] +keywords: [trigonometry] params: functions_and_methods: aliases: [] diff --git a/content/en/functions/math/Pi.md b/content/en/functions/math/Pi.md index 0bc74bf03..44125f544 100644 --- a/content/en/functions/math/Pi.md +++ b/content/en/functions/math/Pi.md @@ -2,7 +2,7 @@ title: math.Pi description: Returns the mathematical constant pi. categories: [] -keywords: [] +keywords: [trigonometry] params: functions_and_methods: aliases: [] diff --git a/content/en/functions/math/Sin.md b/content/en/functions/math/Sin.md index b5ab86bb8..3db4d21c7 100644 --- a/content/en/functions/math/Sin.md +++ b/content/en/functions/math/Sin.md @@ -2,7 +2,7 @@ title: math.Sin description: Returns the sine of the given radian number. categories: [] -keywords: [] +keywords: [trigonometry] params: functions_and_methods: aliases: [] diff --git a/content/en/functions/math/Tan.md b/content/en/functions/math/Tan.md index c4f861c05..be8f8ac88 100644 --- a/content/en/functions/math/Tan.md +++ b/content/en/functions/math/Tan.md @@ -2,7 +2,7 @@ title: math.Tan description: Returns the tangent of the given radian number. categories: [] -keywords: [] +keywords: [trigonometry] params: functions_and_methods: aliases: [] diff --git a/content/en/functions/math/ToDegrees.md b/content/en/functions/math/ToDegrees.md index f01cd4728..9438c46bf 100644 --- a/content/en/functions/math/ToDegrees.md +++ b/content/en/functions/math/ToDegrees.md @@ -2,7 +2,7 @@ title: math.ToDegrees description: ToDegrees converts radians into degrees. categories: [] -keywords: [] +keywords: [trigonometry] params: functions_and_methods: aliases: [] diff --git a/content/en/functions/math/ToRadians.md b/content/en/functions/math/ToRadians.md index b5acbb65b..8e5132490 100644 --- a/content/en/functions/math/ToRadians.md +++ b/content/en/functions/math/ToRadians.md @@ -2,7 +2,7 @@ title: math.ToRadians description: ToRadians converts degrees into radians. categories: [] -keywords: [] +keywords: [trigonometry] params: functions_and_methods: aliases: [] diff --git a/data/keywords.yaml b/data/keywords.yaml new file mode 100644 index 000000000..a12f45c4a --- /dev/null +++ b/data/keywords.yaml @@ -0,0 +1,12 @@ +# 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. + +- menu +- resource +- trigonometry diff --git a/hugo.toml b/hugo.toml index 92a638072..18345e929 100644 --- a/hugo.toml +++ b/hugo.toml @@ -36,7 +36,7 @@ disableAliases = true path = '{/news/**}' [frontmatter] - date = ['date'] # do not add publishdate; it will affect page sorting + date = ['date'] # do not add publishdate; it will affect page sorting expiryDate = ['expirydate'] lastmod = [':git', 'lastmod', 'publishdate', 'date'] publishDate = ['publishdate', 'date'] @@ -110,6 +110,14 @@ disableAliases = true [params.render_hooks.link] errorLevel = 'warning' # ignore (default), warning, or error (fails the build) +[related] + includeNewer = true + threshold = 80 + toLower = true + [[related.indices]] + name = 'keywords' + weight = 1 + [security] [security.funcs] getenv = ['^HUGO_', '^REPOSITORY_URL$', '^BRANCH$'] diff --git a/layouts/partials/helpers/validation/validate-keywords.html b/layouts/partials/helpers/validation/validate-keywords.html new file mode 100644 index 000000000..3447ec4ef --- /dev/null +++ b/layouts/partials/helpers/validation/validate-keywords.html @@ -0,0 +1,22 @@ +{{/* 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 }} diff --git a/layouts/partials/layouts/hooks/body-end.html b/layouts/partials/layouts/hooks/body-end.html index ba4a81300..9ffd93ba8 100644 --- a/layouts/partials/layouts/hooks/body-end.html +++ b/layouts/partials/layouts/hooks/body-end.html @@ -1 +1,3 @@ -{{/* Empty for now */}} +{{- if .IsHome }} + {{- partial "helpers/validation/validate-keywords.html" }} +{{- end }}