Skip to content

Commit

Permalink
feat: waline阅读统计
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon committed Jan 14, 2024
1 parent c9d7e12 commit e3d7079
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 31 deletions.
13 changes: 7 additions & 6 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ waline:
lang: zh-CN
locale: {} # https://waline.js.org/guide/features/i18n.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E8%AF%AD%E8%A8%80
emoji:
- https://unpkg.com/@waline/emojis@1.0.1/weibo
- https://unpkg.com/@waline/emojis@1.0.1/alus
- https://unpkg.com/@waline/emojis@1.0.1/bilibili
- https://unpkg.com/@waline/emojis@1.0.1/qq
- https://unpkg.com/@waline/emojis@1.0.1/tieba
- https://unpkg.com/@waline/emojis@1.0.1/tw-emoji
- https://unpkg.com/@waline/emojis@1.2.0/weibo
- https://unpkg.com/@waline/emojis@1.2.0/alus
- https://unpkg.com/@waline/emojis@1.2.0/bilibili
- https://unpkg.com/@waline/emojis@1.2.0/qq
- https://unpkg.com/@waline/emojis@1.2.0/tieba
- https://unpkg.com/@waline/emojis@1.2.0/tw-emoji
meta:
- nick
- mail
Expand All @@ -130,6 +130,7 @@ waline:
- mail
wordLimit: 0
pageSize: 10
pageview: true

# https://twikoo.js.org
twikoo:
Expand Down
28 changes: 15 additions & 13 deletions layout/_partial/after-footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,24 @@
<% } %>

<% if (theme.waline.enable && theme.waline.serverURL) { %>
<%- js({src: vendorCdn(theme.vendor.js.waline)[0], 'data-pjax': true}) %>
<script data-pjax type="module">
import { init } from "<%= vendorCdn(theme.vendor.js.waline)[0] %>";
init({
el: '.wcomment',
serverURL: '<%= theme.waline.serverURL %>',
lang: '<%= theme.waline.lang %>',
locale: <%- JSON.stringify(theme.waline.locale) %>,
emoji: <%- JSON.stringify(theme.waline.emoji) %>,
meta: <%- JSON.stringify(theme.waline.meta) %>,
requiredMeta: <%-JSON.stringify(theme.waline.requiredMeta) %>,
wordLimit: JSON.parse('<%= theme.waline.wordLimit %>'),
comment: true,
pageSize: JSON.parse('<%= theme.waline.pageSize %>'),
dark: 'html[data-theme="dark"]'
if(document.querySelector('.wcomment')) {
init({
el: '.wcomment',
serverURL: '<%= theme.waline.serverURL %>',
lang: '<%= theme.waline.lang %>',
locale: <%- JSON.stringify(theme.waline.locale) %>,
emoji: <%- JSON.stringify(theme.waline.emoji) %>,
meta: <%- JSON.stringify(theme.waline.meta) %>,
requiredMeta: <%-JSON.stringify(theme.waline.requiredMeta) %>,
wordLimit: JSON.parse('<%= theme.waline.wordLimit %>'),
comment: true,
pageSize: JSON.parse('<%= theme.waline.pageSize %>'),
dark: 'html[data-theme="dark"]',
pageview: JSON.parse('<%= theme.waline.pageview %>'),
});
}
</script>
<% } %>

Expand Down
24 changes: 16 additions & 8 deletions layout/_partial/article.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@
<%= __('comment') %>
</a>
<% } %>
<% if (theme.valine.enable && theme.valine.appId && theme.valine.appKey && theme.valine.visitor) { %>
<span id="<%- url_for(post.path, {relative: false}).endsWith("index.html") ?
url_for(post.path, {relative: false}).slice(0, -10) :
url_for(post.path, {relative: false})%>" class="leancloud_visitors article-visitor-link" data-flag-title="<%= post.title %>">
<span class="leancloud-visitors-count">0</span>
<em class="post-meta-item-text"><%= __('reading') %></em>
</span>
<% } %>
<% if (post.comments && theme.twikoo.enable && theme.twikoo.envId) { %>
<a href="<%- url_for(post.path) %>#comments" class="article-comment-link">
<span class="post-comments-count twikoo-comment-count" data-path="<%- url_for(post.path, {relative: false}) %>" itemprop="commentCount"></span>
Expand All @@ -61,6 +53,22 @@
});
</script>
<% } %>
<% if (theme.valine.enable && theme.valine.appId && theme.valine.appKey && theme.valine.visitor) { %>
<span id="<%- url_for(post.path, {relative: false}).endsWith("index.html") ?
url_for(post.path, {relative: false}).slice(0, -10) :
url_for(post.path, {relative: false})%>" class="leancloud_visitors article-visitor-link" data-flag-title="<%= post.title %>">
<span class="leancloud-visitors-count">0</span>
<em class="post-meta-item-text"><%= __('reading') %></em>
</span>
<% } %>
<% if (theme.waline.enable && theme.waline.serverURL && theme.waline.pageview) { %>
<span class="article-visitor-link">
<span class="waline-pageview-count" data-path="<%- url_for(post.path, {relative: false}).endsWith("index.html") ?
url_for(post.path, {relative: false}).slice(0, -10) :
url_for(post.path, {relative: false})%>">0</span>
<em class="post-meta-item-text"><%= __('reading') %></em>
</span>
<% } %>
<%- partial('post/tag') %>
</footer>
</div>
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
"name": "hexo-theme-reimu",
"version": "0.1.0-alpha",
"description": "A Hakurei Reimu style Hexo theme",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/D-Sketon/hexo-theme-reimu.git"
Expand Down

0 comments on commit e3d7079

Please sign in to comment.