基于 shoka 主题,本篇介绍更多依赖安装以及配置,包括 algoliamini-vlainehexo-feedhexo-symbols-count-time
其他更多的 shoka 主题的配置不再多做介绍,建议直接看主题作者的教程

# 安装依赖

mini-valine 已经内置,只需要安装 algoliasearchhexo-feedhexo-symbols-count-time

npm install hexo-algoliasearch --save
npm install hexo-feed --save-dev
npm install hexo-symbols-count-time

# 配置

# mini-valine

实现评论功能

  1. 获取 LeanCloud 的 appId 和 appKey
  2. 修改 _config.shoka.yml , 填写 appIdappKey
valine:
  appId: #Your_appId
  appKey: #Your_appkey
  placeholder: ヽ(○´∀`)ノ♪ # Comment box placeholder
  avatar: mp # Gravatar style : mp, identicon, monsterid, wavatar, robohash, retro
  pageSize: 10 # Pagination size
  lang: zh-CN
  visitor: true # 文章访问量统计
  NoRecordIP: false # 不记录 IP
  serverURLs: # When the custom domain name is enabled, fill it in here (it will be detected automatically by default, no need to fill in)
  powerMode: true # 默认打开评论框输入特效
  tagMeta:
    visitor: 新朋友
    master: 主人
    friend: 小伙伴
    investor: 金主粑粑
  tagColor:
    master: "var(--color-orange)"
    friend: "var(--color-aqua)"
    investor: "var(--color-pink)"
  tagMember:
    master:
      # - hash of master@email.com
      # - hash of master2@email.com
    friend:
      # - hash of friend@email.com
      # - hash of friend2@email.com
    investor:
      # - hash of investor1@email.com

关于 tagMember 中的身份配置,是根据邮箱来确定身份,注意填写的是经过 MD5 加密后的值
MD5 转码网站:https://tool.chinaz.com/tools/md5.aspx

如果需要实现评论通知以及垃圾评论过滤等功能,需要配合使用 valine-admin
教程参考:https://github.com/amehime/Valine-Admin

# algolia

实现搜索功能

  1. 注册登录 algolia
  2. 登录后点击网页右侧的 index ,创建一个 index

    这里需要注意,新用户是试用状态,14 天过期后会无法使用,那时可以回来更改为免费的方案
  3. 点击网页左侧导航中的 API Keys ,记录 Application IDSearch-Only API KeyAdmin API Key
  4. _config.yml 中配置
algolia:
  appId: #Your appId
  apiKey: #Your Search-Only apiKey
  adminApiKey: #Your adminApiKey
  chunkSize: 5000
  indexName: #"Your indexname"
  fields:
    - title #必须配置
    - path #必须配置
    - categories #推荐配置
    - content:strip:truncate,0,2000
    - gallery
    - photos
    - tags

# feed

给博客添加 feed 页

这里我使用的是主题作者的建议配置,未做修改,在 _config.yml 中加入

feed:
    limit: 20
    order_by: "-date"
    tag_dir: false
    category_dir: false
    rss:
        enable: true
        template: "themes/shoka/layout/_alternate/rss.ejs"
        output: "rss.xml"
    atom:
        enable: true
        template: "themes/shoka/layout/_alternate/atom.ejs"
        output: "atom.xml"
    jsonFeed:
        enable: true
        template: "themes/shoka/layout/_alternate/json.ejs"
        output: "feed.json"

# hexo-symbols-count-time

用于显示博文字数以及阅读时间

修改 _config.shoka.yml , 修改或添加如下内容:

# 页尾全站统计
footer:
  since: 2010
  count: true
# 文章界面统计
post:
  count: true

这样使用的就是默认配置,但个人觉得默认配置统计的太夸张,1K 字提示阅读时间 1 分钟。
所以我在 _config.yml 中添加一些额外的配置,让它稍微合理一些

symbols_count_time:
  jsymbols: true
  time: true
  total_symbols: true
  total_time: true
  exclude_codeblock: false
  awl: 2
  wpm: 200
  suffix: "mins."
更新于 阅读次数

请我喝[茶]~( ̄▽ ̄)~*

木 白 微信支付

微信支付

木 白 支付宝

支付宝

木 白 贝宝

贝宝