From 136359bf00a4b2cf4e830327b79de71fd22eaa05 Mon Sep 17 00:00:00 2001 From: XPoet Date: Thu, 29 Oct 2020 15:42:58 +0800 Subject: [PATCH] chore: optimize directory structure --- README.md | 6 ++--- _config.yml | 2 +- languages/en.yml | 1 - languages/zh-CN.yml | 3 +-- .../{comments => comment}/comment.ejs | 6 ++--- layout/_partial/comment/gitalk.ejs | 22 +++++++++++++++++++ .../_partial/{comments => comment}/valine.ejs | 14 ++++++------ layout/_partial/comments/gitalk.ejs | 22 ------------------- layout/_partial/scripts.ejs | 2 +- layout/_partial/tools.ejs | 2 +- layout/about.ejs | 4 ++-- layout/article-content.ejs | 4 ++-- layout/category-list.ejs | 4 ++-- layout/links.ejs | 4 ++-- .../css/layout/_partial/comment/comment.styl | 18 +++++++++++++++ .../{comments => comment}/gitalk.styl | 0 .../{comments => comment}/valine.styl | 0 .../css/layout/_partial/comments/comment.styl | 14 ------------ source/css/style.styl | 2 +- source/{lib => js/libs}/anime.min.js | 0 20 files changed, 66 insertions(+), 64 deletions(-) rename layout/_partial/{comments => comment}/comment.ejs (50%) create mode 100644 layout/_partial/comment/gitalk.ejs rename layout/_partial/{comments => comment}/valine.ejs (79%) delete mode 100644 layout/_partial/comments/gitalk.ejs create mode 100644 source/css/layout/_partial/comment/comment.styl rename source/css/layout/_partial/{comments => comment}/gitalk.styl (100%) rename source/css/layout/_partial/{comments => comment}/valine.styl (100%) delete mode 100644 source/css/layout/_partial/comments/comment.styl rename source/{lib => js/libs}/anime.min.js (100%) diff --git a/README.md b/README.md index 1c9d1e3..4276e2d 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,7 @@ rss: # 评论插件 # 主题内置了 Valine 和 Gitalk,只能使用其中一款。 # --------------------------------------------------------------------------------------- -comments: +comment: # Valine # See: https://github.com/xCss/Valine # 如何使用 Valine,请参考官方教程:https://github.com/xCss/Valine @@ -430,7 +430,7 @@ top: 9999 hexo new page about ``` 2. 创建成功后,打开博客目录下 `/source/about/index.md` 文件,即可填写自己的内容。 - 支持 Markdown 和 HTML 格式;`comments: true` 表示该页面开启评论功能。 + 支持 Markdown 和 HTML 格式;`comment: true` 表示该页面开启评论功能。 参考如下示例: @@ -438,7 +438,7 @@ top: 9999 --- title: about date: 2020-03-19 14:59:53 - comments: true + comment: true --- ## About me diff --git a/_config.yml b/_config.yml index 5789664..49660df 100644 --- a/_config.yml +++ b/_config.yml @@ -46,7 +46,7 @@ rss: # --------------------------------------------------------------------------------------- # Comment plugin # --------------------------------------------------------------------------------------- -comments: +comment: # Valine # See: https://github.com/xCss/Valine valine: diff --git a/languages/en.yml b/languages/en.yml index 49ab90f..aea7795 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -15,7 +15,6 @@ tag: Tag tags: Tags tagcloud: Tag Cloud comment: Comment -comments: Comments home: Home archive: Archive archives: Archives diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index 103bbcb..276bba9 100644 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -14,8 +14,7 @@ categories: 分类 tag: 标签 tags: 标签 tagcloud: 标签云 -comment: 留言 -comments: 评论 +comment: 评论 home: 首页 archive: 归档 archives: 归档 diff --git a/layout/_partial/comments/comment.ejs b/layout/_partial/comment/comment.ejs similarity index 50% rename from layout/_partial/comments/comment.ejs rename to layout/_partial/comment/comment.ejs index 3856c31..42f7773 100644 --- a/layout/_partial/comments/comment.ejs +++ b/layout/_partial/comment/comment.ejs @@ -1,10 +1,10 @@
- <% if (theme.comments.valine.enable && theme.comments.gitalk.enable) { %> + <% if (theme.comment.valine.enable && theme.comment.gitalk.enable) { %> <%- partial('valine') %> - <% } else if (theme.comments.valine.enable) { %> + <% } else if (theme.comment.valine.enable) { %> <%- partial('valine') %> - <% } else if (theme.comments.gitalk.enable) { %> + <% } else if (theme.comment.gitalk.enable) { %> <%- partial('gitalk') %> <% } %>
diff --git a/layout/_partial/comment/gitalk.ejs b/layout/_partial/comment/gitalk.ejs new file mode 100644 index 0000000..559ae27 --- /dev/null +++ b/layout/_partial/comment/gitalk.ejs @@ -0,0 +1,22 @@ +<% if( + theme.comment.gitalk.enable + && theme.comment.gitalk.client_id + && theme.comment.gitalk.client_secret + && theme.comment.gitalk.github_id + && theme.comment.gitalk.repository +) { %> + +
+ +<% } %> diff --git a/layout/_partial/comments/valine.ejs b/layout/_partial/comment/valine.ejs similarity index 79% rename from layout/_partial/comments/valine.ejs rename to layout/_partial/comment/valine.ejs index 9fd491e..0744b59 100755 --- a/layout/_partial/comments/valine.ejs +++ b/layout/_partial/comment/valine.ejs @@ -1,7 +1,7 @@ <% if( - theme.comments.valine.enable - && theme.comments.valine.appid - && theme.comments.valine.appkey + theme.comment.valine.enable + && theme.comment.valine.appid + && theme.comment.valine.appkey ) { %>
@@ -9,12 +9,12 @@ -
- -<% } %> \ No newline at end of file diff --git a/layout/_partial/scripts.ejs b/layout/_partial/scripts.ejs index e02da4e..0c85c9c 100644 --- a/layout/_partial/scripts.ejs +++ b/layout/_partial/scripts.ejs @@ -22,6 +22,6 @@ <% } %> <% if (theme.toc.enable) { %> - <%- js(['lib/anime.min.js', 'js/toc.js']) %> + <%- js(['js/libs/anime.min.js', 'js/toc.js']) %> <% } %> <% } %> diff --git a/layout/_partial/tools.ejs b/layout/_partial/tools.ejs index c239a71..c714b07 100644 --- a/layout/_partial/tools.ejs +++ b/layout/_partial/tools.ejs @@ -6,7 +6,7 @@ <% } %> - <% if (is_post() && (theme.comments.valine.enable || theme.comments.gitalk.enable)) { %> + <% if (is_post() && (theme.comment.valine.enable || theme.comment.gitalk.enable)) { %>
  • diff --git a/layout/about.ejs b/layout/about.ejs index 573fbe4..bd15310 100644 --- a/layout/about.ejs +++ b/layout/about.ejs @@ -4,8 +4,8 @@ <%- page.content %>
    - <% if (page.comments) { %> - <%- partial('_partial/comments/comment') %> + <% if (page.comment) { %> + <%- partial('_partial/comment/comment') %> <% } %>
    diff --git a/layout/article-content.ejs b/layout/article-content.ejs index e0d0ff5..29dcb33 100644 --- a/layout/article-content.ejs +++ b/layout/article-content.ejs @@ -61,9 +61,9 @@ <% } %> - <% if (theme.comments.valine.enable || theme.comments.gitalk.enable) { %> + <% if (theme.comment.valine.enable || theme.comment.gitalk.enable) { %>
    - <%- partial('_partial/comments/comment') %> + <%- partial('_partial/comment/comment') %>
    <% } %> diff --git a/layout/category-list.ejs b/layout/category-list.ejs index a9ba032..aee9205 100644 --- a/layout/category-list.ejs +++ b/layout/category-list.ejs @@ -6,8 +6,8 @@ }) %>
    - <% if (page.comments) { %> - <%- partial('_partial/comments/comment') %> + <% if (page.comment) { %> + <%- partial('_partial/comment/comment') %> <% } %>
    diff --git a/layout/links.ejs b/layout/links.ejs index dd1fcad..57605e7 100644 --- a/layout/links.ejs +++ b/layout/links.ejs @@ -4,8 +4,8 @@ <%- page.content %> diff --git a/source/css/layout/_partial/comment/comment.styl b/source/css/layout/_partial/comment/comment.styl new file mode 100644 index 0000000..fc7d4da --- /dev/null +++ b/source/css/layout/_partial/comment/comment.styl @@ -0,0 +1,18 @@ +if (hexo-config('comment.valine.enable')) { + @require "./valine.styl"; +} + +if (hexo-config('comment.gitalk.enable')) { + @require "./gitalk.styl"; +} + +if (hexo-config('comment.valine.enable') && hexo-config('comment.gitalk.enable')) { + @require "./valine.styl"; +} + +.comments-container { + #comment-anchor { + width: 100%; + height: 20px; + } +} diff --git a/source/css/layout/_partial/comments/gitalk.styl b/source/css/layout/_partial/comment/gitalk.styl similarity index 100% rename from source/css/layout/_partial/comments/gitalk.styl rename to source/css/layout/_partial/comment/gitalk.styl diff --git a/source/css/layout/_partial/comments/valine.styl b/source/css/layout/_partial/comment/valine.styl similarity index 100% rename from source/css/layout/_partial/comments/valine.styl rename to source/css/layout/_partial/comment/valine.styl diff --git a/source/css/layout/_partial/comments/comment.styl b/source/css/layout/_partial/comments/comment.styl deleted file mode 100644 index 41e1e45..0000000 --- a/source/css/layout/_partial/comments/comment.styl +++ /dev/null @@ -1,14 +0,0 @@ -if (hexo-config('comments.valine.enable')) { - @require "./valine.styl"; -} - -if (hexo-config('comments.gitalk.enable')) { - @require "./gitalk.styl"; -} - -.comments-container { - #comment-anchor { - width: 100%; - height: 20px; - } -} diff --git a/source/css/style.styl b/source/css/style.styl index 5d17b91..b1d9b2e 100644 --- a/source/css/style.styl +++ b/source/css/style.styl @@ -4,7 +4,7 @@ @import "layout/page.styl" @import "layout/_partial/local-search.styl" @import "layout/_partial/toc.styl" -@import "layout/_partial/comments/comment.styl" +@import "layout/_partial/comment/comment.styl" @import "layout/_partial/header.styl" @import "layout/_partial/tools.styl" @import "layout/_partial/tools2.styl" diff --git a/source/lib/anime.min.js b/source/js/libs/anime.min.js similarity index 100% rename from source/lib/anime.min.js rename to source/js/libs/anime.min.js