diff --git a/src/AppRouter.tsx b/src/AppRouter.tsx
index dd0f5e75..93fc3e32 100644
--- a/src/AppRouter.tsx
+++ b/src/AppRouter.tsx
@@ -5,6 +5,7 @@ import { URLFragmentHandler } from "./components/URLFragmentHandler";
import Index from "./pages/Index";
import Clone from "./pages/Clone";
+import Community from "./pages/Community";
import Settings from "./pages/Settings";
import Preferences from "./pages/Preferences";
import NostrSettings from "./pages/NostrSettings";
@@ -36,6 +37,7 @@ export function AppRouter() {
} />
} />
} />
+ } />
} />
} />
} />
diff --git a/src/components/NoteContent.tsx b/src/components/NoteContent.tsx
index a7a7c30f..6cb6e533 100644
--- a/src/components/NoteContent.tsx
+++ b/src/components/NoteContent.tsx
@@ -2,76 +2,130 @@ import { useMemo } from 'react';
import { type NostrEvent } from '@nostrify/nostrify';
import { Link } from 'react-router-dom';
import { nip19 } from 'nostr-tools';
+import { useNostr } from '@nostrify/react';
+import { useQuery } from '@tanstack/react-query';
import { useAuthor } from '@/hooks/useAuthor';
import { genUserName } from '@/lib/genUserName';
import { cn } from '@/lib/utils';
+import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
interface NoteContentProps {
event: NostrEvent;
className?: string;
+ /** When true, renders mentions and hashtags as styled text instead of clickable links */
+ disableLinks?: boolean;
+ /** When true, hides embedded note/event previews entirely */
+ hideEmbeds?: boolean;
}
/** Parses content of text note events so that URLs and hashtags are linkified. */
export function NoteContent({
- event,
- className,
-}: NoteContentProps) {
+ event,
+ className,
+ disableLinks = false,
+ hideEmbeds = false,
+}: NoteContentProps) {
// Process the content to render mentions, links, etc.
const content = useMemo(() => {
const text = event.content;
-
+
// Regex to find URLs, Nostr references, and hashtags
const regex = /(https?:\/\/[^\s]+)|nostr:(npub1|note1|nprofile1|nevent1)([023456789acdefghjklmnpqrstuvwxyz]+)|(#\w+)/g;
-
+
const parts: React.ReactNode[] = [];
let lastIndex = 0;
let match: RegExpExecArray | null;
let keyCounter = 0;
-
+
while ((match = regex.exec(text)) !== null) {
const [fullMatch, url, nostrPrefix, nostrData, hashtag] = match;
const index = match.index;
-
+
// Add text before this match
if (index > lastIndex) {
parts.push(text.substring(lastIndex, index));
}
-
+
if (url) {
- // Handle URLs
- parts.push(
-
- {url}
-
- );
+ // Handle URLs - always render as links (but prevent click propagation when disableLinks)
+ if (disableLinks) {
+ parts.push(
+
+ {url}
+
+ );
+ } else {
+ parts.push(
+
+ {url}
+
+ );
+ }
} else if (nostrPrefix && nostrData) {
// Handle Nostr references
try {
const nostrId = `${nostrPrefix}${nostrData}`;
const decoded = nip19.decode(nostrId);
-
+
if (decoded.type === 'npub') {
const pubkey = decoded.data;
parts.push(
-
+
);
- } else {
- // For other types, just show as a link
+ } else if (decoded.type === 'nprofile') {
+ const pubkey = decoded.data.pubkey;
parts.push(
-
- {fullMatch}
-
+
);
+ } else if (decoded.type === 'nevent') {
+ if (hideEmbeds) {
+ // Skip embedded events entirely when hideEmbeds is true
+ } else if (disableLinks) {
+ parts.push(
+
+ );
+ } else {
+ parts.push(
+
+ );
+ }
+ } else if (decoded.type === 'note') {
+ if (hideEmbeds) {
+ // Skip embedded notes entirely when hideEmbeds is true
+ } else if (disableLinks) {
+ parts.push(
+
+ );
+ } else {
+ parts.push(
+
+ );
+ }
+ } else {
+ // For other types, just show as styled text or link
+ if (disableLinks) {
+ parts.push(
+
+ {fullMatch}
+
+ );
+ } else {
+ parts.push(
+
+ {fullMatch}
+
+ );
+ }
}
} catch {
// If decoding fails, just render as text
@@ -79,33 +133,41 @@ export function NoteContent({
}
} else if (hashtag) {
// Handle hashtags
- const tag = hashtag.slice(1); // Remove the #
- parts.push(
-
- {hashtag}
-
- );
+ if (disableLinks) {
+ parts.push(
+
+ {hashtag}
+
+ );
+ } else {
+ const tag = hashtag.slice(1); // Remove the #
+ parts.push(
+
+ {hashtag}
+
+ );
+ }
}
-
+
lastIndex = index + fullMatch.length;
}
-
+
// Add any remaining text
if (lastIndex < text.length) {
parts.push(text.substring(lastIndex));
}
-
+
// If no special content was found, just use the plain text
if (parts.length === 0) {
parts.push(text);
}
-
+
return parts;
- }, [event]);
+ }, [event, disableLinks, hideEmbeds]);
return (
@@ -114,24 +176,173 @@ export function NoteContent({
);
}
-// Helper component to display user mentions
-function NostrMention({ pubkey }: { pubkey: string }) {
+// Helper component to display user mentions with avatar
+function NostrMention({ pubkey, disableLink = false }: { pubkey: string; disableLink?: boolean }) {
const author = useAuthor(pubkey);
const npub = nip19.npubEncode(pubkey);
const hasRealName = !!author.data?.metadata?.name;
const displayName = author.data?.metadata?.name ?? genUserName(pubkey);
+ const picture = author.data?.metadata?.picture;
+
+ const content = (
+ <>
+
+
+ {displayName.slice(0, 2).toUpperCase()}
+
+ @{displayName}
+ >
+ );
+
+ if (disableLink) {
+ return (
+
+ {content}
+
+ );
+ }
return (
-
- @{displayName}
+ {content}
);
+}
+
+// Helper component to display embedded events
+function NostrEventEmbed({ eventId }: { eventId: string }) {
+ const { nostr } = useNostr();
+
+ const { data: event, isLoading } = useQuery({
+ queryKey: ['nostr', 'event', eventId],
+ queryFn: async (c) => {
+ const signal = AbortSignal.any([c.signal, AbortSignal.timeout(5000)]);
+ const [event] = await nostr.query([{ ids: [eventId], limit: 1 }], { signal });
+ return event;
+ },
+ staleTime: 300000,
+ });
+
+ const author = useAuthor(event?.pubkey);
+ const note1 = nip19.noteEncode(eventId);
+
+ if (isLoading) {
+ return (
+
+ );
+ }
+
+ if (!event) {
+ return (
+
+ nostr:{note1.slice(0, 12)}...
+
+ );
+ }
+
+ const displayName = author.data?.metadata?.name ?? genUserName(event.pubkey);
+ const picture = author.data?.metadata?.picture;
+ const contentPreview = event.content.length > 200
+ ? event.content.slice(0, 200) + '...'
+ : event.content;
+
+ return (
+
+
+
+
+ {displayName.slice(0, 2).toUpperCase()}
+
+
{displayName}
+
+ {new Date(event.created_at * 1000).toLocaleDateString()}
+
+
+
+ {contentPreview}
+
+
+ );
+}
+
+// Helper component to display embedded events without links (for use inside clickable cards)
+function NostrEventPreview({ eventId }: { eventId: string }) {
+ const { nostr } = useNostr();
+
+ const { data: event, isLoading } = useQuery({
+ queryKey: ['nostr', 'event', eventId],
+ queryFn: async (c) => {
+ const signal = AbortSignal.any([c.signal, AbortSignal.timeout(5000)]);
+ const [event] = await nostr.query([{ ids: [eventId], limit: 1 }], { signal });
+ return event;
+ },
+ staleTime: 300000,
+ });
+
+ const author = useAuthor(event?.pubkey);
+
+ if (isLoading) {
+ return (
+
+ );
+ }
+
+ if (!event) {
+ return (
+
+ [quoted note]
+
+ );
+ }
+
+ const displayName = author.data?.metadata?.name ?? genUserName(event.pubkey);
+ const picture = author.data?.metadata?.picture;
+ const contentPreview = event.content.length > 200
+ ? event.content.slice(0, 200) + '...'
+ : event.content;
+
+ return (
+
+
+
+
+ {displayName.slice(0, 2).toUpperCase()}
+
+
{displayName}
+
+ {new Date(event.created_at * 1000).toLocaleDateString()}
+
+
+
+ {contentPreview}
+
+
+ );
}
\ No newline at end of file
diff --git a/src/components/ProjectSidebar.tsx b/src/components/ProjectSidebar.tsx
index 108f5f5a..f544b974 100644
--- a/src/components/ProjectSidebar.tsx
+++ b/src/components/ProjectSidebar.tsx
@@ -1,7 +1,7 @@
import React, { useEffect, useState, useMemo } from 'react';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
-import { Plus, Folder, GitBranch, Loader2, ChevronDown, ChevronRight, Star, Columns2, X, Settings, HelpCircle, Search, Tag, Folders } from 'lucide-react';
+import { Plus, Folder, GitBranch, Loader2, ChevronDown, ChevronRight, Star, Columns2, X, Settings, HelpCircle, Search, Tag, Folders, Users } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton';
import { Input } from '@/components/ui/input';
@@ -511,7 +511,7 @@ export function ProjectSidebar({
- {/* Settings and Help at Bottom */}
+ {/* Settings, Community, and Help at Bottom */}