New way to generate UIDs.

This commit is contained in:
MaikelChan 2024-01-13 01:24:45 +01:00
parent 08305fe2f7
commit 9cfc07565c
No known key found for this signature in database
GPG key ID: B2CE398C279239EC
7 changed files with 19 additions and 7 deletions

View file

@ -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 }}

View file

@ -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") }} {{ $aspect := default "16-9" (.Get "aspectRatio") }}
{{ $images := .Page.Resources.Match (.Get "images") }} {{ $images := .Page.Resources.Match (.Get "images") }}
{{ $interval := default "2000" (.Get "interval") }} {{ $interval := default "2000" (.Get "interval") }}

View file

@ -1,4 +1,4 @@
{{ $id := delimit (slice "chart" .Ordinal now.UnixNano) "-" }} {{ $id := delimit (slice "chart" (partial "functions/uid.html" .)) "-" }}
<div class="chart"> <div class="chart">
<canvas id="{{ $id }}"></canvas> <canvas id="{{ $id }}"></canvas>
<script type="text/javascript"> <script type="text/javascript">

View file

@ -1,5 +1,4 @@
{{ $random := delimit (shuffle (seq 1 9)) "" }} {{ $id := delimit (slice "gallery" (partial "functions/uid.html" .)) "-" }}
{{ $id := delimit (slice "gallery" $random now.UnixNano) "-" }}
<div id="{{ $id }}" class="gallery"> <div id="{{ $id }}" class="gallery">
{{ .Inner }} {{ .Inner }}

View file

@ -1,4 +1,4 @@
{{ $id := delimit (slice "github" .Ordinal now.UnixNano) "-" }} {{ $id := delimit (slice "github" (partial "functions/uid.html" .)) "-" }}
{{- $githubURL := print "https://api.github.com/repos/" (.Get "repo") -}} {{- $githubURL := print "https://api.github.com/repos/" (.Get "repo") -}}
{{- $githubData := getJSON ($githubURL) -}} {{- $githubData := getJSON ($githubURL) -}}
{{- $githubColors := .Site.Data.githubColors -}} {{- $githubColors := .Site.Data.githubColors -}}

View file

@ -1,4 +1,4 @@
{{ $id := delimit (slice "gitlab" .Ordinal now.UnixNano) "-" }} {{ $id := delimit (slice "gitlab" (partial "functions/uid.html" .)) "-" }}
{{- $gitlabURL := print (default "https://gitlab.com/" (.Get "baseURL")) "api/v4/projects/" (.Get "projectID") -}} {{- $gitlabURL := print (default "https://gitlab.com/" (.Get "baseURL")) "api/v4/projects/" (.Get "projectID") -}}
{{- $gitLabData := getJSON ($gitlabURL) -}} {{- $gitLabData := getJSON ($gitlabURL) -}}

View file

@ -13,7 +13,7 @@
{{- end -}} {{- end -}}
{{- $tag := .Get "tag" | default "div" -}} {{- $tag := .Get "tag" | default "div" -}}
{{ $id := delimit (slice "typeit" .Ordinal now.UnixNano) "-" }} {{ $id := delimit (slice "typeit" (partial "functions/uid.html" .)) "-" }}
{{- $attrs := printf `id="%v"` $id -}} {{- $attrs := printf `id="%v"` $id -}}
{{- with $classList -}} {{- with $classList -}}