Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/components/NIPBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getNIPInfo } from "../lib/nip-icons";
import { useAddWindow } from "@/core/state";
import { isNipDeprecated } from "@/constants/nips";
import { getCommunityNipForNipId } from "@/constants/kinds";

export interface NIPBadgeProps {
nipNumber: string;
Expand All @@ -26,7 +27,19 @@ export function NIPBadge({
nipInfo?.description || `Nostr Implementation Possibility ${nipNumber}`;
const isDeprecated = isNipDeprecated(nipNumber);

const communityNip = getCommunityNipForNipId(nipNumber);

const openNIP = () => {
if (communityNip) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, reminder to self to review community kinds and add a pointer to them

const pointer = {
kind: 30817,
pubkey: communityNip.pubkey,
identifier: communityNip.identifier,
relays: communityNip.relayHints,
};
addWindow("open", { pointer }, undefined, communityNip.title);
return;
}
const paddedNum = nipNumber.toString().padStart(2, "0");
addWindow(
"nip",
Expand All @@ -41,7 +54,13 @@ export function NIPBadge({
className={`flex items-center gap-2 border bg-card px-2.5 py-1.5 text-sm hover:underline hover:decoration-dotted cursor-crosshair ${
isDeprecated ? "opacity-50" : ""
} ${className}`}
title={isDeprecated ? `${description} (DEPRECATED)` : description}
title={
isDeprecated
? `${description} (DEPRECATED)`
: communityNip
? `${description} (Community NIP)`
: description
}
>
<span className="text-muted-foreground">
{`${showNIPPrefix ? "NIP-" : ""}${nipNumber}`}
Expand Down
21 changes: 21 additions & 0 deletions src/components/nostr/kinds/CommunityNIPDetailRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { Copy, CopyCheck } from "lucide-react";
import { getTagValue } from "applesauce-core/helpers";
import { UserName } from "../UserName";
import { MarkdownContent } from "../MarkdownContent";
import { KindBadge } from "@/components/KindBadge";
import { Button } from "@/components/ui/button";
import { useCopy } from "@/hooks/useCopy";
import { formatTimestamp } from "@/hooks/useLocale";
import { getTagValues } from "@/lib/nostr-utils";
import { toast } from "sonner";
import type { NostrEvent } from "@/types/nostr";

Expand All @@ -24,6 +26,12 @@ export function CommunityNIPDetailRenderer({ event }: { event: NostrEvent }) {
return getTagValue(event, "r");
}, [event]);

const kinds = useMemo(() => {
return getTagValues(event, "k")
.map(Number)
.filter((n) => !isNaN(n));
}, [event]);

// Format created date using locale utility
const createdDate = formatTimestamp(event.created_at, "long");

Expand Down Expand Up @@ -65,6 +73,19 @@ export function CommunityNIPDetailRenderer({ event }: { event: NostrEvent }) {

{/* NIP Content - Markdown */}
<MarkdownContent content={event.content} canonicalUrl={canonicalUrl} />

{kinds.length > 0 && (
<div className="mt-6 pt-4 border-t border-border">
<h3 className="text-sm font-bold mb-3">
Event Kinds Defined in {title}
</h3>
<div className="flex flex-wrap gap-2">
{kinds.map((kind) => (
<KindBadge key={kind} kind={kind} variant="full" clickable />
))}
</div>
</div>
)}
</div>
);
}
Loading