hexo 博客浏览器地址栏搜索
使用koa2
、redis
完成hexo博客chrome浏览器地址栏搜索
首先访问一次https://i.jakeyu.top/
然后在chrome地址栏输入i.jakeyu.top
,点击Tab
进行搜索
安装hexo-generator-json-content插件
npm install hexo-generator-json-content -S
在_config.yml
添加下面配置
jsonContent: meta: false drafts: false file: localsearch.json keywords: undefined dateFormat: YYYY-MM-DD HH:mm:ss tags: false categories: false pages: false posts: title: true slug: true date: true updated: true comments: true path: true link: true permalink: true excerpt: true keywords: false text: true raw: false content: false author: true categories: true tags: true
在博客source
目录下创建sitesearch.xml
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"> <InputEncoding>utf-8</InputEncoding> <ShortName>标题</ShortName> <Description>描述</Description> <Image height="16" width="16" type="image/x-icon">图标地址(例:https://xxx.com/favicon.ico)</Image> <Url type="text/html" template="https://xxx.com/search?search={searchTerms}"/> </OpenSearchDescription>
在博客源码中添加link
<link rel="search" type="application/opensearchdescription+xml" href="https://xxx.com/sitesearch.xml" title="Jake"> 服务端配置 redis
需要安装redis
,检查是否开启
config.js
说明
module.exports = { index: 'https://i.jakeyu.top', // 网站首页 link: 'https://i.jakeyu.top/archives/', // 归档页面地址 searchFile: 'localsearch.json', // hexo-generator-search path配置 port: 3500, //服务端口 cronTime: '00 59 23 * * *', // 设置定时任务时间 参考 https://github.com/kelektiv/node-cron sentryUrl: '', // https://sentry.io 监控错误,如果不需要删除即可 redis: { port: 6379, // redis 端口 host: '127.0.0.1', // redis 地址 keyPreifx: 'searchDatas', // redis key expire: 30 // redis过期时间(s) }, api: { search: '/search', // 搜索路由 cache: '/search/cache' // 刷新缓存路由 } } nginx
location /search { proxy_pass http://127.0.0.1:3500; } 启动
git clone git@github.com:JakeLaoyu/hexo-browser-search.git
cd hexo-browser-search
npm i
npm i pm2 -g
pm2 start pm2.config.json
开发
git clone https://github.com/JakeLaoyu/hexo-browser-search.git
cd hexo-browser-search
yarn
npm run dev
License
MIT © JakeLaoyu
版权声明:
1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。2、网站不提供资料下载,如需下载请到原作者页面进行下载。