From 862bac9be30cc3867f18ed8009d5f76ada2efaed Mon Sep 17 00:00:00 2001 From: tim_lzh <2921349622@qq.com> Date: Sun, 21 Jan 2024 05:27:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Tags=E9=A1=B5=E9=9D=A2=E5=92=8Ccategori?= =?UTF-8?q?es=E9=A1=B5=E9=9D=A2;=20=E5=8F=AF=E6=89=8B=E5=8A=A8=E5=BC=80?= =?UTF-8?q?=E5=85=B3=E6=9A=97=E9=BB=91=E6=A8=A1=E5=BC=8F;=20=E9=A1=B5?= =?UTF-8?q?=E8=84=9A=E5=8A=9F=E8=83=BD=E5=92=8C=E5=A4=87=E6=A1=88=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 19 +- layout/_partial/article-full.ejs | 12 +- layout/_partial/article-index.ejs | 19 +- layout/_partial/comment.ejs | 2 +- layout/_partial/darkmode.ejs | 0 layout/_partial/footer.ejs | 12 ++ layout/_partial/go-top.ejs | 23 +++ layout/_partial/head.ejs | 36 +++- layout/_partial/page-categories.ejs | 37 ++++ layout/_partial/page-tags.ejs | 38 ++++ layout/_partial/pagination.ejs | 29 +++ layout/_partial/scripts.ejs | 3 +- layout/_partial/toc.ejs | 2 +- layout/layout.ejs | 6 + layout/page.ejs | 8 +- layout/tag.ejs | 16 ++ source/css/article.styl | 15 +- source/css/base.styl | 61 ++++-- source/css/darkmode.styl | 310 ++++++++++++++++++++-------- source/css/more.styl | 31 ++- source/css/style.styl | 2 +- source/css/top_menu.styl | 5 +- source/js/darkmode.js | 56 +++++ 23 files changed, 611 insertions(+), 131 deletions(-) create mode 100644 layout/_partial/darkmode.ejs create mode 100644 layout/_partial/footer.ejs create mode 100644 layout/_partial/go-top.ejs create mode 100644 layout/_partial/page-categories.ejs create mode 100644 layout/_partial/page-tags.ejs create mode 100644 layout/tag.ejs create mode 100644 source/js/darkmode.js diff --git a/_config.yml b/_config.yml index 8fb3351..bd1be08 100755 --- a/_config.yml +++ b/_config.yml @@ -1,6 +1,10 @@ # Top menu menu: - # About: /about + # Tags: /tags + # Categories: /categories + +# Site Icon +favicon: # Camera icon for website baseurl: @@ -19,10 +23,10 @@ comments: disqus_shortname: valine: enable: true - appId: # leancloud application app id - appKey: # leancloud application app key + appId: appid + appKey: appkey placeholder: random # Placeholder. Set to random string if you want to have random placeholders(一言api). - + # Google Analytics Tracking ID google_analytics: @@ -41,8 +45,13 @@ image_viewer: true toc: enable: true +footer: + enable: true + beian: 浙ICP备2022036129号-2 + # content: 本站采用 CC BY-NC-SA 4.0 协议进行许可 + # using highlight.js to show the code # https://highlightjs.org/ hljs: enable: true - theme: xcode + theme: atom-one-dark diff --git a/layout/_partial/article-full.ejs b/layout/_partial/article-full.ejs index 092a430..4442b79 100755 --- a/layout/_partial/article-full.ejs +++ b/layout/_partial/article-full.ejs @@ -1,3 +1,10 @@ +<% + var title = item.title || theme.default_post_title || "Untitled"; + var mainTitle = title.split(" | ")[0]; + var subTitle = title.split(" | ")[1]; +%> + +
<%- partial('_partial/backhome') %> @@ -9,8 +16,11 @@

- <%- item.title || theme.default_post_title || "Untitled" %> + <%- mainTitle %>

+
+ <%- subTitle %> +

diff --git a/layout/_partial/article-index.ejs b/layout/_partial/article-index.ejs index ace536e..40b3280 100755 --- a/layout/_partial/article-index.ejs +++ b/layout/_partial/article-index.ejs @@ -1,8 +1,21 @@
-

- <%- item.title || theme.default_post_title || "Untitled" %> -

