#803, use page-level IDs for shortcodes
This commit is contained in:
@@ -10,7 +10,10 @@ Enhanced image display with click-to-expand behavior.
|
||||
|
||||
## Example
|
||||
|
||||
{{< image src="placeholder.svg" alt="Placeholder image" title="Click to expand" loading="lazy" >}}
|
||||
{{% columns %}}
|
||||
- {{< image src="placeholder.svg" alt="Placeholder image" title="Click to expand" loading="lazy" >}}
|
||||
- {{< image src="placeholder.svg" alt="Placeholder image" title="Click to expand" loading="lazy" >}}
|
||||
{{% /columns %}}
|
||||
|
||||
## Parameters
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{{- $key := printf "book-%s-id" .Name }}
|
||||
{{- .Page.Store.Add $key 1 -}}
|
||||
{{- return .Page.Store.Get $key -}}
|
||||
@@ -7,13 +7,14 @@
|
||||
<script defer src="{{ "asciinema/asciinema-auto.js" | relURL }}"></script>
|
||||
{{- .Page.Store.Set "asciinema" true -}}
|
||||
{{- end -}}
|
||||
{{- $id := partial "docs/text/shortcode-id" . -}}
|
||||
{{- $href := (partial "docs/links/portable-image" (dict "Page" .Page "Destination" (.Get "cast"))) -}}
|
||||
{{- .Store.Set "asciinema" .Params -}}
|
||||
{{- .Store.DeleteInMap "asciinema" "cast" -}}
|
||||
{{- $attributes := partial "docs/text/mapper" (dict
|
||||
"attributes" (dict)
|
||||
"set" (dict
|
||||
"id" (printf "asciinema-%d" .Ordinal)
|
||||
"id" (printf "asciinema-%d" ($id))
|
||||
"x-data-cast" $href
|
||||
"x-data-opts" (.Store.Get "asciinema" | jsonify)
|
||||
)
|
||||
|
||||
@@ -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 }}>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
"attributes" (cond .IsNamedParams .Params dict)
|
||||
"keep" (slice "id" "class" "tabindex" "alt" "title" "loading")
|
||||
) -}}
|
||||
<label class="book-image" for="book-image-toggle-{{ .Ordinal }}">
|
||||
<input class="hidden toggle" type="checkbox" id="book-image-toggle-{{ .Ordinal }}" />
|
||||
<img src="{{ $destination | safeURL }}" {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }} />
|
||||
</label>
|
||||
{{- /* remove whitespaces */ -}}
|
||||
{{- $id := partial "docs/text/shortcode-id" . -}}
|
||||
<label class="book-image" for="book-image-toggle-{{ $id }}">{{- /* remove whitespaces */ -}}
|
||||
<input class="hidden toggle" type="checkbox" id="book-image-toggle-{{ $id }}" />{{- /* remove whitespaces */ -}}
|
||||
<img src="{{ $destination | safeURL }}" {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }} />{{- /* remove whitespaces */ -}}
|
||||
</label>{{- /* remove whitespaces */ -}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- $group := printf "tabs-%v" .Parent.Ordinal -}}
|
||||
{{- $group := printf "tabs-%v" (.Parent.Store.Get "id") -}}
|
||||
{{- $tab := printf "%s-%d" $group .Ordinal -}}
|
||||
<input type="radio" class="toggle" name="{{ $group }}" id="{{ $tab }}" {{ if not .Ordinal }}checked="checked"{{ end }} />
|
||||
{{- /* remove whitespaces */ -}}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{{- .Store.Set "id" (partial "docs/text/shortcode-id" .) -}}
|
||||
{{- $attributes := partial "docs/text/mapper" (dict
|
||||
"attributes" (cond .IsNamedParams .Params dict)
|
||||
"merge" (dict
|
||||
|
||||
Reference in New Issue
Block a user