summary refs log tree commit diff
path: root/search.html
blob: 323d8fedcc582f98286f1e3c0962bae653eda331 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
---
layout: default
title: 搜索
---

<h1>搜索</h1>
<!--[if IE]>
  <p>很遗憾,IE搜不了捏~</p>
<![endif]-->
<!--[if !IE]> -->
<p>Keyword: <input type="text" id="search-input" placeholder="Search blog posts.." /> <img src="/images/loading.svg" alt="Loading..." id="search-loading" style="width:22px;vertical-align: bottom" /></p>
<ul id="results-container"></ul>
<script src="/assets/js/simple-jekyll-search.min.js"></script>
<script>
const urlParams = new URLSearchParams(window.location.search);
const mykeyword = urlParams.get('keyword')?.trim();
const sbox = document.getElementById('search-input');
if (mykeyword) {
  sbox.value = mykeyword;
}
getSearchJSON(function(json){
  var sjs = SimpleJekyllSearch({
     searchInput: sbox,
     resultsContainer: document.getElementById('results-container'),
     json: json,
     searchResultTemplate: '<p><li>{date} - <a href="{url}?kw={query}">{title}</a></li></p>',
     limit: 20
  });
  sjs.search(mykeyword);
  document.getElementById('search-loading').style.display = "none";
});
</script>
<!-- <![endif]-->