mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-29 20:13:31 +08:00
Remove keyword sorts
This commit is contained in:
parent
dda0beadcb
commit
8f8249e3ae
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user