From 49c081a97d8442a8267247a98d196fe05d7b3092 Mon Sep 17 00:00:00 2001 From: Kevin Hamer Date: Sun, 11 Oct 2020 17:35:30 -0400 Subject: add .Site.Params.skipSeconds --- exampleSite/config.yml | 5 +++++ layouts/partials/js.html | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/exampleSite/config.yml b/exampleSite/config.yml index 967505f..9060163 100644 --- a/exampleSite/config.yml +++ b/exampleSite/config.yml @@ -162,6 +162,11 @@ params: # Default: true useRelativeTime: true + # If enabled, doesn't show seconds on relative times. + # + # Default: false + skipSeconds: false + # What header design should we use? # # Default: true diff --git a/layouts/partials/js.html b/layouts/partials/js.html index c4c5a85..8465483 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -67,7 +67,11 @@ if (interval > 1) { return interval + ' {{ T "minsAgo" }}'; } - return Math.floor(seconds) + '{{ T "secondsAgo" }}'; + {{ if .Site.Params.skipSeconds }} + return '<1 {{ T "minsAgo" }}' + {{ else }} + return Math.floor(seconds) + '{{ T "secondsAgo" }}'; + {{ end }} } /** -- cgit v1.2.3-70-g09d2