Skip to content

Commit 75c3f9e

Browse files
kt3kclaude
andcommitted
feat: show a relative hint for the next update in the footer
Recompute the next 06:00 UTC run client-side so the footer stays correct on a cached page, and append a relative ("in 3 hours") hint. The build-time absolute date remains as the no-JS fallback. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 7a4ad17 commit 75c3f9e

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

src/_includes/layouts/base.vto

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,28 @@
3737
RSS on every repo page
3838
</span>
3939
<span aria-hidden="true">·</span>
40-
<span>Next update {{ nextUpdate }}</span>
40+
<span>Next update <span data-next-update>{{ nextUpdate }}</span></span>
4141
</div>
4242
</footer>
43+
44+
<script>
45+
// Recompute the next 06:00 UTC run on the client so the footer stays correct
46+
// even on a cached page, and append a relative ("in 3 hours") hint.
47+
(function () {
48+
var el = document.querySelector("[data-next-update]");
49+
if (!el) return;
50+
var MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
51+
var now = new Date();
52+
var next = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), 6, 0, 0));
53+
if (next.getTime() <= now.getTime()) next.setUTCDate(next.getUTCDate() + 1);
54+
var abs = MONTHS[next.getUTCMonth()] + " " + next.getUTCDate() + ", 06:00 UTC";
55+
var mins = Math.round((next.getTime() - now.getTime()) / 60000);
56+
var rel;
57+
if (mins < 1) rel = "any moment";
58+
else if (mins < 60) rel = "in " + mins + " min";
59+
else { var h = Math.round(mins / 60); rel = "in " + h + " hour" + (h === 1 ? "" : "s"); }
60+
el.textContent = abs + " (" + rel + ")";
61+
})();
62+
</script>
4363
</body>
4464
</html>

0 commit comments

Comments
 (0)