Skip to content

Commit b9efb82

Browse files
committed
[Docs] Resolve .Site.AllPages deprecation
Signed-off-by: Junnygram <junnexclusive@gmail.com>
1 parent 2836594 commit b9efb82

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{- $.Scratch.Add "offline-search-index" slice -}}
2+
{{- range hugo.Sites -}}
3+
{{- range where .Pages ".Params.exclude_search" "!=" true -}}
4+
{{- /* We have to apply `htmlUnescape` again after `truncate` because `truncate`
5+
applies `html.EscapeString` if the argument is not HTML. */ -}}
6+
{{- /* Individual taxonomies can be added in the next line by adding '"taxonomy-name" (.Params.taxonomy-name | default "")' to the dict (as seen for categories and tags). */ -}}
7+
{{- $.Scratch.Add
8+
"offline-search-index"
9+
(dict
10+
"ref" .RelPermalink
11+
"title" .Title
12+
"categories" (.Params.categories | default "")
13+
"tags" (.Params.tags | default "")
14+
"description" (.Description | default "")
15+
"body" (.Plain | htmlUnescape)
16+
"excerpt" ((.Description | default .Plain) | htmlUnescape | truncate (.Site.Params.offlineSearchSummaryLength | default 70) | htmlUnescape)
17+
)
18+
-}}
19+
{{- end -}}
20+
{{- end -}}
21+
{{- $.Scratch.Get "offline-search-index" | jsonify -}}

hugo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ markup:
1111
module:
1212
hugoVersion:
1313
extended: true
14-
min: 0.146.0
14+
min: 0.156.0
1515
imports:
1616

1717
# used to source the base theme for academy.

layouts/_default/sitemap.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
2+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
3+
xmlns:xhtml="http://www.w3.org/1999/xhtml">
4+
{{ range hugo.Sites }}
5+
{{ range .Pages }}
6+
{{- if and (not .Params.sitemap_exclude) (not .Draft) }}
7+
<url>
8+
<loc>{{ .Permalink }}</loc>
9+
{{- if not .Lastmod.IsZero }}
10+
<lastmod>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</lastmod>
11+
{{- end }}
12+
{{- with .Sitemap.ChangeFreq }}
13+
<changefreq>{{ . }}</changefreq>
14+
{{- end }}
15+
{{- if ge .Sitemap.Priority 0.0 }}
16+
<priority>{{ .Sitemap.Priority }}</priority>
17+
{{- end }}
18+
</url>
19+
{{- end }}
20+
{{ end }}
21+
{{ end }}
22+
</urlset>

0 commit comments

Comments
 (0)