- 获取外链
获取到的外链长这样:1
2
3<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86
src="http://music.163.com/outchain/player?type=2&id=1993765&auto=1&height=66">
</iframe>
将它稍作修改:1
2
3
4
5<% if (theme.background_music.enable){ %>
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=200 height=86
src=<%= theme.background_music.src %>>
</iframe>
<% } %>
其中的width
、height
都可以根据自己需求修改播放器宽高。src
部分被改为了主题jacman
配置文件中的变量名,并且在iframe
外面套了一层if
判断。同时将src
后的链接提取出来:1
"http://music.163.com/outchain/player?type=2&id=1993765&auto=1&height=66"
- 修改
E:\Hexo\themes\jacman\_config.yml
,在文件末尾加入如下部分,其中src
后面部分就是上一步src
后的链接,以后要换背景音乐只需替换这一链接就行了。1
2
3background_music:
enable: true
src: "http://music.163.com/outchain/player?type=2&id=1993765&auto=1&height=66"
- 修改
E:\Hexo\themes\jacman\layout\_partial\sidebar.ejs
,在<div id="asidepart">
后面插入第一步修改后的代码:1
2
3<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86
src="http://music.163.com/outchain/player?type=2&id=1993765&auto=1&height=66">
</iframe>