hugo(refactor): use Page.Store instead of Page.Scratch

Page.Scratch was soft-deprecated in v0.138.0
https://github.com/gohugoio/hugo/releases/tag/v0.138.0

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2024-11-07 15:59:16 +01:00
Родитель 9ce906907b
Коммит 54e84be145
1 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -5,8 +5,8 @@
{{ else }}
{{ $data = index site.Data .Params.datafile }}
{{ end }}
{{ .Scratch.Set "headings" slice }}
{{ .Scratch.Set "subheadings" slice }}
{{ .Store.Set "headings" slice }}
{{ .Store.Set "subheadings" slice }}
<div class="flex w-full">
<article class="prose min-w-0 flex-[2_2_0%] max-w-4xl dark:prose-invert">
{{ partial "breadcrumbs.html" . }}
@ -84,11 +84,11 @@ can be removed entirely in a future release.
{{ $heading := dict "level" 2 "text" "Description" }}
{{ partialCached "heading.html" $heading "cli-description" }}
{{ $subHeadings := (strings.FindRE `(?m:#{3,4} .*)` .) }}
{{ $.Scratch.Add "headings" $heading }}
{{ $.Store.Add "headings" $heading }}
{{ range $subHeadings }}
{{ $lvl := strings.Count "#" . }}
{{ $txt := strings.TrimLeft "# " . }}
{{ $.Scratch.Add "headings" (dict "level" $lvl "text" $txt) }}
{{ $.Store.Add "headings" (dict "level" $lvl "text" $txt) }}
{{ end }}
{{ . | $.RenderString (dict "display" "block") }}
{{ end }}
@ -97,7 +97,7 @@ can be removed entirely in a future release.
{{ with $opts }}
{{ $heading := dict "level" 2 "text" "Options" }}
{{ partialCached "heading.html" $heading "cli-options" }}
{{ $.Scratch.Add "headings" $heading }}
{{ $.Store.Add "headings" $heading }}
<div class="overflow-x-auto">
<table>
<thead class="bg-gray-light-100 dark:bg-gray-dark-200">
@ -162,18 +162,18 @@ can be removed entirely in a future release.
{{ $heading := dict "level" 2 "text" "Examples" }}
{{ partialCached "heading.html" $heading "cli-examples" }}
{{ $subHeadings := (strings.FindRE `(?m:#{3,4} .*)` .) }}
{{ $.Scratch.Add "headings" $heading }}
{{ $.Store.Add "headings" $heading }}
{{ range $subHeadings }}
{{ $lvl := strings.Count "#" . }}
{{ $txt := strings.TrimLeft "# " . }}
{{ $.Scratch.Add "headings" (dict "level" $lvl "text" $txt) }}
{{ $.Store.Add "headings" (dict "level" $lvl "text" $txt) }}
{{ end }}
{{ $.RenderString (dict "display" "block") . }}
{{ end }}
{{ if eq .Kind "section" }}
{{ $heading := dict "level" 2 "text" "Subcommands" }}
{{ partialCached "heading.html" $heading "cli-subcommands" }}
{{ $.Scratch.Add "headings" $heading }}
{{ $.Store.Add "headings" $heading }}
<table>
<thead>
<tr>
@ -202,7 +202,7 @@ can be removed entirely in a future release.
<div class="text-lg pb-2">{{ T "tableOfContents" }}</div>
<nav class="toc">
<ul>
{{ range (.Scratch.Get "headings") }}
{{ range (.Store.Get "headings") }}
{{/* add left padding depending on level (pl-2, pl-3, pl-4) */}}
{{ $slice := strings.Split .text "{#" }}
{{ $text := index $slice 0 }}