avatar

目錄
Hexo Butterfly 主題:添加統計圖表 (hexo-butterfly-charts)

前言

感謝這位 guole 大大的插件和教學文檔 表符-比心

使用Charts插件给Butterfly增加统计图表 | guole’s Blog


由於我的 Butterfly 主題是超舊版(2.1.0)(現在已經是 3.8.4 😂),所以有些代碼的插入地方會不同,記錄一下:


效果

歸檔分類頁面加了。(標籤頁面個人覺得沒需要加,就沒加)
hexo-butterfly-charts effect


步驟

1. 安裝 hexo-butterfly-charts 插件

bash
npm install hexo-butterfly-charts --save

2. 修改 Butterfly config 配置

  1. 在這個文件裡 .\themes\Butterfly\_config.yml,添加:
    yml
    #see https://www.npmjs.com/package/hexo-butterfly-charts
    charts:
    enable: true
    postsChart:
    title: 文章發佈統計
    interval: 1
    tagsChart:
    title: Top 10 tags
    interval: 1
    postsCalendar_Title: 文章發佈日曆
    categoriesChart_Title: 分類統計
    categoriesRadar_Title: 分類雷達

2. 分類頁面

在這個文件裡 .\themes\Butterfly\layout\page.pug
div!= list_categories()上方添加這兩行:

Code
#categories-chart
#categories-radar

我的整個page.pug是這樣的:

Code
extends includes/layout.pug

block content
if page.type === 'tags'
.tag-cloud
.tag-cloud__title= _p('page.tag')
| -
span.tag-cloud__amount= site.tags.length
.tag-cloud-tags
include includes/page_tag.pug
if page.comments !== false
include includes/comments/index.pug
#aside_content.aside_content
include includes/widget/index.pug

else if page.type === 'link'
include flink.pug
if page.comments !== false
include includes/comments/index.pug
#aside_content.aside_content
include includes/widget/index.pug
else if page.type === 'categories'
#post-content.category-content
.category-lists
.category__title= _p('page.category')
| -
span.category__amount= site.categories.length
#categories-chart
#categories-radar
div!= list_categories()
if page.comments !== false
include includes/comments/index.pug
#aside_content.aside_content
include includes/widget/index.pug
else
article#page
h1= page.title
.article-container!= page.content
include includes/pagination.pug
if page.comments !== false
include includes/comments/index.pug
#aside_content.aside_content
include includes/widget/index.pug

3. 歸檔頁面

在這個文件裡 .\themes\Butterfly\layout\archive.pug
.article-sort-title上方添加這兩行:

Code
#posts-chart
#posts-calendar

我的整個archive.pug是這樣的:

Code
extends includes/layout.pug

block content
include ./includes/mixins/article-sort.pug
#archive
#posts-chart
#posts-calendar
.article-sort-title= _p('page.articles') + ' - ' + site.posts.length
+articleSort(page.posts)
include includes/pagination.pug
#aside_content.aside_content
include includes/widget/index.pug

完成 表符-DONE


如果您喜歡我的文章,歡迎幫我在下面按5下讚!感謝您的鼓勵和支持!

文章作者: ouoholly
文章鏈接: https://ouoholly.github.io/post/butterfly-add-hexo-butterfly-charts/
版權聲明: 本博客所有文章除特別聲明外,均採用 CC BY-NC-SA 4.0 許可協議。歡迎「部份引用」與介紹(如要全文轉貼請先留言詢問),轉載引用請註明來源 ouoholly 的倉庫,謝謝!

評論