giscus配置与置顶图标

在hexo-icarus主题中,使用giscus博客评论

觉得在众多博客评论系统中,giscus这个做的不错,挺好看的,支持很多种配置,所以想采用这个方案

但是目前icarus对giscus不太支持,有bug

需要手动在博客源码中嵌入js代码片段

具体是,在node_modules\hexo-theme-icarus\layout\comment中,添加giscus代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const logger = require('hexo-log')();
const { Component } = require('inferno');
const view = require('hexo-component-inferno/lib/core/view');

module.exports = class extends Component {
render() {
const { config, page, helper } = this.props;
const { __ } = helper;
const { comment } = config;
if (!comment || typeof comment.type !== 'string') {
return null;
}

return <div class="card">
<div class="card-content">
<h3 class="title is-5">{__('article.comments')}</h3>
<script src="https://giscus.app/client.js"
data-repo="xxx"
data-repo-id="xxx"
data-category="Announcements"
data-category-id="xxx"
data-mapping="title"
data-strict="0"
data-reactions-enabled="1"
data-emit-metadata="0"
data-input-position="top"
data-theme="light"
data-lang="zh-CN"
data-loading="lazy"
crossorigin="anonymous"
async>
</script>
{(() => {
try {
let Comment = view.require('comment/' + comment.type);
Comment = Comment.Cacheable ? Comment.Cacheable : Comment;
return <Comment config={config} page={page} helper={helper} comment={comment} />;
} catch (e) {
logger.w(`Icarus cannot load comment "${comment.type}"`);
return null;
}
})()}
</div>
</div>;
}
};

Read more

求职模板

简历

个人信息

  • 姓名:卢天宇
  • 性别:男
  • 年龄:23
  • 邮箱:384668412@qq.com

工作及教育经历

  • 2019.09-2025.06 上海交通大学 软件工程专业本科生
  • 2021.07-2021.09 上海那一科技有限公司 前端开发实习生

专业技能

Read more

CNAME的必要性

首先,如果不写CNAME的话,我们只能从https://username.github.io这个网址进行访问,但是显然如果有一个更好记忆的自定义域名会更好。

于是,我在腾讯云上买了两个域名lulu010722.cnlulu010722.com

之后需要在域名提供商处进行域名解析,一般是通过CNAME类型进行解析。

最后,在项目目录中也需要添加CNAME文件,在其中输入使用的域名。

之前一直不懂的地方就是这里,为什么腾讯云的域名已经解析到github page了,还是无法访问,现在推测,可能是权限问题。

在将CNAME文件定义好之后,我们就可以从原本地址和新购买的地址进行访问了。

Read more