hexo6--next美化整理


title: hexo6--next美化整理
date: 2017-10-25 13:15:08
categories: hexo建博
tags: [hexo, next]
copyright: true
keywords: hexo,next,美化
comments: ture


既然選擇了next主題,也不打算經(jīng)常換,但是做一些美化還是可以考慮的。

在右上角或者左上角實(shí)現(xiàn)fork me on github

效果

1.png

實(shí)現(xiàn)

點(diǎn)擊這里挑選自己喜歡的樣式,并復(fù)制代碼。 然后粘貼剛才復(fù)制的代碼到themes/next/layout/_layout.swig文件中(放在<div class="headband"></div>的下面),并把href改為你的github地址。

2.png

重新clean并生成。

404頁面

默認(rèn)的404頁面是github的,如果想自定義,需要把自己的404.html頁面放在皮膚的source目錄下即可。建議使用騰訊公益的頁面:

<!DOCTYPE HTML> 
<html> 
<head> 
<meta http-equiv="content-type" content="text/html;charset=utf-8;"/> 
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> 
<meta name="robots" content="all" /> <meta name="robots" content="index,follow"/> 
</head> 
<body> 
<script type="text/javascript" src="http://www.qq.com/404/search_children.js" charset="utf-8" homePageUrl="your site url " homePageName="回到我的主頁"></script> 
</body> 
</html>

添加動態(tài)背景

效果

3.png

線條會動啊動,飄啊飄。

實(shí)現(xiàn)

添加js

修改 themes/next/layout/_layout.swig

{% if theme.canvas_nest %}
<script type="text/javascript" src="http://cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js">
</script>
{% endif %}

將上述代碼防止在< /body> 前就可以了(注意不要放在< /head>的后面)。

修改_config.yml

打開皮膚目錄下的_config.yml 配置文件,添加如下代碼:

# background settings
# add canvas-nest effect
# see detail from https://github.com/hustcc/canvas-nest.js
canvas_nest: true

設(shè)置

動態(tài)背景的某些屬性可以自定義,

{% if theme.canvas_nest %}
<script type="text/javascript"
color="0,0,255" opacity='0.7' zIndex="-2" count="99" src="http://cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>
{% endif %}
  • color :線條顏色, 默認(rèn): '0,0,0';三個數(shù)字分別為(R,G,B)
  • opacity: 線條透明度(0~1), 默認(rèn): 0.5
  • count: 線條的總數(shù)量, 默認(rèn): 150
  • zIndex: 背景的z-index屬性,css屬性用于控制所在層的位置, 默認(rèn): -1

重新clean并生成。

網(wǎng)站底部字?jǐn)?shù)統(tǒng)計&文章字?jǐn)?shù)統(tǒng)計功能

效果

4.png
5.png

實(shí)現(xiàn)

安裝插件:

$ npm install hexo-wordcount --save

修改主題配置文件

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

網(wǎng)站的圖標(biāo)Favicon

把圖標(biāo)文件favicon.ico 放在/themes/next/source/images里,并且修改主題配置文件:

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

在文章底部增加版權(quán)信息

效果

6.png

實(shí)現(xiàn)

在目錄 /themes/next/layout/_macro/下添加 my-copyright.swig文件:

{% if page.copyright %}
<div class="my_post_copyright">
  <script src="http://cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

  <!-- JS庫 sweetalert 可修改路徑 -->
  <script type="text/javascript" src="http://jslibs.wuxubj.cn/sweetalert_mini/jquery-1.7.1.min.js"></script>
  <script src="http://jslibs.wuxubj.cn/sweetalert_mini/sweetalert.min.js"></script>
  <link rel="stylesheet" type="text/css" >
  <p><span>本文標(biāo)題:</span><a href="{{ url_for(page.path) }}">{{ page.title }}</a></p>
  <p><span>文章作者:</span><a href="/" title="訪問 {{ theme.author }} 的個人博客">{{ theme.author }}</a></p>
  <p><span>發(fā)布時間:</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>
    <span class="copy-path"  title="點(diǎn)擊復(fù)制文章鏈接"><i class="fa fa-clipboard" data-clipboard-text="{{ page.permalink }}"  aria-label="復(fù)制成功!"></i></span>
  </p>
  <p><span>許可協(xié)議:</span><i class="fa fa-creative-commons"></i> <a rel="license"  target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商業(yè)性使用-禁止演繹 4.0 國際</a> 轉(zhuǎn)載請保留原文鏈接及作者。</p>  
</div>
<script> 
    var clipboard = new Clipboard('.fa-clipboard');
    clipboard.on('success', $(function(){
      $(".fa-clipboard").click(function(){
        swal({   
          title: "",   
          text: '復(fù)制成功',   
          html: false,
          timer: 500,   
          showConfirmButton: false
        });
      });
    }));  
</script>
{% endif %}

在目錄/themes/next/source/css/_common/components/post/下添加my-post-copyright.styl文件:

.my_post_copyright {
  width: 85%;
  max-width: 45em;
  margin: 2.8em auto 0;
  padding: 0.5em 1.0em;
  border: 1px solid #d3d3d3;
  font-size: 0.93rem;
  line-height: 1.6em;
  word-break: break-all;
  background: rgba(255,255,255,0.4);
}
.my_post_copyright p{margin:0;}
.my_post_copyright span {
  display: inline-block;
  width: 5.2em;
  color: #b5b5b5;
  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 %}

之前添加增加如下代碼:

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

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

@import "my-post-copyright"

保存重新生成即可。

隱藏網(wǎng)頁底部hexo和主題信息

7.png

打開/themes/next/layout/_partials/footer.swig,注釋掉下述代碼:

8.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容