A 概述
本文敘述了將 NexT 5.1.0 遷移到 6.3.0 的過(guò)程中的一些筆記挡育。使用 NexT 6 的考慮在于:
- 優(yōu)化配置項(xiàng)
- 支持 Valine 評(píng)論系統(tǒng)
- 代碼快支持復(fù)制功能
- 其他從 v5.1.0 起內(nèi)置的功能
B 準(zhǔn)備工作
如何安裝 NexT 6 有多種選擇,這里僅介紹的是一種簡(jiǎn)單機(jī)械的方法。
備份 : 將 themes\next 文件夾復(fù)制備份到另外一個(gè)目錄下快毛,然后刪除原有的 next 文件夾。
下載:打開(kāi) 代碼倉(cāng)庫(kù) 就乓,切換到標(biāo)簽 v6.3.0 坝茎,點(diǎn)擊 “Download zip” 下載壓縮包。
替換: 解壓并重名為 next 镣衡,放入 themes 目錄霜定。
在 github 訪問(wèn)緩慢時(shí),與 克隆代碼 和 瀏覽器下載 相比廊鸥,使用迅雷工具下載會(huì)提高不少的速度望浩。
C 遷移步驟
文件配置
通常來(lái)說(shuō),需要改動(dòng)一下幾個(gè)文件:
- 博客配置文件 _config.yml
- 主題配置文件 themes\next_config.yml
- 語(yǔ)言翻譯文件 themes\next\languages\zh-CN.yml
語(yǔ)言&翻譯
在 NexT 6 中惰说,簡(jiǎn)體中文的名稱變?yōu)?zh-CN 磨德,因此在 博客配置文件 里需要將原有的:
language: zh-Hans
改為
language: zh-CN
另外現(xiàn)在語(yǔ)言文件名稱為 zh-CN.yaml ,格式?jīng)]有變化吆视,可以使用原有的 zh-Hans.yaml 覆蓋典挑。
菜單鏈接
NexT 6 將分開(kāi)的 鏈接 和 圖標(biāo) 配置合并在了一個(gè)配置項(xiàng)中,并使用 || 分割啦吧。受這一特性影響您觉,以下配置項(xiàng)目有所變化,需手動(dòng)修改:
- 菜單 theme.menu
- 社交 theme.social
- 代碼Fork theme.github_banner
Hexo 5 風(fēng)格:
menu:
home: /
archives: /archives
topics: /topics
library: /library
about: /about
menu_icons:
enable: true
home: home
archives: archive
topics: file
library: book
about: user
Hexo 6 風(fēng)格:
menu:
home: / || home
archives: /archives/ || archive
topics: /topic/ || file
library: /library/ || book
about: /about/ || user
其他配置
這些配置無(wú)任何變化授滓,將配置內(nèi)容復(fù)制到對(duì)應(yīng)選項(xiàng)即可琳水。
- 右下角的“回到頂部”按鈕
- 打賞文字肆糕、圖片 theme.reward_comment
- 網(wǎng)站 icon 圖片 theme.favicon
- 本地搜索 theme.local_search
D 插件
這些功能之前是使用修改源代碼方式,現(xiàn)在可以使用 “包/插件引入 + 選項(xiàng)配置” 的方式激活該功能炫刷。
插件路徑定義在 themes\next\source\lib 目錄下擎宝。
功能 | 插件 | 引入方式 | 配置項(xiàng) |
---|---|---|---|
字?jǐn)?shù)統(tǒng)計(jì) | hexo-symbols-count-time | 包 | theme.symbols_count_time |
圖片瀏覽 | theme-next-fancybox3 | 插件 | theme.fancybox |
頂部進(jìn)度條 | theme-next-pace | 插件 | theme.pace |
leancloud訪問(wèn)計(jì)數(shù) | leancloud-visitors | 插件 | theme.leancloud_visitors |
引入方式
以包方式引入比較簡(jiǎn)單,使用 命令 npm install <package-name> -save
即可浑玛。
以插件方式引入绍申,在 theme\next 目錄使用代碼克隆命令。
git clone <github-url> source\lib\<plugin-name>
進(jìn)度條
進(jìn)度條使用 pace.js 插件顾彰,點(diǎn)此 查看每個(gè)配置的效果圖极阅。
E 評(píng)論系統(tǒng)
NexT 6 已經(jīng)集成這個(gè)功能了,可以使用和訪問(wèn)量同一個(gè)應(yīng)用涨享。
1 在云端的 leancloud 應(yīng)用中創(chuàng)建一個(gè)名為 Comment
的類筋搏,使用默認(rèn)的 ACL 權(quán)限設(shè)置。
2 在主題配置文件中設(shè)置 app_id 和 app_key 即可厕隧。
valine:
enable: true
appid: # your leancloud application appid
appkey: # your leancloud application appkey
notify: false # mail notifier , https://github.com/xCss/Valine/wiki
verify: false # Verification code
placeholder: Just go go # comment box placeholder
avatar: mm # gravatar style
guest_info: nick,mail # custom comment header
pageSize: 10 # pagination size
F 部署
修改 theme\next.gitignore 文件奔脐,將 theme\next\source\lib 下的文件也提交到版本庫(kù)。
具體做法是刪除以下內(nèi)容:
# Ignore optional external libraries
source/lib/*
# Track internal libraries & Ignore unused verdors files
source/lib/font-awesome/less/
source/lib/font-awesome/scss/
!source/lib/font-awesome/*
!source/lib/jquery/
source/lib/ua-parser-js/*
!source/lib/ua-parser-js/dist/
!source/lib/velocity/