Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cusdis comments system #374

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ A responsive, clean and simple [Hexo](http://hexo.io) theme for a personal websi
- Support for local search
- Projects list
- I18n support
- Disqus / Utterances
- Google analytics / Baidu Tongji / [Umami Analytics](https://umami.is)
- Disqus / Utterances / Cusdis
- Google analytics / Baidu Tongji / [Umami Analytics](https://umami.is)
- Font Awesome icons
- Simplicity

Expand Down Expand Up @@ -64,23 +64,23 @@ A responsive, clean and simple [Hexo](http://hexo.io) theme for a personal websi
# theme: landscape
theme: cactus
```

See below for more information on how to customize this theme.

3. Create pages and articles with the `hexo new [layout] <title>` command.
For example, to create an "about me" page, run:

```sh
$ hexo new page about
```

This will create a new file in `source/about/index.md`
Similarly, you can create a new article with

```sh
$ hexo new post "hello world"
```

and add some interesting content in `source/_posts/hello-world.md`.

4. Run: `hexo generate` and `hexo server`
Expand Down Expand Up @@ -344,6 +344,26 @@ where each of the parameters are the respective values ​​provided during the
* `label`: the label that will be assigned to issues created by Utterances
* `theme`: the selected Utterances theme.

#### Cusdis

First, create an account on Cusdis: [https://cusdis.com/](https://cusdis.com/).

Next, update the `_config.yml` file:

```yml
cusdis:
enabled: false
host: https://cusdis.com
app_id: XXX
script: https://cusdis.com/js/cusdis.es.js
```

where each of the parameters are the respective values ​​provided during the configuration of the Cusdis:

* `host`: the host domain. Default is `https://cusdis.com`.
* `app_id`: the id provided when you create an app on Cusdis.
* `script`: the url for importing the JS script, default is the source file on official website.

### Code Highlighting

Pick one of [the available colorschemes](https://github.com/probberechts/hexo-theme-cactus/tree/master/source/css/_highlight) and add it to the `_config.yml`:
Expand All @@ -362,7 +382,7 @@ date: 2017-12-24 23:29:53
tags:
- Foo
- Bar
categories:
categories:
- Baz
---

Expand All @@ -384,7 +404,7 @@ Similarly, you can create a page with an overview of all categories by running:
$ hexo new page categories
```

and adding `type: categories` to the front-matter of `source/categories/index.md`.
and adding `type: categories` to the front-matter of `source/categories/index.md`.

Finally, don't forget to create a link to these pages, for example in the navigation menu:

Expand Down
9 changes: 8 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ nav:
# The 'icon' keys should correspond to Fontawesome icon names
# (see https://fontawesome.com/icons?d=gallery&s=brands);
# only 'mail' is an exception.
# You can optionally add a 'label' key to set the title attribute on the link.
# You can optionally add a 'label' key to set the title attribute on the link.
# 'icon' value will be used as title when 'label' is missing.
social_links:
-
Expand Down Expand Up @@ -180,6 +180,13 @@ utterances:
label: Comment
theme: github-dark

# Fill in your Cusdis Comments Shortname to enable Cusdis comments.
cusdis:
enabled: false
host: https://cusdis.com
app_id: XXX
script: https://cusdis.com/js/cusdis.es.js

# Fill in your Google Analytics tracking ID to enable Google Analytics.
google_analytics:
enabled: false
Expand Down
1 change: 1 addition & 0 deletions languages/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ counter:

comments:
no_js: Please enable JavaScript to view the comments.
header: Comments

tooltip:
copy_tip: Copy to clipboard!
Expand Down
5 changes: 3 additions & 2 deletions languages/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ nav:
tag: 标签
category: 分类
search: 搜索

icons:
menu: 目录
top: 顶部
Expand Down Expand Up @@ -44,7 +44,7 @@ tag_cloud:

pagination:
page: 第 %d 页,共 %d 页

counter:
tag_cloud:
zero: 没有标签
Expand All @@ -63,6 +63,7 @@ counter:

comments:
no_js: 加载评论需要在浏览器启用 JavaScript 脚本支持。
header: 评论

tooltip:
copy_tip: 复制到粘贴板!
Expand Down
14 changes: 14 additions & 0 deletions layout/_partial/comments.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,18 @@
<noscript><%= __('comments.no_js') %></noscript>
</div>
</div>
<% } %>
<% if (page.comments && theme.cusdis.enabled){ %>
<div id="blog-post-comments">
<h1 class="title"><%= __('comments.header') %></h1>
<div id="cusdis_thread"
data-host="<%= theme.cusdis.host || 'https://cusdis.com' %>"
data-app-id="<%= theme.cusdis.app_id %>"
data-page-id="<%= page.path %>"
data-page-url="<%= page.permalink %>"
data-page-title="<%= page.title %>"
></div>
<!-- <script async defer src="https://cusdis.com/js/cusdis.es.js"></script> -->

</div>
<% } %>
13 changes: 13 additions & 0 deletions layout/_partial/scripts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,17 @@
(document.getElementById('utterances_thread')).appendChild(script);
}());
</script>
<% } %>
<!-- Cusdis Comments -->
<% if (page.comments && theme.cusdis.enabled){ %>
<script type="text/javascript">

(function(){
var script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.src = '<%= theme.cusdis.script || "https://cusdis.com/js/cusdis.es.js" %>';
(document.getElementById('cusdis_thread')).appendChild(script);
}());
</script>
<% } %>