mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
theme: make expand and image ids stable #477
This commit is contained in:
parent
09e7aebcd8
commit
e7a0ef9d9e
4 changed files with 11 additions and 2 deletions
|
@ -1,6 +1,14 @@
|
|||
{{- $version := split hugo.Version "." }}
|
||||
{{- $major := int (index $version 0) }}
|
||||
{{- $minor := int (index $version 1) }}
|
||||
{{- $id := "" }}
|
||||
{{- if and (ge $major 0) (ge $major 108) }}
|
||||
{{- $id = .Ordinal }}
|
||||
{{- end }}
|
||||
{{- partial "shortcodes/image.html" (dict
|
||||
"context" .Page
|
||||
"url" .Destination
|
||||
"title" .Title
|
||||
"alt" .Text
|
||||
"id" $id
|
||||
) }}
|
|
@ -6,8 +6,8 @@
|
|||
{{- if eq (printf "%T" $expanded) "string" }}
|
||||
{{- $expanded = (eq $expanded "true") }}
|
||||
{{- end }}
|
||||
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo") .id }}
|
||||
{{- with $context }}
|
||||
{{- $id := partial "make-random-md5.hugo" }}
|
||||
<div class="expand">
|
||||
<input type="checkbox" id="expand-{{ $id }}" aria-controls="expandcontent-{{ $id }}" {{ if $expanded }} checked{{ end }}>
|
||||
<label class="expand-label" for="expand-{{ $id }}" >
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
{{ $width = . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $id := partial "make-random-md5.hugo" }}
|
||||
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo") .id }}
|
||||
{{- if $lightbox }}
|
||||
<a href="#image-{{ $id }}" class="lightbox-link">
|
||||
{{- end }}
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
"content" .Inner
|
||||
"open" (.Get "open" | default (.Get 1))
|
||||
"title" (.Get "title" | default (.Get 0))
|
||||
"id" .Ordinal
|
||||
) }}
|
Loading…
Reference in a new issue