Hexo NexT 主题个性化配置

test

个性化配置

修改文件时一定要注意保存编码选择 utf-8,否则容易出现乱码或者打不开的情况。

子主题设定

Scheme 是 NexT 提供的一种特性,借助于 Scheme,NexT 为你提供多种不同的外观。同时,几乎所有的配置都可以 在 Scheme 之间共用。目前 NexT 支持三种 Scheme,他们是:

Muse      - 默认 Scheme,这是 NexT 最初的版本,黑白主调,大量留白
Mist     - Muse 的紧凑版本,整洁有序的单栏外观
Pisces     - 双栏 Scheme,小家碧玉似的清新
Gemini    - 双栏 Scheme,比 Pisces更宽

通过更改主题配置文件,即 /next/_config.yml 中的 scheme 关键字,通过注销前面的# 进行配置

设置菜单

默认情况下,菜单配置包括了home,archivestags,但是为了方便管理文章,我们可以把其他菜单通过配置开启。

通过打开主题配置文件 /next/_config.yml中对 menu选项进行解除注释的方式进行启用:

menu:
  home: /
  archives: /archives
  #about: /about
  #categories: /categories
  tags: /tags
  #commonweal: /404.html

当然配置后,需要新建对应同名文件,才可以把对应的菜单连接对应到页面中,如下是新建了categoriesabouttags页面,位置在source目录:

hexo new page categories 
hexo new page tags
hexo new page about

在categories里对 index.md 进行初始化设置,其他类似

---
title: categories
date: 2017-08-27 20:30:10
type: "categories"
---

配置完成后,以后在创建文章的时候,只需添加好对应的 tagscategories即可

title: theme-next!Hexo网站的一次华丽升级
date: 2017-08-27 20:12:16  
categories: 前端技术
tags: ['hexo']

修改语言

更改项目配置文件/_config.yml中的 language 字段:

设置为 zh-Hans

或者查看当前使用主题文件夹下的 languages文件夹,zh 开头的为中文,直接修改该文件中的内容进行汉化。

设置RSS

