Hexo主题butterfly音乐全局吸底教程
1.安装hexo插件
音乐界面使用了插件 hexo-tag-aplayer
1 | npm install --save hexo-tag-aplayer |
2.配置配置文件
首先在Hexo根目录_config里配置asset_inject为false
1 | aplayer: |
在主题的配置文件中,enable 设为 true 和 per_page 设为 true
1 | aplayerInject: |
3.添加全局吸底Aplayer
把 aplayer代码 插入到主题配置文件的 inject.bottom 去
1 | inject: |
如果你想切换页面时,音乐不会中断,修改主题配置文件如下:
1 | pjax: |
4. 文章添加播放器
1 | {% meting "2063487880" "netease" "song" "theme:#555" "mutex:true" "listmaxheight:340px" "preload:auto" %} |
有关参数描述如下:
选项 | 默认值 | 描述 |
---|---|---|
id | 必须值 | 歌曲 id / 播放列表 id / 相册 id / 搜索关键字 |
server | 必须值 | 音乐平台: netease, tencent, kugou, xiami, baidu |
type | 必须值 | song, playlist, album, search, artist |
fixed | false | 开启固定模式 |
mini | false | 开启迷你模式 |
loop | all | 列表循环模式:all, one,none |
order | list | 列表播放模式: list, random |
volume | 0.7 | 播放器音量 |
lrctype | 0 | 歌词格式类型 |
listfolded | false | 指定音乐播放列表是否折叠 |
storagename | metingjs | LocalStorage 中存储播放器设定的键名 |
autoplay | true | 自动播放,移动端浏览器暂时不支持此功能 |
mutex | true | 该选项开启时,如果同页面有其他 aplayer 播放,该播放器会暂停 |
listmaxheight | 340px | 播放列表的最大长度 |
preload | auto | 音乐文件预载入模式,可选项: none, metadata, auto |
theme | #ad7a86 | 播放器风格色彩设置 |
5. 创建音乐页面
希望在导航条添加音乐页面链接
在命令行执行新建music页面命令:
1
hexo new page music
执行完命令之后,/source 文件夹下会生成一个music文件夹,打开里面的index.md,修改如下:
1 | title: 音乐 |
- 新建菜单的音乐链接
1 | menu: |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Hihahoo:想你所想 做你所做!
评论