diff --git a/layouts/partials/functions/uid.html b/layouts/partials/functions/uid.html new file mode 100644 index 00000000..f4269dc4 --- /dev/null +++ b/layouts/partials/functions/uid.html @@ -0,0 +1,13 @@ +{{ $uid := .Page.RelPermalink }} +{{ $ctx := . }} + +{{ range seq 16 }} + {{ with $ctx }} + {{ $uid = printf "%s-%d" $uid .Ordinal }} + {{ $ctx = .Parent }} + {{ else }} + {{ break }} + {{ end }} +{{ end }} + +{{ return md5 $uid }} \ No newline at end of file diff --git a/layouts/shortcodes/carousel.html b/layouts/shortcodes/carousel.html index 97e51696..ccfb4595 100644 --- a/layouts/shortcodes/carousel.html +++ b/layouts/shortcodes/carousel.html @@ -1,4 +1,4 @@ -{{ $id := delimit (slice "carousel" .Ordinal now.UnixNano) "-" }} +{{ $id := delimit (slice "carousel" (partial "functions/uid.html" .)) "-" }} {{ $aspect := default "16-9" (.Get "aspectRatio") }} {{ $images := .Page.Resources.Match (.Get "images") }} {{ $interval := default "2000" (.Get "interval") }} diff --git a/layouts/shortcodes/chart.html b/layouts/shortcodes/chart.html index 82c92aad..1e172753 100644 --- a/layouts/shortcodes/chart.html +++ b/layouts/shortcodes/chart.html @@ -1,4 +1,4 @@ -{{ $id := delimit (slice "chart" .Ordinal now.UnixNano) "-" }} +{{ $id := delimit (slice "chart" (partial "functions/uid.html" .)) "-" }}