Next主题设置-安装DaoVoice和Aplayer
安装在线聊天工具DaoVoice
- 登录DaoVoice官网注册,点击
应用设置
–>安装到网站
,搜索app_id
,复制后面的id。 - 在主题配置里添加:
1 | daovoice: true |
- 在
Hexo\themes\next\layout\_partials\head
的head.njk
文件末尾添加如下内容,粘贴你的id。
1 | {% if theme.daovoice %} |
- 收到的信息在DaoVoice官网的
对话
里查看与回复。
安装音乐插件Aplayer、meting
- 安装:
npm install --save hexo-tag-aplayer
- 使用方法:
1 | {% aplayer "title" "author" "url" [picture_url, narrow, autoplay, width:xxx, lrc:xxx] %} |
- 如果使用网络音乐,可以进入音乐外链网站获取音乐链接。
1 | {% aplayer "花儿纳吉" "洛萱" "https://sharefs.ali.kugou.com/202110202136/4bf5427ae89feacb1c10fd2db1c212cc/G202/M00/1C/01/Cg4DAF5QC-CAQbPvADlpgRlSql4871.mp3" "https://satparamita.top/images/my.jpg" "width:100%" "lrc:花儿纳吉-洛萱.txt" %} |
- 也可以插入本地音乐,需要自定义头像,下载歌词。
1 | {% aplayer "花儿纳吉" "洛萱" "./file/洛萱 - 花儿纳吉.mp3" "https://satparamita.top/images/my.jpg" "width:100%" "lrc:花儿纳吉-洛萱.txt" %} |
注意:音乐和歌词文件都放在与文章同级的文件夹里,上例里文件夹名为file。
- Aplayer可以建立歌单,一般是将歌单放在侧栏。为了在侧栏上方菜单里添加音乐选项,在
Hexo/source
下新建文件夹music
和assets
。文件夹assets
用来存放歌曲和歌词,文件夹名必须是assets
。 - 在
themes\next\languages\zh-CN
里添加music
的翻译。 - 在music文件夹里新建
index.md
文件,打开后修改title、type等。添加歌单,参考官方文档的参数解释。注意不要写入参数//
后面的注释。歌词可以是lrc格式的。
1 | --- |
注意事项:
- 使用歌单加入网络歌曲时,歌曲链接可能会失效。
- 插入单曲时,建议也使用歌单,歌单只有一首歌而已。
- Aplayer与Pjax存在冲突,需要手动刷新音乐页面,或者在新标签页打开才能显示。可以关闭pjax,在主题配置里修改为
pjax: false
,不过对网页运行有一点影响。 - 也可以直接在文章里添加音乐,这样就可以在不关闭Pjax的情况下,使用
window.open()
,在新标签页打开音乐,相当于刷新了音乐的网页。
1 | <a onclick="window.open('https://satparamita.top/about/%E9%9F%B3%E4%B9%90.html', '_blank');"></a> |
- meting支持多个音乐平台,可以插入单曲,也可以插入列表。官方文档里有对参数的解释。
"listmaxheight:400px"
表示列表长度,单曲时不用加入。
1 | {% meting "id" "netease, tencent, kugou, xiami, baidu" "song, playlist, album, search, artist" "mutex:true" "listmaxheight:400px" "preload:none" "theme:#33a3dc" %} |
- 在站点配置文件里添加:
1 | aplayer: |
- 以单曲为例,在文章里写入:
1 | {% meting "0A184307F0CB47068D6E2B12893FB962" "kugou" "song" "mutex:true" "preload:none" "theme:#33a3dc" %} |
- meting的另一种使用方式:
1 | <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css"> |
PS:使用酷狗音乐时,本地预览和手机都能用meting,但是我的电脑端不能;而网易云的音乐可以。如果meting能正确显示,建议对单曲优先使用meting,因为自带头像与歌词。aplayer和meting在同一个页面使用时,只显示meting。