From 55d6f551ec0c64d45a2951e9d16cb0081b83610b3e430a98656ed4fa0d5ae5b8 Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Thu, 7 Nov 2024 00:00:00 +0000 Subject: Increase timestamp obfuscation feature usability By incrementing the timestamp by one second for each new entry falling on the same day, the timestamps remain obfuscated while ensuring correct ordering of entries on the homepage and Atom feeds. This saves me from changing the timestamps manually to accomplish the same. --- archetypes/entry.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/archetypes/entry.md b/archetypes/entry.md index 32d6347..317c8b6 100644 --- a/archetypes/entry.md +++ b/archetypes/entry.md @@ -1,6 +1,20 @@ --- +{{ $today := now.UTC.Truncate (time.Duration "hour" 24) -}} +{{ $tomorrow := $today.Add (time.Duration "hour" 24) -}} + +{{ $numSameDayEntries := len (where (where (where + .Site.RegularPages.ByTitle "Section" "entry") + "Date" "ge" $today) + "Date" "lt" $tomorrow) -}} + +{{ $entryDate := $today.Add (time.Duration "second" $numSameDayEntries) -}} + +{{ if eq $entryDate $tomorrow -}} + {{ errorf "Too many entries in one day!" }} +{{ end -}} + title: "{{ replace .Name "-" " " | title }}" -date: {{ now.UTC.Format "2006-01-02T00:00:00Z" }} -draft: true +date: {{ $entryDate.Format "2006-01-02T15:04:05Z" }} +draft: false --- -- cgit v1.2.3