Arknights Theme 修改日志

First Post:

Last Update:

Word Count:
474

Read Time:
2 min

Page View: loading...

声明

作为一名合格(可能并不)的程序猿,我当然会对主题中部分不习惯的部分进行修改。但这毕竟不再完全是原作者的代码,因此我认为说明对哪些部分进行了修改是一件负责任的事情。
另外,原作者的项目使用了 MIT 许可证。

修改内容

f9cea56 404 页面

  • themes\arknights\source\404.html

修改标题为 404 NOT FOUND

d2128cb 评论系统

  • themes\arknights\layout\post.pug

加入引用 giscus 的相关代码。

7290ec1 署名

  • themes\arknights\layout\includes\aside.pug
  • themes\arknights\languages\en-us.yml
  • themes\arknights\languages\zh-cn.yml

增加 modified by

d62b651 颜色模式( 适配 giscus

  • themes\arknights\source\js\_src\include\ColorMode.ts

按照 giscus 的教程,增加了函数:

1
2
3
4
5
6
7
8
function sendMessage<T>(message: T) {
const iframe = document.getElementsByClassName("giscus-frame");
if (iframe.length !== 1) return;
const target = iframe[0];
if (target instanceof HTMLIFrameElement) {
target.contentWindow?.postMessage({ giscus: message }, 'https://giscus.app');
}
}

使用 sendMessage({ setConfig: { theme: 'light_high_contrast' } }); 切换 giscus 到指定主题(示例中是 light_high_contrast)。

250b190 更改 giscus 的嵌入方式

  • themes\arknights\layout\post.pug

在启动时根据 theme-mod 的值自动选择合适的主题。

9a788a3 删除鼠标动画

  • themes\arknights\source\js\_src\include\Cursors.ts

注意改完后要用 tsc 重新编译。

a677431 实现 giscus 自动刷新

  • themes\arknights\layout\post.pug
  • themes\arknights\source\js\_src\include\InitializeGiscus.ts

网站的站内跳转使用 pjax 实现,默认不会执行更新后的页面中的 js 语句,因此考虑检测 pjax 的更新事件。

Final

今后将修改同时上传 hexo-theme-arknights (fork)

修改日志将在项目的自述文件中维护,不再同步。

Details

懒得开新 post 了,在这里记录一些部署时遇到的问题,未来可能迁移。

  • 若使用 Cloudflare 缓存,且开启了文章加密功能,不要开启 Rocket Loader™ 来缩短包含 JavaScript 的页面的绘制时间。