diff --git a/README.md b/README.md index ff98f85..14a5ec9 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,10 @@ hexo deploy 主题下的 _config.yml 文件 ``` +# Top menu +menu: + # About: /about + # Camera icon for website # 填写 baseurl 开启主页小相机,也可以在博客根目录的 _config.yml 文件末尾添加 baseurl: @@ -43,8 +47,14 @@ date_format: YYYY 年 MM 月 DD 日 # Comment. comments: # Disqus comment - # 填写 disqus_shortname 即可使用 disqus - disqus_shortname: + disqus: + enable: false + disqus_shortname: + valine: + enable: true + appId: # leancloud application app id + appKey: # leancloud application app key + placeholder: random # Placeholder. Set to random string if you want to have random placeholders(一言api). # Google Analytics Tracking ID # 填写谷歌分析跟踪 ID,使用谷歌分析应用 @@ -70,6 +80,12 @@ image_viewer: true # 也许在之后的更新中会支持更多目录样式 toc: enable: true + +# using highlight.js to show the code +# https://highlightjs.org/ +hljs: + enable: true + theme: xcode ``` ## 文章格式 @@ -93,6 +109,16 @@ date: <文章日期> [YYYY-MM-DD] ## CHANGELOG +20240121 @timlzh +- 增加暗黑模式开关 +- 页脚以及备案信息显示 +- Tags/Categories页面生成 + +20231102 @timlzh +- 增加highlight.js代码高亮 +- 增加顶部导航栏功能 +- 增加valine评论系统 + 20220202 @zchen9 - 调整 toc 样式 - 修复 Bootstrap CDN 404 问题 diff --git a/_config.yml b/_config.yml index 7fd97b8..2984cdb 100755 --- a/_config.yml +++ b/_config.yml @@ -1,3 +1,11 @@ +# Top menu +menu: + # Tags: /tags + # Categories: /categories + +# Site Icon +favicon: + # Camera icon for website baseurl: @@ -10,8 +18,15 @@ date_format: YYYY 年 MM 月 DD 日 # Comment. comments: # Disqus comment - disqus_shortname: - + disqus: + enable: false + disqus_shortname: + valine: + enable: true + 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: @@ -29,3 +44,16 @@ image_viewer: true # Maybe support more toc style in future. 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: + light: github + dark: github-dark-dimmed diff --git a/layout/_partial/article-full.ejs b/layout/_partial/article-full.ejs index 00bf000..d7d6a0d 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,12 @@

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

+
+ <%- subTitle %> +
+
@@ -54,7 +65,15 @@
-<%- partial('_partial/img-viewer') %> +<% if(!(item.img_viewer==false)) { %> + <%- partial('_partial/img-viewer') %> +<% } %> -<%- partial("_partial/toc", {post: item}) %> \ No newline at end of file + + +<% if(theme.hljs.enable){ %> + +<% } %> \ No newline at end of file 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/backhome.ejs b/layout/_partial/backhome.ejs index 27695c6..c463524 100755 --- a/layout/_partial/backhome.ejs +++ b/layout/_partial/backhome.ejs @@ -1,3 +1,14 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/layout/_partial/comment.ejs b/layout/_partial/comment.ejs index 2e005a4..20279f4 100644 --- a/layout/_partial/comment.ejs +++ b/layout/_partial/comment.ejs @@ -1,8 +1,8 @@ -<% if (theme.comments && theme.comments.disqus_shortname){ %> +<% if (theme.comments && theme.comments.disqus.enable && theme.comments.disqus.disqus_shortname){ %>
-<% } %> + +<% } else if(theme.comments && theme.comments.valine.enable){ %> +
+ +<% } %> \ No newline at end of file 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..b5e3882 --- /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 %> +
+ <% } %> +<% } %> 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 5095b54..b15be77 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,21 +34,61 @@ %> <%= title.join(' | ') %> + + <%if (theme.favicon){ %> + + <% } else { %> + + <% } %> + - + + + + + + + <%- css('css/style.css') %> + +
+ <% if (theme.menu) { %> + <% Object.keys(theme.menu).forEach(key => { %> + <%=key%> + <% }); %> + <% } %> + + + + +
+ + + + - + + - + + + + + <% if(theme.hljs.enable){ %> + + + <% } %> @@ -56,4 +96,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-friends.ejs b/layout/_partial/page-friends.ejs new file mode 100644 index 0000000..6931688 --- /dev/null +++ b/layout/_partial/page-friends.ejs @@ -0,0 +1,57 @@ +
+ + <%- partial('_partial/backhome') %> + + +
+
+
+
+
+

+ <%- item.title %> +

+
+
+
+
+
+
+ + +
+
+
+ +
+
+ <% item.data.sort((a, b) => { + var i = 0; + while(a.nick[i] == b.nick[i]) i++; + return a.nick.toLowerCase().charCodeAt(i) - b.nick.toLowerCase().charCodeAt(i); + }) %> + <% item.data.forEach(function(data){ %> +
+
+ Avatar +
+
+

<%= data.nick %>

+

<%= data.description %>

+
+ +
+ <% }); %> +
+
+ <%- item.content %> +
+ + +
+ <%- 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) { %>