+
+ + <% + var title = item.title || theme.default_post_title || "Untitled"; + var mainTitle = title.split(" | ")[0]; + var subTitle = title.split(" | ")[1]; + %> +
+ <%- mainTitle %> +
+
+ + <%- subTitle %> +
+
+ <%- item.excerpt %>
\ No newline at end of file diff --git a/layout/_partial/comment.ejs b/layout/_partial/comment.ejs index 011bbb1..20279f4 100644 --- a/layout/_partial/comment.ejs +++ b/layout/_partial/comment.ejs @@ -26,7 +26,7 @@ appId: '<%= theme.comments.valine.appId %>', appKey: '<%= theme.comments.valine.appKey %>', placeholder: '<%= theme.comments.valine.placeholder %>', - avatar: 'retro', + avatar: '', enableQQ: true, emojiCDN: '//i0.hdslb.com/bfs/emote/', // 表情title和图片映射 diff --git a/layout/_partial/darkmode.ejs b/layout/_partial/darkmode.ejs new file mode 100644 index 0000000..e69de29 diff --git a/layout/_partial/footer.ejs b/layout/_partial/footer.ejs new file mode 100644 index 0000000..ffe6a39 --- /dev/null +++ b/layout/_partial/footer.ejs @@ -0,0 +1,12 @@ +<% if (theme.footer && theme.footer.enable) { %> + <% if (theme.footer.content) { %> +
+ <%- theme.footer.content %> +
+ <% } %> + <% if (theme.footer.beian) { %> +
+ <%- theme.footer.beian %> +
+ <% } %> +<% } %> \ No newline at end of file diff --git a/layout/_partial/go-top.ejs b/layout/_partial/go-top.ejs new file mode 100644 index 0000000..e5cf8e9 --- /dev/null +++ b/layout/_partial/go-top.ejs @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/layout/_partial/head.ejs b/layout/_partial/head.ejs index 5b46d2c..f68c12a 100755 --- a/layout/_partial/head.ejs +++ b/layout/_partial/head.ejs @@ -22,7 +22,7 @@ <% var title = []; - if (page.current > 1) title.push(__('page', page.current)); + if (page.title) title.push(page.title); if (page.category) title.push(page.category); if (page.tag) title.push(page.tag); @@ -34,14 +34,12 @@ %> <%= title.join(' | ') %> - -
- <% if (theme.menu && theme.menu.length){ %> - <% Object.keys(theme.menu).forEach(key => { %> - <%=key%> - <% }); %> - <% } %> -
+ + <%if (theme.favicon){ %> + + <% } else { %> + + <% } %> @@ -49,9 +47,27 @@ + + <%- css('css/style.css') %> + +
+ <% if (theme.menu) { %> + <% Object.keys(theme.menu).forEach(key => { %> + <%=key%> + <% }); %> + <% } %> + + + + +
+ + + + @@ -75,4 +91,6 @@ + + diff --git a/layout/_partial/page-categories.ejs b/layout/_partial/page-categories.ejs new file mode 100644 index 0000000..418a791 --- /dev/null +++ b/layout/_partial/page-categories.ejs @@ -0,0 +1,37 @@ +
+ + <%- partial('_partial/backhome') %> + + +
+
+
+
+
+

+ <%- item.title %> +

+
+
+
+
+
+
+ + +
+
+
+ +
+ <%- list_categories(site.categories, {orderby:'count'}) %> +
+ + +
+ <%- partial("_partial/comment.ejs") %> +
+
+
+
+
\ No newline at end of file diff --git a/layout/_partial/page-tags.ejs b/layout/_partial/page-tags.ejs new file mode 100644 index 0000000..decddec --- /dev/null +++ b/layout/_partial/page-tags.ejs @@ -0,0 +1,38 @@ +
+ + <%- partial('_partial/backhome') %> + + +
+
+
+
+
+

+ <%- item.title %> +

+
+
+
+
+
+
+ + +
+
+
+ +
+ + <%- tagcloud({orderby: 'count', order: 1, min_font: 0.8, max_font: 2, unit: 'em', amount: 40, show_count: true, class: 'tagcloud'}) %> +
+ + +
+ <%- partial("_partial/comment.ejs") %> +
+
+
+
+
\ No newline at end of file diff --git a/layout/_partial/pagination.ejs b/layout/_partial/pagination.ejs index 1403b74..f08ca79 100755 --- a/layout/_partial/pagination.ejs +++ b/layout/_partial/pagination.ejs @@ -2,6 +2,35 @@ <% if (page.prev){ %> <% } %> + <% var page_list = []; %> + <% if (page.total > 1){ + var total = page.total; + var current = page.current; + if (total <= 5){ + for (var i = 1; i <= total; i++){ + page_list.push(i); + } + } else { + if (current < 3){ + page_list = [1, 2, 3, '...', total]; + } else if (current >= 3 && current < total - 2){ + page_list = [1, '...', current - 1, current, current + 1, '...', total]; + } else { + page_list = [1, '...', total - 2, total - 1, total]; + } + } + } %> + <% page_list.forEach(function(item){ %> + <% if (item == '...'){ %> +
  • ...
  • + <% } else { %> + <% if (item == page.current){ %> +
  • <%- item %>
  • + <% } else { %> +
  • <%- item %>
  • + <% } %> + <% } %> + <% }) %> <% if (page.next){ %> <% } %> diff --git a/layout/_partial/scripts.ejs b/layout/_partial/scripts.ejs index ccd5ca7..98500b2 100755 --- a/layout/_partial/scripts.ejs +++ b/layout/_partial/scripts.ejs @@ -1,4 +1,5 @@ \ No newline at end of file diff --git a/layout/_partial/toc.ejs b/layout/_partial/toc.ejs index e7f1402..948d2cc 100644 --- a/layout/_partial/toc.ejs +++ b/layout/_partial/toc.ejs @@ -1,4 +1,4 @@ -<% if (theme.toc.enable){ %> +<% if (theme.toc.enable && !post.type) { %>