更改主题配置文件/next/_config.yml中的 rss `字段:

false:禁用 RSS,不在页面上显示 RSS 连接。
留空:使用 Hexo 生成的 Feed 链接。 你可以需要先安装 hexo-generator-feed 插
件。
具体的链接地址:适用于已经烧制过 Feed 的情形。

代码高亮

更改主题配置文件/next/_config.yml中的 highlight_theme 字段。

侧栏社交链接

更改主题配置文件/next/_config.yml中的 social字段。

侧栏头像

更改主题配置文件/next/_config.yml中的 avatar字段。

头像路径 themes\next\source\images

侧栏加入网易云音乐

打开网易云网页版,找到自己喜欢的音乐,然后在音乐详情页面点击【生成外链播放器】,设置喜欢的格式,复制生成的 html 代码,插入到想要的位置即可,

<div id="music163player">
    <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=19027626&auto=1&height=66">
    </iframe>
</div>

侧栏位置在layout/_macro/sidebar.swig 文件,将复制的代码放到该页面合适的位置(我放在最后一个div里的最后)即可。注意要带 div 标签。

打赏功能

更改主题配置文件/next/_config.yml中的 reward_comment字段:

reward_comment: 坚持原创技术分享,您的支持将鼓励我继续创作!
wechatpay: /path/to/wechat-reward-image
alipay: /path/to/alipay-reward-image

注意,要将个人的二维码导出后,放到对应的images目录中,不然是无效的。

订阅微信公众号

更改主题配置文件/next/_config.yml中的 wechat_subscriber字段:

# Wechat Subscriber
wechat_subscriber:
  enabled: true
  qcode: /uploads/wechat-qcode.jpg
  description: 欢迎您扫一扫上面的微信公众号,订阅我的网站!

主题动画

通过对主题配置文件 /next/_config.yml配置 user_motion

use_motion: true  # 开启动画效果
use_motion: false # 关闭动画效果

编辑 主题配置文件, 搜索 canvas_nestthree_waves,根据您的需求设置值为 true 或者 false 即可:

# canvas_nest
canvas_nest: true //开启动画
canvas_nest: false //关闭动画

不蒜子统计

编辑 主题配置文件, 搜索 busuanzi_count 根据您的需求设置值为 true 或者 false 即可:

# Show PV/UV of the website/page with busuanzi.
# Get more information on http://ibruce.info/2015/04/04/busuanzi/
busuanzi_count:
  # count values only if the other configs are false
  enable: true
  # custom uv span for the whole site
  site_uv: true
  site_uv_header: <i class="fa fa-user"></i> 访问用户 :
  site_uv_footer: 人
  # custom pv span for the whole site
  site_pv: true
  site_pv_header: <i class="fa fa-eye"></i> 访问次数 :
  site_pv_footer: 次
  # custom pv span for one page only
  page_pv: true
  page_pv_header: <i class="fa fa-file-o"></i>&nbsp点击量
  page_pv_footer: 次

不蒜子统计不显示、失效问题解决方法:

查看控制台,发现不蒜子js 404,说明该链接失效,换一个新的即可。

首先需要先找到NexT下引用不蒜子统计的方法。文件路径为/theme/next/layout/_third-party/analytics/busuanzi-counter.swig文件。

src替换为 https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js

自定义其他统计

除此以外,我们日常一些需要的增加一些其他的统计平台的嵌入代码,此时,我们可以在 主题配置文件 /next/_config.yml中,通过自定义的方式,增加对应的 pid,如下就是我增加了国内的百度统计GrowingIo 以及国外的 Heap的代码:

# Swiftype Search API Key
#swiftype_key:
# Baidu Analytics ID
baidu_analytics: 2129cd61363d382d1734d5e8c0ead722
# growingio Analytics ID
growingio_analytics: 87fe382bdb2695f2
# heap Analytics ID
heap_analytics: 256127732

同时,我们还需要在 baidu-analytics.swig模板页中加入其他的的产品代码,如下

{% if theme.baidu_analytics %}
  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?{{ theme.baidu_analytics }}";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>
{% endif %}
{% if theme.growingio_analytics %}
  <script type='text/javascript'>
      var _vds = _vds || [];
      window._vds = _vds;
      (function(){
        _vds.push(['setAccountId', '{{ theme.growingio_analytics }}']);
        (function() {
          var vds = document.createElement('script');
          vds.type='text/javascript';
          vds.async = true;
          vds.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'dn-growing.qbox.me/vds.js';
          var s = document.getElementsByTagName('script')[0];
          s.parentNode.insertBefore(vds, s);
        })();
      })();
  </script>
{% endif %}
{% if theme.heap_analytics %}
  <script type='text/javascript'>
      window.heap=window.heap||[],heap.load=function(e,t){window.heap.appid=e,window.heap.config=t=t||{};var r=t.forceSSL||"https:"===document.location.protocol,a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=(r?"https:":"http:")+"//cdn.heapanalytics.com/js/heap-"+e+".js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n);for(var o=function(e){return function(){heap.push([e].concat(Array.prototype.slice.call(arguments,0)))}},p=["addEventProperties","addUserProperties","clearEventProperties","identify","removeEventProperty","setEventProperties","track","unsetEventProperty"],c=0;c<p.length;c++)heap[p[c]]=o(p[c])};
      heap.load("{{ theme.heap_analytics }}");
  </script>
{% endif %}

文章字数统计

默认的,NexT是有提供了文章字数统计的选项,通过打开 /next/_config.yml文件中,搜索post_wordcount,进行配置:

# Post wordcount display settings
# Dependencies: https://github.com/willin/hexo-wordcount
post_wordcount:
  item_text: true
  wordcount: true
  min2read: true
  separated_meta: true

我这里配置后,发现没有结果,查看 hexo-site根目录,发现 node_modules中没有相关的依赖包,此时我们需要手动安装:

npm install hexo-wordcount --save

默认情况下,统计数据只有数值没有单位,我们可以在 themes\next\layout_macro\post.swig 模板文件中,增加自己想要的单位,如:

{% if theme.post_wordcount.wordcount or theme.post_wordcount.min2read %}
           <div class="post-wordcount">
             {% if theme.post_wordcount.wordcount %}
               <span class="post-meta-item-icon">
                 <i class="fa fa-edit"></i>
               </span>
                 {% if theme.post_wordcount.item_text %}
                   <span class="post-meta-item-text">{{ __('post.wordcount') }}</span>
                 {% endif %}
                   <span title="{{ __('post.wordcount') }}" }}">
                     {{ wordcount(post.content) }} 字                   </span>
             {% endif %}
             {% if theme.post_wordcount.wordcount and theme.post_wordcount.min2read %}
               <span class="post-meta-divider">|</span>
             {% endif %}
             {% if theme.post_wordcount.min2read %}
               <span class="post-meta-item-icon">
                 <i class="fa fa-clock-o"></i>
               </span>
                 {% if theme.post_wordcount.item_text %}
                   <span class="post-meta-item-text">{{ __('post.min2read') }}</span>
                 {% endif %}
                   <span title="{{ __('post.min2read') }}" }}">
                     {{ min2read(post.content) }} 分钟
                   </span>
             {% endif %}
           </div>
         {% endif %}

评论插件

进入来必力官网,点击右上角的注册,通过输入邮件地址密码,然后把邮箱中接收到验证码输入到框中,直接按enter跳过。

然后选择个人免费city版,并立即安装

输入个人站点信息,并提交确认

最后开启来必力的选项,在主题配置文件 /next/_config.yml中配置

livere_uid: MTAyMC8zMDY4NC83MjM2

隐藏网页底部 powered By Hexo / 强力驱动

打开 themes/next/layout/_partials/footer.swig

{% if theme.footer.powered.enable %}
<div class="powered-by">{#
#}{{ __('footer.powered', '<a class="theme-link" target="_blank"' + nofollow + ' href="https://hexo.io">Hexo</a>') }}{% if theme.footer.powered.version %} v{{ hexo_env('version') }}{% endif %}{#
#}</div>
{% endif %}
{% if theme.footer.powered.enable and theme.footer.theme.enable %}
<span class="post-meta-divider">|</span>
{% endif %}
{% if theme.footer.theme.enable %}
<div class="theme-info">{#
#}{{ __('footer.theme') }} – {#
#}<a class="theme-link" target="_blank"{{ nofollow }} href="https://theme-next.org">{#
#}NexT.{{ theme.scheme }}{#
#}</a>{% if theme.footer.theme.version %} v{{ version }}{% endif %}{#
#}</div>
{% endif %}

把这段代码首尾分别加上:<!---->,或者直接删除。

显示浏览进度

打开 /next/_config.yml,搜索关键字 scrollpercent,把 false 改为 true。

Local Search本地搜索

安装插件 hexo-generator-searchdb,执行以下命令:

npm install hexo-generator-searchdb --save

修改hexo/_config.yml站点配置文件,新增以下内容到任意位置:

search:
path: search.xml
field: post
format: html
limit: 10000

编辑 主题配置文件,启用本地搜索功能:

# Local search
local_search:
enable: true

设置网站图标

在 EasyIcon 中找一张(32 * 32)的 ico 图标,并将图标名称改为 favicon.ico,然后把图标放在/themes/next/source/images里,并且修改主题配置文件:

Put your favicon.ico into `hexo-site/source/` directory.
favicon: /favicon.ico

修改Tags图标

修改文章底部的#号的标签,改为图标

修改模板/themes/next/layout/_macro/post.swig

搜索 rel=“tag”>#,将 # 换成<i class="fa fa-tag"></i>

文章分享

打开themes/next/_config.yml 搜索关键字needmoreshare2 修改为下面设置

needmoreshare2:
  enable: true
  postbottom:
    enable: true
    options:
      iconStyle: default
      boxForm: horizontal
      #位置
      position: bottomCenter
      #可分享网站
      networks: Weibo,Wechat,Douban,QQZone,Twitter,Facebook
  float:
    enable: true
    options:
      iconStyle: default
      boxForm: vertical
      #位置
      position: topRight
       #可分享网站
      networks: Weibo,Wechat,Douban,QQZone,Twitter,Facebook

postbottom为文章末尾分享 float则是在页面侧端分享

文章加载条

打开themes/next/_config.yml 搜索关键字pace 修改为下面设置

# 页面顶部加载条
# Progress bar in the top during page loading.
pace: true
pace_theme: pace-theme-minimal  #默认设置,可以修改为上述任何一个

代码块复制

Next6 中自带了复制代码按钮,搜索 codeblock,找到如下配置:

codeblock:
border_radius: 8   # 按钮圆滑度
copy_button:  # 设置是否开启代码块复制按钮
    enable: true
    show_result: true  # 是否显示复制成功信息

Next5 需要自己手动配置

在themes/next/layout/_third-party/下新建文件copy-code.swig,写入下面的内容:

{% if theme.codeblock.copy_button.enable %}
  <style>
    .copy-btn {
      display: inline-block;
      padding: 6px 12px;
      font-size: 13px;
      font-weight: 700;
      line-height: 20px;
      color: #333;
      white-space: nowrap;
      vertical-align: middle;
      cursor: pointer;
      background-color: #eee;
      background-image: linear-gradient(#fcfcfc, #eee);
      border: 1px solid #d5d5d5;
      border-radius: 3px;
      user-select: none;
      outline: 0;
    }

    .highlight-wrap .copy-btn {
      transition: opacity .3s ease-in-out;
      opacity: 0;
      padding: 2px 6px;
      position: absolute;
      right: 4px;
      top: 8px;
    }

    .highlight-wrap:hover .copy-btn,
    .highlight-wrap .copy-btn:focus {
      opacity: 1
    }

    .highlight-wrap {
      position: relative;
    }
  </style>
  
  <script>
    $('.highlight').each(function (i, e) {
      var $wrap = $('<div>').addClass('highlight-wrap')
      $(e).after($wrap)
      $wrap.append($('<button>').addClass('copy-btn').append('{{__("post.copy_button")}}').on('click', function (e) {
        var code = $(this).parent().find('.code').find('.line').map(function (i, e) {
          return $(e).text()
        }).toArray().join('\n')
        var ta = document.createElement('textarea')
        document.body.appendChild(ta)
        ta.style.position = 'absolute'
        ta.style.top = '0px'
        ta.style.left = '0px'
        ta.value = code
        ta.select()
        ta.focus()
        var result = document.execCommand('copy')
        document.body.removeChild(ta)
        {% if theme.codeblock.copy_button.show_result %}
          if(result)$(this).text('{{__("post.copy_success")}}')
          else $(this).text('{{__("post.copy_failure")}}')
        {% endif %}
        $(this).blur()
      })).on('mouseleave', function (e) {
        var $b = $(this).find('.copy-btn')
        setTimeout(function () {
          $b.text('{{__("post.copy_button")}}')
        }, 300)
      }).append(e)
    })
  </script>
{% endif %}

编辑themes/next/layout/_layout.swig文件,在文件末尾的如下位置添加一行代码:

{% include '_third-party/copy-code.swig' %}

添加按钮上显示的语言
在themes/next/languages/zh-CN.yml文件的post板块中添加下列代码:

copy_button: 复制
copy_success: 复制成功
copy_failure: 复制失败

在主题配置文件themes/next/_config.yml中添加开关

codeblock:
  border_radius:
  copy_button:
    enable: true
    # Show text copy result
    show_result: true

重新生成启动即可。

文章置顶功能

移除默认安装的插件:
npm uninstall hexo-generator-index --save

安装新插件:
npm install hexo-generator-index-pin-top --save

最后编辑有这需求的相关文章时,在Front-matter(文件最上方以—分隔的区域)加上一行:
top: true

如果你置顶了多篇,怎么控制顺序呢?设置top的值(大的在前面),比如:

Post a.md
title: a
top: 1

Post b.md
title: b
top: 10

文章 b 便会显示在文章 a 的前面

设置置顶图标
打开/themes/next/layout/_macro/post.swig文件,在<div class="post-meta">下方,插入如下代码:

{% if post.top %}
    <i class="fa fa-arrow-circle-o-up"></i>
    <font color=222222>置顶</font>
    <span class="post-meta-divider">|</span>
{% endif %}

设置图标颜色

打开 themes\next\source\css\_custom\custom.styl,新增图标样式,图标名称在浏览器控制台下查看。

修改文章链接

在做次优化之前,hexo-next文章链接默认的生成规则是::year/:month/:day/:title,是按照年、月、日、标题来生成的。

https://march21sunny.gitee.io/2020/07/24/Hexo%20NexT%20%E4%B8%BB%E9%A2%98%E4%B8%AA%E6%80%A7%E5%8C%96%E9%85%8D%E7%BD%AE/

比如这样,如果文章标题是中文的话,URL链接是也会是中文。

那么要生存简洁且唯一的URL,怎么办呢

安装插件

npm install hexo-abbrlink --save

执行此命令可能会不成功,提示你缺少相应的依赖,比如babel-eslint、mini-css-extract-plugin、webpack-cli…
使用npm命令安装即可,比如npm install eslint@4.x babel-eslint@8 --save-dev

修改根目录站点配置文件config.yml,改为:

permalink: posts/:abbrlink/
abbrlink:
    alg: crc32   #算法: crc16(default) and crc32
    rep: hex     #进制: dec(default) and hex

生成的链接将会是这样的(官方样例):

crc16 & hex
https://post.zz173.com/posts/66c8.html

crc16 & dec
https://post.zz173.com/posts/65535.html

crc32 & hex
https://post.zz173.com/posts/8ddf18fb.html

crc32 & dec
https://post.zz173.com/posts/1690090958.html

生成完后,原md文件的Front-matter 内会增加abbrlink 字段,值为生成的ID 。这个字段确保了在我们修改了Front-matter 内的博客标题title或创建日期date字段之后而不会改变链接地址。

文章加密访问

打开themes->next->layout->_partials->head.swig文件,在以下位置插入这样一段代码:

<script src="{{ pace_js_uri }}"></script>
<link href="{{ pace_css_uri }}" rel="stylesheet">

代码如下:

<script>
    (function(){
        if('{{ page.password }}'){
            if (prompt('请输入文章密码') !== '{{ page.password }}'){
                alert('密码错误!');
                if (history.length === 1) {
                    window.opener = null;
                    window.open('', '_self');
                    window.close();
                } else {
                    history.back();
                }
            }
        }
     })();
</script>

设置加密图标

打开/themes/next/layout/_macro/post.swig文件,在<div class="post-meta">下方,插入如下代码:

{% if post.password %}
    <i class="fa fa-lock"></i>
    <font color=ff1700>加密</font>
    <span class="post-meta-divider">|</span>
{% endif %}

然后在文章添加password就可以了

title: Hexo NexT 主题个性化配置
description: Hexo NexT主题个性化配置
categories:
  - Hexo
tags:
  - Hexo
  - NexT
password: 123456

调整宽度

/themes/next/source/css/_schemes/Picses/_layout.styl文件末尾添加如下代码

// 以下为新增代码,调整宽度
header{ width: 65% !important; }
header.post-header {
  width: auto !important;
}
.container .main-inner { width: 65%; }
.content-wrap { width: calc(100% - 260px); }

.header {
  +tablet() {
    width: auto !important;
  }
  +mobile() {
    width: auto !important;
  }
}

.container .main-inner {
  +tablet() {
    width: auto !important;
  }
  +mobile() {
    width: auto !important;
  }
}

.content-wrap {
  +tablet() {
    width: 100% !important;
  }
  +mobile() {
    width: 100% !important;
  }
}

文章内引入本地图片

在根目录的source目录下新建 images文件夹,并将图片放入。

在文章中引入 /images/即可,如下:

![test](/images/test.jpg)

test

设置网站icon

主题配置文件中第一行代码就是网站icon设置,这里你只需要找到你喜欢的logo把它制作成ico格式然后改名favicon.ico,放到/themes/next/source/images下面即可。

# Put your favicon.ico into `hexo-site/source/` directory.
favicon: /favicon.ico # 网站logo

增加版权信息

在目录themes/next/layout/_macro/下添加my-copyright.swig,代码如下:

{% if page.copyright %}
<div class="my_post_copyright">
  <script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
  
  <!-- JS库 sweetalert 可修改路径 -->
  <script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
  <p><span>本文标题:</span>{{ page.title }}</p>
  <p><span>文章作者:</span>{{ theme.author }}</p>
  <p><span>发布时间:</span>{{ page.date.format("YYYY-MM-DD HH:MM") }}</p>
  <p><span>最后更新:</span>{{ page.updated.format("YYYY-MM-DD HH:MM") }}</p>
  <p><span>原始链接:</span><a href="{{ url_for(page.path) }}" title="{{ page.title }}">{{ page.permalink }}</a></p>
  <p><span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
</div>

{% endif %}

在目录themes/next/source/css/_common/components/post/下添加my-post-copyright.styl

.my_post_copyright {
  margin: 2.8em 0;
  padding: 0.8em 1.0em;
  border-left: 4px solid #ff1700;
  font-size: 0.95rem;
  line-height: 1.6em;
  word-break: break-all;
  background: #f9f9f9;
}
.my_post_copyright p{margin:0;}
.my_post_copyright span {
  display: inline-block;
  width: 5.2em;
  color: #555555;
  font-weight: bold;
}
.my_post_copyright .raw {
  margin-left: 1em;
  width: 5em;
}
.my_post_copyright a {
  color: #808080;
  border-bottom:0;
}
.my_post_copyright a:hover {
  color: #a3d2a3;
  text-decoration: underline;
}
.my_post_copyright:hover .fa-clipboard {
  color: #000;
}
.my_post_copyright .post-url:hover {
  font-weight: normal;
}
.my_post_copyright .copy-path {
  margin-left: 1em;
  width: 1em;
  +mobile(){display:none;}
}
.my_post_copyright .copy-path:hover {
  color: #808080;
  cursor: pointer;
}

修改themes/next/layout/_macro/post.swig,在代码:

{% if theme.wechat_subscriber.enabled and not is_index %}
    <div>
        {% include 'wechat-subscriber.swig' %}
    </div>
{% endif %}

前面添加代码:

<div>
      {% if not is_index %}
        {% include 'my-copyright.swig' %}
      {% endif %}
</div>

修改themes/next/source/css/_common/components/post/post.styl文件,在最后一行增加代码:

@import "my-post-copyright"

最后到站点根目录/scaffolds/post.md,在两个---中间增加一行:

copyright: true

之后的每一篇文章都会自己加上版权信息,之前的文章也可以通过在文章对应的md文件头部加上以上代码添加版权信息。

DaoVoice 在线聊天

DaoVoice官网注册帐号,可以输入我的邀请码 9ecb3772

进入应用设置 -> 安装到网站 -> 选择 JavaScript,仅匿名用户 -> 聊天设置,自定义喜欢的样式

修改的hexo的文件路劲如下: /themes/next/layout/_partials/head/head.swig 末尾添加下面的代码:

{% if theme.daovoice %}
 <script>(function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/b6dbddb6.js","daovoice")
 daovoice('init', {
  app_id: "用户ID"
});
daovoice('update');
 </script>
{% endif %}

用户ID需要自行填写,在安装到网站中的 app_id

修改主题配置文件
在Next主题的配置文件博客/themes/next/_config.yml末尾中添加:

daovoice: true
daovoice_app_id: 用户ID

部署预览即可。

已知 Bugs(5.1.4)

底部左右标签显示错误

底部左右标签无法显示图标,如下:

<i class="fa fa-angle-right"></i>

修改\themes\next\layout\_partials\pagination.swig为:

{%- if page.prev or page.next %}
  <nav class="pagination">
    {{
      paginator({
        prev_text: '<i class="fa fa-angle-double-left" aria-label="' + __('accessibility.prev_page') + '"></i>',
        next_text: '<i class="fa fa-angle-double-right" aria-label="' + __('accessibility.next_page') + '"></i>',
        mid_size : 1,
        escape   : false
      })
    }}
  </nav>
{%- endif %}

其中:fa-chevron-circle-left为图标样式,可以自己改为自己喜欢的,去http://www.fontawesome.com.cn/faicons/找。

不蒜子统计失效

不蒜子统计不显示、失效问题解决方法:

查看控制台,发现不蒜子js 404,说明该链接失效,换一个新的即可。

首先需要先找到NexT下引用不蒜子统计的方法。文件路径为/theme/next/layout/_third-party/analytics/busuanzi-counter.swig文件。

src替换为:

https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js

侧边栏日志出现问题

点击侧边栏日志出现 Cannot GET /archives/%7C%7C%20list/

themes/next/layout/_macro/sidebar.swig文件中找到

<a href="{{ url_for(theme.menu.archives).split('||')[0] | trim }}">

改为

<a href="{{url_for(theme.menu.archives.split('||')[0])| trim}}">

原因是 url_for 函数将 || 转码了

相似问题

侧边栏其他点击打开可能是 %20/tags/,原因是将空格转码了

/themes/next/_config.yml 中修改 menu 的内容,去掉 || 前面的空格,如下:

menu:
  home: /|| home
  about: /about/|| user
  tags: /tags/|| tags

参考

ht

本文链接: https://jianz.xyz/index.php/archives/49/

1 + 8 =
快来做第一个评论的人吧~