mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-14 13:14:41 -04:00
theme: Implement related content tooling
This commit is contained in:
parent
fd628be6ed
commit
a943a4bb83
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -2,7 +2,7 @@
|
||||
title: math.Pi
|
||||
description: Returns the mathematical constant pi.
|
||||
categories: []
|
||||
keywords: []
|
||||
keywords: [trigonometry]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
|
@ -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: []
|
||||
|
@ -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: []
|
||||
|
@ -2,7 +2,7 @@
|
||||
title: math.ToDegrees
|
||||
description: ToDegrees converts radians into degrees.
|
||||
categories: []
|
||||
keywords: []
|
||||
keywords: [trigonometry]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
|
@ -2,7 +2,7 @@
|
||||
title: math.ToRadians
|
||||
description: ToRadians converts degrees into radians.
|
||||
categories: []
|
||||
keywords: []
|
||||
keywords: [trigonometry]
|
||||
params:
|
||||
functions_and_methods:
|
||||
aliases: []
|
||||
|
12
data/keywords.yaml
Normal file
12
data/keywords.yaml
Normal file
@ -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
|
10
hugo.toml
10
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$']
|
||||
|
22
layouts/partials/helpers/validation/validate-keywords.html
Normal file
22
layouts/partials/helpers/validation/validate-keywords.html
Normal file
@ -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 }}
|
@ -1 +1,3 @@
|
||||
{{/* Empty for now */}}
|
||||
{{- if .IsHome }}
|
||||
{{- partial "helpers/validation/validate-keywords.html" }}
|
||||
{{- end }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user