diff --git a/components/Header.vue b/components/Header.vue index 93b295c..4a37d67 100644 --- a/components/Header.vue +++ b/components/Header.vue @@ -44,8 +44,10 @@ useAsyncData(async () => { }) const results = ref([]) +const episodeResults = ref([]) const visible = ref(false) const thumbs = ref({}) + async function search (d) { const term = d.target.value if (term.length > 1) { @@ -57,16 +59,28 @@ async function search (d) { ofst: 0 }) })).json() - if (res.data.length === 0) { + if (res.data.topics.length === 0) { results.value = [{ error: 'No Results Found' }] } else { - for (let i = 0; i < res.data.length; i++) { - thumbs.value[res.data[i].id] = sb.storage.from('thumbs').getPublicUrl(res.data[i].id + '.jpeg').data.publicUrl + for (let i = 0; i < res.data.topics.length; i++) { + thumbs.value[res.data.topics[i].id] = sb.storage.from('thumbs').getPublicUrl(res.data.topics[i].id + '.jpeg').data.publicUrl } - results.value = res.data + results.value = res.data.topics + } + + if (res.data.episodes.length === 0) { + episodeResults.value = [{ + error: 'No Results Found' + }] + } else { + for (let i = 0; i < res.data.topics.length; i++) { + thumbs.value[res.data.episodes[i].id] = sb.storage.from('thumbs').getPublicUrl(res.data.episodes[i].id + '.jpeg').data.publicUrl + } + + episodeResults.value = res.data.episodes } visible.value = results.value.length > 0 @@ -147,6 +161,7 @@ function logout () { opacity: visible ? '0.95' : '0' }" > +

Topics Matching Search

+ }"> +
+

Episodes containing search

+ diff --git a/server/api/v1/search.post.ts b/server/api/v1/search.post.ts index 6d0e31f..ff7bedf 100644 --- a/server/api/v1/search.post.ts +++ b/server/api/v1/search.post.ts @@ -22,9 +22,16 @@ export default defineEventHandler(async (event) => { } } else { const s = (await sb.rpc('search', q)).data - searchCache.set(q.phrase, s) + const se = (await sb.rpc('search_episodes', q)).data + searchCache.set(q.phrase, { + topics: s, + episodes: se + }) return { - data: s, + data: { + topics: s, + episodes: se + }, time: new Date().getTime() - t.getTime() } }