mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 16:31:52 +01:00
New way to generate UIDs.
This commit is contained in:
13
layouts/partials/functions/uid.html
Normal file
13
layouts/partials/functions/uid.html
Normal 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 }}
|
||||
@@ -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") }}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{ $id := delimit (slice "chart" .Ordinal now.UnixNano) "-" }}
|
||||
{{ $id := delimit (slice "chart" (partial "functions/uid.html" .)) "-" }}
|
||||
<div class="chart">
|
||||
<canvas id="{{ $id }}"></canvas>
|
||||
<script type="text/javascript">
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{{ $random := delimit (shuffle (seq 1 9)) "" }}
|
||||
{{ $id := delimit (slice "gallery" $random now.UnixNano) "-" }}
|
||||
{{ $id := delimit (slice "gallery" (partial "functions/uid.html" .)) "-" }}
|
||||
|
||||
<div id="{{ $id }}" class="gallery">
|
||||
{{ .Inner }}
|
||||
|
||||
@@ -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") -}}
|
||||
{{- $githubData := getJSON ($githubURL) -}}
|
||||
{{- $githubColors := .Site.Data.githubColors -}}
|
||||
|
||||
@@ -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") -}}
|
||||
|
||||
{{- $gitLabData := getJSON ($gitlabURL) -}}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
{{- end -}}
|
||||
{{- $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 -}}
|
||||
{{- with $classList -}}
|
||||
|
||||
Reference in New Issue
Block a user