diff --git a/src/components/common/Comment.tsx b/src/components/common/Comment.tsx index a497c5ea..aa8f5c9d 100644 --- a/src/components/common/Comment.tsx +++ b/src/components/common/Comment.tsx @@ -13,7 +13,7 @@ export const Comment: React.FC<{ }) return ( -
+
{comments.data?.count || "0"} Comment diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 80a86416..c22ff9b3 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -19,13 +19,14 @@ import { useRefCallback } from "@crossbell/util-hooks" import NextNProgress from "nextjs-progressbar" import { CharacterEntity, Network } from "crossbell.js" -import { IPFS_GATEWAY } from "~/lib/env" +import { IPFS_GATEWAY, CSB_IO } from "~/lib/env" import { toGateway } from "~/lib/ipfs-parser" import { connectors, provider } from "~/lib/wallet-config" import { createIDBPersister } from "~/lib/persister.client" import { NotificationModal } from "@crossbell/notification" import { getSiteLink } from "~/lib/helpers" +import type { NoteEntity } from "crossbell.js" Network.setIpfsGateway(IPFS_GATEWAY) @@ -60,13 +61,35 @@ try { const urlComposer: Partial = { characterUrl: ({ handle }) => getSiteLink({ subdomain: handle }), noteUrl: (note) => { - const { character } = note as { character?: CharacterEntity } - - if (character) { - // ... + let originalNote = note + while (originalNote?.toNote) { + originalNote = originalNote.toNote } - return `` + if (originalNote.metadata?.content?.sources?.includes("xlog")) { + const { character } = originalNote + + if (character) { + return ( + getSiteLink({ + subdomain: character.handle, + }) + + "/" + + ( + originalNote.metadata?.content?.attributes?.find( + (a: any) => a?.trait_type === "xlog_slug", + )?.value || + (originalNote as any).metadata?.content?._xlog_slug || + (originalNote as any).metadata?.content?._crosslog_slug + )?.toLowerCase?.() + + (originalNote !== note ? `#comments` : "") + ) + } else { + return "" + } + } else { + return `${CSB_IO}/notes/${note.characterId}-${note.noteId}` + } }, }