Skip to content

Commit

Permalink
fix: duplicate results in search fixed #257 (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
alek13 authored and QingWei-Li committed Oct 17, 2017
1 parent fac7ce6 commit 3476f6f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/plugins/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,22 @@ export function genIndex (path, content = '', router, depth) {
return index
}

export function search (keywords) {
/**
* @param {String} query
* @returns {Array}
*/
export function search (query) {
const matchingResults = []
let data = []
Object.keys(INDEXS).forEach(key => {
data = data.concat(Object.keys(INDEXS[key]).map(page => INDEXS[key][page]))
})

keywords = [].concat(keywords, keywords.trim().split(/[\s\-\,\\/]+/))
query = query.trim()
let keywords = query.split(/[\s\-\,\\/]+/)
if (keywords.length !== 1) {
keywords = [].concat(query, keywords)
}

for (let i = 0; i < data.length; i++) {
const post = data[i]
Expand Down

0 comments on commit 3476f6f

Please sign in to comment.