summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Johnson <mail@nicholasjohnson.ch>2024-11-07 00:00:00 +0000
committerNicholas Johnson <mail@nicholasjohnson.ch>2024-11-08 00:00:00 +0000
commit55d6f551ec0c64d45a2951e9d16cb0081b83610b3e430a98656ed4fa0d5ae5b8 (patch)
treea3840070269c4602b2baa9a867340a6e19b5979d2c0c60fa3fc8adf52ad15d5c
parent05cf686fbdc1e5539e123bb56db31570f6c9789355d1201b33b331acd085d350 (diff)
downloadjournal-55d6f551ec0c64d45a2951e9d16cb0081b83610b3e430a98656ed4fa0d5ae5b8.tar.gz
journal-55d6f551ec0c64d45a2951e9d16cb0081b83610b3e430a98656ed4fa0d5ae5b8.zip
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.
-rw-r--r--archetypes/entry.md18
1 files 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
---