Skip to content

Commit

Permalink
Merge pull request #326 from fi3ework/dev
Browse files Browse the repository at this point in the history
Fix bugs and add waline support
  • Loading branch information
LolipopJ committed Dec 18, 2021
2 parents a74d9f0 + d780a5d commit de5d473
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 43 deletions.
5 changes: 5 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ comment:
valine_appId:
valine_appKey:
valine_placeHolder:
# Waline site: https://waline.js.org/
waline_serverURL:
waline_placeHolder:
waline_avatar:
waline_login:
# gitalk site: https://github.com/gitalk/gitalk/
# Value 'true' is recommended for gitalk_pathname_id setting
gitalk_client_id:
Expand Down
2 changes: 1 addition & 1 deletion docs/develop-guide-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Archer 主题开发依赖于 node-sass 5.0.0,对 Node.js 版本有要求。如

在修改源代码时可以实时自动编译并刷新预览。

1. 如果有,请首先删除 Hexo 根目录下的 `public` 文件夹。避免已生成的静态文件对开发造成干扰。
1. 如果有,请首先删除 Hexo 根目录下的 `public` 文件夹,或在 Hexo 根目录下执行 `hexo clean` 命令。避免已生成的静态文件对开发造成干扰。
2. 在 Hexo 根目录下执行 `hexo s` 启动 Hexo 服务。
3. 在 Archer 主题目录下执行 `npm run dev` 进入本地开发模式。该模式会代理 Hexo 服务,监听 Archer 主题目录下 `src``layout` 中文件的修改,实时进行编译,然后通过 BrowserSync 在 `localhost:3000`(默认)下自动刷新页面。对其他位置的文件修改并不会触发页面刷新,可能需手动重启 Hexo 服务或本地开发。

Expand Down
13 changes: 13 additions & 0 deletions layout/_partial/comment/waline.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<% if(theme.comment && theme.comment.waline_serverURL) { %>
<script src="//cdn.jsdelivr.net/npm/@waline/client"></script>
<div id="comment"></div>
<script>
Waline({
el: '#comment' ,
serverURL: "<%- theme.comment.waline_serverURL %>",
placeholder: "<%- theme.comment.waline_placeHolder %>",
avatar: "<%- theme.comment.waline_avatar %>",
login: "<%- theme.comment.waline_login %>"
});
</script>
<% } %>
4 changes: 2 additions & 2 deletions layout/_partial/sidebar/sidebar-categories.ejs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="sidebar-panel-categories">
<div class="sidebar-categories-name">
<% site.categories.each(function (category) { %>
<span class="sidebar-category-name" data-categories="<%- category.slug %>">
<span class="sidebar-category-name" data-categories="<%- category.name %>">
<span class="iconfont-archer">&#xe60a;</span>
<%- category.slug %>
<%- category.name %>
</span>
<% }) %>
</div>
Expand Down
1 change: 1 addition & 0 deletions layout/post.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<%- partial('_partial/comment/youyan') %>
<%- partial('_partial/comment/custom') %>
<%- partial('_partial/comment/valine') %>
<%- partial('_partial/comment/waline') %>
</div>
<% } %>
<!-- timeliness note -->
Expand Down
2 changes: 1 addition & 1 deletion source/css/dark.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion source/css/dark.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/scripts/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/scripts/main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/scripts/search.js.map

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions src/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ const init = function () {
// Jump to url hash location if exit
const currentHash = window.location.hash
window.location.hash = archerUtil.getWindowHash()
window.location.hash = currentHash
window.history.replaceState({}, '', currentHash)

// Init anchors
// https://www.bryanbraun.com/anchorjs/
const anchors = new AnchorJS()
anchors.options = {
placement: 'right',
class: 'anchorjs-archer',
}
anchors.add()

// As headers' absolute offset-y can be queried properly
// after remove container's `container-unloaded` class,
Expand All @@ -46,15 +55,6 @@ const init = function () {
},
false
)

// Init anchors
// https://www.bryanbraun.com/anchorjs/
const anchors = new AnchorJS()
anchors.options = {
placement: 'right',
class: 'anchorjs-archer',
}
anchors.add()
}

export default init
7 changes: 5 additions & 2 deletions src/js/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,17 @@ class MetaInfo {

for (let postIndex = 0; postIndex < postsArr.length; postIndex++) {
const currPostLabels = postsArr[postIndex][this.metaName]
const key = 'name'
// if there is any post has a tag
if (currPostLabels && currPostLabels.length) {
currPostLabels.forEach((tagOrCatetory) => {
// if this.metaName is 'categories', tagOrCatetory['slug'] will be used as key in this.indexMap
// else if this.metaName is 'tag', tagOrCatetory['name'] will be used as key in this.indexMap
// check the array postsArr and you'll know why. (actually you can just use 'slug' in both case)
// check the array postsArr and you'll know why.
// console.log(tagOrCatetory)
// const key = this.metaName === 'categories' ? 'slug' : 'name'
const key = 'slug'

// Hey bro, but why? If use 'name' both, we can use special characters like blank and dot.

if (this.indexMap.has(tagOrCatetory[key])) {
this.indexMap.get(tagOrCatetory[key]).push(postIndex)
Expand Down
Loading

0 comments on commit de5d473

Please sign in to comment.