Skip to content

Commit

Permalink
fix: search
Browse files Browse the repository at this point in the history
  • Loading branch information
MHuiG committed Aug 25, 2022
1 parent 02ffa97 commit 7f11915
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions source/js/search/hexo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let SearchService = (() => {
fn = {};
const fn = {};
fn.queryText = null;
fn.data = null;
fn.template = `<div id="u-search">
Expand Down Expand Up @@ -58,8 +58,8 @@ let SearchService = (() => {
fn.data = await fn.fetchData();
}
let results = "";
results += fn.buildResultList(data.pages);
results += fn.buildResultList(data.posts);
results += fn.buildResultList(fn.data.pages);
results += fn.buildResultList(fn.data.posts);
document.querySelector("#u-search .modal-results").innerHTML = results;
window.pjax && pjax.refresh(document.querySelector("#u-search"));
document.addEventListener("keydown", function f(event) {
Expand All @@ -76,7 +76,7 @@ let SearchService = (() => {
return fetch(SearchServiceDataPath)
.then((response) => response.text())
.then((res) => {
data = JSON.parse(res);
const data = JSON.parse(res);
// console.log(data);
return data;
});
Expand All @@ -87,8 +87,8 @@ let SearchService = (() => {
if (post.text) {
post.text = post.text.replace(/12345\d*/g, "") // 简易移除代码行号
}
if (!post.title&&post.text) {
post.title = post.text.trim().slice(0,15)
if (!post.title && post.text) {
post.title = post.text.trim().slice(0, 15)
}
if (fn.contentSearch(post)) {
html += fn.buildResult(post.permalink, post.title, post.digest);
Expand Down

0 comments on commit 7f11915

Please sign in to comment.