feat: dayjs lib

This commit is contained in:
DIYgod
2024-01-24 16:42:35 +08:00
parent a94933116e
commit 59290dafc2
7 changed files with 44 additions and 42 deletions
@@ -1,9 +1,9 @@
import dayjs from "dayjs"
import { NextRequest } from "next/server"
import { QueryClient } from "@tanstack/react-query"
import { locales } from "~/i18n"
import dayjs from "~/lib/dayjs"
import { getSiteLink } from "~/lib/helpers"
import { NextServerResponse } from "~/lib/server-helper"
import { ExpandedNote, PageVisibilityEnum } from "~/lib/types"
+1 -4
View File
@@ -1,14 +1,11 @@
"use client"
import dayjs from "dayjs"
import advancedFormat from "dayjs/plugin/advancedFormat"
import { useTranslations } from "next-intl"
import { Tooltip } from "~/components/ui/Tooltip"
import dayjs from "~/lib/dayjs"
import { useCalendar } from "~/queries/page"
dayjs.extend(advancedFormat)
export default function CalHeatmap({ characterId }: { characterId?: number }) {
const calendar = useCalendar(characterId)
const t = useTranslations()
+1 -17
View File
@@ -1,23 +1,7 @@
import dayjs from "dayjs"
import "dayjs/locale/en"
import "dayjs/locale/ja"
import "dayjs/locale/zh"
import "dayjs/locale/zh-tw"
import duration from "dayjs/plugin/duration"
import localizedFormat from "dayjs/plugin/localizedFormat"
import relativeTime from "dayjs/plugin/relativeTime"
import tz from "dayjs/plugin/timezone"
import utc from "dayjs/plugin/utc"
import { useLocale } from "next-intl"
import { useMemo } from "react"
dayjs.extend(localizedFormat)
dayjs.extend(utc)
dayjs.extend(tz)
dayjs.extend(duration)
dayjs.extend(relativeTime)
import dayjs from "~/lib/dayjs"
export function useDate() {
const locale = useLocale()
+20
View File
@@ -0,0 +1,20 @@
import dayjs from "dayjs"
import "dayjs/locale/en"
import "dayjs/locale/ja"
import "dayjs/locale/zh"
import "dayjs/locale/zh-tw"
import duration from "dayjs/plugin/duration"
import localizedFormat from "dayjs/plugin/localizedFormat"
import relativeTime from "dayjs/plugin/relativeTime"
import tz from "dayjs/plugin/timezone"
import utc from "dayjs/plugin/utc"
dayjs.extend(localizedFormat)
dayjs.extend(utc)
dayjs.extend(tz)
dayjs.extend(duration)
dayjs.extend(relativeTime)
export default dayjs
+1 -1
View File
@@ -1,4 +1,4 @@
import dayjs from "dayjs"
import dayjs from "~/lib/dayjs"
import { ExpandedNote, PageVisibilityEnum } from "./types"
+19 -13
View File
@@ -1,10 +1,10 @@
import type { NoteEntity } from "crossbell"
import dayjs from "dayjs"
import { indexer } from "@crossbell/indexer"
import { gql } from "@urql/core"
import countCharacters from "~/lib/character-count"
import dayjs from "~/lib/dayjs"
import { expandCrossbellNote } from "~/lib/expand-unit"
import { ExpandedNote, Language } from "~/lib/types"
import { client } from "~/queries/graphql"
@@ -154,8 +154,9 @@ export async function getFeed({
resultAll = {
list,
cursor: list?.length
? `${list[list.length - 1]?.characterId}_${list[list.length - 1]
?.noteId}`
? `${list[list.length - 1]?.characterId}_${
list[list.length - 1]?.noteId
}`
: undefined,
count: list?.length || 0,
}
@@ -271,8 +272,9 @@ export async function getFeed({
resultAll = {
list,
cursor: list?.length
? `${list[list.length - 1]?.characterId}_${list[list.length - 1]
?.noteId}`
? `${list[list.length - 1]?.characterId}_${
list[list.length - 1]?.noteId
}`
: undefined,
count: list?.length || 0,
}
@@ -340,8 +342,9 @@ export async function getFeed({
resultAll = {
list,
cursor: list?.length
? `${list[list.length - 1]?.characterId}_${list[list.length - 1]
?.noteId}`
? `${list[list.length - 1]?.characterId}_${
list[list.length - 1]?.noteId
}`
: undefined,
count: list?.length || 0,
}
@@ -488,8 +491,9 @@ export async function getFeed({
resultAll = {
list: list,
cursor: list?.length
? `${list[list.length - 1]?.characterId}_${list[list.length - 1]
?.noteId}`
? `${list[list.length - 1]?.characterId}_${
list[list.length - 1]?.noteId
}`
: undefined,
count: list?.length || 0,
}
@@ -565,8 +569,9 @@ export async function getFeed({
resultAll = {
list: list,
cursor: list?.length
? `${list[list.length - 1]?.characterId}_${list[list.length - 1]
?.noteId}`
? `${list[list.length - 1]?.characterId}_${
list[list.length - 1]?.noteId
}`
: undefined,
count: list?.length || 0,
}
@@ -798,8 +803,9 @@ export async function getFeed({
)
const cursor = list?.length
? `${list[list.length - 1]?.characterId}_${list[list.length - 1]
?.noteId}`
? `${list[list.length - 1]?.characterId}_${
list[list.length - 1]?.noteId
}`
: undefined
list = list.sort((a, b) => {
+1 -6
View File
@@ -6,9 +6,6 @@ import type {
NoteEntity,
NoteMetadata,
} from "crossbell"
import dayjs from "dayjs"
import advancedFormat from "dayjs/plugin/advancedFormat"
import weekOfYear from "dayjs/plugin/weekOfYear"
import { type Address } from "viem"
import { GeneralAccount } from "@crossbell/connect-kit"
@@ -17,6 +14,7 @@ import { extractCharacterAttribute } from "@crossbell/util-metadata"
import { gql } from "@urql/core"
import { RESERVED_TAGS } from "~/lib/constants"
import dayjs from "~/lib/dayjs"
import { editor2Crossbell } from "~/lib/editor-converter"
import { expandCrossbellNote } from "~/lib/expand-unit"
import { filterComment } from "~/lib/filter"
@@ -32,9 +30,6 @@ import {
} from "~/lib/types"
import { client } from "~/queries/graphql"
dayjs.extend(weekOfYear)
dayjs.extend(advancedFormat)
export const PINNED_PAGE_KEY = "xlog_pinned_page"
export async function checkPageSlug(input: {