1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Change searching by tag

This commit is contained in:
asmsuechan
2017-10-13 10:37:43 +09:00
parent 15dc424ade
commit caa5deac4e

View File

@@ -2,15 +2,15 @@ import _ from 'lodash'
export default function searchFromNotes (notes, search) { export default function searchFromNotes (notes, search) {
if (search.trim().length === 0) return [] if (search.trim().length === 0) return []
let searchBlocks = search.split(' ') const searchBlocks = search.split(' ').filter(block => { return block !== '' })
let foundNotes = []
searchBlocks.forEach((block) => { searchBlocks.forEach((block) => {
foundNotes = findByWord(notes, block)
if (block.match(/^#.+/)) { if (block.match(/^#.+/)) {
notes = findByTag(notes, block) foundNotes = foundNotes.concat(findByTag(notes, block))
} else {
notes = findByWord(notes, block)
} }
}) })
return notes return foundNotes
} }
function findByTag (notes, block) { function findByTag (notes, block) {