From 8f8249e3ae36837749d8b94133001dad37b83946 Mon Sep 17 00:00:00 2001 From: Jimmy Cai Date: Tue, 28 Dec 2021 23:22:38 +0000 Subject: [PATCH] Remove keyword sorts --- assets/ts/search.tsx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/assets/ts/search.tsx b/assets/ts/search.tsx index 9478844..faa197d 100644 --- a/assets/ts/search.tsx +++ b/assets/ts/search.tsx @@ -98,14 +98,9 @@ class Search { const rawData = await this.getData(); let results: pageData[] = []; - /// Sort keywords by their length - keywords.sort((a, b) => { - return b.length - a.length - }); - for (const item of rawData) { let titleMatches: match[] = [], - bodyMatches: match[] = []; + contentMatches: match[] = []; let result = { ...item, @@ -132,7 +127,7 @@ class Search { } if (contentMatch) { - bodyMatches.push({ + contentMatches.push({ start: contentMatch.index, end: contentMatch.index + contentMatch[0].length }); @@ -143,12 +138,11 @@ class Search { result.title = Search.processMatches(result.title, titleMatches).join(''); } - console.log(bodyMatches); - if (bodyMatches.length > 0) { - result.preview = Search.processMatches(result.content, bodyMatches).join(''); + if (contentMatches.length > 0) { + result.preview = Search.processMatches(result.content, contentMatches).join(''); } - if (titleMatches.length > 0 || bodyMatches.length > 0) { + if (titleMatches.length > 0 || contentMatches.length > 0) { results.push(result); } }