fasionchan

读万卷书,行万里路,品万味肴,撸万行码。

用黑客的方式写博客

| Comments

开始写博客

1
2
# 新建post,标题为title
rake new_post["title"]

评论

Octopress自带的评论系统使用disqus,然而被墙了。 祸不单行,国内的多说评论系统也退出运营了。

有个好心人利用GithubIssue功能,写了一个新的评论系统gitment,看上去还是挺不错的呢! 引入gitment,读者通过github账号登录后,就可以评论了,很方便有木有! 作为编程人员,没有Github账号的应该很少很少吧!

新增source/_includes/gitment.html文件,内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{% comment %} Load script if gitment is enabled and `page.comments` is either empty (index) or set to true {% endcomment %}
{% if site.gitment_owner and page.comments != false %}
<link rel="stylesheet" href="https://imsun.github.io/gitment/style/default.css">
<script src="https://imsun.github.io/gitment/dist/gitment.browser.js"></script>
<script>
var gitment = new Gitment({
  owner: '{{ site.gitment_owner }}',
  repo: '{{ site.gitment_repo }}',
  oauth: {
    client_id: '{{ site.gitment_client_id }}',
    client_secret: '{{ site.gitment_client_secret }}{ % endraw %}',
  },
})
gitment.render('gitment')
</script>
{% endif %}

source/_includes/after_footer.html文件新增一行,在网页结尾引入gitment.html

1
{% include gitment.html %}

source/_layouts/page.html以及source/_layouts/post.html新增以下内容,注意位置应与disqus的类似:

1
2
3
4
5
6
{% if site.gitment_owner and page.comments == true %}
  <section>
    <h1>Comments</h1>
    <div id="gitment"></div>
  </section>
{% endif %}

source/_includes/article.html

1
2
3
{% if site.gitment_owner and page.comments != false and post.comments != false %}
   | <a href="{% if index %}{{ root_url }}{{ post.url }}{% endif %}#gitment">Comments</a>
{% endif %}

最后,在_config.yml文件新增以下配置,开启gitment评论:

1
2
3
4
5
# Gitment
gitment_owner: "xxxx"
gitment_repo: "xxxx"
gitment_client_id: "xxxx"
gitment_client_secret: "xxxx"

常用语法

关键字

1
2
3
4
5
6
7
8
---
layout: post
title: "Linux文件描述符"
date: 2016-09-20 22:16:26 +0800
comments: true
categories: Linux
keywords: linux, file descriptor, 文件描述符
---

图片

1
{% img /images/bei-hai-gong-yuan-bai-ta.jpg %}

代码高亮

代码高亮支持列表

常见问题

自定义域名配置CNAME不生效,查了很久发现是Jekyll失效引起的。

Comments