mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
theme: make IDs stable for testing
This commit is contained in:
parent
4bdbb9ea6a
commit
899cab1cf6
5 changed files with 16 additions and 10 deletions
|
@ -3,6 +3,7 @@ set /p version=<..\layouts\partials\version.txt
|
|||
echo %version%>metrics.%version%.txt
|
||||
echo disableAssetsBusting=true>>config.toml
|
||||
echo disableGeneratorVersion=true>>config.toml
|
||||
echo disableRandomIds=true>>config.toml
|
||||
hugo --templateMetrics --templateMetricsHints --cleanDestinationDir --destination public.%version% >> metrics.%version%.txt
|
||||
move /Y metrics.%version%.txt public.%version%\metrics.txt 2>&1 >NUL
|
||||
git restore config.toml
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
{{- $random := "" }}
|
||||
{{- $set := split "012345abcdefghijklmnopqrstuvwxyz" "" }}
|
||||
{{- range (seq 16) }}
|
||||
{{- with ($set | shuffle | first 1) }}
|
||||
{{- $random = printf "%s%s" $random . }}
|
||||
{{- $context := . }}
|
||||
{{- if (ne $context.Site.Params.disableRandomIds true) }}
|
||||
{{- $random := "" }}
|
||||
{{- $set := split "012345abcdefghijklmnopqrstuvwxyz" "" }}
|
||||
{{- range (seq 16) }}
|
||||
{{- with ($set | shuffle | first 1) }}
|
||||
{{- $random = printf "%s%s" $random . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- md5 $random }}
|
||||
{{- md5 $random }}
|
||||
{{- else }}
|
||||
{{- printf "00000000000000000000000000000000" }}
|
||||
{{- end }}
|
|
@ -6,7 +6,7 @@
|
|||
{{- 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 }}
|
||||
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context.Page) .id }}
|
||||
{{- with $context }}
|
||||
<div class="expand">
|
||||
<input type="checkbox" id="expand-{{ $id }}" aria-controls="expandcontent-{{ $id }}" {{ if $expanded }} checked{{ end }}>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
{{ $width = . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo") .id }}
|
||||
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context) .id }}
|
||||
{{- if $lightbox }}
|
||||
<a href="#image-{{ $id }}" class="lightbox-link">
|
||||
{{- end }}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{- $context := .context }}
|
||||
{{- $src := .src }}
|
||||
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo") .id }}
|
||||
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context.Page) .id }}
|
||||
{{- with $context }}
|
||||
{{- with .Page.Resources.Match $src }}
|
||||
{{- range . }}
|
||||
|
|
Loading…
Reference in a new issue