将博客搜索引擎改为Swiftype

之前博客用的是谷歌搜索,主题为chenall,今天突然发现hexo的官网用的搜索时Swiftype,感觉挺不错,便想试试。结果发现chenall的主题中已经集成了Swiftype,不过弄了很长时间没有弄出来,索性就照搬了官网的代码。

办法为修改chenall\layout\_widgets\search.ejs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<div id="search-form-wrap">
<form class="input-group">
<input type="text" id="st-search-input" class="form-control" />
<span class="input-group-btn"><button class="btn btn-default" type="search"><i class="fa fa-search"></i></button></span>
</form>
<script type="text/javascript">
var Swiftype = window.Swiftype || {};
(function() {
Swiftype.key = '你在Swiftype官网注册后提供的key';

/** DO NOT EDIT BELOW THIS LINE **/
var script = document.createElement('script'); script.type = 'text/javascript'; script.async = true;
script.src = "//s.swiftypecdn.com/embed.js";
var entry = document.getElementsByTagName('script')[0];
entry.parentNode.insertBefore(script, entry);
}());
</script>
</div>
小鹏 wechat
公众号:数据Man
0%