mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-27 11:38:28 -04:00
remove unnecessary dayjs plugins (prefer native Intl.DateTimeFormat
)
This commit is contained in:
parent
5f3b9b7a04
commit
a3c2bbcab0
@ -3,9 +3,6 @@ import { useState, useEffect } from "preact/hooks";
|
|||||||
import fetch from "unfetch";
|
import fetch from "unfetch";
|
||||||
import { parse as parseEmoji } from "imagemoji";
|
import { parse as parseEmoji } from "imagemoji";
|
||||||
import dayjs from "dayjs";
|
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";
|
import dayjsRelativeTime from "dayjs/plugin/relativeTime.js";
|
||||||
|
|
||||||
// shared react components:
|
// shared react components:
|
||||||
@ -91,7 +88,17 @@ const RepositoryCard = (repo) => (
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div class="repo-meta-item" title={dayjs(repo.updatedAt).format("lll z")}>
|
<div
|
||||||
|
class="repo-meta-item"
|
||||||
|
title={new Intl.DateTimeFormat("en-US", {
|
||||||
|
year: "numeric",
|
||||||
|
month: "short",
|
||||||
|
day: "numeric",
|
||||||
|
hour: "numeric",
|
||||||
|
minute: "numeric",
|
||||||
|
timeZoneName: "short",
|
||||||
|
}).format(new Date(repo.updatedAt))}
|
||||||
|
>
|
||||||
<span>Updated {dayjs(repo.updatedAt).fromNow()}</span>
|
<span>Updated {dayjs(repo.updatedAt).fromNow()}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -101,13 +108,7 @@ const RepositoryCard = (repo) => (
|
|||||||
// detect if these cards are wanted on this page (only /projects)
|
// detect if these cards are wanted on this page (only /projects)
|
||||||
if (typeof window !== "undefined" && document.querySelector("div#github-cards")) {
|
if (typeof window !== "undefined" && document.querySelector("div#github-cards")) {
|
||||||
// dayjs plugins: https://day.js.org/docs/en/plugin/loading-into-nodejs
|
// dayjs plugins: https://day.js.org/docs/en/plugin/loading-into-nodejs
|
||||||
dayjs.extend(dayjsAdvancedFormat);
|
|
||||||
dayjs.extend(dayjsLocalizedFormat);
|
|
||||||
dayjs.extend(dayjsTimezone);
|
|
||||||
dayjs.extend(dayjsRelativeTime);
|
dayjs.extend(dayjsRelativeTime);
|
||||||
|
|
||||||
// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
|
|
||||||
dayjs.tz.setDefault("America/New_York");
|
|
||||||
|
|
||||||
render(<RepositoryGrid />, document.querySelector("div#github-cards"));
|
render(<RepositoryGrid />, document.querySelector("div#github-cards"));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user