refactor: Rename renderTextWithLinkedTags to renderTextWithLinks for clarity and combine hashtag and nostr reference handling

This commit is contained in:
2025-05-23 21:24:09 +02:00
parent 8b53f5da79
commit 1ed65cd0ea
3 changed files with 121 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ import type { Event as NostrEvent } from "nostr-tools"
import ZapButton from "./ZapButton"
import Image from "next/image"
import CardOptionsDropdown from "./CardOptionsDropdown"
import { renderTextWithLinkedTags } from "@/utils/textUtils"
import { renderTextWithLinkedTags, renderTextWithLinks } from "@/utils/textUtils"
// Function to extract all images from a kind 20 event's imeta tags
const extractImagesFromEvent = (tags: string[][]): string[] => {
@@ -169,7 +169,7 @@ const KIND20Card: React.FC<KIND20CardProps> = ({
)}
</div>
<div className="p-4">
<div className="break-word overflow-hidden">{renderTextWithLinkedTags(text, tags)}</div>
<div className="break-word overflow-hidden">{renderTextWithLinks(text, tags, { [pubkey]: userData || {} })}</div>
<hr className="my-4" />
<div className="space-x-4 flex justify-between items-start">
<div className="flex space-x-4">

View File

@@ -30,7 +30,7 @@ import Link from 'next/link';
import { Event as NostrEvent } from "nostr-tools";
import ZapButton from './ZapButton';
import CardOptionsDropdown from './CardOptionsDropdown';
import { renderTextWithLinkedTags } from '@/utils/textUtils';
import { renderTextWithLinkedTags, renderTextWithLinks } from '@/utils/textUtils';
interface NoteCardProps {
pubkey: string;
@@ -143,7 +143,7 @@ const NoteCard: React.FC<NoteCardProps> = ({ pubkey, text, eventId, tags, event,
}
<br />
<div className='break-word overflow-hidden'>
{renderTextWithLinkedTags(textWithoutImage, tags)}
{renderTextWithLinks(textWithoutImage, tags, { [pubkey]: userData || {} })}
</div>
</div>
<hr />