Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/google/docsy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Deininger <adeininger@urbanonline.de>2022-10-19 17:27:39 +0300
committerGeri Ochoa <gerino@protonmail.com>2022-10-21 20:14:56 +0300
commitdd2e2b94852a08ae1e529fd0d60390e50ec9c787 (patch)
treee4e57c449e554e70080af7a040725c85e4af3889
parenta2f7ecd91d67540afb622454994b7845b396a8bb (diff)
Tabbed pane, fix: avoid duplicate html id if content is pulled in via readfile shortcode (#1289)
-rw-r--r--layouts/shortcodes/readfile.html9
-rw-r--r--layouts/shortcodes/tabpane.html19
2 files changed, 20 insertions, 8 deletions
diff --git a/layouts/shortcodes/readfile.html b/layouts/shortcodes/readfile.html
index f97541c..7d27caa 100644
--- a/layouts/shortcodes/readfile.html
+++ b/layouts/shortcodes/readfile.html
@@ -1,3 +1,8 @@
+{{/* Store ordinal, to be retrieved by parent element */}}
+{{ if ge hugo.Version "0.93.0" }}
+ {{ .Page.Store.Add "Ordinal" 1 }}
+{{ end }}
+
{{/* Handle the "file" named parameter or a single unnamed parameter as the file
path */}}
{{ if .IsNamedParams }}
@@ -24,10 +29,10 @@ if the file is not found */}}
{{ if fileExists ($.Scratch.Get "filepath") }}
{{ if eq (.Get "code") "true" }}
- {{- highlight ($.Scratch.Get "filepath" | readFile | htmlUnescape |
+ {{- highlight ($.Scratch.Get "filepath" | readFile | htmlUnescape |
safeHTML ) (.Get "lang") "" -}}
{{ else }}
- {{- $.Scratch.Get "filepath" | readFile | .Page.RenderString | htmlUnescape | safeHTML -}}
+ {{- $.Scratch.Get "filepath" | os.ReadFile | .Page.RenderString | htmlUnescape | safeHTML -}}
{{ end }}
{{ else }}
diff --git a/layouts/shortcodes/tabpane.html b/layouts/shortcodes/tabpane.html
index de644ea..1c38aff 100644
--- a/layouts/shortcodes/tabpane.html
+++ b/layouts/shortcodes/tabpane.html
@@ -38,7 +38,14 @@
{{ $duplicate := false -}}
{{ $duplicateLang := "" -}}
-<ul class="nav nav-tabs{{ if $rightPane }} justify-content-end{{ end }}" id="tabs-{{- $.Ordinal -}}" role="tablist">
+{{ $Ordinal := $.Ordinal -}}
+{{ if ge hugo.Version "0.93.0" -}}
+ {{ if .Page.Store.Get "Ordinal" -}}
+ {{ $Ordinal = .Page.Store.Get "Ordinal" -}}
+ {{end -}}
+{{ end -}}
+
+<ul class="nav nav-tabs{{ if $rightPane }} justify-content-end{{ end }}" id="tabs-{{- $Ordinal -}}" role="tablist">
{{ range $index, $element := $.Scratch.Get "tabs" -}}
{{ $disabled := false -}}
@@ -74,8 +81,8 @@
{{ $lang := replaceRE "[\\s+]" "-" $lang -}}
<li class="nav-item{{ if $rightpush }} ml-auto{{ end -}}">
{{/* Generate the IDs for the <a> and the <div> elements */ -}}
- {{ $tabid := printf "tabs-%02v-%v-tab" $.Ordinal $index | anchorize -}}
- {{ $entryid := printf "tabs-%02v-%v" $.Ordinal $index | anchorize -}}
+ {{ $tabid := printf "tabs-%02v-%v-tab" $Ordinal $index | anchorize -}}
+ {{ $entryid := printf "tabs-%02v-%v" $Ordinal $index | anchorize -}}
<a class="nav-link{{ if and ( not $activeSet ) ( not $disabled ) }} active{{ end }}{{ if $disabled }} disabled{{ end }}{{ if ne $lang "" }}{{ if and $persistLang (not $duplicate) }} persistLang-{{- $lang -}}{{ end }}{{ end }}"
id="{{ $tabid }}" data-toggle="tab" href="#{{ $entryid }}" role="tab"
@@ -100,7 +107,7 @@
{{ $activeSet = false -}}
{{/* Inner content */ -}}
-<div class="tab-content" id="tabs-{{ $.Ordinal }}-content">
+<div class="tab-content" id="tabs-{{ $Ordinal }}-content">
{{- range $index, $element := $.Scratch.Get "tabs" -}}
{{ $lang := $langPane -}}
@@ -126,8 +133,8 @@
{{ $text = . }}
{{ end -}}
- {{ $tabid := printf "tabs-%02v-%v-tab" $.Ordinal $index | anchorize -}}
- {{ $entryid := printf "tabs-%02v-%v" $.Ordinal $index | anchorize }}
+ {{ $tabid := printf "tabs-%02v-%v-tab" $Ordinal $index | anchorize -}}
+ {{ $entryid := printf "tabs-%02v-%v" $Ordinal $index | anchorize }}
<div class="{{ if $text }}tab-body {{end}}tab-pane fade{{ if and ( not $activeSet ) ( not $disabled ) }} show active{{ end }}"
id="{{ $entryid }}" role="tabpanel" aria-labelled-by="{{ $tabid }}">
{{ if $text -}}