search download fix

This commit is contained in:
nmemmert
2026-06-09 10:02:01 -04:00
parent c4645e3475
commit 75d490020b
3 changed files with 21 additions and 12 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
{ {
"users": {}, "users": {},
"updatedAt": "2026-06-08T20:46:20.016Z" "updatedAt": "2026-06-09T13:41:20.565Z"
} }
+1 -1
View File
@@ -52,7 +52,7 @@ export function GlobalSearch({ query, setQuery, results }: Props) {
function handleSelect(result: SearchResult) { function handleSelect(result: SearchResult) {
setOpen(false) setOpen(false)
setQuery('') setQuery('')
if (result.type === 'episode' && result.href.startsWith('http')) { if (result.href.startsWith('http')) {
window.open(result.href, '_blank', 'noreferrer') window.open(result.href, '_blank', 'noreferrer')
} else { } else {
navigate(result.href) navigate(result.href)
+19 -10
View File
@@ -53,18 +53,27 @@ export function useGlobalSearch(content: SiteContent) {
fetch('/api/episodes/all') fetch('/api/episodes/all')
.then(r => r.ok ? r.json() : Promise.reject()) .then(r => r.ok ? r.json() : Promise.reject())
.then((data: { episodes?: Array<{ title: string; link: string; description?: string; episode?: string }> }) => { .then((data: { episodes?: Array<{ title: string; link: string; description?: string; episode?: string }> }) => {
const eps: SearchResult[] = (data.episodes ?? []).map(ep => ({ const eps: SearchResult[] = (data.episodes ?? []).map(ep => {
id: `episode-${ep.episode ?? ep.title}`, // Check if there's a matching podcastFeaturedLink highlight page for this episode number
type: 'episode' as const, const highlight = content.podcastFeaturedLinks?.find(
title: ep.title, f => f.episodeNumber && ep.episode && String(f.episodeNumber) === String(ep.episode)
subtitle: ep.episode ? `Episode ${ep.episode}` : 'Episode', )
description: ep.description, const hasRichPage = highlight && !!(
href: ep.link || '/episodes', highlight.embedUrl || highlight.showNotes || (highlight.discussionQuestions ?? []).length > 0
})) )
return {
id: `episode-${ep.episode ?? ep.title}`,
type: 'episode' as const,
title: ep.title,
subtitle: ep.episode ? `Episode ${ep.episode}` : 'Episode',
description: ep.description,
href: hasRichPage ? `/episodes/${highlight!.id}` : (ep.link || '/episodes'),
}
})
setEpisodeItems(eps) setEpisodeItems(eps)
}) })
.catch(() => {}) .catch(() => {})
}, []) }, [content.podcastFeaturedLinks])
// Debounced server-side script search — runs whenever query changes // Debounced server-side script search — runs whenever query changes
useEffect(() => { useEffect(() => {
@@ -104,7 +113,7 @@ export function useGlobalSearch(content: SiteContent) {
title: link.label, title: link.label,
subtitle: link.placement === 'resources' ? 'Download' : 'Resource', subtitle: link.placement === 'resources' ? 'Download' : 'Resource',
description: link.description, description: link.description,
href: `/downloads/${link.id}`, href: `/downloads/custom--${link.id}`,
}) })
} }
} }