fix: search by tags (#171)

This commit is contained in:
bayang 2023-06-26 16:41:07 +02:00 committed by GitHub
parent bda59556a2
commit 7df3ef0d1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -128,7 +128,7 @@
})
posts.forEach((p, idx) => {
contentIndex.add({
id: idx, title: p.title, content: p.content, //Change to removeHTML
id: idx, title: p.title, content: p.content, tags: p.tags //Change to removeHTML
})
});
return contentIndex;
@ -333,7 +333,7 @@
function offlineSearch(searchQuery) {
let data = window.docs;
let isTagSearch = search[0] === "#" && search.length > 1;
let isTagSearch = searchQuery[0] === "#" && searchQuery.length > 1;
let searchResults = isTagSearch
? index.search(searchQuery.substring(1), [
@ -361,7 +361,8 @@
}
const allIds = new Set([
...getByField("title"),
...getByField("content")
...getByField("content"),
...getByField("tags")
])
const dataIds = [...allIds];
const finalResults = dataIds.map((id) => {