search download fix
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"users": {},
|
"users": {},
|
||||||
"updatedAt": "2026-06-08T20:46:20.016Z"
|
"updatedAt": "2026-06-09T13:41:20.565Z"
|
||||||
}
|
}
|
||||||
@@ -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)
|
||||||
|
|||||||
@@ -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 => {
|
||||||
|
// 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}`,
|
id: `episode-${ep.episode ?? ep.title}`,
|
||||||
type: 'episode' as const,
|
type: 'episode' as const,
|
||||||
title: ep.title,
|
title: ep.title,
|
||||||
subtitle: ep.episode ? `Episode ${ep.episode}` : 'Episode',
|
subtitle: ep.episode ? `Episode ${ep.episode}` : 'Episode',
|
||||||
description: ep.description,
|
description: ep.description,
|
||||||
href: ep.link || '/episodes',
|
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}`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user