#803, use page-level IDs for shortcodes

This commit is contained in:
Alex Shpak
2026-05-16 23:47:34 +02:00
parent 54f9ceeeee
commit fe5f41f15d
7 changed files with 20 additions and 11 deletions
+4 -3
View File
@@ -1,11 +1,12 @@
{{- $ratio := (split (.Get "ratio") ":") -}}
{{- $id := partial "docs/text/shortcode-id" . -}}
{{- if strings.Contains .InnerDeindent "<--->" -}}
{{- warnf "{{<columns>}} shortcode separator '<--->' is deprecated, use markdown list instead." -}}
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"merge" (dict
"class" (slice "book-columns" "flex" "flex-wrap")
"id" (printf "book-columns-%d" .Ordinal)
"id" (printf "book-columns-%d" $id)
)
) -}}
<div {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>
@@ -19,7 +20,7 @@
{{- else -}}
{{- if .Get "ratio" -}}
<style>{{- range $index, $grow := $ratio -}}
#book-columns-{{ $.Ordinal }}>ul>li:nth-child({{ $index | add 1 }}) {
#book-columns-{{ $id }}>ul>li:nth-child({{ $index | add 1 }}) {
flex-grow: {{ default 1 $grow }};
}
{{ end -}}
@@ -29,7 +30,7 @@
"attributes" (cond .IsNamedParams .Params dict)
"merge" (dict
"class" (slice "book-columns")
"id" (printf "book-columns-%d" .Ordinal)
"id" (printf "book-columns-%d" $id)
)
) -}}
<div {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>