48 lines
1.4 KiB
TypeScript
Raw Permalink Normal View History

2023-10-14 18:57:37 -04:00
"use client";
import Container from "./components/Container";
import { CardTitle, CardDescription } from "@/components/ui/card";
import { getTagValues, getTagsValues } from "@/lib/nostr/utils";
2023-10-16 00:57:59 -04:00
import { nip19 } from "nostr-tools";
2023-10-14 18:57:37 -04:00
import { removeDuplicates } from "@/lib/utils";
2023-10-16 00:57:59 -04:00
import { toast } from "sonner";
import { copyText } from "@/lib/utils";
2023-10-20 15:26:55 -04:00
import { type KindCardProps } from "./";
2023-10-14 18:57:37 -04:00
2023-10-20 15:26:55 -04:00
export default function Kind30023(props: KindCardProps) {
2023-10-16 00:57:59 -04:00
const { content, pubkey, tags, created_at: createdAt } = props;
const npub = nip19.npubEncode(pubkey);
2023-10-14 18:57:37 -04:00
const title = getTagValues("title", tags);
const summary = getTagValues("summary", tags);
const contentTags = removeDuplicates(getTagsValues("t", tags)).filter(
Boolean,
);
2023-10-14 18:57:37 -04:00
return (
2023-10-16 00:57:59 -04:00
<Container
event={props}
2023-10-16 00:57:59 -04:00
actionOptions={[
{
label: "View profile",
href: `/${npub}`,
type: "link",
},
{
label: "Copy raw data",
type: "button",
onClick: () => {
void copyText(JSON.stringify(props));
toast.success("Copied Text!");
},
},
]}
>
2023-10-16 00:28:09 -04:00
<CardTitle className="mb-1.5 line-clamp-2 text-lg font-semibold leading-6">
2023-10-14 18:57:37 -04:00
{title}
</CardTitle>
<CardDescription className="line-clamp-4 text-sm">
{summary ?? content}
</CardDescription>
</Container>
);
}