mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 11:36:23 +00:00
search patch
This commit is contained in:
parent
df23b99951
commit
8ca31df3f2
1 changed files with 10 additions and 4 deletions
|
@ -177,10 +177,16 @@
|
|||
limit: 5,
|
||||
}
|
||||
]).then(searchResults => {
|
||||
const titleIds = [...searchResults.filter(x => x.field === 'title')?.[0].result] ?? []
|
||||
const contentIds = [...searchResults.filter(x => x.field === 'content')?.[0].result] ?? []
|
||||
const allIds = [...titleIds, ...contentIds]
|
||||
const finalResults = allIds.map(fetch)
|
||||
const getByField = field => {
|
||||
const results = searchResults.filter(x => x.field === field)
|
||||
if (results.length === 0) {
|
||||
return []
|
||||
} else {
|
||||
return [...results[0].result]
|
||||
}
|
||||
}
|
||||
const allIds = [...getByField('title'), ...getByField('content')]
|
||||
const finalResults = allIds.map(fetch)
|
||||
|
||||
// display
|
||||
if (finalResults.length === 0) {
|
||||
|
|
Loading…
Reference in a new issue