next主题7.8版本localsearch搜索功能启用
问题描述:
以前的老版本直接设置localsearch为true,就可以,新版本需要安装搜索插件才可以使用。
解决办法:
- 编辑
站点配置文件(不是主题配置文件)
,新增以下内容到任意位置:
# 搜索
search:
path: search.xml
field: post
format: html
limit: 10000
- 编辑
主题配置文件
,启用本地搜索功能:
# Local Search
# Dependencies: https://github.com/theme-next/hexo-generator-searchdb
local_search:
enable: true # 修改为true
# If auto, trigger search by changing input.
# If manual, trigger search by pressing enter key or search button.
trigger: auto
# Show top n results per article, show all results by setting to -1
top_n_per_article: 1
# Unescape html strings to the readable one.
unescape: false
# Preload the search data when the page loads.
preload: false
- 安装搜索插件(新版本需要安装搜索插件)
npm install hexo-generator-searchdb --save
然后再重新生成静态文件,会发现 Hexo
博客的搜索功能已经可以正常使用了。