diff --git a/src/components/SearchBar.tsx b/src/components/SearchBar.tsx index 36760a1..76539e2 100644 --- a/src/components/SearchBar.tsx +++ b/src/components/SearchBar.tsx @@ -65,7 +65,7 @@ export function SearchBar({ className }: { className?: string }) { handleInputChange(e.target.value)} onKeyDown={handleKeyDown} diff --git a/src/hooks/useSearch.ts b/src/hooks/useSearch.ts index d08b6ee..d76c4bd 100644 --- a/src/hooks/useSearch.ts +++ b/src/hooks/useSearch.ts @@ -20,7 +20,27 @@ export function useSearch(searchTerm: string, enabled = true) { return []; } - // Query both profiles (kind 0) and articles (kind 30023) in one request + // Check if the search term is a hashtag + const isHashtagSearch = term.startsWith('#'); + const tagValue = isHashtagSearch ? term.slice(1) : term; + + // If hashtag search, query specifically for articles with that tag + if (isHashtagSearch && tagValue) { + const events = await nostr.query( + [ + { + kinds: [30023], + '#t': [tagValue], + limit: 100, + }, + ], + { signal } + ); + + return events.map((event) => ({ type: 'article' as const, event })); + } + + // Regular search: Query both profiles (kind 0) and articles (kind 30023) in one request const events = await nostr.query( [ { diff --git a/src/pages/SearchResultsPage.tsx b/src/pages/SearchResultsPage.tsx index d402392..305ff5a 100644 --- a/src/pages/SearchResultsPage.tsx +++ b/src/pages/SearchResultsPage.tsx @@ -72,10 +72,14 @@ export default function SearchResultsPage() { {searchTerm && (

- Search Results for "{searchTerm}" + {searchTerm.startsWith('#') ? ( + <>Articles tagged with "{searchTerm}" + ) : ( + <>Search Results for "{searchTerm}" + )}

- Found {results?.length || 0} results + Found {results?.length || 0} {searchTerm.startsWith('#') ? 'articles' : 'results'}

)}