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
@@ -52,7 +52,7 @@ export function GlobalSearch({ query, setQuery, results }: Props) {
function handleSelect(result: SearchResult) {
setOpen(false)
setQuery('')
if (result.type === 'episode' && result.href.startsWith('http')) {
if (result.href.startsWith('http')) {
window.open(result.href, '_blank', 'noreferrer')
} else {
navigate(result.href)
+19 -10
View File
@@ -53,18 +53,27 @@ export function useGlobalSearch(content: SiteContent) {
fetch('/api/episodes/all')
.then(r => r.ok ? r.json() : Promise.reject())
.then((data: { episodes?: Array<{ title: string; link: string; description?: string; episode?: string }> }) => {
const eps: SearchResult[] = (data.episodes ?? []).map(ep => ({
id: `episode-${ep.episode ?? ep.title}`,
type: 'episode' as const,
title: ep.title,
subtitle: ep.episode ? `Episode ${ep.episode}` : 'Episode',
description: ep.description,
href: ep.link || '/episodes',
}))
const eps: SearchResult[] = (data.episodes ?? []).map(ep => {
// Check if there's a matching podcastFeaturedLink highlight page for this episode number
const highlight = content.podcastFeaturedLinks?.find(
f => f.episodeNumber && ep.episode && String(f.episodeNumber) === String(ep.episode)
)
const hasRichPage = highlight && !!(
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)
})
.catch(() => {})
}, [])
}, [content.podcastFeaturedLinks])
// Debounced server-side script search — runs whenever query changes
useEffect(() => {
@@ -104,7 +113,7 @@ export function useGlobalSearch(content: SiteContent) {
title: link.label,
subtitle: link.placement === 'resources' ? 'Download' : 'Resource',
description: link.description,
href: `/downloads/${link.id}`,
href: `/downloads/custom--${link.id}`,
})
}
}