1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-18 21:53:26 +00:00

Prevent the post date from shifting when loading

This commit is contained in:
Cotes Chung
2021-07-11 17:04:13 +08:00
parent bea170cff0
commit d52fa88337
5 changed files with 10 additions and 10 deletions

View File

@@ -10,14 +10,13 @@ $(function() {
let intervalId = void 0;
function timeago(iso, preposition) {
function timeago(iso) {
let now = new Date();
let past = new Date(iso);
let prep = (typeof preposition !== "undefined" ? `${preposition} ` : "");
if (past.getFullYear() !== now.getFullYear()) {
toRefresh -= 1;
return prep + past.toLocaleString("en-US", {
return past.toLocaleString("en-US", {
year: "numeric",
month: "short",
day: "numeric"
@@ -26,7 +25,7 @@ $(function() {
if (past.getMonth() !== now.getMonth()) {
toRefresh -= 1;
return prep + past.toLocaleString("en-US", {
return past.toLocaleString("en-US", {
month: "short",
day: "numeric"
});