From 3293091173f7bba0b6ccb0f2a092db3b2de21297 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Thu, 23 Feb 2023 19:19:13 +0000 Subject: [PATCH] feat: dayjs i18n --- public/locales/en/common.json | 1 - public/locales/zh/common.json | 1 - public/locales/zh/index.json | 2 +- src/components/common/CharacterCard.tsx | 9 +++--- src/components/common/CommentItem.tsx | 9 +++--- src/components/dashboard/PagesManager.tsx | 7 +++-- src/components/site/PostMeta.tsx | 25 ++++++++-------- src/components/site/SiteArchives.tsx | 5 ++-- src/components/site/SiteHome.tsx | 27 +++++++++-------- src/hooks/useDate.ts | 34 ++++++++++++++++++++++ src/lib/date.ts | 31 -------------------- src/lib/page-helpers.ts | 2 +- src/pages/dashboard/[subdomain]/editor.tsx | 17 ++++++----- src/pages/dashboard/[subdomain]/index.tsx | 6 ++-- 14 files changed, 95 insertions(+), 81 deletions(-) create mode 100644 src/hooks/useDate.ts delete mode 100644 src/lib/date.ts diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 59492dd1..6772c68b 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -1,4 +1,3 @@ { - "intlDateTime": "{{val, datetime}}", "intlRelativeTime": "{{val, relativetime}}" } \ No newline at end of file diff --git a/public/locales/zh/common.json b/public/locales/zh/common.json index fceaa6a0..fabb2fc6 100644 --- a/public/locales/zh/common.json +++ b/public/locales/zh/common.json @@ -5,7 +5,6 @@ "Followings": "正在关注", "Follow": "关注", "Unfollow": "取消关注", - "intlDateTime": "{{val, datetime}}", "intlRelativeTime": "{{val, relativetime}}", "post": "文章", "posts": "文章", diff --git a/public/locales/zh/index.json b/public/locales/zh/index.json index c9aee12c..6c258d1e 100644 --- a/public/locales/zh/index.json +++ b/public/locales/zh/index.json @@ -1,6 +1,6 @@ { "Blog Free": "自由创作", - "description": "xLog,给所有人的 <1>链上 <3>开源 博客平台。", + "description": "xLog,给所有人的 <2>链上 <6>开源 博客平台。", "Get my xLog in 5 minutes": "5 分钟拥有自己的 xLog", "Features": "特点", "Showcase": "展示", diff --git a/src/components/common/CharacterCard.tsx b/src/components/common/CharacterCard.tsx index b3f374ac..efc63964 100644 --- a/src/components/common/CharacterCard.tsx +++ b/src/components/common/CharacterCard.tsx @@ -1,11 +1,11 @@ import { useEffect, useState } from "react" import { Avatar } from "~/components/ui/Avatar" -import dayjs, { formatToISO } from "~/lib/date" import { FollowingButton } from "~/components/common/FollowingButton" import { FollowingCount } from "~/components/common/FollowingCount" import * as siteModel from "~/models/site.model" import type { Profile } from "~/lib/types" import clsx from "clsx" +import { useDate } from "~/hooks/useDate" export const CharacterCard: React.FC<{ siteId?: string @@ -17,6 +17,7 @@ export const CharacterCard: React.FC<{ }> = ({ siteId, address, open, setButtonLoading, hideFollowButton, style }) => { const [firstOpen, setFirstOpen] = useState("") const [site, setSite] = useState() + const date = useDate() useEffect(() => { if (open && (firstOpen !== (siteId || address) || !site)) { @@ -72,10 +73,10 @@ export const CharacterCard: React.FC<{ {site?.date_created && ( Joined{" "} -