From a3c2bbcab0dacfccad9a6c369d7eddd1cfaeb5b6 Mon Sep 17 00:00:00 2001 From: Jake Jarvis Date: Tue, 30 Nov 2021 13:56:41 -0500 Subject: [PATCH] remove unnecessary dayjs plugins (prefer native `Intl.DateTimeFormat`) --- assets/js/src/projects.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/assets/js/src/projects.js b/assets/js/src/projects.js index ad218e54..9858a26a 100644 --- a/assets/js/src/projects.js +++ b/assets/js/src/projects.js @@ -3,9 +3,6 @@ import { useState, useEffect } from "preact/hooks"; import fetch from "unfetch"; import { parse as parseEmoji } from "imagemoji"; import dayjs from "dayjs"; -import dayjsAdvancedFormat from "dayjs/plugin/advancedFormat.js"; -import dayjsLocalizedFormat from "dayjs/plugin/localizedFormat.js"; -import dayjsTimezone from "dayjs/plugin/timezone.js"; import dayjsRelativeTime from "dayjs/plugin/relativeTime.js"; // shared react components: @@ -91,7 +88,17 @@ const RepositoryCard = (repo) => ( )} -
+
Updated {dayjs(repo.updatedAt).fromNow()}
@@ -101,13 +108,7 @@ const RepositoryCard = (repo) => ( // detect if these cards are wanted on this page (only /projects) if (typeof window !== "undefined" && document.querySelector("div#github-cards")) { // dayjs plugins: https://day.js.org/docs/en/plugin/loading-into-nodejs - dayjs.extend(dayjsAdvancedFormat); - dayjs.extend(dayjsLocalizedFormat); - dayjs.extend(dayjsTimezone); dayjs.extend(dayjsRelativeTime); - // https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List - dayjs.tz.setDefault("America/New_York"); - render(, document.querySelector("div#github-cards")); }