hugo: replace Shortcode.Scratch with Shortcode.Store

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2024-11-19 14:18:16 +01:00
parent b629fdadcf
commit c9dc7f99c6
2 changed files with 6 additions and 6 deletions

View File

@ -4,9 +4,9 @@
{{ $name := trim (.Get "name") " " }} {{ $name := trim (.Get "name") " " }}
{{ if not (.Parent.Scratch.Get "tabs") }} {{ if not (.Parent.Store.Get "tabs") }}
{{ .Parent.Scratch.Set "tabs" slice }} {{ .Parent.Store.Set "tabs" slice }}
{{ end }} {{ end }}
{{ with .Inner }} {{ with .Inner }}
{{ $.Parent.Scratch.Add "tabs" (dict "name" $name "content" . ) }} {{ $.Parent.Store.Add "tabs" (dict "name" $name "content" . ) }}
{{ end }} {{ end }}

View File

@ -1,5 +1,5 @@
{{ with .Inner }}{{/* don't do anything, just call it */}}{{ end }} {{ with .Inner }}{{/* don't do anything, just call it */}}{{ end }}
{{ $first := urlize (index (.Scratch.Get "tabs") 0).name }} {{ $first := urlize (index (.Store.Get "tabs") 0).name }}
{{ $group := .Get "group" }} {{ $group := .Get "group" }}
{{ $groupID := fmt.Printf "tabgroup-%s" (urlize $group) }} {{ $groupID := fmt.Printf "tabgroup-%s" (urlize $group) }}
{{ $persist := .Get "persist" }} {{ $persist := .Get "persist" }}
@ -19,7 +19,7 @@
{{ end }} {{ end }}
aria-role="tabpanel"> aria-role="tabpanel">
<div aria-role="tablist" class="space-x-2"> <div aria-role="tablist" class="space-x-2">
{{ range (.Scratch.Get "tabs") }} {{ range (.Store.Get "tabs") }}
<button <button
class="p-1" class="p-1"
:class="selected === '{{ .name | urlize }}' && :class="selected === '{{ .name | urlize }}' &&
@ -37,7 +37,7 @@
</div> </div>
<hr class="!mt-0" /> <hr class="!mt-0" />
<div> <div>
{{ range (.Scratch.Get "tabs") }} {{ range (.Store.Get "tabs") }}
<div <div
aria-role="tab" aria-role="tab"
:class="selected !== '{{ .name | urlize }}' && 'hidden'" :class="selected !== '{{ .name | urlize }}' && 'hidden'"