Hexo-Next-主題優(yōu)化(二)

1.主頁文章添加邊框陰影效果

border.png
  • 打開themes/next/source/css/_custom/下的custom.styl,向里面加代碼
// 主頁文章添加陰影效果
.post {
   margin-top: 0px;
   margin-bottom: 60px;
   padding: 25px;
   -webkit-box-shadow: 0 0 5px rgba(202, 203, 203, .5);
   -moz-box-shadow: 0 0 5px rgba(202, 203, 204, .5);
}

2.修改文章間分割線

  • 打開themes/next/source/css/_common/components/post/下的post-eof.styl,修改
.posts-expand {
  .post-eof {
    display: block;
  //  margin: $post-eof-margin-top auto $post-eof-margin-bottom;  
    width: 0%; //分割線長度
    height: 0px; // 分割線高度
    background: $grey-light;
    text-align: center;
  }
}

3.代碼塊自定義樣式

image.png
  • 打開themes/next/source/css/_custom/下的custom.styl,向里面加代碼(顏色可以自己定義)
// Custom styles.
code {
    color: #ff7600;
    background: #fbf7f8;
    margin: 2px;
}
// 邊框的自定義樣式
.highlight, pre {
    margin: 5px 0;
    padding: 5px;
    border-radius: 3px;
}
.highlight, code, pre {
    border: 1px solid #d6d6d6;
}

4.開啟版權(quán)聲明

  • 主題配置文件下,搜索關(guān)鍵字post_copyright,enable改為true
# Declare license on posts
post_copyright:
  enable: true
  license: CC BY-NC-SA 3.0
  license_url: https://creativecommons.org/licenses/by-nc-sa/3.0/

5.自定義文章底部版權(quán)聲明

image.png
5.1在目錄 themes/next/layout/_macro/下添加 my-copyright.swig,內(nèi)容如下:
{% 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>{{ page.title }}</a></p>
  <p><span>文章作者:</span>{{ theme.author }}</a></p>
  <p><span>發(fā)布時(shí)間:</span>{{ page.date.format("YYYY年MM月DD日 - HH:mm:ss") }}</p>
  <p><span>最后更新:</span>{{ page.updated.format("YYYY年MM月DD日 - HH:mm:ss") }}</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 %}
5.2在目錄themes/next/source/css/_common/components/post/下添加my-post-copyright.styl,內(nèi)容如下:
.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: #333333; // title color
  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: #0593d3; // link color
  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;
}
5.3 修改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"
5.4設(shè)置新建文章自動開啟copyright,即新建文章自動顯示自定義的版權(quán)聲明,設(shè)置your site/scaffolds/post.md文件
---
title: {{ title }}
date: {{ date }}
tags:
type: "categories"
categories:
copyright: true #新增,開啟
---

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

No.1.png
  • 選擇樣式GitHub Ribbons,修改圖片跳轉(zhuǎn)鏈接,并復(fù)制文本框中的代碼
    ribbons.png
  • 打開themes/next/layout/下的_layout.swig文件,把代碼復(fù)制到<div class="headband"></div>下面

7.修改文章底部的那個帶#號的標(biāo)簽

No.2.png
  • 打開themes/next/layout/_macro/下的post.swig文件,搜索rel="tag">#,將 # 換成<i class="fa fa-tag"></i>
<div class="post-tags">
    {% for tag in post.tags %}
       <a href="{{ url_for(tag.path) }}" rel="tag"><i class="fa fa-tag"></i> {{ tag.name }}</a>
    {% endfor %}
</div>

8.添加頂部加載條

  • 打開themes/next下的_config.yml,搜索關(guān)鍵字pace,設(shè)置為true,可以更換加載樣式
# Progress bar in the top during page loading.
pace: true
# Themes list:
#pace-theme-big-counter
#pace-theme-bounce
#pace-theme-barber-shop
#pace-theme-center-atom
#pace-theme-center-circle
#pace-theme-center-radar
#pace-theme-center-simple
#pace-theme-corner-indicator
#pace-theme-fill-left
#pace-theme-flash
#pace-theme-loading-bar
#pace-theme-mac-osx
#pace-theme-minimal
# For example
# pace_theme: pace-theme-center-simple
pace_theme: pace-theme-flash #替換更換樣式

9.本地搜索

search.png
  • 在你站點(diǎn)的根目錄下
$ npm install hexo-generator-searchdb --save
  • 打開Hexo 站點(diǎn)_config.yml,添加配置
search:
  path: search.xml
  field: post
  format: html
  limit: 10000
  • 打開themes/next下的_config.yml,搜索關(guān)鍵字local_search,設(shè)置為true
# Local search
# Dependencies: https://github.com/flashlab/hexo-generator-search
local_search:
  enable: 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

10.修改網(wǎng)頁底部

heart.png
10.1在圖標(biāo)庫中找到你自己喜歡的圖標(biāo), 修改桃心,打開themes/next下的_config.yml,搜索關(guān)鍵字authoricon,替換圖標(biāo)名
# icon between year and author @Footer
authoricon: id-card
10.2隱藏網(wǎng)頁底部Hexo 強(qiáng)力驅(qū)動
  • 打開主題配置文件,搜索關(guān)鍵字copyright,如下:
# Footer `powered-by` and `theme-info` copyright
copyright: false

Hexo-Next-主題優(yōu)化(一)
Hexo-Next-主題優(yōu)化(三)
Hexo-Next-主題優(yōu)化(四)

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

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

  • 1. 設(shè)置主題風(fēng)格 打開 themes/next/_config.yml 文件,搜索 scheme 關(guān)鍵字,將你...
    遲道閱讀 21,361評論 10 47
  • 看到有些next主題的網(wǎng)站很炫酷,那么是怎么配置的呢?接下來我會講一講如何實(shí)現(xiàn)一些炫酷的效果 主要有以下32種: ...
    Moorez閱讀 58,765評論 118 282
  • 本篇教程基于NexT主題的博客配置,實(shí)現(xiàn)更換主題、評論、打賞等36項(xiàng)功能,接下來根據(jù)這些功能進(jìn)行分點(diǎn)描述,附上個人...
    wangwlj閱讀 2,381評論 0 11
  • 前言 配置完yilia后,發(fā)現(xiàn)缺少一些東西,百度之下,找到了特別喜歡的主題——next。跟大家分享配置經(jīng)驗(yàn)。 首先...
    destiny0904閱讀 9,263評論 0 5
  • 這個陌生的城市,一多在這里沒有朋友,這個家只是一多的住所,沒有四合院的溫暖。 一多是長輩眼里的好孩子,懂禮貌,以笑...
    佹宄閱讀 316評論 0 1

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