第五篇 Hexo 魔改实录 | 给博客添个“追番页“,摸鱼必备!

转自:

更详细描述请见

安装插件

1
npm install hexo-bilibili-bangumi --save

配置文件

将下面的配置写入主题的配置文件 _config.yml 下 (不是主题的配置文件)

1
2
3
4
5
6
7
8
9
10
11
12
13
bangumi: # 追番设置
enable: true
source: bili
path:
vmid:
title: '追番列表'
quote: '摸鱼是第一生产力💼→🐟'
show: 1
loading:
metaColor:
color:
webp:
progress:

参数释义

参数 释义
enable 是否启用
source 据源,仅支持番剧,bili:哔哩哔哩源;bgm:Bangumi 源
path 默认 bangumis/index.html,cinemas/index.html
vmid 哔哩哔哩的 vmid (uid)
title 该页面的标题
quote 写在页面开头的一段话,支持 html 语法,可留空
show 初始显示页面:0:想看,1:在看,2:看过,默认为 1
loading 图片加载完成前的 loading 图片
metaColor meta 部分 (简介上方) 字体颜色
color 简介字体颜色
webp 番剧封面使用 webp 格式 (此格式在 safari 浏览器下不显示,但是图片大小可以缩小 100 倍左右),默认 true
progress 获取番剧数据时是否显示进度条,默认 true

在主题配置文件导航栏添加追番选项(自行自定义位置)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

menu:
文章:
归档: /archives/ || anzhiyu-icon-box-archive
分类: /categories/ || anzhiyu-icon-shapes
标签: /tags/ || anzhiyu-icon-tags

藏宝:
警告: /Warning/ || anzhiyu-icon-shoe-prints1
藏宝阁: /treasure/ || anzhiyu-icon-fan



社交:
友人帐: /link/ || anzhiyu-icon-link
# 朋友圈: /fcircle/ || anzhiyu-icon-artstation
留言板: /comments/ || anzhiyu-icon-envelope

我的:
# 音乐馆: /music/ || anzhiyu-icon-music
+ 追番页: /bangumis/ || anzhiyu-icon-bilibili
# 相册集: /album/ || anzhiyu-icon-images
# 小空调: /air-conditioner/ || anzhiyu-icon-fan

登录 b 站

  1. 登录自己的 b 站,把自己的追番列表设置为公开。
  2. 登录后找到自己的追番列表 https://space.bilibili.com/,在网址最后一串数字就是 vmid
  3. 在 hexo generate 或 hexo deploy 之前使用 hexo bangumi -u 命令更新追番数据,使用 hexo cinema -u 命令更新追剧数据!
  4. 删除数据命令: hexo bangumi -dhexo cinema -d(也可以手动删除)。

手动添加追剧

有一些番剧在 b 站是没有版权或者已下架,如果你想在 hexo 中显示,这就需要手动添加番剧,在 sources/_data/ 目录下创建文件,命名为 extra_bangumis.json(追番数据) 或 extra_cinemas.json(追剧数据) ,并添加以如下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"watchedExtra": [
{
"title": "缘之空",
"type": "番剧",
"area": "日本",
"cover": "https://cdn.jsdelivr.net/gh/mmdjiji/bangumis@main/Yosuga-no-Sora/cover.jpg",
"totalCount": "全12话",
"id": 0,
"follow": "不可用",
"view": "不可用",
"danmaku": "不可用",
"coin": "不可用",
"score": "不可用",
"des": "远离都市的田园小镇,奥木染。春日野悠带着妹妹穹,来到了这座城镇。坐落在这里的是,儿时暑假经常造访的充满回忆的已故祖父的家。双亲因意外事故而丧生,变得无依无靠..."
}
]
}