Hexo博客yilia主题添加背景音乐-网易云音乐

8次阅读

共计 574 个字符,预计需要花费 2 分钟才能阅读完成。

  • 博主博客地址
1、打开网易云音乐首页,复制选择的背景音乐分享外链

网易云音乐


2、引入播放器代码

    在 themes/yilia/layout/_partial/left-col.ejs 文件 nav 标签中添加代码

注:放在 <nav></nav>之内

    笔者添加了一些判断和表达式

<!-- 网易云音乐插件 -->
<% if (theme.music && theme.music.enable){ %>
    <div style="position:absolute; bottom:120px left:auto; width:85%">
        <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="240" height="52" src="//music.163.com/outchain/player?type=2&id=<%=theme.music.id||1334445174%>&auto=<%=theme.music.autoplay?1:0%>&height=32"></iframe>
    </div>
<% } %>


3、在 yilia 主题配置文件中添加属性
# 网易云音乐插件
music:
  enable: true
  #id: 1332647902  # 网易云分享的 ID
  autoplay: true  # 是否开启自动播放

正文完
 0