修改Pug模板/blog/blog/themes/butterfly/layout/includes/header

为了能够正确地处理 _config.yml 中的数据,稍微调整一下 Pug 模板中的循环部分。

each socialItem in theme.social
a.social-icon(href=url_for(trim(socialItem[1])) target="_blank"
title=socialItem[2] === undefined ? '' : trim(socialItem[2]))
i(class=socialItem[0] style=socialItem[3] === undefined ? '' : `color: ${trim(socialItem[3]).replace(/[\'\"]/g, '')};`)
这里的关键点是: 我们使用 socialItem(即数组)来迭代每个社交链接设置。 第一个元素 (socialItem[0]) 是图标类名。 第二个元素 (socialItem[1]) 是 URL。 第三个元素 (socialItem[2]) 是标题(可选)。 第四个元素 (socialItem[3]) 是颜色(可选)。 完整的 _config.yml 示例 为了确保一切都按预期工作,这里是完整的 _config.yml 示例:

Social Settings (社交图标设置)

social:
- [fab fa-github, https://github.com/yourusername, Github, '#24292e']
- [fab fa-bilibili, https://bilibili.com/, Bilibili, '#FA7298']

调试步骤 保存文件:确保您已将这些更改保存到 _config.yml 和 Pug 模板文件中。 清理并生成:运行 hexo clean 清理缓存,然后运行 hexo g 生成静态文件。 启动服务器:运行 hexo s 启动本地服务器来预览网站。

设置文章优先级

1:下载插件

npm uninstall hexo-generator-index --save
npm install hexo-generator-index-pin-top --save

2:设置文章的优先级 /source/_posts/(要修改编辑的博客)

然后打开了这篇博客,加上top属性,top后面数字越大优先级越大

---
layout: '[layout]'
title: 备忘录
date: 2024-07-26 16:12:19
tags:
top: 1
---
头部

Butterfly 添加全局吸底 Aplayer

卸载 hexo-tag-aplayer 插件 在Hexo站点根目录执行以下卸载hexo-tag-aplayer命令,使用 CDN 的方式引入

npm un hexo-tag-aplayer
打开 Butterfly 主题配置文件_config.butterfly.yml,进行以下修改…
# Inject the css and script (aplayer/meting)
aplayerInject:
enable: true
per_page: true
# Inject
# Insert the code to head (before '</head>' tag) and the bottom (before '</body>' tag)
# 插入代码到头部 </head> 之前 和 底部 </body> 之前
inject:
bottom:
- <div class="aplayer no-destroy" data-id="8932390" data-server="netease" data-type="playlist" data-fixed="true" data-autoplay="false" data-order="random" data-volume="0.3" data-mutex="true" data-listMaxHeight="36vh"> </div>

Hexo-admonition

安装插件

npm install hexo-admonition --save
!!! node "嵌套链接及引用块" 欢迎访问我的博客链接:悟尘纪

>这里嵌套一行引用信息。

<div class="admonition note"><p class="admonition-title">Hexo-admonition 插件使用示例 </p><p>这是基于 hexo-admonition 插件渲染的一条提示信息。类型为 note,并设置了自定义标题。</p> <p>提示内容开头留 4 个空格,可以有多行,最后用空行结束此标记。</p> </div>

<div class="admonition warning"><p class="admonition-title">warning</p><p>这是一条采用默认标题的警告信息。</p> </div>

<div class="admonition warning"><p>这是一条不带标题的警告信息。</p> </div>

Note: 这是一个提示信息

这里是提示内容。

Warning: 这是一个警告信息

这里是警告内容。

Error: 这是一个错误信息

这里是错误内容。

<div class="admonition warning"><p>这是一条不带标题的警告信息。</p> </div>