Hello Hexo

Hello Hexo

我的hexo使用笔记(不定期更新)

主题

主题使用了removeif修改后的icarus,之前看到了icarus就很喜欢它的设计,但是总有一些不太尽如人意的地方,自己又没有特别多的时间去一一修改,当看到removeif修改后的icarus(amazing)主题,只感觉到相见恨晚。

永久链接

hexo原版的固定链接实在是太长了,我一开始采取的修改措施是改成了:categories/:title/的形式,并使用中文转拼音的插件,但是这样的话如果使用hexo new的时候输入的是中文名,生成的链接往往极其冗长也并不好看,所以我才去了网上的方案,如果输入的是英文名然后修改title为中文的方案虽然可以自定义链接,但是文章多了也不好管理,所以最终我采取了将hexo目录下的_config配置中的permalink改为了 posts/:urlname 的形式,并修改scaffold中的post.md,给模板也加上该字段,之后hexo生成链接时使用的名字就是我们自己写在urlname的值了,然后我们便可以直接在hexo new的时候使用中文了。

百度收录

比起谷歌收录,百度收录较为麻烦,我采取了双部署的方式,在coding page上也部署了一份,并且通过dnspod将搜索引擎的访问解析到了coding page上,当前国内大部分网络访问也是解析到coding page上的,感觉会快一些。

为amazing主题添加widget

我为该主题添加了一个widget用于显示访客所在的地方,即 revolvermaps.com的统计js。
假设该widget命名为global

首先添加widget的json文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
nano themes/amazing/include/schema/widget/global.json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "/widget/global.json",
"description": "Table of contents widget configurations",
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "global"
}
},
"required": [
"type"
]
}

在widget.json里面添加该widget

1
2
3
4
5
nano themes/amazing/include/schema/common/widgets.json
//添加上
{
"$ref": "/widget/global.json"
}

创建该widget的模板文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
nano themes/amazing/layout/widget/global.jsx
const { Component } = require('inferno');
const { cacheComponent } = require('../util/cache');

class Global extends Component {
render() {
return <div class="card widget">
<div class="card-content">
<div class="menu">
<h3 class="menu-label">网站访客</h3>
<script type="text/javascript" src="//rf.revolvermaps.com/0/0/8.js?i=l&amp;m=0&amp;c=ff0000&amp;cr1=ffffff&amp;f=arial&amp;l=33" async="async"></script>
</div>
</div>
</div>;
}
}

module.exports = cacheComponent(Global, 'widget.global', props => {
const { helper, widget } = props;

return {
buttonTitle: helper.__('widget.global')
};
});

最后在_config.yml里面加上

1
2
3
4
'
position: right
type: global
'

即可


评论

:D 一言句子获取中...

加载中,最新评论有1分钟缓存...