其他Hexo Next主题添加萌备案
翱翔大使
本套方案进一步增强了可读性,减少对源代码的破坏。
开启自定义样式
- 打开站点的
_config.yml
文件,解除以下两行的注释:
_config.yml1 2 3
| custom_file_path: style: source/_data/styles.styl footer: source/_data/footer.njk
|
- 创建
source/_data/
文件夹(注意有下划线),在文件夹内创建styles.styl
和footer.njk
。
激活图标样式(可选项)
- 打开
styles.styl
,增加以下代码:
styles.styl1 2 3 4 5 6 7 8 9 10 11 12 13
|
if (hexo-config('footer.moeicp.enable') and hexo-config('footer.moeicp.moeicon')) { .beian img { display: inline-block; margin: 0 3px; vertical-align: middle; } .beian a { color: #ffffff; } }
|
注意:如果已经添加了工信部的备案,不用加这段代码。
新增页脚萌备案链接
- 打开
footer.njk
,增加以下代码:
1 2 3 4 5 6 7 8
| {%- if theme.footer.moeicp.enable %} <div class="beian"> {%- if theme.footer.moeicp.moeicon %} <img src="{{ url_for(theme.footer.moeicp.moeicon) }}" alt="{{ '萌备案' + theme.footer.moeicp.number + '号' }}"> {%- endif %} {{- next_url('https://icp.gov.moe/?keyword=' + theme.footer.moeicp.number, "萌ICP备" + theme.footer.moeicp.number + "号") }} </div> {%- endif %}
|
新增站点配置下的属性
- 打开站点的
_config.yml
文件,在footer
属性下添加以下子属性:
_config.yml1 2 3 4 5 6
| footer: moeicp: enable: true number: 20250777 moeicon: /images/moeicon.png
|
- 完成。