Remove dependency Unidata (#473)
This commit is contained in:
@@ -38,7 +38,7 @@ export const AchievementItem: React.FC<{
|
||||
group: AchievementSection["groups"][number]
|
||||
layoutId: string
|
||||
size?: number
|
||||
characterId?: string
|
||||
characterId?: number
|
||||
isOwner: boolean
|
||||
}> = ({ group, layoutId, size, characterId, isOwner }) => {
|
||||
const date = useDate()
|
||||
|
||||
@@ -18,7 +18,7 @@ export const AchievementModal: React.FC<{
|
||||
group: AchievementSection["groups"][number]
|
||||
layoutId: string
|
||||
isOwner: boolean
|
||||
characterId?: string
|
||||
characterId?: number
|
||||
}> = ({ opened, setOpened, group, layoutId, isOwner, characterId }) => {
|
||||
const date = useDate()
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
@@ -3,24 +3,26 @@ import { useTranslation } from "next-i18next"
|
||||
import { Disclosure } from "@headlessui/react"
|
||||
|
||||
import { BlockchainIcon } from "~/components/icons/BlockchainIcon"
|
||||
import { CSB_SCAN, IPFS_GATEWAY } from "~/lib/env"
|
||||
import { CSB_SCAN } from "~/lib/env"
|
||||
import { toCid, toGateway, toIPFS } from "~/lib/ipfs-parser"
|
||||
import { Note, Profile } from "~/lib/types"
|
||||
import { ExpandedCharacter, ExpandedNote } from "~/lib/types"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { useGetGreenfieldId } from "~/queries/site"
|
||||
|
||||
export const BlockchainInfo: React.FC<{
|
||||
site?: Profile | null
|
||||
page?: Note | null
|
||||
site?: ExpandedCharacter
|
||||
page?: ExpandedNote
|
||||
}> = ({ site, page }) => {
|
||||
const { t } = useTranslation(["common", "site"])
|
||||
|
||||
const ipfs = page
|
||||
? page.related_urls?.filter((url) => url.startsWith(IPFS_GATEWAY))?.[0]
|
||||
: site?.metadata?.uri
|
||||
const ipfs = (page ? page.metadata?.uri : site?.metadata?.uri) || ""
|
||||
const greenfieldId = useGetGreenfieldId(toCid(ipfs))
|
||||
|
||||
const type = page ? (page?.tags?.includes("post") ? "post" : "page") : "blog"
|
||||
const type = page
|
||||
? page?.metadata?.content?.tags?.includes("post")
|
||||
? "post"
|
||||
: "page"
|
||||
: "blog"
|
||||
|
||||
return (
|
||||
<div className="text-sm">
|
||||
@@ -54,46 +56,53 @@ export const BlockchainInfo: React.FC<{
|
||||
<div className="font-medium">{t("Owner")}</div>
|
||||
<div>
|
||||
<BlockchainInfoLink
|
||||
href={`${CSB_SCAN}/address/${
|
||||
page?.metadata?.owner || site?.metadata?.owner
|
||||
}`}
|
||||
key={page?.metadata?.owner || site?.metadata?.owner}
|
||||
href={`${CSB_SCAN}/address/${page?.owner || site?.owner}`}
|
||||
key={page?.owner || site?.owner}
|
||||
>
|
||||
{page?.metadata?.owner || site?.metadata?.owner}
|
||||
{page?.owner || site?.owner}
|
||||
</BlockchainInfoLink>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div className="font-medium">{t("Transaction Hash")}</div>
|
||||
<div>
|
||||
{page
|
||||
? page?.related_urls
|
||||
?.filter((url) => url.startsWith(CSB_SCAN + "/tx/"))
|
||||
.map((url, index) => {
|
||||
return (
|
||||
<BlockchainInfoLink href={url} key={url}>
|
||||
{t(index === 0 ? "Creation" : "Last Update")}{" "}
|
||||
{url
|
||||
.replace(CSB_SCAN + "/tx/", "")
|
||||
.slice(0, 10)}
|
||||
...
|
||||
{url.replace(CSB_SCAN + "/tx/", "").slice(-10)}
|
||||
</BlockchainInfoLink>
|
||||
)
|
||||
})
|
||||
: site?.metadata?.transactions.map(
|
||||
(hash: string, index: number) => {
|
||||
return (
|
||||
<BlockchainInfoLink
|
||||
href={`${CSB_SCAN}/tx/${hash}`}
|
||||
key={hash}
|
||||
>
|
||||
{t(index === 0 ? "Creation" : "Last Update")}{" "}
|
||||
{hash.slice(0, 10)}...{hash.slice(-10)}
|
||||
</BlockchainInfoLink>
|
||||
)
|
||||
},
|
||||
)}
|
||||
{page ? (
|
||||
<>
|
||||
<BlockchainInfoLink
|
||||
href={`${CSB_SCAN}/tx/${page?.transactionHash}`}
|
||||
key={page?.transactionHash}
|
||||
>
|
||||
{t("Creation")} {page?.transactionHash.slice(0, 10)}
|
||||
...{page?.transactionHash.slice(-10)}
|
||||
</BlockchainInfoLink>
|
||||
<BlockchainInfoLink
|
||||
href={`${CSB_SCAN}/tx/${page?.updatedTransactionHash}`}
|
||||
key={page?.updatedTransactionHash}
|
||||
>
|
||||
{t("Last Update")}{" "}
|
||||
{page?.updatedTransactionHash.slice(0, 10)}...
|
||||
{page?.updatedTransactionHash.slice(-10)}
|
||||
</BlockchainInfoLink>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<BlockchainInfoLink
|
||||
href={`${CSB_SCAN}/tx/${site?.transactionHash}`}
|
||||
key={site?.transactionHash}
|
||||
>
|
||||
{t("Creation")} {site?.transactionHash.slice(0, 10)}
|
||||
...{site?.transactionHash.slice(-10)}
|
||||
</BlockchainInfoLink>
|
||||
<BlockchainInfoLink
|
||||
href={`${CSB_SCAN}/tx/${site?.updatedTransactionHash}`}
|
||||
key={site?.updatedTransactionHash}
|
||||
>
|
||||
{t("Last Update")}{" "}
|
||||
{site?.updatedTransactionHash.slice(0, 10)}...
|
||||
{site?.updatedTransactionHash.slice(-10)}
|
||||
</BlockchainInfoLink>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
@@ -6,7 +6,7 @@ import { FollowingCount } from "~/components/common/FollowingCount"
|
||||
import { Titles } from "~/components/common/Titles"
|
||||
import { Avatar } from "~/components/ui/Avatar"
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import type { Profile } from "~/lib/types"
|
||||
import type { ExpandedCharacter } from "~/lib/types"
|
||||
import { cn } from "~/lib/utils"
|
||||
import * as siteModel from "~/models/site.model"
|
||||
|
||||
@@ -28,7 +28,7 @@ export const CharacterCard: React.FC<{
|
||||
style,
|
||||
}) => {
|
||||
const [firstOpen, setFirstOpen] = useState("")
|
||||
const [site, setSite] = useState<Profile>()
|
||||
const [site, setSite] = useState<ExpandedCharacter>()
|
||||
const date = useDate()
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
@@ -39,9 +39,7 @@ export const CharacterCard: React.FC<{
|
||||
if (siteId) {
|
||||
siteModel.getSite(siteId).then((site) => setSite(site))
|
||||
} else if (address) {
|
||||
siteModel
|
||||
.getUserSites({ address })
|
||||
.then((sites) => setSite(sites?.[0]))
|
||||
siteModel.getSiteByAddress(address).then((site) => setSite(site))
|
||||
}
|
||||
} else {
|
||||
setSite(undefined)
|
||||
@@ -64,7 +62,11 @@ export const CharacterCard: React.FC<{
|
||||
{site ? (
|
||||
<>
|
||||
<span className="flex items-center justify-between">
|
||||
<Avatar images={site?.avatars || []} name={site?.name} size={45} />
|
||||
<Avatar
|
||||
images={site?.metadata?.content?.avatars || []}
|
||||
name={site?.metadata?.content?.name}
|
||||
size={45}
|
||||
/>
|
||||
{!hideFollowButton && (
|
||||
<FollowingButton
|
||||
site={site}
|
||||
@@ -75,30 +77,31 @@ export const CharacterCard: React.FC<{
|
||||
</span>
|
||||
<span className="flex items-center space-x-1">
|
||||
<span className="font-bold text-base text-zinc-800">
|
||||
{site?.name}
|
||||
{site?.metadata?.content?.name}
|
||||
</span>
|
||||
<Titles characterId={+(site.metadata?.proof || "")} />
|
||||
<span className="text-gray-600">@{site?.username}</span>
|
||||
<Titles characterId={+(site?.characterId || "")} />
|
||||
<span className="text-gray-600">@{site?.handle}</span>
|
||||
</span>
|
||||
{site?.description && (
|
||||
{site?.metadata?.content?.bio && (
|
||||
<span className="text-gray-600 line-clamp-4">
|
||||
{site?.description}
|
||||
{site?.metadata?.content?.bio}
|
||||
</span>
|
||||
)}
|
||||
{!simple && (
|
||||
<span className="block">
|
||||
<FollowingCount siteId={site.username} disableList={true} />
|
||||
<FollowingCount
|
||||
characterId={site.characterId}
|
||||
disableList={true}
|
||||
/>
|
||||
</span>
|
||||
)}
|
||||
{!simple && site?.date_created && (
|
||||
{!simple && site?.createdAt && (
|
||||
<span className="block text-gray-500">
|
||||
<time dateTime={date.formatToISO(site.date_created)}>
|
||||
<time dateTime={date.formatToISO(site.createdAt)}>
|
||||
{t("joined ago", {
|
||||
time: date.dayjs
|
||||
.duration(
|
||||
date
|
||||
.dayjs(site.date_created)
|
||||
.diff(date.dayjs(), "minute"),
|
||||
date.dayjs(site.createdAt).diff(date.dayjs(), "minute"),
|
||||
"minute",
|
||||
)
|
||||
.humanize(),
|
||||
|
||||
@@ -3,6 +3,7 @@ import React, { useCallback, useState } from "react"
|
||||
import { Virtuoso } from "react-virtuoso"
|
||||
|
||||
import { Modal } from "~/components/ui/Modal"
|
||||
import { ExpandedCharacter } from "~/lib/types"
|
||||
|
||||
import { Button } from "../ui/Button"
|
||||
import CharacterListItem from "./CharacterListItem"
|
||||
@@ -53,7 +54,8 @@ export const CharacterList: React.FC<{
|
||||
}}
|
||||
data={flattenList}
|
||||
itemContent={(index, sub) => {
|
||||
const character = sub?.character || sub?.fromCharacter
|
||||
const character: ExpandedCharacter =
|
||||
sub?.character || sub?.fromCharacter || sub?.toCharacter
|
||||
return (
|
||||
<CharacterListItem
|
||||
key={index}
|
||||
|
||||
@@ -5,13 +5,14 @@ import { BlockchainIcon } from "~/components/icons/BlockchainIcon"
|
||||
import { CSB_SCAN } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { noopArr } from "~/lib/noop"
|
||||
import { ExpandedCharacter } from "~/lib/types"
|
||||
|
||||
import { Avatar } from "../ui/Avatar"
|
||||
import { UniLink } from "../ui/UniLink"
|
||||
import { FollowingButton } from "./FollowingButton"
|
||||
|
||||
const CharacterListItem: React.FC<{
|
||||
character: any
|
||||
character: ExpandedCharacter
|
||||
sub: any
|
||||
}> = ({ character, sub }) => {
|
||||
return (
|
||||
@@ -43,17 +44,7 @@ const CharacterListItem: React.FC<{
|
||||
<BlockchainIcon />
|
||||
</UniLink>
|
||||
</div>
|
||||
<FollowingButton
|
||||
site={
|
||||
{
|
||||
username: character?.handle,
|
||||
metadata: {
|
||||
proof: character?.characterId,
|
||||
},
|
||||
} as any
|
||||
}
|
||||
size="sm"
|
||||
/>
|
||||
<FollowingButton site={character} size="sm" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,16 +3,17 @@ import { Virtuoso } from "react-virtuoso"
|
||||
|
||||
import { CommentInput } from "~/components/common/CommentInput"
|
||||
import { CommentItem } from "~/components/common/CommentItem"
|
||||
import { Note } from "~/lib/types"
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { useGetComments } from "~/queries/page"
|
||||
|
||||
export const Comment: React.FC<{
|
||||
page?: Note | null
|
||||
page?: ExpandedNote
|
||||
className?: string
|
||||
}> = ({ page, className }) => {
|
||||
const comments = useGetComments({
|
||||
pageId: page?.id,
|
||||
characterId: page?.characterId,
|
||||
noteId: page?.noteId,
|
||||
})
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
@@ -37,7 +38,7 @@ export const Comment: React.FC<{
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<CommentInput pageId={page?.id} />
|
||||
<CommentInput characterId={page?.characterId} noteId={page?.noteId} />
|
||||
|
||||
<Virtuoso
|
||||
className="xlog-comment-list"
|
||||
@@ -51,7 +52,8 @@ export const Comment: React.FC<{
|
||||
p?.list?.map((comment, idx) => (
|
||||
<CommentItem
|
||||
className="mt-6"
|
||||
originalId={page?.id}
|
||||
originalCharacterId={page?.characterId}
|
||||
originalNoteId={page?.noteId}
|
||||
comment={comment}
|
||||
key={comment.transactionHash}
|
||||
depth={0}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { CharacterEntity, NoteEntity } from "crossbell.js"
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import { useEffect, useState } from "react"
|
||||
import { useEffect } from "react"
|
||||
import { useForm } from "react-hook-form"
|
||||
|
||||
import { useAccountState } from "@crossbell/connect-kit"
|
||||
@@ -10,34 +9,32 @@ import { Popover } from "@headlessui/react"
|
||||
import { Avatar } from "~/components/ui/Avatar"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { Input } from "~/components/ui/Input"
|
||||
import { Profile } from "~/lib/types"
|
||||
import { useCommentPage, useUpdateComment } from "~/queries/page"
|
||||
import { useAccountSites } from "~/queries/site"
|
||||
|
||||
import { EmojiPicker } from "./EmojiPicker"
|
||||
|
||||
export const CommentInput: React.FC<{
|
||||
pageId?: string
|
||||
originalId?: string
|
||||
characterId?: number
|
||||
noteId?: number
|
||||
originalCharacterId?: number
|
||||
originalNoteId?: number
|
||||
onSubmitted?: () => void
|
||||
comment?: NoteEntity & {
|
||||
character?: CharacterEntity | null
|
||||
}
|
||||
}> = ({ pageId, originalId, onSubmitted, comment }) => {
|
||||
}> = ({
|
||||
characterId,
|
||||
noteId,
|
||||
originalCharacterId,
|
||||
originalNoteId,
|
||||
onSubmitted,
|
||||
comment,
|
||||
}) => {
|
||||
const account = useAccountState((s) => s.computed.account)
|
||||
const userSites = useAccountSites()
|
||||
const commentPage = useCommentPage()
|
||||
const updateComment = useUpdateComment()
|
||||
const router = useRouter()
|
||||
const [viewer, setViewer] = useState<Profile | null>(null)
|
||||
const { t } = useTranslation(["common", "site"])
|
||||
|
||||
useEffect(() => {
|
||||
if (userSites.isSuccess && userSites.data?.length) {
|
||||
setViewer(userSites.data[0])
|
||||
}
|
||||
}, [userSites, router])
|
||||
|
||||
const form = useForm({
|
||||
defaultValues: {
|
||||
content: comment?.metadata?.content?.content || "",
|
||||
@@ -45,24 +42,26 @@ export const CommentInput: React.FC<{
|
||||
})
|
||||
|
||||
const handleSubmit = form.handleSubmit(async (values) => {
|
||||
if (pageId) {
|
||||
if (characterId && noteId) {
|
||||
if (comment) {
|
||||
if (values.content) {
|
||||
updateComment.mutate({
|
||||
pageId,
|
||||
content: values.content,
|
||||
externalUrl: window.location.href,
|
||||
originalId,
|
||||
characterId: comment.characterId,
|
||||
noteId: comment.noteId,
|
||||
originalCharacterId,
|
||||
originalNoteId,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
commentPage.mutate({
|
||||
pageId: pageId,
|
||||
characterId,
|
||||
noteId,
|
||||
content: values.content,
|
||||
externalUrl: window.location.href,
|
||||
originalId: originalId,
|
||||
originalCharacterId,
|
||||
originalNoteId,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -79,8 +78,8 @@ export const CommentInput: React.FC<{
|
||||
<div className="xlog-comment-input flex">
|
||||
<Avatar
|
||||
className="align-middle mr-3"
|
||||
images={viewer?.avatars || []}
|
||||
name={viewer?.name}
|
||||
images={account?.character?.metadata?.content?.avatars || []}
|
||||
name={account?.character?.metadata?.content?.name}
|
||||
size={45}
|
||||
/>
|
||||
<form className="w-full" onSubmit={handleSubmit}>
|
||||
@@ -88,12 +87,8 @@ export const CommentInput: React.FC<{
|
||||
<Input
|
||||
id="content"
|
||||
isBlock
|
||||
required={
|
||||
!!account && userSites.isSuccess && !!userSites.data?.length
|
||||
}
|
||||
disabled={
|
||||
!account || !userSites.isSuccess || !userSites.data?.length
|
||||
}
|
||||
required={!!account?.character}
|
||||
disabled={!account?.character}
|
||||
multiline
|
||||
maxLength={600}
|
||||
className="mb-2"
|
||||
@@ -125,21 +120,14 @@ export const CommentInput: React.FC<{
|
||||
</Popover>
|
||||
<Button
|
||||
type="submit"
|
||||
isLoading={
|
||||
userSites.isLoading ||
|
||||
commentPage.isLoading ||
|
||||
updateComment.isLoading
|
||||
}
|
||||
isLoading={commentPage.isLoading || updateComment.isLoading}
|
||||
isDisabled={
|
||||
!!account &&
|
||||
userSites.isSuccess &&
|
||||
!!userSites.data?.length &&
|
||||
form.watch("content").trim().length === 0
|
||||
!!account?.character && form.watch("content").trim().length === 0
|
||||
}
|
||||
>
|
||||
{t(
|
||||
account
|
||||
? userSites.isSuccess && !userSites.data?.length
|
||||
? !account.character
|
||||
? "Create Character"
|
||||
: comment
|
||||
? "Confirm Modification"
|
||||
|
||||
@@ -22,10 +22,11 @@ export const CommentItem: React.FC<{
|
||||
comment: NoteEntity & {
|
||||
character?: CharacterEntity | null
|
||||
}
|
||||
originalId?: string
|
||||
originalCharacterId?: number
|
||||
originalNoteId?: number
|
||||
depth: number
|
||||
className?: string
|
||||
}> = ({ comment, originalId, depth, className }) => {
|
||||
}> = ({ comment, originalCharacterId, originalNoteId, depth, className }) => {
|
||||
const [replyOpen, setReplyOpen] = useState(false)
|
||||
const [editOpen, setEditOpen] = useState(false)
|
||||
|
||||
@@ -108,7 +109,8 @@ export const CommentItem: React.FC<{
|
||||
>
|
||||
<ReactionLike
|
||||
size="sm"
|
||||
pageId={`${comment.characterId}-${comment.noteId}`}
|
||||
characterId={comment.characterId}
|
||||
noteId={comment.noteId}
|
||||
/>
|
||||
</div>
|
||||
{depth < 2 && (
|
||||
@@ -137,8 +139,10 @@ export const CommentItem: React.FC<{
|
||||
{replyOpen && (
|
||||
<div className="pt-6">
|
||||
<CommentInput
|
||||
originalId={originalId}
|
||||
pageId={`${comment.characterId}-${comment.noteId}`}
|
||||
originalCharacterId={originalCharacterId}
|
||||
originalNoteId={originalNoteId}
|
||||
characterId={comment.characterId}
|
||||
noteId={comment.noteId}
|
||||
onSubmitted={() => setReplyOpen(false)}
|
||||
/>
|
||||
</div>
|
||||
@@ -146,8 +150,10 @@ export const CommentItem: React.FC<{
|
||||
{editOpen && (
|
||||
<div className="pt-6">
|
||||
<CommentInput
|
||||
originalId={originalId}
|
||||
pageId={`${comment.characterId}-${comment.noteId}`}
|
||||
originalCharacterId={originalCharacterId}
|
||||
originalNoteId={originalNoteId}
|
||||
characterId={comment.characterId}
|
||||
noteId={comment.noteId}
|
||||
onSubmitted={() => setEditOpen(false)}
|
||||
comment={comment}
|
||||
/>
|
||||
@@ -164,7 +170,8 @@ export const CommentItem: React.FC<{
|
||||
},
|
||||
) => (
|
||||
<CommentItem
|
||||
originalId={originalId}
|
||||
originalCharacterId={originalCharacterId}
|
||||
originalNoteId={originalNoteId}
|
||||
comment={subcomment}
|
||||
key={subcomment.transactionHash}
|
||||
depth={depth + 1}
|
||||
|
||||
@@ -32,7 +32,6 @@ import { Menu } from "~/components/ui/Menu"
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { useAccountSites } from "~/queries/site"
|
||||
|
||||
import { UniLink } from "../ui/UniLink"
|
||||
|
||||
@@ -90,8 +89,6 @@ export const ConnectButton: React.FC<{
|
||||
const selectCharactersModal = useSelectCharactersModal()
|
||||
const walletMintNewCharacterModal = useWalletMintNewCharacterModal()
|
||||
|
||||
const userSites = useAccountSites()
|
||||
|
||||
const showNotificationModal = useShowNotificationModal()
|
||||
const { isAllRead } = useNotifications()
|
||||
|
||||
@@ -112,12 +109,12 @@ export const ConnectButton: React.FC<{
|
||||
}, [balance])
|
||||
|
||||
const dropdownLinks: HeaderLinkType[] = [
|
||||
userSites.data?.[0]?.username
|
||||
account?.character
|
||||
? {
|
||||
icon: "icon-[mingcute--home-1-line]",
|
||||
label: t("My xLog") || "",
|
||||
url: getSiteLink({
|
||||
subdomain: userSites.data?.[0]?.username,
|
||||
subdomain: account?.character?.handle || "",
|
||||
}),
|
||||
}
|
||||
: {
|
||||
@@ -219,115 +216,107 @@ export const ConnectButton: React.FC<{
|
||||
className="relative flex items-center -mr-2"
|
||||
style={{ height: avatarSize + "px" }}
|
||||
>
|
||||
{userSites.isSuccess ? (
|
||||
{!hideNotification && (
|
||||
<>
|
||||
{!hideNotification && (
|
||||
<>
|
||||
{isAllRead ? (
|
||||
<BellIcon
|
||||
className={`${
|
||||
size === "base" ? "w-6 h-6" : "w-5 h-5"
|
||||
} text-zinc-500 cursor-pointer sm:hover:animate-buzz-out`}
|
||||
onClick={showNotificationModal}
|
||||
/>
|
||||
) : (
|
||||
<BellAlertIcon
|
||||
className={`${
|
||||
size === "base" ? "w-6 h-6" : "w-5 h-5"
|
||||
} text-accent cursor-pointer sm:hover:animate-buzz-out`}
|
||||
onClick={showNotificationModal}
|
||||
/>
|
||||
)}
|
||||
<div className="h-full w-[2px] py-1 ml-3">
|
||||
<div className="w-full h-full bg-zinc-200 rounded-full"></div>
|
||||
</div>
|
||||
</>
|
||||
{isAllRead ? (
|
||||
<BellIcon
|
||||
className={`${
|
||||
size === "base" ? "w-6 h-6" : "w-5 h-5"
|
||||
} text-zinc-500 cursor-pointer sm:hover:animate-buzz-out`}
|
||||
onClick={showNotificationModal}
|
||||
/>
|
||||
) : (
|
||||
<BellAlertIcon
|
||||
className={`${
|
||||
size === "base" ? "w-6 h-6" : "w-5 h-5"
|
||||
} text-accent cursor-pointer sm:hover:animate-buzz-out`}
|
||||
onClick={showNotificationModal}
|
||||
/>
|
||||
)}
|
||||
<Menu
|
||||
placement="bottom-end"
|
||||
target={
|
||||
<button
|
||||
className="flex items-center w-full hover:bg-hover transition-colors py-1 px-2 rounded-lg ml-1"
|
||||
type="button"
|
||||
aria-label="connector"
|
||||
>
|
||||
<Avatar
|
||||
className="align-middle"
|
||||
images={userSites.data?.[0]?.avatars || []}
|
||||
name={userSites.data?.[0]?.name}
|
||||
size={avatarSize}
|
||||
/>
|
||||
{!hideName && (
|
||||
<>
|
||||
<div
|
||||
className={`flex-1 flex-col min-w-0 ml-2 max-w-[100px] ${
|
||||
mobileSimplification ? "hidden sm:flex" : "flex"
|
||||
<div className="h-full w-[2px] py-1 ml-3">
|
||||
<div className="w-full h-full bg-zinc-200 rounded-full"></div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<Menu
|
||||
placement="bottom-end"
|
||||
target={
|
||||
<button
|
||||
className="flex items-center w-full hover:bg-hover transition-colors py-1 px-2 rounded-lg ml-1"
|
||||
type="button"
|
||||
aria-label="connector"
|
||||
>
|
||||
<Avatar
|
||||
className="align-middle"
|
||||
images={account.character?.metadata?.content?.avatars || []}
|
||||
name={account.character?.metadata?.content?.name}
|
||||
size={avatarSize}
|
||||
/>
|
||||
{!hideName && (
|
||||
<>
|
||||
<div
|
||||
className={`flex-1 flex-col min-w-0 ml-2 max-w-[100px] ${
|
||||
mobileSimplification ? "hidden sm:flex" : "flex"
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`text-left leading-none font-medium truncate ${
|
||||
InsufficientBalance
|
||||
? "text-red-600"
|
||||
: "text-gray-600"
|
||||
} ${size === "base" ? "text-base" : "text-sm"}`}
|
||||
style={{ marginBottom: "0.15rem" }}
|
||||
>
|
||||
{account.character?.metadata?.content?.name ||
|
||||
getAccountDisplayName(account)}
|
||||
</span>
|
||||
{account.character?.handle && (
|
||||
<span
|
||||
className={`text-left leading-none ${
|
||||
sizeDecrease === "sm" ? "text-sm" : "text-xs"
|
||||
} truncate ${
|
||||
InsufficientBalance
|
||||
? "text-red-400"
|
||||
: "text-gray-400"
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`text-left leading-none font-medium truncate ${
|
||||
InsufficientBalance
|
||||
? "text-red-600"
|
||||
: "text-gray-600"
|
||||
} ${size === "base" ? "text-base" : "text-sm"}`}
|
||||
style={{ marginBottom: "0.15rem" }}
|
||||
>
|
||||
{userSites.data?.[0]?.name ||
|
||||
getAccountDisplayName(account)}
|
||||
</span>
|
||||
{userSites.data?.[0]?.username && (
|
||||
<span
|
||||
className={`text-left leading-none ${
|
||||
sizeDecrease === "sm" ? "text-sm" : "text-xs"
|
||||
} truncate ${
|
||||
InsufficientBalance
|
||||
? "text-red-400"
|
||||
: "text-gray-400"
|
||||
}`}
|
||||
>
|
||||
{"@" + userSites.data?.[0]?.username ||
|
||||
getAccountDisplayName(account)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<i className="icon-[mingcute--down-line] text-xl ml-[2px]" />
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
dropdown={
|
||||
<div
|
||||
className={`text-gray-600 bg-white rounded-lg ring-1 ring-border min-w-[140px] shadow-md py-2 ${
|
||||
size === "base" ? "text-base" : "text-sm"
|
||||
} mt-1`}
|
||||
>
|
||||
{dropdownLinks.map((link, i) => {
|
||||
return (
|
||||
<UniLink
|
||||
key={i}
|
||||
href={link.url}
|
||||
onClick={link.onClick}
|
||||
className={`${
|
||||
size === "base"
|
||||
? "pl-5 pr-6 h-11"
|
||||
: "pl-4 pr-5 h-9"
|
||||
} flex items-center w-full whitespace-nowrap hover:bg-hover`}
|
||||
aria-label={link.label}
|
||||
>
|
||||
<span className="mr-2 flex justify-center">
|
||||
<i className={cn(link.icon, "text-base")} />
|
||||
</span>
|
||||
{link.label}
|
||||
</UniLink>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{"@" + account.character?.handle ||
|
||||
getAccountDisplayName(account)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<i className="icon-[mingcute--down-line] text-xl ml-[2px]" />
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
}
|
||||
dropdown={
|
||||
<div
|
||||
className={`text-gray-600 bg-white rounded-lg ring-1 ring-border min-w-[140px] shadow-md py-2 ${
|
||||
size === "base" ? "text-base" : "text-sm"
|
||||
} mt-1`}
|
||||
>
|
||||
{dropdownLinks.map((link, i) => {
|
||||
return (
|
||||
<UniLink
|
||||
key={i}
|
||||
href={link.url}
|
||||
onClick={link.onClick}
|
||||
className={`${
|
||||
size === "base" ? "pl-5 pr-6 h-11" : "pl-4 pr-5 h-9"
|
||||
} flex items-center w-full whitespace-nowrap hover:bg-hover`}
|
||||
aria-label={link.label}
|
||||
>
|
||||
<span className="mr-2 flex justify-center">
|
||||
<i className={cn(link.icon, "text-base")} />
|
||||
</span>
|
||||
{link.label}
|
||||
</UniLink>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
})()}
|
||||
|
||||
@@ -6,17 +6,16 @@ import { Button } from "~/components/ui/Button"
|
||||
import type { Variant } from "~/components/ui/Button"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import { Profile } from "~/lib/types"
|
||||
import { ExpandedCharacter } from "~/lib/types"
|
||||
import { cn } from "~/lib/utils"
|
||||
import {
|
||||
useAccountSites,
|
||||
useGetSubscription,
|
||||
useSubscribeToSite,
|
||||
useUnsubscribeFromSite,
|
||||
} from "~/queries/site"
|
||||
|
||||
export const FollowingButton: React.FC<{
|
||||
site: Profile | undefined | null
|
||||
site?: ExpandedCharacter
|
||||
variant?: Variant
|
||||
className?: string
|
||||
size?: "sm" | "xl"
|
||||
@@ -24,27 +23,25 @@ export const FollowingButton: React.FC<{
|
||||
}> = ({ site, variant, className, size, loadingStatusChange }) => {
|
||||
const subscribeToSite = useSubscribeToSite()
|
||||
const unsubscribeFromSite = useUnsubscribeFromSite()
|
||||
const userSite = useAccountSites()
|
||||
const characterId = site?.metadata?.proof ? Number(site.metadata.proof) : null
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
const handleClickSubscribe = () => {
|
||||
if (characterId) {
|
||||
if (site?.characterId) {
|
||||
if (subscription.data) {
|
||||
unsubscribeFromSite.mutate({
|
||||
characterId,
|
||||
siteId: site?.username,
|
||||
characterId: site?.characterId,
|
||||
siteId: site?.handle,
|
||||
} as any)
|
||||
} else {
|
||||
subscribeToSite.mutate({
|
||||
characterId,
|
||||
siteId: site?.username,
|
||||
characterId: site?.characterId,
|
||||
siteId: site?.handle,
|
||||
} as any)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const subscription = useGetSubscription(site?.username)
|
||||
const subscription = useGetSubscription(site?.characterId)
|
||||
|
||||
useEffect(() => {
|
||||
if (subscribeToSite.isError) {
|
||||
@@ -99,8 +96,7 @@ export const FollowingButton: React.FC<{
|
||||
isLoading={
|
||||
subscription.data
|
||||
? unsubscribeFromSite.isLoading || subscribeToSite.isLoading
|
||||
: userSite.isLoading ||
|
||||
unsubscribeFromSite.isLoading ||
|
||||
: unsubscribeFromSite.isLoading ||
|
||||
subscribeToSite.isLoading ||
|
||||
subscription.isLoading
|
||||
}
|
||||
|
||||
@@ -9,18 +9,18 @@ import {
|
||||
} from "~/queries/site"
|
||||
|
||||
export const FollowingCount: React.FC<{
|
||||
siteId?: string
|
||||
characterId?: number
|
||||
disableList?: boolean
|
||||
}> = ({ siteId, disableList }) => {
|
||||
}> = ({ characterId, disableList }) => {
|
||||
let [isFollowListOpen, setIsFollowListOpen] = useState(false)
|
||||
let [isToFollowListOpen, setIsToFollowListOpen] = useState(false)
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
const subscriptions = useGetSiteSubscriptions({
|
||||
siteId: siteId || "",
|
||||
characterId,
|
||||
})
|
||||
const toSubscriptions = useGetSiteToSubscriptions({
|
||||
siteId: siteId || "",
|
||||
characterId,
|
||||
})
|
||||
|
||||
return (
|
||||
@@ -34,7 +34,7 @@ export const FollowingCount: React.FC<{
|
||||
onClick={() => setIsFollowListOpen(true)}
|
||||
>
|
||||
<span className="font-medium text-zinc-700 pr-[2px]">
|
||||
{subscriptions.data?.pages?.[0]?.total || 0}
|
||||
{subscriptions.data?.pages?.[0]?.count || 0}
|
||||
</span>{" "}
|
||||
{t("Followers")}
|
||||
</Button>
|
||||
@@ -47,7 +47,7 @@ export const FollowingCount: React.FC<{
|
||||
onClick={() => setIsToFollowListOpen(true)}
|
||||
>
|
||||
<span className="font-medium text-zinc-700 pr-[2px]">
|
||||
{toSubscriptions.data?.pages?.[0]?.total || 0}
|
||||
{toSubscriptions.data?.pages?.[0]?.count || 0}
|
||||
</span>{" "}
|
||||
{t("Followings")}
|
||||
</Button>
|
||||
|
||||
@@ -3,11 +3,11 @@ import { useState } from "react"
|
||||
|
||||
import { PatronModal } from "~/components/common/PatronModal"
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { Profile } from "~/lib/types"
|
||||
import { ExpandedCharacter } from "~/lib/types"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
export const PatronButton: React.FC<{
|
||||
site: Profile | undefined | null
|
||||
site?: ExpandedCharacter
|
||||
className?: string
|
||||
size?: "sm" | "xl"
|
||||
loadingStatusChange?: (status: boolean) => void
|
||||
|
||||
@@ -11,8 +11,7 @@ import { Button } from "~/components/ui/Button"
|
||||
import { Modal } from "~/components/ui/Modal"
|
||||
import { CSB_SCAN, MIRA_LINK } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { Note, Profile } from "~/lib/types"
|
||||
import { parsePageId } from "~/models/page.model"
|
||||
import { ExpandedCharacter, ExpandedNote } from "~/lib/types"
|
||||
import { useGetTips, useTipCharacter } from "~/queries/site"
|
||||
|
||||
import { Tabs } from "../ui/Tabs"
|
||||
@@ -20,17 +19,23 @@ import { UniLink } from "../ui/UniLink"
|
||||
import { CharacterFloatCard } from "./CharacterFloatCard"
|
||||
|
||||
export const PatronModal: React.FC<{
|
||||
site: Profile | undefined | null
|
||||
page?: Note | null
|
||||
site?: ExpandedCharacter
|
||||
page?: ExpandedNote
|
||||
open: boolean
|
||||
setOpen: (open: boolean) => void
|
||||
}> = ({ site, page, open, setOpen }) => {
|
||||
const { t } = useTranslation("common")
|
||||
const tipCharacter = useTipCharacter()
|
||||
const tips = useGetTips({
|
||||
toCharacterId: site?.metadata?.proof,
|
||||
toNoteId: parsePageId(page?.id || "").noteId,
|
||||
})
|
||||
const tips = useGetTips(
|
||||
page
|
||||
? {
|
||||
toCharacterId: page?.characterId,
|
||||
toNoteId: page?.noteId,
|
||||
}
|
||||
: {
|
||||
toCharacterId: site?.characterId,
|
||||
},
|
||||
)
|
||||
const connectModal = useConnectModal()
|
||||
|
||||
const radios = [
|
||||
@@ -66,12 +71,12 @@ export const PatronModal: React.FC<{
|
||||
)
|
||||
|
||||
const submit = () => {
|
||||
if (currentCharacterId && site?.metadata?.proof && parseInt(value)) {
|
||||
if (currentCharacterId && site?.characterId && parseInt(value)) {
|
||||
tipCharacter.mutate({
|
||||
fromCharacterId: currentCharacterId,
|
||||
toCharacterId: site?.metadata?.proof,
|
||||
toCharacterId: site?.characterId,
|
||||
amount: parseInt(value),
|
||||
noteId: parsePageId(page?.id || "").noteId,
|
||||
noteId: page?.noteId,
|
||||
})
|
||||
} else {
|
||||
setOpen(false)
|
||||
@@ -100,7 +105,7 @@ export const PatronModal: React.FC<{
|
||||
tipCharacter.reset()
|
||||
}
|
||||
}
|
||||
}, [tipCharacter.isSuccess, t, site?.name])
|
||||
}, [tipCharacter.isSuccess, t])
|
||||
|
||||
useEffect(() => {
|
||||
if (tipCharacter.isError) {
|
||||
@@ -112,10 +117,10 @@ export const PatronModal: React.FC<{
|
||||
const title =
|
||||
(page
|
||||
? t("Tip the post: {{name}}", {
|
||||
name: page.title,
|
||||
name: page.metadata?.content?.title,
|
||||
})
|
||||
: t("Become a patron of {{name}}", {
|
||||
name: site?.name,
|
||||
name: site?.metadata?.content?.name,
|
||||
})) || ""
|
||||
|
||||
return (
|
||||
@@ -135,17 +140,21 @@ export const PatronModal: React.FC<{
|
||||
<div className="px-5 py-4 space-y-4 text-center">
|
||||
<div className="space-y-1">
|
||||
<span className="flex items-center justify-center">
|
||||
<Avatar images={site?.avatars || []} name={site?.name} size={100} />
|
||||
<Avatar
|
||||
images={site?.metadata?.content?.avatars || []}
|
||||
name={site?.metadata?.content?.name}
|
||||
size={100}
|
||||
/>
|
||||
</span>
|
||||
<span className="block">
|
||||
<span className="font-bold text-lg text-zinc-800">
|
||||
{site?.name}
|
||||
{site?.metadata?.content?.name}
|
||||
</span>
|
||||
<span className="ml-1 text-gray-600">@{site?.username}</span>
|
||||
<span className="ml-1 text-gray-600">@{site?.handle}</span>
|
||||
</span>
|
||||
{site?.description && (
|
||||
{site?.metadata?.content?.bio && (
|
||||
<span className="text-gray-600 text-sm line-clamp-4">
|
||||
{site?.description}
|
||||
{site?.metadata?.content?.bio}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,6 @@ import { Tooltip } from "~/components/ui/Tooltip"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { CSB_SCAN } from "~/lib/env"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { parsePageId } from "~/models/page.model"
|
||||
import {
|
||||
useCheckLike,
|
||||
useGetLikeCounts,
|
||||
@@ -21,8 +20,9 @@ import { Button } from "../ui/Button"
|
||||
|
||||
export const ReactionLike: React.FC<{
|
||||
size?: "sm" | "base"
|
||||
pageId?: string
|
||||
}> = ({ size, pageId }) => {
|
||||
characterId?: number
|
||||
noteId?: number
|
||||
}> = ({ size, characterId, noteId }) => {
|
||||
const toggleLikePage = useToggleLikePage()
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
@@ -30,29 +30,44 @@ export const ReactionLike: React.FC<{
|
||||
const [isLikeListOpen, setIsLikeListOpen] = useState(false)
|
||||
const likeRef = useRef<HTMLButtonElement>(null)
|
||||
|
||||
const [likes, likesMutation] = useGetLikes({ pageId })
|
||||
const [likeStatus] = useCheckLike({
|
||||
pageId,
|
||||
const [likes, likesMutation] = useGetLikes({
|
||||
characterId,
|
||||
noteId,
|
||||
})
|
||||
const [likeStatus] = useCheckLike({
|
||||
characterId,
|
||||
noteId,
|
||||
})
|
||||
const { data: likeCount = 0 } = useGetLikeCounts({
|
||||
characterId,
|
||||
noteId,
|
||||
})
|
||||
const { data: likeCount = 0 } = useGetLikeCounts({ pageId })
|
||||
|
||||
const [isUnlikeOpen, setIsUnlikeOpen] = useState(false)
|
||||
|
||||
const like = () => {
|
||||
if (pageId) {
|
||||
if (characterId && noteId) {
|
||||
if (likeStatus.isLiked) {
|
||||
setIsLikeOpen(true)
|
||||
} else {
|
||||
toggleLikePage.mutate({ ...parsePageId(pageId), action: "link" })
|
||||
toggleLikePage.mutate({
|
||||
characterId,
|
||||
noteId,
|
||||
action: "link",
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const unlike = () => {
|
||||
if (pageId) {
|
||||
if (characterId && noteId) {
|
||||
setIsUnlikeOpen(false)
|
||||
if (likeStatus.isLiked) {
|
||||
toggleLikePage.mutate({ ...parsePageId(pageId), action: "unlink" })
|
||||
toggleLikePage.mutate({
|
||||
noteId,
|
||||
characterId,
|
||||
action: "unlink",
|
||||
})
|
||||
} // else do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import { UniLink } from "~/components/ui/UniLink"
|
||||
import { CSB_SCAN, CSB_XCHAR } from "~/lib/env"
|
||||
import { noopArr } from "~/lib/noop"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { parsePageId } from "~/models/page.model"
|
||||
import { useCheckMint, useGetMints, useMintPage } from "~/queries/page"
|
||||
|
||||
import { AvatarStack } from "../ui/AvatarStack"
|
||||
@@ -20,8 +19,9 @@ import { Button } from "../ui/Button"
|
||||
|
||||
export const ReactionMint: React.FC<{
|
||||
size?: "sm" | "base"
|
||||
pageId?: string
|
||||
}> = ({ size, pageId }) => {
|
||||
noteId?: number
|
||||
characterId?: number
|
||||
}> = ({ size, noteId, characterId }) => {
|
||||
const mintPage = useMintPage()
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
@@ -32,17 +32,24 @@ export const ReactionMint: React.FC<{
|
||||
const mintRef = useRef<HTMLButtonElement>(null)
|
||||
|
||||
const mints = useGetMints({
|
||||
pageId: pageId,
|
||||
characterId,
|
||||
noteId,
|
||||
includeCharacter: size !== "sm",
|
||||
})
|
||||
const isMint = useCheckMint(pageId)
|
||||
const isMint = useCheckMint({
|
||||
characterId,
|
||||
noteId,
|
||||
})
|
||||
|
||||
const mint = () => {
|
||||
if (pageId) {
|
||||
if (characterId && noteId) {
|
||||
if (isMint.data?.count) {
|
||||
setIsMintOpen(true)
|
||||
} else {
|
||||
mintPage.mutate(parsePageId(pageId))
|
||||
mintPage.mutate({
|
||||
characterId,
|
||||
noteId,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,11 +84,11 @@ export const ReactionMint: React.FC<{
|
||||
const avatars = useMemo(
|
||||
() =>
|
||||
mints.data?.pages?.[0]?.list
|
||||
?.sort((a, b: any) =>
|
||||
?.sort((a, b) =>
|
||||
b.character?.metadata?.content?.avatars?.[0] ? 1 : -1,
|
||||
)
|
||||
.slice(0, 3)
|
||||
.map((mint: any) => ({
|
||||
.map((mint) => ({
|
||||
images: mint.character?.metadata?.content?.avatars,
|
||||
name: mint.character?.metadata?.content?.name,
|
||||
})) || noopArr,
|
||||
|
||||
@@ -6,18 +6,18 @@ import { useAccountState } from "@crossbell/connect-kit"
|
||||
import { PatronModal } from "~/components/common/PatronModal"
|
||||
import { Tooltip } from "~/components/ui/Tooltip"
|
||||
import { noopArr } from "~/lib/noop"
|
||||
import { Note, Profile } from "~/lib/types"
|
||||
import { parsePageId } from "~/models/page.model"
|
||||
import { ExpandedCharacter, ExpandedNote } from "~/lib/types"
|
||||
import { useGetTips } from "~/queries/site"
|
||||
|
||||
import { AvatarStack } from "../ui/AvatarStack"
|
||||
import { Button } from "../ui/Button"
|
||||
|
||||
export const ReactionTip: React.FC<{
|
||||
pageId?: string
|
||||
site?: Profile | null
|
||||
page?: Note | null
|
||||
}> = ({ pageId, site, page }) => {
|
||||
characterId?: number
|
||||
noteId?: number
|
||||
site?: ExpandedCharacter
|
||||
page?: ExpandedNote
|
||||
}> = ({ characterId, noteId, site, page }) => {
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
const account = useAccountState((s) => s.computed.account)
|
||||
@@ -25,7 +25,6 @@ export const ReactionTip: React.FC<{
|
||||
const [isTipOpen, setIsTipOpen] = useState(false)
|
||||
const tipRef = useRef<HTMLButtonElement>(null)
|
||||
|
||||
const { characterId, noteId } = parsePageId(pageId || "")
|
||||
const tips = useGetTips({
|
||||
toCharacterId: characterId,
|
||||
toNoteId: noteId,
|
||||
@@ -37,7 +36,7 @@ export const ReactionTip: React.FC<{
|
||||
})
|
||||
|
||||
const tip = () => {
|
||||
if (pageId) {
|
||||
if (characterId && noteId) {
|
||||
setIsTipOpen(true)
|
||||
}
|
||||
}
|
||||
@@ -45,11 +44,11 @@ export const ReactionTip: React.FC<{
|
||||
const avatars = useMemo(
|
||||
() =>
|
||||
tips.data?.pages?.[0]?.list
|
||||
?.sort((a, b: any) =>
|
||||
?.sort((a, b) =>
|
||||
b.character?.metadata?.content?.avatars?.[0] ? 1 : -1,
|
||||
)
|
||||
.slice(0, 3)
|
||||
.map((mint: any) => ({
|
||||
.map((mint) => ({
|
||||
images: mint.character?.metadata?.content?.avatars,
|
||||
name: mint.character?.metadata?.content?.name,
|
||||
})) || noopArr,
|
||||
|
||||
@@ -19,7 +19,7 @@ import { toGateway } from "~/lib/ipfs-parser"
|
||||
import { getStorage } from "~/lib/storage"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { useGetPagesBySite } from "~/queries/page"
|
||||
import { useAccountSites, useGetSite } from "~/queries/site"
|
||||
import { useGetSite } from "~/queries/site"
|
||||
|
||||
import { SEOHead } from "../common/SEOHead"
|
||||
import { UniLink } from "../ui/UniLink"
|
||||
@@ -36,12 +36,11 @@ export function DashboardLayout({
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
const site = useGetSite(subdomain)
|
||||
const userSite = useAccountSites()
|
||||
|
||||
const userRole = useUserRole(subdomain)
|
||||
const [ssrReady, isConnected] = useAccountState(({ ssrReady, computed }) => [
|
||||
const [ssrReady, account] = useAccountState(({ ssrReady, computed }) => [
|
||||
ssrReady,
|
||||
!!computed.account,
|
||||
computed.account,
|
||||
])
|
||||
const connectModal = useConnectModal()
|
||||
const [ready, setReady] = React.useState(false)
|
||||
@@ -52,7 +51,7 @@ export function DashboardLayout({
|
||||
|
||||
useEffect(() => {
|
||||
if (ssrReady) {
|
||||
if (!isConnected) {
|
||||
if (!account) {
|
||||
setReady(false)
|
||||
setHasPermission(false)
|
||||
connectModal.show()
|
||||
@@ -65,22 +64,22 @@ export function DashboardLayout({
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [ssrReady, userRole.isSuccess, userRole.data, isConnected, connectModal])
|
||||
}, [ssrReady, userRole.isSuccess, userRole.data, account, connectModal])
|
||||
|
||||
const showNotificationModal = useShowNotificationModal()
|
||||
const { isAllRead } = useNotifications()
|
||||
|
||||
const pages = useGetPagesBySite({
|
||||
type: "post",
|
||||
site: "xlog-events",
|
||||
take: 1,
|
||||
characterId: 50153,
|
||||
limit: 1,
|
||||
})
|
||||
const [isEventsAllRead, setIsEventsAllRead] = React.useState(true)
|
||||
const latestEventRead = getStorage("latestEventRead")?.value || 0
|
||||
useEffect(() => {
|
||||
if (pages.isSuccess) {
|
||||
if (
|
||||
new Date(pages.data.pages[0].list?.[0].date_created) >
|
||||
new Date(pages.data.pages[0].list?.[0].createdAt) >
|
||||
new Date(latestEventRead)
|
||||
) {
|
||||
setIsEventsAllRead(false)
|
||||
@@ -169,13 +168,15 @@ export function DashboardLayout({
|
||||
hasPermission ? (
|
||||
<>
|
||||
<SEOHead title={t(title) || ""} siteName={APP_NAME} />
|
||||
{site?.data?.css && (
|
||||
{site?.data?.metadata?.content?.css && (
|
||||
<link
|
||||
type="text/css"
|
||||
rel="stylesheet"
|
||||
href={
|
||||
"data:text/css;base64," +
|
||||
Buffer.from(toGateway(site.data.css)).toString("base64")
|
||||
Buffer.from(toGateway(site.data.metadata?.content?.css)).toString(
|
||||
"base64",
|
||||
)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
@@ -274,23 +275,25 @@ export function DashboardLayout({
|
||||
</div>
|
||||
{isOpen && "xLog"}
|
||||
</div>
|
||||
{userSite.data?.[0]?.username &&
|
||||
{account?.character?.handle &&
|
||||
subdomain &&
|
||||
userSite.data[0].username !== subdomain && (
|
||||
account?.character?.handle !== subdomain && (
|
||||
<div className="mb-2 px-5 pt-3 pb-2 bg-orange-50 text-center">
|
||||
<div className="mb-2">
|
||||
{isOpen && "You are operating"}
|
||||
</div>
|
||||
<Avatar
|
||||
images={site.data?.avatars || []}
|
||||
images={site.data?.metadata?.content?.avatars || []}
|
||||
size={isOpen ? 60 : 40}
|
||||
name={site.data?.name}
|
||||
name={site.data?.metadata?.content?.name}
|
||||
/>
|
||||
{isOpen && (
|
||||
<span className="flex flex-col justify-center">
|
||||
<span className="block">{site.data?.name}</span>
|
||||
<span className="block">
|
||||
{site.data?.metadata?.content?.name}
|
||||
</span>
|
||||
<span className="block text-sm text-zinc-400">
|
||||
@{site.data?.username}
|
||||
@{site.data?.handle}
|
||||
</span>
|
||||
</span>
|
||||
)}
|
||||
|
||||
@@ -11,9 +11,10 @@ import { useDate } from "~/hooks/useDate"
|
||||
import { getPageVisibility } from "~/lib/page-helpers"
|
||||
import { readFiles } from "~/lib/read-files"
|
||||
import { setStorage } from "~/lib/storage"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import { ExpandedNote, PageVisibilityEnum } from "~/lib/types"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { useGetPagesBySite } from "~/queries/page"
|
||||
import { useGetSite } from "~/queries/site"
|
||||
|
||||
import { Button } from "../ui/Button"
|
||||
import { EmptyState } from "../ui/EmptyState"
|
||||
@@ -29,6 +30,7 @@ export const PagesManager: React.FC<{
|
||||
}> = ({ isPost }) => {
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
const site = useGetSite(subdomain)
|
||||
|
||||
const visibility = useMemo<PageVisibilityEnum>(
|
||||
() =>
|
||||
@@ -43,13 +45,13 @@ export const PagesManager: React.FC<{
|
||||
|
||||
const pages = useGetPagesBySite({
|
||||
type: isPost ? "post" : "page",
|
||||
site: subdomain!,
|
||||
take: 100,
|
||||
characterId: site.data?.characterId,
|
||||
limit: 100,
|
||||
visibility,
|
||||
})
|
||||
|
||||
// Batch selections
|
||||
const [batchSelected, setBatchSelected] = useState<string[]>([])
|
||||
const [batchSelected, setBatchSelected] = useState<(string | number)[]>([])
|
||||
|
||||
const tabItems: TabItem[] = [
|
||||
{
|
||||
@@ -68,10 +70,6 @@ export const PagesManager: React.FC<{
|
||||
value: PageVisibilityEnum.Scheduled,
|
||||
text: "Scheduled",
|
||||
},
|
||||
{
|
||||
value: PageVisibilityEnum.Crossbell,
|
||||
text: "Others on Crossbell",
|
||||
},
|
||||
].map((item) => ({
|
||||
text: item.text,
|
||||
onClick: () => {
|
||||
@@ -90,10 +88,10 @@ export const PagesManager: React.FC<{
|
||||
active: item.value === visibility,
|
||||
}))
|
||||
|
||||
const getPageEditLink = (page: { id: string }) => {
|
||||
return `/dashboard/${subdomain}/editor?id=${page.id}&type=${
|
||||
isPost ? "post" : "page"
|
||||
}`
|
||||
const getPageEditLink = (page: ExpandedNote) => {
|
||||
return `/dashboard/${subdomain}/editor?id=${
|
||||
page.noteId || page.draftKey
|
||||
}&type=${isPost ? "post" : "page"}`
|
||||
}
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
@@ -106,7 +104,7 @@ export const PagesManager: React.FC<{
|
||||
const file = (await readFiles(e.target?.files))?.[0]
|
||||
if (file) {
|
||||
const id = nanoid()
|
||||
const key = `draft-${subdomain}-local-${id}`
|
||||
const key = `draft-${site.data?.characterId}-local-${id}`
|
||||
setStorage(key, {
|
||||
date: +new Date(),
|
||||
values: {
|
||||
@@ -119,7 +117,10 @@ export const PagesManager: React.FC<{
|
||||
},
|
||||
isPost: isPost,
|
||||
})
|
||||
queryClient.invalidateQueries(["getPagesBySite", subdomain])
|
||||
queryClient.invalidateQueries([
|
||||
"getPagesBySite",
|
||||
site.data?.characterId,
|
||||
])
|
||||
router.push(
|
||||
`/dashboard/${subdomain}/editor?id=local-${id}&type=${
|
||||
isPost ? "post" : "page"
|
||||
@@ -220,7 +221,7 @@ export const PagesManager: React.FC<{
|
||||
!!tabItems.find((item) => item.text === "Others on Crossbell") // Not sure if there are better ways
|
||||
?.active
|
||||
}
|
||||
pages={pages}
|
||||
pages={pages.data}
|
||||
batchSelected={batchSelected}
|
||||
setBatchSelected={setBatchSelected}
|
||||
/>
|
||||
@@ -229,7 +230,7 @@ export const PagesManager: React.FC<{
|
||||
)}
|
||||
|
||||
<div className="-mt-3">
|
||||
{!pages.data?.pages?.[0].total && (
|
||||
{!pages.data?.pages?.[0].count && (
|
||||
<EmptyState resource={isPost ? "posts" : "pages"} />
|
||||
)}
|
||||
|
||||
@@ -238,7 +239,7 @@ export const PagesManager: React.FC<{
|
||||
currentLength++
|
||||
return (
|
||||
<Link
|
||||
key={page.id}
|
||||
key={page.transactionHash}
|
||||
href={getPageEditLink(page)}
|
||||
className="group relative hover:bg-zinc-100 rounded-lg py-3 px-3 transition-colors -mx-3 flex"
|
||||
>
|
||||
@@ -246,27 +247,39 @@ export const PagesManager: React.FC<{
|
||||
<button
|
||||
className={cn(
|
||||
`text-gray-400 relative z-10 w-8 h-8 rounded inline-flex group-hover:visible justify-center items-center`,
|
||||
batchSelected.includes(page.id)
|
||||
batchSelected.includes(page.noteId || page.draftKey || 0)
|
||||
? "bg-gray-200"
|
||||
: `hover:bg-gray-200`,
|
||||
)}
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
// Toggle selection
|
||||
if (batchSelected.includes(page.id)) {
|
||||
if (
|
||||
batchSelected.includes(
|
||||
page.noteId || page.draftKey || 0,
|
||||
)
|
||||
) {
|
||||
// Deselect
|
||||
setBatchSelected(
|
||||
batchSelected.filter((pageId) => pageId !== page.id),
|
||||
batchSelected.filter(
|
||||
(pageId) =>
|
||||
pageId !== page.noteId || page.draftKey || 0,
|
||||
),
|
||||
)
|
||||
} else {
|
||||
// Do select
|
||||
setBatchSelected([...batchSelected, page.id])
|
||||
setBatchSelected([
|
||||
...batchSelected,
|
||||
page.noteId || page.draftKey || 0,
|
||||
])
|
||||
}
|
||||
}}
|
||||
>
|
||||
<i
|
||||
className={`${
|
||||
batchSelected.includes(page.id)
|
||||
batchSelected.includes(
|
||||
page.noteId || page.draftKey || 0,
|
||||
)
|
||||
? "icon-[mingcute--check-line]"
|
||||
: isPost
|
||||
? "icon-[mingcute--news-line]"
|
||||
@@ -276,13 +289,13 @@ export const PagesManager: React.FC<{
|
||||
</button>
|
||||
</div>
|
||||
<div className="min-w-0">
|
||||
{page.title ? (
|
||||
{page.metadata?.content?.title ? (
|
||||
<div className="flex items-center">
|
||||
<span>{page.title}</span>
|
||||
<span>{page.metadata?.content?.title}</span>
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-zinc-500 text-xs mt-1 truncate">
|
||||
<span>{page.summary?.content}</span>
|
||||
<span>{page.metadata?.content?.summary}</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="text-zinc-400 text-xs mt-1">
|
||||
@@ -292,8 +305,10 @@ export const PagesManager: React.FC<{
|
||||
<span className="mx-2">·</span>
|
||||
<span>
|
||||
{getPageVisibility(page) === PageVisibilityEnum.Draft
|
||||
? date.formatDate(page.date_updated)
|
||||
: date.formatDate(page.date_published)}
|
||||
? date.formatDate(page.updatedAt)
|
||||
: date.formatDate(
|
||||
page.metadata?.content?.date_published || "",
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -341,11 +356,11 @@ export const PagesManager: React.FC<{
|
||||
isPost
|
||||
? "post"
|
||||
: "page" +
|
||||
((pages.data?.pages?.[0].total || 0) - currentLength > 1
|
||||
((pages.data?.pages?.[0].count || 0) - currentLength > 1
|
||||
? "s"
|
||||
: ""),
|
||||
),
|
||||
count: (pages.data?.pages?.[0].total || 0) - currentLength,
|
||||
count: (pages.data?.pages?.[0].count || 0) - currentLength,
|
||||
ns: "site",
|
||||
})}
|
||||
</Button>
|
||||
|
||||
@@ -2,14 +2,14 @@ import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import React, { useState } from "react"
|
||||
import toast from "react-hot-toast"
|
||||
import type { Note, Notes } from "unidata.js"
|
||||
|
||||
import type { UseInfiniteQueryResult } from "@tanstack/react-query"
|
||||
import type { InfiniteData } from "@tanstack/react-query"
|
||||
import { useQueryClient } from "@tanstack/react-query"
|
||||
|
||||
import { type TabItem, Tabs } from "~/components/ui/Tabs"
|
||||
import { APP_NAME } from "~/lib/env"
|
||||
import { delStorage, getStorage, setStorage } from "~/lib/storage"
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
import { useCreateOrUpdatePage, useDeletePage } from "~/queries/page"
|
||||
|
||||
import { DeleteConfirmationModal } from "./DeleteConfirmationModal"
|
||||
@@ -17,8 +17,10 @@ import { DeleteConfirmationModal } from "./DeleteConfirmationModal"
|
||||
export const PagesManagerBatchSelectActionTab: React.FC<{
|
||||
isPost: boolean
|
||||
isNotxLogContent: boolean
|
||||
pages: UseInfiniteQueryResult<Notes, unknown>
|
||||
batchSelected: string[]
|
||||
pages?: InfiniteData<{
|
||||
list: ExpandedNote[]
|
||||
}>
|
||||
batchSelected: (string | number)[]
|
||||
setBatchSelected: (selected: string[]) => void
|
||||
}> = ({ isPost, isNotxLogContent, pages, batchSelected, setBatchSelected }) => {
|
||||
const { t } = useTranslation(["dashboard", "site"])
|
||||
@@ -38,9 +40,9 @@ export const PagesManagerBatchSelectActionTab: React.FC<{
|
||||
onClick: () => {
|
||||
// Get all page IDs
|
||||
const allIDs: string[] = []
|
||||
pages.data?.pages.map((page) =>
|
||||
pages?.pages.map((page) =>
|
||||
page.list?.map((page) => {
|
||||
allIDs.push(page.id)
|
||||
allIDs.push(page.metadata?.content?.slug || "")
|
||||
}),
|
||||
)
|
||||
setBatchSelected(allIDs)
|
||||
@@ -65,10 +67,10 @@ export const PagesManagerBatchSelectActionTab: React.FC<{
|
||||
const toastId = toast.loading("Converting...")
|
||||
|
||||
// Find all selected
|
||||
const selectedPages: Note[] = []
|
||||
pages.data?.pages.map((page) =>
|
||||
const selectedPages: ExpandedNote[] = []
|
||||
pages?.pages.map((page) =>
|
||||
page.list?.map((page) => {
|
||||
if (batchSelected.includes(page.id)) {
|
||||
if (batchSelected.includes(page.metadata?.content?.slug || "")) {
|
||||
selectedPages.push(page)
|
||||
}
|
||||
}),
|
||||
@@ -79,34 +81,38 @@ export const PagesManagerBatchSelectActionTab: React.FC<{
|
||||
await Promise.all(
|
||||
selectedPages.map((page) => {
|
||||
// Check again to ensure it's not
|
||||
const isNotxLogContent = !page.applications?.includes("xlog")
|
||||
const isNotxLogContent =
|
||||
!page.metadata?.content?.sources?.includes("xlog")
|
||||
|
||||
const targetNoteBase = {
|
||||
published: true,
|
||||
pageId: page.id,
|
||||
pageId: `${page.characterId}-${page.noteId}`,
|
||||
siteId: subdomain,
|
||||
tags: page.tags
|
||||
tags: page.metadata?.content?.tags
|
||||
?.filter((tag) => tag !== "post" && tag !== "page")
|
||||
?.join(", "),
|
||||
applications: page.applications,
|
||||
applications: page.metadata?.content?.sources,
|
||||
}
|
||||
|
||||
if (isNotxLogContent) {
|
||||
return createOrUpdatePage.mutateAsync({
|
||||
...targetNoteBase,
|
||||
isPost: isPost, // Convert to xLog content
|
||||
characterId: page.characterId,
|
||||
})
|
||||
} else {
|
||||
if (!page.metadata) {
|
||||
if (!page.noteId) {
|
||||
// Is draft
|
||||
const data = getStorage(`draft-${subdomain}-${page.id}`)
|
||||
const key = `draft-${page?.characterId}-${page.draftKey}`
|
||||
const data = getStorage(key)
|
||||
data.isPost = !isPost
|
||||
setStorage(`draft-${subdomain}-${page.id}`, data)
|
||||
setStorage(key, data)
|
||||
} else {
|
||||
// IsNote
|
||||
return createOrUpdatePage.mutateAsync({
|
||||
...targetNoteBase,
|
||||
isPost: !isPost, // Change type
|
||||
characterId: page.characterId,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -125,9 +131,12 @@ export const PagesManagerBatchSelectActionTab: React.FC<{
|
||||
|
||||
// Invalidate site data refresh
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries(["getPagesBySite", subdomain]),
|
||||
queryClient.invalidateQueries([
|
||||
"getPagesBySite",
|
||||
selectedPages[0]?.characterId,
|
||||
]),
|
||||
...selectedPages.map((page) =>
|
||||
queryClient.invalidateQueries(["getPage", page.id]),
|
||||
queryClient.invalidateQueries(["getPage", page?.characterId]),
|
||||
),
|
||||
])
|
||||
|
||||
@@ -150,10 +159,10 @@ export const PagesManagerBatchSelectActionTab: React.FC<{
|
||||
const toastId = toast.loading("Deleting...")
|
||||
|
||||
// Find all selected
|
||||
const selectedPages: Note[] = []
|
||||
pages.data?.pages.map((page) =>
|
||||
const selectedPages: ExpandedNote[] = []
|
||||
pages?.pages.map((page) =>
|
||||
page.list?.map((page) => {
|
||||
if (batchSelected.includes(page.id)) {
|
||||
if (batchSelected.includes(page.noteId || page.draftKey || 0)) {
|
||||
selectedPages.push(page)
|
||||
}
|
||||
}),
|
||||
@@ -163,14 +172,15 @@ export const PagesManagerBatchSelectActionTab: React.FC<{
|
||||
try {
|
||||
await Promise.all(
|
||||
selectedPages.map((page) => {
|
||||
if (!page.metadata) {
|
||||
if (!page.noteId) {
|
||||
// Is draft
|
||||
delStorage(`draft-${subdomain}-${page.id}`)
|
||||
delStorage(`draft-${page?.characterId}-${page.draftKey}`)
|
||||
} else {
|
||||
// Is Note
|
||||
return deletePage.mutateAsync({
|
||||
site: subdomain,
|
||||
id: page.id,
|
||||
id: `${page.characterId}-${page.noteId}`,
|
||||
characterId: page.characterId,
|
||||
})
|
||||
}
|
||||
}),
|
||||
@@ -188,9 +198,12 @@ export const PagesManagerBatchSelectActionTab: React.FC<{
|
||||
|
||||
// Refresh site data
|
||||
await Promise.all([
|
||||
queryClient.refetchQueries(["getPagesBySite", subdomain]),
|
||||
queryClient.refetchQueries([
|
||||
"getPagesBySite",
|
||||
selectedPages[0]?.characterId,
|
||||
]),
|
||||
...selectedPages.map((page) =>
|
||||
queryClient.refetchQueries(["getPage", page.id]),
|
||||
queryClient.refetchQueries(["getPage", page.characterId]),
|
||||
),
|
||||
])
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { useTranslation } from "next-i18next"
|
||||
import { useRouter } from "next/router"
|
||||
import { FC, useEffect, useState } from "react"
|
||||
import toast from "react-hot-toast"
|
||||
import type { Note } from "unidata.js"
|
||||
|
||||
import { Menu } from "@headlessui/react"
|
||||
import { useQueryClient } from "@tanstack/react-query"
|
||||
@@ -11,16 +10,17 @@ import { useGetState } from "~/hooks/useGetState"
|
||||
import { APP_NAME } from "~/lib/env"
|
||||
import { getNoteSlugFromNote, getTwitterShareUrl } from "~/lib/helpers"
|
||||
import { delStorage, getStorage, setStorage } from "~/lib/storage"
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
import { useCreateOrUpdatePage, useDeletePage } from "~/queries/page"
|
||||
import { useGetSite } from "~/queries/site"
|
||||
|
||||
import { DeleteConfirmationModal } from "./DeleteConfirmationModal"
|
||||
|
||||
const usePageEditLink = (page: { id: string }, isPost: boolean) => {
|
||||
const usePageEditLink = (page: ExpandedNote, isPost: boolean) => {
|
||||
const router = useRouter()
|
||||
const subdomain = router.query.subdomain as string
|
||||
|
||||
return `/dashboard/${subdomain}/editor?id=${page.id}&type=${
|
||||
return `/dashboard/${subdomain}/editor?id=${page.noteId}&type=${
|
||||
isPost ? "post" : "page"
|
||||
}`
|
||||
}
|
||||
@@ -32,12 +32,12 @@ interface Item {
|
||||
}
|
||||
export const PagesManagerMenu: FC<{
|
||||
isPost: boolean
|
||||
page: Note
|
||||
page: ExpandedNote
|
||||
onClick: () => void
|
||||
}> = ({ isPost, page, onClick: onClose }) => {
|
||||
const { t } = useTranslation(["dashboard", "site"])
|
||||
|
||||
const isCrossbell = !page.applications?.includes("xlog")
|
||||
const isCrossbell = !page.metadata?.content?.sources?.includes("xlog")
|
||||
const router = useRouter()
|
||||
const createOrUpdatePage = useCreateOrUpdatePage()
|
||||
|
||||
@@ -110,21 +110,27 @@ export const PagesManagerMenu: FC<{
|
||||
setConvertToastId(toastId)
|
||||
createOrUpdatePage.mutate({
|
||||
published: true,
|
||||
pageId: page.id,
|
||||
pageId: `${page.characterId}-${page.noteId}`,
|
||||
siteId: subdomain,
|
||||
tags: page.tags
|
||||
tags: page.metadata?.content?.tags
|
||||
?.filter((tag) => tag !== "post" && tag !== "page")
|
||||
?.join(", "),
|
||||
isPost: isPost,
|
||||
applications: page.applications,
|
||||
applications: page.metadata?.content?.sources,
|
||||
characterId: page.characterId,
|
||||
})
|
||||
} else {
|
||||
if (!page.metadata) {
|
||||
const data = getStorage(`draft-${subdomain}-${page.id}`)
|
||||
if (!page.noteId) {
|
||||
const data = getStorage(
|
||||
`draft-${site.data?.characterId}-${page.draftKey}`,
|
||||
)
|
||||
data.isPost = !isPost
|
||||
setStorage(`draft-${subdomain}-${page.id}`, data)
|
||||
queryClient.invalidateQueries(["getPagesBySite", subdomain])
|
||||
queryClient.invalidateQueries(["getPage", page.id])
|
||||
setStorage(`draft-${site.data?.characterId}-${page.draftKey}`, data)
|
||||
queryClient.invalidateQueries([
|
||||
"getPagesBySite",
|
||||
site.data?.characterId,
|
||||
])
|
||||
queryClient.invalidateQueries(["getPage", page.characterId])
|
||||
toast.success("Converted!", {
|
||||
id: toastId,
|
||||
})
|
||||
@@ -132,13 +138,14 @@ export const PagesManagerMenu: FC<{
|
||||
setConvertToastId(toastId)
|
||||
createOrUpdatePage.mutate({
|
||||
published: true,
|
||||
pageId: page.id,
|
||||
pageId: `${page.characterId}-${page.noteId}`,
|
||||
siteId: subdomain,
|
||||
tags: page.tags
|
||||
tags: page.metadata?.content?.tags
|
||||
?.filter((tag) => tag !== "post" && tag !== "page")
|
||||
?.join(", "),
|
||||
isPost: !isPost,
|
||||
applications: page.applications,
|
||||
applications: page.metadata?.content?.sources,
|
||||
characterId: page.characterId,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -193,12 +200,12 @@ export const PagesManagerMenu: FC<{
|
||||
const [deleteConfirmModalOpen, setDeleteConfirmModalOpen] =
|
||||
useState<boolean>(false)
|
||||
const onDelete = () => {
|
||||
if (!page.metadata) {
|
||||
if (!page.noteId) {
|
||||
const toastId = toast.loading("Deleting...")
|
||||
delStorage(`draft-${subdomain}-${page.id}`)
|
||||
delStorage(`draft-${site.data?.characterId}-${page.draftKey}`)
|
||||
Promise.all([
|
||||
queryClient.refetchQueries(["getPagesBySite", subdomain]),
|
||||
queryClient.refetchQueries(["getPage", page.id]),
|
||||
queryClient.refetchQueries(["getPagesBySite", site.data?.characterId]),
|
||||
queryClient.refetchQueries(["getPage", page.characterId]),
|
||||
]).then(() => {
|
||||
toast.success("Deleted!", {
|
||||
id: toastId,
|
||||
@@ -208,7 +215,8 @@ export const PagesManagerMenu: FC<{
|
||||
setDeleteToastId(toast.loading("Deleting..."))
|
||||
deletePage.mutate({
|
||||
site: subdomain,
|
||||
id: page.id,
|
||||
id: `${page.characterId}-${page.noteId}`,
|
||||
characterId: page.characterId,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,42 +10,37 @@ import { DashboardMain } from "./DashboardMain"
|
||||
export const SettingsLayout: React.FC<{
|
||||
title: string
|
||||
children: React.ReactNode
|
||||
type: "site" | "account"
|
||||
}> = ({ title, children, type }) => {
|
||||
}> = ({ title, children }) => {
|
||||
const router = useRouter()
|
||||
const { t } = useTranslation("dashboard")
|
||||
const xSettingsModal = useXSettingsModal()
|
||||
|
||||
const subdomain = router.query.subdomain as string
|
||||
const tabItems: TabItem[] = (
|
||||
type === "site"
|
||||
? [
|
||||
{ text: "General", href: `/dashboard/${subdomain}/settings/general` },
|
||||
{
|
||||
text: "Social Platforms",
|
||||
href: `/dashboard/${subdomain}/settings/social-platforms`,
|
||||
},
|
||||
{
|
||||
text: "Navigation",
|
||||
href: `/dashboard/${subdomain}/settings/navigation`,
|
||||
},
|
||||
{ text: "Domains", href: `/dashboard/${subdomain}/settings/domains` },
|
||||
{ text: "Custom CSS", href: `/dashboard/${subdomain}/settings/css` },
|
||||
{
|
||||
text: "Operators",
|
||||
href: `/dashboard/${subdomain}/settings/operator`,
|
||||
},
|
||||
{
|
||||
text: "xSettings",
|
||||
onClick: () => xSettingsModal.show(),
|
||||
},
|
||||
{
|
||||
text: "Export data",
|
||||
href: `https://export.crossbell.io/?handle=${subdomain}`,
|
||||
},
|
||||
]
|
||||
: [{ text: "Profile", href: `/dashboard/${subdomain}/account/profile` }]
|
||||
).map((item) => ({ ...item, active: router.asPath === item.href }))
|
||||
const tabItems: TabItem[] = [
|
||||
{ text: "General", href: `/dashboard/${subdomain}/settings/general` },
|
||||
{
|
||||
text: "Social Platforms",
|
||||
href: `/dashboard/${subdomain}/settings/social-platforms`,
|
||||
},
|
||||
{
|
||||
text: "Navigation",
|
||||
href: `/dashboard/${subdomain}/settings/navigation`,
|
||||
},
|
||||
{ text: "Domains", href: `/dashboard/${subdomain}/settings/domains` },
|
||||
{ text: "Custom CSS", href: `/dashboard/${subdomain}/settings/css` },
|
||||
{
|
||||
text: "Operators",
|
||||
href: `/dashboard/${subdomain}/settings/operator`,
|
||||
},
|
||||
{
|
||||
text: "xSettings",
|
||||
onClick: () => xSettingsModal.show(),
|
||||
},
|
||||
{
|
||||
text: "Export data",
|
||||
href: `https://export.crossbell.io/?handle=${subdomain}`,
|
||||
},
|
||||
].map((item) => ({ ...item, active: router.asPath === item.href }))
|
||||
|
||||
return (
|
||||
<DashboardMain>
|
||||
|
||||
@@ -65,7 +65,7 @@ export function MainSidebar({ hideSearch }: { hideSearch?: boolean }) {
|
||||
>
|
||||
{t("Show more")}
|
||||
</div>
|
||||
{showcaseSites.data?.map((site: any) => (
|
||||
{showcaseSites.data?.map((site) => (
|
||||
<li className="flex align-middle" key={site.handle}>
|
||||
<UniLink
|
||||
href={getSiteLink({
|
||||
@@ -78,7 +78,7 @@ export function MainSidebar({ hideSearch }: { hideSearch?: boolean }) {
|
||||
<Image
|
||||
className="rounded-full"
|
||||
src={
|
||||
site.metadata.content?.avatars?.[0] ||
|
||||
site?.metadata?.content?.avatars?.[0] ||
|
||||
"ipfs://bafkreiabgixxp63pg64moxnsydz7hewmpdkxxi3kdsa4oqv4pb6qvwnmxa"
|
||||
}
|
||||
alt={site.handle}
|
||||
@@ -89,9 +89,9 @@ export function MainSidebar({ hideSearch }: { hideSearch?: boolean }) {
|
||||
</CharacterFloatCard>
|
||||
<span className="ml-3 min-w-0 flex-1 justify-center inline-flex flex-col">
|
||||
<span className="truncate w-full inline-block font-medium">
|
||||
{site.metadata.content?.name}
|
||||
{site?.metadata?.content?.name}
|
||||
</span>
|
||||
{site.metadata.content?.bio && (
|
||||
{site?.metadata?.content?.bio && (
|
||||
<span className="text-gray-500 text-xs truncate w-full inline-block mt-1">
|
||||
{site.metadata.content?.bio}
|
||||
</span>
|
||||
|
||||
@@ -2,11 +2,11 @@ import { Comment } from "~/components/common/Comment"
|
||||
import { ReactionLike } from "~/components/common/ReactionLike"
|
||||
import { ReactionMint } from "~/components/common/ReactionMint"
|
||||
import { ReactionTip } from "~/components/common/ReactionTip"
|
||||
import { Note, Profile } from "~/lib/types"
|
||||
import { ExpandedCharacter, ExpandedNote } from "~/lib/types"
|
||||
|
||||
export const PostFooter: React.FC<{
|
||||
page?: Note | null
|
||||
site?: Profile | null
|
||||
page?: ExpandedNote
|
||||
site?: ExpandedCharacter
|
||||
}> = ({ page, site }) => {
|
||||
return (
|
||||
<>
|
||||
@@ -14,9 +14,14 @@ export const PostFooter: React.FC<{
|
||||
className="xlog-reactions flex fill-gray-400 text-gray-500 sm:items-center space-x-6 sm:space-x-10 mt-14 mb-12"
|
||||
data-hide-print
|
||||
>
|
||||
<ReactionLike pageId={page?.id} />
|
||||
<ReactionMint pageId={page?.id} />
|
||||
<ReactionTip pageId={page?.id} site={site} page={page} />
|
||||
<ReactionLike characterId={page?.characterId} noteId={page?.noteId} />
|
||||
<ReactionMint characterId={page?.characterId} noteId={page?.noteId} />
|
||||
<ReactionTip
|
||||
characterId={page?.characterId}
|
||||
noteId={page?.noteId}
|
||||
site={site}
|
||||
page={page}
|
||||
/>
|
||||
</div>
|
||||
<Comment page={page} />
|
||||
</>
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
import { useTranslation } from "next-i18next"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
import { CharacterFloatCard } from "~/components/common/CharacterFloatCard"
|
||||
import { BlockchainIcon } from "~/components/icons/BlockchainIcon"
|
||||
import { Avatar } from "~/components/ui/Avatar"
|
||||
import { UniLink } from "~/components/ui/UniLink"
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { useUserRole } from "~/hooks/useUserRole"
|
||||
import { CSB_SCAN, SITE_URL } from "~/lib/env"
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { toCid } from "~/lib/ipfs-parser"
|
||||
import { Note, Profile } from "~/lib/types"
|
||||
import { ExpandedCharacter, ExpandedNote } from "~/lib/types"
|
||||
import { useGetSummary } from "~/queries/page"
|
||||
|
||||
export const PostMeta: React.FC<{
|
||||
page: Note
|
||||
site?: Profile | null
|
||||
author?: Profile | null
|
||||
}> = ({ page, site, author }) => {
|
||||
page: ExpandedNote
|
||||
site?: ExpandedCharacter
|
||||
}> = ({ page, site }) => {
|
||||
const { t } = useTranslation("common")
|
||||
const date = useDate()
|
||||
const [isMounted, setIsMounted] = useState(false)
|
||||
const { i18n } = useTranslation()
|
||||
const summary = useGetSummary({
|
||||
cid: toCid(page.related_urls?.[0] || ""),
|
||||
cid: toCid(page.metadata?.uri || ""),
|
||||
lang: i18n.resolvedLanguage,
|
||||
})
|
||||
|
||||
@@ -32,7 +28,7 @@ export const PostMeta: React.FC<{
|
||||
}, [])
|
||||
|
||||
const [showEdit, setShowEdit] = useState(false)
|
||||
const userRole = useUserRole(site?.username)
|
||||
const userRole = useUserRole(site?.handle)
|
||||
useEffect(() => {
|
||||
if (userRole.isSuccess && userRole.data) {
|
||||
setShowEdit(true)
|
||||
@@ -43,19 +39,23 @@ export const PostMeta: React.FC<{
|
||||
<div className="xlog-post-meta">
|
||||
<div className="text-zinc-400 mt-4 space-x-5 flex items-center">
|
||||
<time
|
||||
dateTime={date.formatToISO(page.date_published)}
|
||||
dateTime={date.formatToISO(
|
||||
page?.metadata?.content?.date_published || "",
|
||||
)}
|
||||
className="xlog-post-date whitespace-nowrap"
|
||||
>
|
||||
{date.formatDate(
|
||||
page.date_published,
|
||||
page.metadata?.content?.date_published || "",
|
||||
undefined,
|
||||
isMounted ? undefined : "America/Los_Angeles",
|
||||
)}
|
||||
</time>
|
||||
{page.tags?.filter((tag) => tag !== "post" && tag !== "page").length ? (
|
||||
{page.metadata?.content?.tags?.filter(
|
||||
(tag) => tag !== "post" && tag !== "page",
|
||||
).length ? (
|
||||
<>
|
||||
<span className="xlog-post-tags space-x-1 truncate min-w-0">
|
||||
{page.tags
|
||||
{page.metadata?.content?.tags
|
||||
?.filter((tag) => tag !== "post" && tag !== "page")
|
||||
.map((tag) => (
|
||||
<UniLink
|
||||
@@ -71,46 +71,22 @@ export const PostMeta: React.FC<{
|
||||
) : null}
|
||||
<span className="xlog-post-views inline-flex items-center">
|
||||
<i className="icon-[mingcute--eye-line] mr-[2px]" />
|
||||
<span>{page.views}</span>
|
||||
<span>{page.metadata?.content?.views}</span>
|
||||
</span>
|
||||
{author?.username && site?.username !== author?.username && (
|
||||
<>
|
||||
<span className="inline-flex items-center">
|
||||
<CharacterFloatCard siteId={author?.username}>
|
||||
<UniLink
|
||||
href={getSiteLink({
|
||||
subdomain: author?.username,
|
||||
})}
|
||||
className="cursor-pointer hover:text-zinc-600 inline-flex items-center"
|
||||
>
|
||||
<Avatar
|
||||
className="mr-1"
|
||||
images={author?.avatars || []}
|
||||
size={19}
|
||||
name={author?.name}
|
||||
/>
|
||||
<span>{author?.name}</span>
|
||||
</UniLink>
|
||||
</CharacterFloatCard>
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
<UniLink
|
||||
className="xlog-post-blockchain inline-flex items-center"
|
||||
href={
|
||||
page.related_urls?.filter((url) =>
|
||||
url.startsWith(CSB_SCAN + "/tx/"),
|
||||
)?.[0]
|
||||
}
|
||||
href={`${CSB_SCAN}/tx/${page.updatedTransactionHash}`}
|
||||
>
|
||||
<BlockchainIcon className="fill-zinc-500 ml-1" />
|
||||
</UniLink>
|
||||
{showEdit && (
|
||||
<UniLink
|
||||
className="xlog-post-editor inline-flex items-center"
|
||||
href={`${SITE_URL}/dashboard/${site?.username}/editor?id=${
|
||||
page.id
|
||||
}&type=${page.tags?.includes("post") ? "post" : "page"}`}
|
||||
href={`${SITE_URL}/dashboard/${site?.handle}/editor?id=${
|
||||
page.noteId
|
||||
}&type=${
|
||||
page.metadata?.content?.tags?.includes("post") ? "post" : "page"
|
||||
}`}
|
||||
>
|
||||
<i className="icon-[mingcute--edit-line] mx-1" /> Edit
|
||||
</UniLink>
|
||||
|
||||
@@ -2,9 +2,11 @@ import { useTranslation } from "next-i18next"
|
||||
import Link from "next/link"
|
||||
import { useMemo } from "react"
|
||||
|
||||
import type { InfiniteData } from "@tanstack/react-query"
|
||||
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { Note, Notes } from "~/lib/types"
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
|
||||
import { EmptyState } from "../ui/EmptyState"
|
||||
import { UniLink } from "../ui/UniLink"
|
||||
@@ -12,14 +14,17 @@ import { UniLink } from "../ui/UniLink"
|
||||
export const SiteArchives: React.FC<{
|
||||
title?: string
|
||||
showTags?: boolean
|
||||
postPages?: Notes[]
|
||||
posts?: InfiniteData<{
|
||||
list: ExpandedNote[]
|
||||
count: number
|
||||
}>
|
||||
fetchNextPage: () => void
|
||||
hasNextPage?: boolean
|
||||
isFetchingNextPage?: boolean
|
||||
}> = ({
|
||||
title,
|
||||
showTags,
|
||||
postPages,
|
||||
posts,
|
||||
fetchNextPage,
|
||||
hasNextPage,
|
||||
isFetchingNextPage,
|
||||
@@ -28,13 +33,16 @@ export const SiteArchives: React.FC<{
|
||||
const date = useDate()
|
||||
const { t } = useTranslation(["common", "site"])
|
||||
|
||||
const groupedByYear = useMemo<Map<string, Note[]>>(() => {
|
||||
const groupedByYear = useMemo<Map<string, ExpandedNote[]>>(() => {
|
||||
const map = new Map()
|
||||
|
||||
if (postPages?.length) {
|
||||
for (const posts of postPages) {
|
||||
for (const post of posts.list) {
|
||||
const year = date.formatDate(post.date_published, "YYYY")
|
||||
if (posts?.pages?.length) {
|
||||
for (const page of posts.pages) {
|
||||
for (const post of page.list) {
|
||||
const year = date.formatDate(
|
||||
post.metadata?.content?.date_published || "",
|
||||
"YYYY",
|
||||
)
|
||||
const items = map.get(year) || []
|
||||
items.push(post)
|
||||
map.set(year, items)
|
||||
@@ -43,15 +51,15 @@ export const SiteArchives: React.FC<{
|
||||
}
|
||||
|
||||
return map
|
||||
}, [postPages, date])
|
||||
}, [posts?.pages, date])
|
||||
|
||||
const tags = useMemo<Map<string, number>>(() => {
|
||||
const result = new Map()
|
||||
|
||||
if (postPages?.length) {
|
||||
for (const posts of postPages) {
|
||||
for (const post of posts.list) {
|
||||
post.tags?.forEach((tag) => {
|
||||
if (posts?.pages?.length) {
|
||||
for (const page of posts.pages) {
|
||||
for (const post of page.list) {
|
||||
post.metadata?.content?.tags?.forEach((tag) => {
|
||||
if (tag !== "post" && tag !== "page") {
|
||||
if (result.has(tag)) {
|
||||
result.set(tag, result.get(tag) + 1)
|
||||
@@ -65,21 +73,21 @@ export const SiteArchives: React.FC<{
|
||||
}
|
||||
|
||||
return result
|
||||
}, [postPages])
|
||||
}, [posts?.pages])
|
||||
|
||||
if (!postPages?.length) return null
|
||||
if (!posts?.pages?.length) return null
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="text-xl font-bold page-title">
|
||||
{title || t("Archives", { ns: "site" })}
|
||||
</h2>
|
||||
{!postPages[0].total && (
|
||||
{!posts?.pages[0].count && (
|
||||
<div className="mt-5">
|
||||
<EmptyState />
|
||||
</div>
|
||||
)}
|
||||
{!!postPages[0].total && (
|
||||
{!!posts?.pages[0].count && (
|
||||
<>
|
||||
{showTags && tags.size > 0 && (
|
||||
<div className="mt-5">
|
||||
@@ -100,7 +108,6 @@ export const SiteArchives: React.FC<{
|
||||
)}
|
||||
<div className="mt-5 space-y-5">
|
||||
{[...groupedByYear.keys()].map((year) => {
|
||||
currentLength++
|
||||
const posts = groupedByYear.get(year)!
|
||||
return (
|
||||
<div key={year}>
|
||||
@@ -108,16 +115,21 @@ export const SiteArchives: React.FC<{
|
||||
{year}
|
||||
</h3>
|
||||
{posts.map((post) => {
|
||||
currentLength++
|
||||
return (
|
||||
<Link
|
||||
key={post.id}
|
||||
href={`/${post.slug || post.id}`}
|
||||
key={post.transactionHash}
|
||||
href={`/${post.metadata?.content?.slug}`}
|
||||
className="flex justify-between items-center p-2 rounded-lg -mx-2 hover:bg-hover"
|
||||
>
|
||||
<span className="text-zinc-700">{post.title}</span>
|
||||
<span className="text-zinc-700">
|
||||
{post.metadata?.content?.title}
|
||||
</span>
|
||||
<span className="text-zinc-400 mr-3 whitespace-nowrap">
|
||||
{t("intlDateTime", {
|
||||
val: new Date(post.date_published),
|
||||
val: new Date(
|
||||
post.metadata?.content?.date_published || "",
|
||||
),
|
||||
formatParams: {
|
||||
val: {
|
||||
month: "short",
|
||||
@@ -140,8 +152,8 @@ export const SiteArchives: React.FC<{
|
||||
isLoading={isFetchingNextPage}
|
||||
aria-label="load more"
|
||||
>
|
||||
There are {postPages[0].total - currentLength} more post
|
||||
{postPages[0].total - currentLength > 1 ? "s" : ""}, click to
|
||||
There are {posts?.pages[0].count - currentLength} more post
|
||||
{posts?.pages[0].count - currentLength > 1 ? "s" : ""}, click to
|
||||
load more
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -5,15 +5,14 @@ import { useEffect, useState } from "react"
|
||||
import { Logo } from "~/components/common/Logo"
|
||||
import { Platform } from "~/components/site/Platform"
|
||||
import { SITE_URL } from "~/lib/env"
|
||||
import { Note, Profile } from "~/lib/types"
|
||||
import { ExpandedCharacter } from "~/lib/types"
|
||||
|
||||
import { DarkModeSwitch } from "../common/DarkModeSwitch"
|
||||
import { UniLink } from "../ui/UniLink"
|
||||
|
||||
export const SiteFooter: React.FC<{
|
||||
site?: Profile | null
|
||||
page?: Note | null
|
||||
}> = ({ site, page }) => {
|
||||
site?: ExpandedCharacter
|
||||
}> = ({ site }) => {
|
||||
const [logoType, setLogoType] = useState<"svg" | "png" | "lottie">("svg")
|
||||
|
||||
useEffect(() => {
|
||||
@@ -38,7 +37,7 @@ export const SiteFooter: React.FC<{
|
||||
<div className="font-medium text-base">
|
||||
<span>© </span>
|
||||
<UniLink href="/" className="hover:text-accent">
|
||||
<span>{site?.name}</span>
|
||||
<span>{site?.metadata?.content?.name}</span>
|
||||
</UniLink>
|
||||
<span> · </span>
|
||||
<Trans
|
||||
@@ -51,25 +50,32 @@ export const SiteFooter: React.FC<{
|
||||
ns="site"
|
||||
/>
|
||||
</div>
|
||||
{site?.connected_accounts && (
|
||||
{site?.metadata?.content?.connected_accounts && (
|
||||
<div className="sm:-mr-5 sm:block inline-block align-middle mr-4">
|
||||
{site?.connected_accounts.map((account, index) => (
|
||||
<Platform
|
||||
key={index}
|
||||
platform={account.platform}
|
||||
username={account.identity}
|
||||
className="mr-2 sm:mr-5"
|
||||
></Platform>
|
||||
))}
|
||||
{site?.metadata?.content?.connected_accounts.map(
|
||||
(account, index) => {
|
||||
const match = account.match(/:\/\/account:(.*)@(.*)/)
|
||||
if (match) {
|
||||
return (
|
||||
<Platform
|
||||
key={account}
|
||||
platform={match[2]}
|
||||
username={match[1]}
|
||||
className="mr-2 sm:mr-5"
|
||||
></Platform>
|
||||
)
|
||||
}
|
||||
},
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<DarkModeSwitch />
|
||||
</div>
|
||||
</footer>
|
||||
{site?.ga && (
|
||||
{site?.metadata?.content?.ga && (
|
||||
<div className="xlog-google-analytics">
|
||||
<Script
|
||||
src={`https://www.googletagmanager.com/gtag/js?id=G-${site.ga}`}
|
||||
src={`https://www.googletagmanager.com/gtag/js?id=G-${site.metadata?.content?.ga}`}
|
||||
strategy="afterInteractive"
|
||||
/>
|
||||
<Script id="google-analytics" strategy="afterInteractive">
|
||||
@@ -78,7 +84,7 @@ export const SiteFooter: React.FC<{
|
||||
function gtag(){window.dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-${site.ga}');
|
||||
gtag('config', 'G-${site.metadata?.content?.ga}');
|
||||
`}
|
||||
</Script>
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,7 @@ import { Modal } from "~/components/ui/Modal"
|
||||
import { Tooltip } from "~/components/ui/Tooltip"
|
||||
import { useIsDark } from "~/hooks/useDarkMode"
|
||||
import { CSB_IO, CSB_SCAN, CSB_XCHAR } from "~/lib/env"
|
||||
import { Profile } from "~/lib/types"
|
||||
import { ExpandedCharacter } from "~/lib/types"
|
||||
import { getUserContentsUrl } from "~/lib/user-contents"
|
||||
import { cn } from "~/lib/utils"
|
||||
|
||||
@@ -58,25 +58,28 @@ const HeaderLink: React.FC<{ link: HeaderLinkType }> = ({ link }) => {
|
||||
}
|
||||
|
||||
export const SiteHeader: React.FC<{
|
||||
site?: Profile | undefined | null
|
||||
site?: ExpandedCharacter
|
||||
}> = ({ site }) => {
|
||||
const { t } = useTranslation("site")
|
||||
const leftLinks: HeaderLinkType[] = site?.navigation?.find(
|
||||
const leftLinks: HeaderLinkType[] = site?.metadata?.content?.navigation?.find(
|
||||
(nav) => nav.url === "/",
|
||||
)
|
||||
? site.navigation
|
||||
: [{ label: "Home", url: "/" }, ...(site?.navigation || [])]
|
||||
? site.metadata?.content?.navigation
|
||||
: [
|
||||
{ label: "Home", url: "/" },
|
||||
...(site?.metadata?.content?.navigation || []),
|
||||
]
|
||||
|
||||
const moreMenuItems = [
|
||||
{
|
||||
text: "View on xChar",
|
||||
icon: <XCharLogo className="w-full h-full" />,
|
||||
url: `${CSB_XCHAR}/${site?.username}`,
|
||||
url: `${CSB_XCHAR}/${site?.handle}`,
|
||||
},
|
||||
{
|
||||
text: "View on xFeed",
|
||||
icon: <XFeedLogo className="w-full h-full" />,
|
||||
url: `${CSB_IO}/@${site?.username}`,
|
||||
url: `${CSB_IO}/@${site?.handle}`,
|
||||
},
|
||||
{
|
||||
text: "View on Hoot It",
|
||||
@@ -91,12 +94,12 @@ export const SiteHeader: React.FC<{
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
url: `https://hoot.it/search/${site?.username}.csb/activities`,
|
||||
url: `https://hoot.it/search/${site?.handle}.csb/activities`,
|
||||
},
|
||||
{
|
||||
text: "View on Crossbell Scan",
|
||||
icon: <BlockchainIcon className="fill-[#c09526] w-full h-full" />,
|
||||
url: `${CSB_SCAN}/address/${site?.metadata?.owner}`,
|
||||
url: `${CSB_SCAN}/address/${site?.owner}`,
|
||||
},
|
||||
{
|
||||
text: "Subscribe to JSON Feed",
|
||||
@@ -196,12 +199,14 @@ export const SiteHeader: React.FC<{
|
||||
}}
|
||||
>
|
||||
{(() => {
|
||||
switch (site?.banners?.[0]?.mime_type?.split("/")[0]) {
|
||||
switch (
|
||||
site?.metadata?.content?.banners?.[0]?.mime_type?.split("/")[0]
|
||||
) {
|
||||
case "image":
|
||||
return (
|
||||
<Image
|
||||
className="max-w-screen-md mx-auto object-cover"
|
||||
src={site?.banners?.[0]?.address}
|
||||
src={site?.metadata?.content?.banners?.[0]?.address}
|
||||
alt="banner"
|
||||
fill
|
||||
imageRef={bannerRef as MutableRefObject<HTMLImageElement>}
|
||||
@@ -211,7 +216,7 @@ export const SiteHeader: React.FC<{
|
||||
return (
|
||||
<video
|
||||
className="max-w-screen-md mx-auto object-cover h-full w-full"
|
||||
src={site?.banners?.[0]?.address}
|
||||
src={site?.metadata?.content?.banners?.[0]?.address}
|
||||
autoPlay
|
||||
muted
|
||||
playsInline
|
||||
@@ -230,24 +235,26 @@ export const SiteHeader: React.FC<{
|
||||
<div
|
||||
className={cn(
|
||||
"xlog-site-info flex space-x-6 items-center w-full",
|
||||
site?.banners?.[0]?.address
|
||||
site?.metadata?.content?.banners?.[0]?.address
|
||||
? "bg-white bg-opacity-50 backdrop-blur-sm rounded-xl p-4 sm:p-8 z-[1] border"
|
||||
: "",
|
||||
)}
|
||||
>
|
||||
{site?.avatars?.[0] && (
|
||||
{site?.metadata?.content?.avatars?.[0] && (
|
||||
<Avatar
|
||||
className="xlog-site-icon max-w-[80px] max-h-[80px] sm:max-w-none sm:max-h-none"
|
||||
images={[getUserContentsUrl(site?.avatars?.[0])]}
|
||||
images={[
|
||||
getUserContentsUrl(site?.metadata?.content?.avatars?.[0]),
|
||||
]}
|
||||
size={120}
|
||||
name={site?.name}
|
||||
name={site?.metadata?.content?.name}
|
||||
imageRef={avatarRef as MutableRefObject<HTMLImageElement>}
|
||||
/>
|
||||
)}
|
||||
<div className="flex-1 min-w-0 relative">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="xlog-site-name text-2xl sm:text-3xl font-bold text-zinc-900 leading-snug break-words min-w-0">
|
||||
{site?.name}
|
||||
{site?.metadata?.content?.name}
|
||||
</div>
|
||||
<div className="ml-0 sm:ml-8 space-x-3 sm:space-x-4 flex items-center sm:static absolute -bottom-0 right-0">
|
||||
<div className="xlog-site-more-menu relative inline-block align-middle">
|
||||
@@ -318,14 +325,14 @@ export const SiteHeader: React.FC<{
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{site?.description && (
|
||||
{site?.metadata?.content?.bio && (
|
||||
<div className="xlog-site-description text-gray-500 leading-snug my-2 sm:my-3 text-sm sm:text-base line-clamp-4 whitespace-pre-wrap">
|
||||
{site?.description}
|
||||
{site?.metadata?.content?.bio}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex space-x-0 sm:space-x-5 space-y-2 sm:space-y-0 flex-col sm:flex-row text-sm sm:text-base">
|
||||
<span className="xlog-site-follow-count block sm:inline-block whitespace-nowrap">
|
||||
<FollowingCount siteId={site?.username} />
|
||||
<FollowingCount characterId={site?.characterId} />
|
||||
</span>
|
||||
<span className="xlog-site-patron">
|
||||
<PatronButton site={site} />
|
||||
|
||||
@@ -3,20 +3,25 @@ import Link from "next/link"
|
||||
import { useRouter } from "next/router"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
import type { InfiniteData } from "@tanstack/react-query"
|
||||
|
||||
import { Button } from "~/components/ui/Button"
|
||||
import { Image } from "~/components/ui/Image"
|
||||
import { useDate } from "~/hooks/useDate"
|
||||
import { getSlugUrl } from "~/lib/helpers"
|
||||
import { Notes } from "~/lib/types"
|
||||
import { ExpandedNote } from "~/lib/types"
|
||||
|
||||
import { EmptyState } from "../ui/EmptyState"
|
||||
|
||||
export const SiteHome: React.FC<{
|
||||
postPages?: Notes[]
|
||||
posts?: InfiniteData<{
|
||||
list: ExpandedNote[]
|
||||
count: number
|
||||
}>
|
||||
fetchNextPage: () => void
|
||||
hasNextPage?: boolean
|
||||
isFetchingNextPage?: boolean
|
||||
}> = ({ postPages, fetchNextPage, hasNextPage, isFetchingNextPage }) => {
|
||||
}> = ({ posts, fetchNextPage, hasNextPage, isFetchingNextPage }) => {
|
||||
const router = useRouter()
|
||||
const { t } = useTranslation(["common", "site"])
|
||||
const date = useDate()
|
||||
@@ -27,45 +32,47 @@ export const SiteHome: React.FC<{
|
||||
setIsMounted(true)
|
||||
}, [])
|
||||
|
||||
if (!postPages?.length) return null
|
||||
if (!posts?.pages?.length) return null
|
||||
|
||||
let currentLength = 0
|
||||
|
||||
return (
|
||||
<>
|
||||
{!postPages[0].total && <EmptyState />}
|
||||
{!!postPages[0].total && (
|
||||
{!posts.pages[0].count && <EmptyState />}
|
||||
{!!posts.pages[0].count && (
|
||||
<div className="xlog-posts space-y-8">
|
||||
{postPages.map((posts) =>
|
||||
{posts.pages.map((posts) =>
|
||||
posts.list.map((post) => {
|
||||
currentLength++
|
||||
return (
|
||||
<Link
|
||||
key={post.id}
|
||||
href={getSlugUrl(`/${post.slug || post.id}`)}
|
||||
key={post.transactionHash}
|
||||
href={getSlugUrl(`/${post.metadata?.content?.slug}`)}
|
||||
className="xlog-post sm:hover:bg-hover bg-white transition-all px-5 py-7 -mx-5 first:-mt-5 sm:rounded-xl flex flex-col sm:flex-row items-center"
|
||||
suppressHydrationWarning
|
||||
>
|
||||
<div className="flex-1 flex justify-center flex-col w-full min-w-0">
|
||||
<h3 className="xlog-post-title text-2xl font-bold text-zinc-700">
|
||||
{post.title}
|
||||
{post.metadata?.content?.title}
|
||||
</h3>
|
||||
<div className="xlog-post-meta text-sm text-zinc-400 mt-1 space-x-4 flex items-center mr-8">
|
||||
<time
|
||||
dateTime={date.formatToISO(post.date_published)}
|
||||
dateTime={date.formatToISO(
|
||||
post.metadata?.content?.date_published || "",
|
||||
)}
|
||||
className="xlog-post-date whitespace-nowrap"
|
||||
>
|
||||
{date.formatDate(
|
||||
post.date_published,
|
||||
post.metadata?.content?.date_published || "",
|
||||
undefined,
|
||||
isMounted ? undefined : "America/Los_Angeles",
|
||||
)}
|
||||
</time>
|
||||
{!!post.tags?.filter(
|
||||
{!!post.metadata?.content?.tags?.filter(
|
||||
(tag) => tag !== "post" && tag !== "page",
|
||||
).length && (
|
||||
<span className="xlog-post-tags space-x-1 truncate min-w-0">
|
||||
{post.tags
|
||||
{post.metadata?.content?.tags
|
||||
?.filter((tag) => tag !== "post" && tag !== "page")
|
||||
.map((tag) => (
|
||||
<span
|
||||
@@ -83,7 +90,7 @@ export const SiteHome: React.FC<{
|
||||
)}
|
||||
<span className="xlog-post-views inline-flex items-center">
|
||||
<i className="icon-[mingcute--eye-line] mr-[2px]" />
|
||||
<span>{post.views}</span>
|
||||
<span>{post.metadata?.content?.views}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
@@ -92,17 +99,17 @@ export const SiteHome: React.FC<{
|
||||
wordBreak: "break-word",
|
||||
}}
|
||||
>
|
||||
{post.summary?.content}
|
||||
{post.summary?.content && "..."}
|
||||
{post.metadata?.content?.summary}
|
||||
{post.metadata?.content?.summary && "..."}
|
||||
</div>
|
||||
</div>
|
||||
{post.cover && (
|
||||
{post.metadata?.content?.cover && (
|
||||
<div className="xlog-post-cover flex items-center relative w-full sm:w-24 h-40 sm:h-24 mt-2 sm:ml-4 sm:mt-0">
|
||||
<Image
|
||||
className="object-cover rounded"
|
||||
alt="cover"
|
||||
fill={true}
|
||||
src={post.cover}
|
||||
src={post.metadata?.content?.cover}
|
||||
></Image>
|
||||
</div>
|
||||
)}
|
||||
@@ -123,9 +130,9 @@ export const SiteHome: React.FC<{
|
||||
{t("load more", {
|
||||
ns: "site",
|
||||
name: t(
|
||||
"post" + (postPages[0].total - currentLength > 1 ? "s" : ""),
|
||||
"post" + (posts?.pages[0].count - currentLength > 1 ? "s" : ""),
|
||||
),
|
||||
count: postPages[0].total - currentLength,
|
||||
count: posts?.pages[0].count - currentLength,
|
||||
})}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { notFound } from "~/lib/server-side-props"
|
||||
import { PageVisibilityEnum } from "~/lib/types"
|
||||
import { fetchGetPage, prefetchGetPagesBySite } from "~/queries/page.server"
|
||||
import {
|
||||
prefetchGetSite,
|
||||
fetchGetSite,
|
||||
prefetchGetSiteSubscriptions,
|
||||
prefetchGetSiteToSubscriptions,
|
||||
} from "~/queries/site.server"
|
||||
@@ -16,7 +16,7 @@ export const getServerSideProps = async (
|
||||
ctx: any,
|
||||
queryClient: QueryClient,
|
||||
options?: {
|
||||
take?: number
|
||||
limit?: number
|
||||
useStat?: boolean
|
||||
skipPages?: boolean
|
||||
preview?: boolean
|
||||
@@ -25,67 +25,69 @@ export const getServerSideProps = async (
|
||||
const domainOrSubdomain = ctx.params!.site as string
|
||||
const pageSlug = ctx.params!.page as string
|
||||
const tag = ctx.params!.tag as string
|
||||
const site = await fetchGetSite(domainOrSubdomain, queryClient)
|
||||
|
||||
await Promise.all([
|
||||
prefetchGetSite(domainOrSubdomain, queryClient),
|
||||
prefetchGetSiteSubscriptions(
|
||||
{
|
||||
siteId: domainOrSubdomain,
|
||||
},
|
||||
queryClient,
|
||||
),
|
||||
prefetchGetSiteToSubscriptions(
|
||||
{
|
||||
siteId: domainOrSubdomain,
|
||||
},
|
||||
queryClient,
|
||||
),
|
||||
new Promise(async (resolve, reject) => {
|
||||
if (options?.preview) {
|
||||
// do nothing
|
||||
} else if (pageSlug) {
|
||||
try {
|
||||
const page = await fetchGetPage(
|
||||
{
|
||||
site: domainOrSubdomain,
|
||||
page: pageSlug,
|
||||
...(options?.useStat && {
|
||||
useStat: true,
|
||||
}),
|
||||
},
|
||||
queryClient,
|
||||
)
|
||||
if (site?.characterId) {
|
||||
await Promise.all([
|
||||
prefetchGetSiteSubscriptions(
|
||||
{
|
||||
characterId: site.characterId,
|
||||
},
|
||||
queryClient,
|
||||
),
|
||||
prefetchGetSiteToSubscriptions(
|
||||
{
|
||||
characterId: site.characterId,
|
||||
},
|
||||
queryClient,
|
||||
),
|
||||
new Promise(async (resolve, reject) => {
|
||||
if (options?.preview) {
|
||||
// do nothing
|
||||
} else if (pageSlug) {
|
||||
try {
|
||||
const page = await fetchGetPage(
|
||||
{
|
||||
characterId: site.characterId,
|
||||
slug: pageSlug,
|
||||
...(options?.useStat && {
|
||||
useStat: true,
|
||||
}),
|
||||
},
|
||||
queryClient,
|
||||
)
|
||||
|
||||
if (!page || new Date(page!.date_published) > new Date()) {
|
||||
reject(notFound())
|
||||
if (
|
||||
!page ||
|
||||
new Date(page!.metadata?.content?.date_published || "") >
|
||||
new Date()
|
||||
) {
|
||||
reject(notFound())
|
||||
}
|
||||
} catch (error) {
|
||||
reject(error)
|
||||
}
|
||||
} else {
|
||||
if (!options?.skipPages) {
|
||||
await prefetchGetPagesBySite(
|
||||
{
|
||||
characterId: site.characterId,
|
||||
...(options?.limit && { limit: options.limit }),
|
||||
type: "post",
|
||||
visibility: PageVisibilityEnum.Published,
|
||||
...(tag && { tags: [tag] }),
|
||||
...(options?.useStat && {
|
||||
useStat: true,
|
||||
}),
|
||||
},
|
||||
queryClient,
|
||||
)
|
||||
}
|
||||
|
||||
// if (page?.authors[0]) {
|
||||
// await prefetchGetUserSites(page?.authors[0], queryClient)
|
||||
// }
|
||||
} catch (error) {
|
||||
reject(error)
|
||||
}
|
||||
} else {
|
||||
if (!options?.skipPages) {
|
||||
await prefetchGetPagesBySite(
|
||||
{
|
||||
site: domainOrSubdomain,
|
||||
...(options?.take && { take: options.take }),
|
||||
type: "post",
|
||||
visibility: PageVisibilityEnum.Published,
|
||||
...(tag && { tags: [tag] }),
|
||||
...(options?.useStat && {
|
||||
useStat: true,
|
||||
}),
|
||||
},
|
||||
queryClient,
|
||||
)
|
||||
}
|
||||
}
|
||||
resolve(null)
|
||||
}),
|
||||
])
|
||||
resolve(null)
|
||||
}),
|
||||
])
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
|
||||
@@ -39,27 +39,33 @@ export const SiteLayout: React.FC<SiteLayoutProps> = ({
|
||||
const pageSlug = router.query.page as string
|
||||
const tag = router.query.tag as string
|
||||
|
||||
const site = useGetSite(domainOrSubdomain)
|
||||
|
||||
const page = useGetPage({
|
||||
site: domainOrSubdomain,
|
||||
page: pageSlug,
|
||||
characterId: site.data?.characterId,
|
||||
slug: pageSlug,
|
||||
...(useStat && {
|
||||
useStat: true,
|
||||
}),
|
||||
})
|
||||
|
||||
const site = useGetSite(domainOrSubdomain)
|
||||
|
||||
const isConnected = useAccountState((s) => !!s.computed.account)
|
||||
const userRole = useUserRole(domainOrSubdomain)
|
||||
const subscription = useGetSubscription(domainOrSubdomain)
|
||||
const [{ isLiked }] = useCheckLike({ pageId: page.data?.id })
|
||||
const isMint = useCheckMint(page.data?.id)
|
||||
const subscription = useGetSubscription(site.data?.characterId)
|
||||
const [{ isLiked }] = useCheckLike({
|
||||
characterId: page.data?.characterId,
|
||||
noteId: page.data?.noteId,
|
||||
})
|
||||
const isMint = useCheckMint({
|
||||
characterId: page.data?.characterId,
|
||||
noteId: page.data?.noteId,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (site.data) {
|
||||
if (
|
||||
window.location.host.split(".").slice(-2).join(".") !== OUR_DOMAIN &&
|
||||
window.location.host !== site.data?.custom_domain &&
|
||||
window.location.host !== site.data?.metadata?.content?.custom_domain &&
|
||||
IS_PROD
|
||||
) {
|
||||
window.location.href = SITE_URL
|
||||
@@ -83,32 +89,37 @@ export const SiteLayout: React.FC<SiteLayoutProps> = ({
|
||||
)}
|
||||
>
|
||||
<SEOHead
|
||||
title={title || tag || page.data?.title || ""}
|
||||
siteName={site.data?.name || ""}
|
||||
title={title || tag || page.data?.metadata?.content?.title || ""}
|
||||
siteName={site.data?.metadata?.content?.name || ""}
|
||||
description={
|
||||
page.data?.summary?.content ??
|
||||
site.data?.description?.replace(/<[^>]*>/g, "")
|
||||
page.data?.metadata?.content?.summary ??
|
||||
site.data?.metadata?.content?.bio?.replace(/<[^>]*>/g, "")
|
||||
}
|
||||
image={page.data?.cover || getUserContentsUrl(site.data?.avatars?.[0])}
|
||||
icon={getUserContentsUrl(site.data?.avatars?.[0])}
|
||||
image={
|
||||
page.data?.metadata?.content?.cover ||
|
||||
getUserContentsUrl(site.data?.metadata?.content?.avatars?.[0])
|
||||
}
|
||||
icon={getUserContentsUrl(site.data?.metadata?.content?.avatars?.[0])}
|
||||
site={domainOrSubdomain}
|
||||
/>
|
||||
<Style content={site.data?.css} />
|
||||
<Style content={site.data?.metadata?.content?.css} />
|
||||
{site.data && <SiteHeader site={site.data} />}
|
||||
<div
|
||||
className={cn(
|
||||
`xlog-post-id-${page.data?.id} max-w-screen-md mx-auto px-5 pt-12 relative`,
|
||||
page.data?.tags?.map((tag) => `xlog-post-tag-${tag}`),
|
||||
`xlog-post-id-${page.data?.characterId}-${page.data?.noteId} max-w-screen-md mx-auto px-5 pt-12 relative`,
|
||||
page.data?.metadata?.content?.tags?.map(
|
||||
(tag) => `xlog-post-tag-${tag}`,
|
||||
),
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
{site.data && (
|
||||
<div className="max-w-screen-md mx-auto pt-12 pb-10">
|
||||
<BlockchainInfo site={site.data} page={page.data} />
|
||||
<BlockchainInfo site={site.data} page={page.data || undefined} />
|
||||
</div>
|
||||
)}
|
||||
<SiteFooter site={site.data} page={page.data} />
|
||||
<SiteFooter site={site.data || undefined} />
|
||||
|
||||
<FABContainer>
|
||||
<BackToTopFAB />
|
||||
|
||||
@@ -3,17 +3,17 @@ import Head from "next/head"
|
||||
import serialize from "serialize-javascript"
|
||||
|
||||
import { getSiteLink } from "~/lib/helpers"
|
||||
import { Note, Profile } from "~/lib/types"
|
||||
import { ExpandedCharacter, ExpandedNote } from "~/lib/types"
|
||||
|
||||
import { PageContent } from "../common/PageContent"
|
||||
import { PostFooter } from "./PostFooter"
|
||||
import { PostMeta } from "./PostMeta"
|
||||
|
||||
export const SitePage: React.FC<{
|
||||
page?: Note | null
|
||||
site?: Profile | null
|
||||
}> = ({ page, site }) => {
|
||||
// const author = useGetUserSites(page?.authors?.[0])
|
||||
page?: ExpandedNote
|
||||
site?: ExpandedCharacter
|
||||
preview?: boolean
|
||||
}> = ({ page, site, preview }) => {
|
||||
const { t } = useTranslation("site")
|
||||
|
||||
function addPageJsonLd() {
|
||||
@@ -21,18 +21,18 @@ export const SitePage: React.FC<{
|
||||
__html: serialize({
|
||||
"@context": "https://schema.org",
|
||||
"@type": "BlogPosting",
|
||||
headline: page?.title,
|
||||
...(page?.cover && {
|
||||
image: [page?.cover],
|
||||
headline: page?.metadata?.content?.title,
|
||||
...(page?.metadata?.content?.cover && {
|
||||
image: [page?.metadata?.content?.cover],
|
||||
}),
|
||||
datePublished: page?.date_published,
|
||||
dateModified: page?.date_updated,
|
||||
datePublished: page?.metadata?.content?.date_published,
|
||||
dateModified: page?.updatedAt,
|
||||
author: [
|
||||
{
|
||||
"@type": "Person",
|
||||
name: site?.name,
|
||||
name: site?.metadata?.content?.name,
|
||||
url: getSiteLink({
|
||||
subdomain: site?.username || "",
|
||||
subdomain: site?.handle || "",
|
||||
}),
|
||||
},
|
||||
],
|
||||
@@ -48,7 +48,7 @@ export const SitePage: React.FC<{
|
||||
dangerouslySetInnerHTML={addPageJsonLd()}
|
||||
/>
|
||||
</Head>
|
||||
{page?.preview && (
|
||||
{preview && (
|
||||
<div className="fixed top-0 left-0 w-full text-center text-red-500 bg-gray-100 py-2 opacity-80 text-sm z-10">
|
||||
{t(
|
||||
"This address is in local editing preview mode and cannot be viewed by the public.",
|
||||
@@ -57,20 +57,22 @@ export const SitePage: React.FC<{
|
||||
)}
|
||||
<article>
|
||||
<div>
|
||||
{page?.tags?.includes("post") ? (
|
||||
<h2 className="xlog-post-title text-4xl font-bold">{page.title}</h2>
|
||||
{page?.metadata?.content?.tags?.includes("post") ? (
|
||||
<h2 className="xlog-post-title text-4xl font-bold">
|
||||
{page.metadata?.content?.title}
|
||||
</h2>
|
||||
) : (
|
||||
<h2 className="xlog-post-title text-xl font-bold page-title">
|
||||
{page?.title}
|
||||
{page?.metadata?.content?.title}
|
||||
</h2>
|
||||
)}
|
||||
{page?.tags?.includes("post") && !page?.preview && (
|
||||
{page?.metadata?.content?.tags?.includes("post") && !preview && (
|
||||
<PostMeta page={page} site={site} />
|
||||
)}
|
||||
</div>
|
||||
<PageContent
|
||||
className="mt-10"
|
||||
content={page?.body?.content}
|
||||
content={page?.metadata?.content?.content}
|
||||
toc={true}
|
||||
></PageContent>
|
||||
</article>
|
||||
|
||||
Reference in New Issue
Block a user