Update hashtag routing in NoteContent and enhance hashtag search logic in useHashtagFeed

This commit is contained in:
2025-11-27 23:33:25 +01:00
parent 1f73d4c5ee
commit 71e6ffd089
3 changed files with 10 additions and 5 deletions

View File

@@ -98,8 +98,8 @@ describe('NoteContent', () => {
expect(nostrHashtag).toBeInTheDocument();
expect(bitcoinHashtag).toBeInTheDocument();
expect(nostrHashtag).toHaveAttribute('href', '/t/nostr');
expect(bitcoinHashtag).toHaveAttribute('href', '/t/bitcoin');
expect(nostrHashtag).toHaveAttribute('href', '/tag/nostr');
expect(bitcoinHashtag).toHaveAttribute('href', '/tag/bitcoin');
});
it('generates deterministic names for users without metadata and styles them differently', () => {

View File

@@ -83,7 +83,7 @@ export function NoteContent({
parts.push(
<Link
key={`hashtag-${keyCounter++}`}
to={`/t/${tag}`}
to={`/tag/${tag}`}
className="text-blue-500 hover:underline"
>
{hashtag}

View File

@@ -8,13 +8,18 @@ import type { NostrEvent } from '@nostrify/nostrify';
export function useHashtagFeed(hashtag: string) {
const { nostr } = useNostr();
const normalizedTag = hashtag.toLowerCase();
// Search for both normalized and original tag if they differ
const tagsToSearch = normalizedTag === hashtag
? [normalizedTag]
: [normalizedTag, hashtag];
return useInfiniteQuery({
queryKey: ['hashtag-feed', normalizedTag],
queryFn: async ({ pageParam, signal }) => {
const filter = pageParam
? { kinds: [20], '#t': [normalizedTag], limit: 20, until: pageParam as number }
: { kinds: [20], '#t': [normalizedTag], limit: 20 };
? { kinds: [20], '#t': tagsToSearch, limit: 20, until: pageParam as number }
: { kinds: [20], '#t': tagsToSearch, limit: 20 };
const events = await nostr.query([filter], {
signal: AbortSignal.any([signal, AbortSignal.timeout(1500)])