hexo-theme-stellar 1.22.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/_config.yml +18 -10
  2. package/_data/widgets.yml +3 -0
  3. package/languages/en.yml +1 -0
  4. package/languages/zh-CN.yml +1 -0
  5. package/languages/zh-TW.yml +1 -0
  6. package/layout/_partial/head.ejs +29 -19
  7. package/layout/_partial/main/footer.ejs +1 -1
  8. package/layout/_partial/main/navbar/author_banner.ejs +31 -0
  9. package/layout/_partial/main/navbar/breadcrumb.ejs +20 -4
  10. package/layout/_partial/main/post_list/post_card.ejs +13 -1
  11. package/layout/_partial/plugins/comments/giscus/script.ejs +0 -1
  12. package/layout/_partial/plugins/parser/head.ejs +3 -0
  13. package/layout/_partial/plugins/parser/katex/head.ejs +3 -0
  14. package/layout/_partial/plugins/parser/katex/script.ejs +4 -0
  15. package/layout/_partial/plugins/parser/mathjax/script.ejs +20 -0
  16. package/layout/_partial/plugins/parser/mermaid/script.ejs +29 -0
  17. package/layout/_partial/plugins/parser/script.ejs +9 -0
  18. package/layout/_partial/scripts/index.ejs +19 -5
  19. package/layout/_partial/sidebar/index.ejs +1 -1
  20. package/layout/_partial/widgets/toc.ejs +1 -1
  21. package/layout/archive.ejs +54 -37
  22. package/layout/page.ejs +1 -4
  23. package/layout/post.ejs +1 -7
  24. package/layout/wiki.ejs +1 -4
  25. package/package.json +1 -1
  26. package/scripts/events/index.js +2 -0
  27. package/scripts/events/lib/authors.js +21 -0
  28. package/scripts/events/lib/doc_tree.js +1 -2
  29. package/scripts/events/lib/links.js +17 -0
  30. package/scripts/filters/index.js +0 -13
  31. package/scripts/generators/author.js +22 -0
  32. package/scripts/tags/index.js +2 -0
  33. package/scripts/tags/lib/albums.js +47 -0
  34. package/scripts/tags/lib/copy.js +11 -13
  35. package/scripts/tags/lib/friends.js +13 -24
  36. package/scripts/tags/lib/gallery.js +6 -5
  37. package/scripts/tags/lib/posters.js +47 -0
  38. package/scripts/tags/lib/sites.js +15 -24
  39. package/scripts/tags/lib/swiper.js +1 -1
  40. package/source/css/_common/toast.styl +25 -5
  41. package/source/css/_custom.styl +2 -1
  42. package/source/css/_defines/func.styl +11 -0
  43. package/source/css/_defines/theme.styl +2 -2
  44. package/source/css/_layout/list.styl +6 -2
  45. package/source/css/_layout/main.styl +4 -0
  46. package/source/css/_layout/pages/archives.styl +7 -3
  47. package/source/css/_layout/partial/bread-nav.styl +3 -5
  48. package/source/css/_layout/partial/navbar.styl +5 -5
  49. package/source/css/_layout/tag-plugins/banner.styl +22 -8
  50. package/source/css/_layout/tag-plugins/copy.styl +16 -13
  51. package/source/css/_layout/tag-plugins/friends.styl +7 -37
  52. package/source/css/_layout/tag-plugins/gallery.styl +32 -15
  53. package/source/css/_layout/tag-plugins/grid.styl +1 -4
  54. package/source/css/_layout/tag-plugins/link.styl +1 -4
  55. package/source/css/_layout/tag-plugins/sites.styl +11 -39
  56. package/source/css/_layout/tag-plugins/tabs.styl +2 -0
  57. package/source/css/_layout/widgets/ghrepo.styl +1 -4
  58. package/source/css/_layout/widgets/toc_common.styl +22 -8
  59. package/source/css/_plugins/copycode.styl +2 -1
  60. package/source/css/_plugins/fancybox.styl +1 -4
  61. package/source/css/_plugins/index.styl +1 -1
  62. package/source/css/_plugins/lazyload.styl +4 -4
  63. package/source/js/main.js +6 -8
  64. package/source/js/plugins/copycode.js +1 -1
  65. package/source/js/plugins/friends.js +11 -11
  66. package/source/js/plugins/sites.js +13 -14
  67. package/_data/links.yml +0 -7
  68. package/layout/mathjax.ejs +0 -29
  69. package/layout/mermaid.ejs +0 -32
package/_config.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  ######## Stellar info ########
2
2
  stellar:
3
- version: '1.22.0'
3
+ version: '1.23.0'
4
4
  homepage: 'https://xaoxuu.com/wiki/stellar/'
5
5
  repo: 'https://github.com/xaoxuu/hexo-theme-stellar'
6
6
  cdn_css: # Use cdn links instead of /css/main.css
@@ -8,6 +8,10 @@ stellar:
8
8
 
9
9
 
10
10
  ######## head tags ########
11
+ preconnect:
12
+ # - https://gcore.jsdelivr.net
13
+ # - https://unpkg.com
14
+
11
15
  open_graph:
12
16
  enable: true
13
17
  twitter_id: # for open_graph meta
@@ -107,6 +111,7 @@ comments:
107
111
  # giscus
108
112
  # https://giscus.app/zh-CN
109
113
  giscus:
114
+ src: https://giscus.app/client.js
110
115
  data-repo: xxx/xxx # [在此输入仓库]
111
116
  data-repo-id: # [在此输入仓库 ID]
112
117
  data-category: # [在此输入分类名]
@@ -208,7 +213,7 @@ footer:
208
213
  # - '[关于本站](/)'
209
214
  # - '[GitHub](/)'
210
215
  content: | # 支持 Markdown 格式
211
- 本站由 [@anonymity](/) 使用 [Stellar](https://github.com/xaoxuu/hexo-theme-stellar) 主题创建。
216
+ 本站由 [${author}](/) 使用 [${theme.name} ${theme.version}](${theme.tree}) 主题创建。
212
217
  本博客所有文章除特别声明外,均采用 [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) 许可协议,转载请注明出处。
213
218
  # 主题用户越多,开发者维护和更新的积极性就越高,如果您喜欢本主题,请在适当的位置显示主题信息和仓库链接以表支持。
214
219
 
@@ -240,8 +245,9 @@ tag_plugins:
240
245
  # {% image %}
241
246
  image:
242
247
  fancybox: false # true, false
243
- parse_markdown: true # markdown 格式的图片解析成图片标签
244
-
248
+ # {% copy xxx %}
249
+ copy:
250
+ toast: 复制成功
245
251
  # {% timeline %}
246
252
  timeline:
247
253
  max-height: 80vh
@@ -333,7 +339,7 @@ plugins:
333
339
  # 可以处理评论区的图片(不支持 iframe 类评论系统)例如:
334
340
  # 使用twikoo评论可以写: .tk-content img:not([class*="emo"])
335
341
  # 使用waline评论可以写: #waline_container .vcontent img
336
- selector: .swiper-slide img, .gallery img # 多个选择器用英文逗号隔开
342
+ selector: .fancybox img # 多个选择器用英文逗号隔开
337
343
 
338
344
  # swiper
339
345
  swiper:
@@ -353,15 +359,15 @@ plugins:
353
359
  # 需在Markdown文件开头加入mathjax: true
354
360
  # 推荐使用Pandoc: npm uninstall hexo-renderer-marked --save & npm install hexo-renderer-pandoc --save
355
361
  mathjax:
356
- enable: false
357
- cdn: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML
362
+ # set <mathjax: true> to enable in page's front-matter
363
+ js: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML
358
364
 
359
365
  # Katex - The fastest math typesetting library for the web
360
366
  # https://katex.org/docs/autorender.html
361
367
  # https://github.com/KaTeX/KaTeX
362
368
  # 使用 hexo-renderer-markdown-it-plus 作为公式渲染器:npm uninstall hexo-renderer-marked --save npm install hexo-renderer-markdown-it-plus --save
363
369
  katex:
364
- enable: false
370
+ # set <katex: true> to enable in page's front-matter
365
371
  min_css: <link rel="stylesheet" href="https://gcore.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.css" integrity="sha384-vKruj+a13U8yHIkAyGgK1J3ArTLzrFGBbBc0tDp4ad/EyewESeXE/Iv67Aj8gKZ0" crossorigin="anonymous">
366
372
  min_js: <script defer src="https://gcore.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.js" integrity="sha384-PwRUT/YqbnEjkZO0zZxNqcxACrXe+j766U2amXcgMg5457rve2Y7I6ZJSm2A0mS4" crossorigin="anonymous"></script>
367
373
  auto_render_min_js: <script defer src="https://gcore.jsdelivr.net/npm/katex@0.16.4/dist/contrib/auto-render.min.js" integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05" crossorigin="anonymous"onload="renderMathInElement(document.body);"></script>
@@ -376,7 +382,8 @@ plugins:
376
382
  # B -->|option 2| C(Section C)
377
383
  # ```
378
384
  mermaid:
379
- enable: false
385
+ # set <mermaid: true> to enable in page's front-matter
386
+ style_optimization: false # use custom style in stellar
380
387
  # js: https://unpkg.com/mermaid@9.0.0/dist/mermaid.min.js
381
388
  js: https://cdn.jsdelivr.net/npm/mermaid@v9/dist/mermaid.min.js
382
389
  # Available themes: default | dark | forest | neutral
@@ -388,6 +395,7 @@ plugins:
388
395
  js: /js/plugins/copycode.js
389
396
  default_text: 'Copy'
390
397
  success_text: 'Copied'
398
+ toast: 复制成功
391
399
 
392
400
  # AI 摘要
393
401
  # https://github.com/zhheo/Post-Abstract-AI
@@ -420,7 +428,7 @@ style:
420
428
  # 动态颜色(会根据明暗主题重设明度值,只用关心色相和饱和度即可)
421
429
  background: 'hsl(212 16% 98%)' # 浅色背景颜色
422
430
  block: 'hsl(212 8% 95%)' # 块背景颜色
423
- code: 'hsl(14 100% 48%)' # 行内代码颜色
431
+ code: 'hsl(220 20% 10%)' # 'hsl(14 100% 48%)' # 行内代码颜色
424
432
  text: 'hsl(0 0% 20%)' # 文本颜色
425
433
  # 主题色配置(不会根据明暗动态调整,请设置为通用的颜色)
426
434
  theme: 'hsl(192 98% 55%)' # 主题色
package/_data/widgets.yml CHANGED
@@ -34,6 +34,7 @@ recent:
34
34
  layout: recent
35
35
  rss: # /atom.xml # npm i hexo-generator-feed
36
36
  limit: 5 # Count of posts
37
+
37
38
  # TOC (valid only in layout:post/wiki)
38
39
  toc:
39
40
  layout: toc
@@ -41,6 +42,8 @@ toc:
41
42
  min_depth: 2
42
43
  max_depth: 5
43
44
  fallback: recent # Use a backup widget when toc does not exist.
45
+ collapse: false # true / false / auto
46
+
44
47
  # github user info
45
48
  ghuser:
46
49
  layout: ghuser
package/languages/en.yml CHANGED
@@ -24,6 +24,7 @@ meta:
24
24
  comment_title: Join the discussion
25
25
  back_to_top: Back to top
26
26
  more: 'More %s'
27
+ created_author: '%s posted on'
27
28
  created: 'Posted on'
28
29
  updated: 'Updated on'
29
30
  license: License
@@ -24,6 +24,7 @@ meta:
24
24
  comment_title: 快来参与讨论吧
25
25
  back_to_top: 回到顶部
26
26
  more: '更多「%s」'
27
+ created_author: 本文由 %s 发布于
27
28
  created: 发布于
28
29
  updated: 更新于
29
30
  license: 许可协议
@@ -24,6 +24,7 @@ meta:
24
24
  comment_title: 參與討論
25
25
  back_to_top: 回到頁首
26
26
  more: '更多「%s」'
27
+ created_author: 本文由 %s 發布於
27
28
  created: 發布於
28
29
  updated: 更新於
29
30
  license: 授權條款
@@ -67,18 +67,38 @@ function og_args() {
67
67
  }
68
68
  return Object.assign(args, page.open_graph);
69
69
  }
70
+
71
+ function preconnect() {
72
+ var el = '';
73
+ for (let href of (theme.preconnect || [])) {
74
+ el += `<link rel="preconnect" href="${href}" crossorigin>`;
75
+ }
76
+ return el;
77
+ }
78
+
79
+ function custom_inject() {
80
+ var el = '';
81
+ for (let item of (config.inject?.head || [])) {
82
+ el += item;
83
+ }
84
+ for (let item of (theme.inject?.head || [])) {
85
+ el += item;
86
+ }
87
+ for (let item of (page.inject?.head || [])) {
88
+ el += item;
89
+ }
90
+ return el;
91
+ }
92
+
70
93
  %>
94
+
71
95
  <head>
72
- <%- meta_generator() %>
73
- <meta name="hexo-theme" content="<%- stellar_info('tree') %>">
74
96
  <meta charset="utf-8">
97
+ <meta name="hexo-theme" content="<%- stellar_info('tree') %>" theme-name="<%- stellar_info('name') %>" theme-version="<%- stellar_info('version') %>">
75
98
  <%- generate_robots() %>
76
-
99
+ <%- meta_generator() %>
77
100
  <meta http-equiv='x-dns-prefetch-control' content='on' />
78
- <link rel='dns-prefetch' href='https://gcore.jsdelivr.net'>
79
- <link rel="preconnect" href="https://gcore.jsdelivr.net" crossorigin>
80
- <link rel='dns-prefetch' href='//unpkg.com'>
81
-
101
+ <%- preconnect() %>
82
102
  <meta name="renderer" content="webkit">
83
103
  <meta name="force-rendering" content="webkit">
84
104
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
@@ -115,16 +135,6 @@ function og_args() {
115
135
  <%- css(theme.style.codeblock.highlightjs_theme) %>
116
136
  <% } %>
117
137
 
118
- <% if (theme.plugins.katex && theme.plugins.katex.enable) { %>
119
- <%- theme.plugins.katex.min_css %>
120
- <%- theme.plugins.katex.min_js %>
121
- <%- theme.plugins.katex.auto_render_min_js %>
122
- <% } %>
123
-
124
-
125
- <% if (config.inject && config.inject.head){ %>
126
- <% (config.inject.head||[]).forEach(function(item){ %>
127
- <%- item %>
128
- <% }) %>
129
- <% } %>
138
+ <%- partial('plugins/parser/head') %>
139
+ <%- custom_inject() %>
130
140
  </head>
@@ -1,5 +1,5 @@
1
1
  <%
2
- const content = theme.footer.content;
2
+ const content = theme.footer.content?.replace('${author}', config.author)?.replace('${theme.name}', stellar_info('name'))?.replace('${theme.version}', stellar_info('version'))?.replace('${theme.tree}', stellar_info('tree'))
3
3
  function layoutDiv() {
4
4
  var el = '';
5
5
  el += '<footer class="page-footer reveal fs12">';
@@ -0,0 +1,31 @@
1
+ <%
2
+ function layoutDiv() {
3
+ const author = page.author
4
+ var el = ``
5
+ el += `<div class="tag-plugin banner author">`
6
+ if (author.banner) {
7
+ el += `<img class="bg" src="${author.banner}">`
8
+ }
9
+ el += `
10
+ <div class="content">
11
+ <div class="top">
12
+ <button class="back cap" onclick="window.history.back()">
13
+ <svg aria-hidden="true" viewBox="0 0 16 16" fill="currentColor">
14
+ <path fill-rule="evenodd" d="M7.78 12.53a.75.75 0 01-1.06 0L2.47 8.28a.75.75 0 010-1.06l4.25-4.25a.75.75 0 011.06 1.06L4.81 7h7.44a.75.75 0 010 1.5H4.81l2.97 2.97a.75.75 0 010 1.06z"></path>
15
+ </svg>
16
+ </button>
17
+ </div>
18
+ <div class="bottom">
19
+ <img class="avatar" src="${author.avatar}">
20
+ <div class="text-area">
21
+ <p class="text title">${author.name}</p>
22
+ <div class="text subtitle">${author.description || ""}</div>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ `
27
+ el += `</div>`
28
+ return el
29
+ }
30
+ %>
31
+ <%- layoutDiv() %>
@@ -35,13 +35,29 @@ function layoutDiv() {
35
35
  });
36
36
  }
37
37
  el += '</div>';
38
- // 发布日期
38
+ // 作者
39
+ var author = null
40
+ if (theme.authors) {
41
+ if (page.author?.length > 0 && theme.authors[page.author] != null) {
42
+ author = theme.authors[page.author]
43
+ } else {
44
+ author = theme.default_author
45
+ }
46
+ }
39
47
  el += '<div id="post-meta">';
48
+ if (author) {
49
+ let link = `<a href="${url_for(author.path)}">${author.name}</a>`
50
+ el += `<span class="author">${__("meta.created_author", link)}</span>`
51
+ } else {
52
+ el += `<span class="author">${__("meta.created")}</span>`
53
+ }
54
+ // 发布日期
40
55
  el += `
41
- <span>${__("meta.created")}&nbsp;<time datetime="${date_xml(page.date)}">${date(page.date, config.date_format)}</time></span>
56
+ <span class="created"><time datetime="${date_xml(page.date)}">${date(page.date, config.date_format)}</time></span>
42
57
  `;
58
+ // 更新日期
43
59
  el += `
44
- <span>${__("meta.updated")}&nbsp;<time datetime="${date_xml(page.updated)}">${date(page.updated, config.date_format)}</time></span>
60
+ <span class="updated">${__("symbol.comma") + __("meta.updated")}&nbsp;<time datetime="${date_xml(page.updated)}">${date(page.updated, config.date_format)}</time></span>
45
61
  `;
46
62
  el += '</div>';
47
63
 
@@ -84,7 +100,7 @@ function layoutDiv() {
84
100
  el += '</div>';
85
101
  el += '</div>';
86
102
 
87
- let repo = page.repo || proj.repo
103
+ const repo = page.repo || proj?.repo
88
104
  if (repo) {
89
105
  el += `
90
106
  <div class="right ghrepo stellar-ghinfo-api" api="${theme.api_host.ghapi}/repos/${repo}">
@@ -68,8 +68,20 @@ function div_default() {
68
68
 
69
69
  // meta
70
70
  el += '<div class="meta cap">';
71
- // time
72
71
  el += '<span class="cap" id="post-meta">';
72
+ // author
73
+ var author = null
74
+ if (theme.authors) {
75
+ if (page.author?.length > 0 && theme.authors[page.author] != null) {
76
+ author = theme.authors[page.author]
77
+ } else {
78
+ author = theme.default_author
79
+ }
80
+ }
81
+ if (author) {
82
+ el += author.name + '&nbsp;'
83
+ }
84
+ // time
73
85
  el += __("meta.created") + '&nbsp;' + '<time datetime="' + date_xml(post.date) + '">' + date(post.date, config.date_format) + '</time>';
74
86
  el += '</span>';
75
87
  // cat
@@ -9,7 +9,6 @@
9
9
  console.error(error);
10
10
  }
11
11
  var script = document.createElement('script');
12
- script.src = 'https://giscus.app/client.js';
13
12
  script.async = true;
14
13
  for (let key of Object.keys(el.attributes)) {
15
14
  let attr = el.attributes[key];
@@ -0,0 +1,3 @@
1
+ <% if (page.katex == true) { %>
2
+ <%- partial('katex/head') %>
3
+ <% } %>
@@ -0,0 +1,3 @@
1
+ <% if (theme.plugins.katex) { %>
2
+ <%- theme.plugins.katex.min_css %>
3
+ <% } %>
@@ -0,0 +1,4 @@
1
+ <% if (theme.plugins.katex) { %>
2
+ <%- theme.plugins.katex.min_js %>
3
+ <%- theme.plugins.katex.auto_render_min_js %>
4
+ <% } %>
@@ -0,0 +1,20 @@
1
+ <script type="text/javascript" src="<%- theme.plugins.mathjax.js %>"></script>
2
+ <script type="text/x-mathjax-config">
3
+ MathJax.Hub.Config({
4
+ tex2jax: {
5
+ inlineMath: [ ['$','$'], ["\\(","\\)"] ],
6
+ processEscapes: true
7
+ }
8
+ });
9
+ MathJax.Hub.Config({
10
+ tex2jax: {
11
+ skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
12
+ }
13
+ });
14
+ MathJax.Hub.Queue(function() {
15
+ var all = MathJax.Hub.getAllJax(), i;
16
+ for(i=0; i < all.length; i += 1) {
17
+ all[i].SourceElement().parentNode.className += ' has-jax';
18
+ }
19
+ });
20
+ </script>
@@ -0,0 +1,29 @@
1
+ <script type="text/javascript" src="<%- theme.plugins.mermaid.js %>"></script>
2
+ <script>
3
+ var mermaid_config = {
4
+ startOnLoad: true,
5
+ theme:
6
+ "<%- theme.style.darkmode %>" == "auto" &&
7
+ window.matchMedia("(prefers-color-scheme: dark)").matches
8
+ ? "dark"
9
+ : "<%- theme.plugins.mermaid.theme %>",
10
+ logLevel: 3,
11
+ themeVariables: {
12
+ darkMode: true
13
+ },
14
+ flowchart: {
15
+ useMaxWidth: false,
16
+ htmlLabels: true,
17
+ curve: "linear"
18
+ },
19
+ gantt: {
20
+ axisFormat: "%Y/%m/%d"
21
+ },
22
+ sequence: {
23
+ actorMargin: 50
24
+ }
25
+ }
26
+ if (window.mermaid) {
27
+ mermaid.initialize(mermaid_config);
28
+ }
29
+ </script>
@@ -0,0 +1,9 @@
1
+ <% if (page.katex == true) { %>
2
+ <%- partial('katex/script') %>
3
+ <% } %>
4
+ <% if (page.mathjax == true) { %>
5
+ <%- partial('mathjax/script') %>
6
+ <% } %>
7
+ <% if (page.mermaid == true) { %>
8
+ <%- partial('mermaid/script') %>
9
+ <% } %>
@@ -1,3 +1,20 @@
1
+ <%
2
+
3
+ function custom_inject() {
4
+ var el = '';
5
+ for (let item of (config.inject?.script || [])) {
6
+ el += item;
7
+ }
8
+ for (let item of (theme.inject?.script || [])) {
9
+ el += item;
10
+ }
11
+ for (let item of (page.inject?.script || [])) {
12
+ el += item;
13
+ }
14
+ return el;
15
+ }
16
+
17
+ %>
1
18
  <script type="text/javascript">
2
19
  const stellar = {
3
20
  // 懒加载 css https://github.com/filamentgroup/loadCSS
@@ -157,10 +174,7 @@
157
174
 
158
175
  <!-- optional -->
159
176
  <%- partial('../plugins/comments/script') %>
177
+ <%- partial('../plugins/parser/script') %>
160
178
 
161
179
  <!-- inject -->
162
- <% if (config.inject && config.inject.script && config.inject.script.length > 0) { %>
163
- <% config.inject.script.forEach(function(js) { %>
164
- <%- js %>
165
- <% }) %>
166
- <% } %>
180
+ <%- custom_inject() %>
@@ -7,7 +7,7 @@ if (page.layout === 'wiki' && page.wiki) {
7
7
  if (page.sidebar == undefined) {
8
8
  if (page.layout == 'post' && page.content) {
9
9
  page.sidebar = theme.sidebar.widgets.post;
10
- } else if (page.layout == 'wiki' && page.content && page.wiki) {
10
+ } else if (page.layout == 'wiki' && page.wiki) {
11
11
  let proj = theme.wiki.tree[page.wiki];
12
12
  if (proj?.sidebar) {
13
13
  page.sidebar = proj.sidebar;
@@ -66,7 +66,7 @@ function layoutDiv(fallback) {
66
66
 
67
67
  var el = '';
68
68
  if (type.length > 0) {
69
- el += '<widget class="widget-wrapper toc ' + type + '" id="data-toc">';
69
+ el += `<widget class="widget-wrapper toc ${type}" id="data-toc" collapse="${item.collapse}">`;
70
70
  if (page.layout !== 'wiki') {
71
71
  // post 布局
72
72
  el += layoutTocHeader(page.toc_title);
@@ -3,41 +3,58 @@ page.robots = 'noindex,follow';
3
3
  if (page.menu_id == undefined) {
4
4
  page.menu_id = 'post';
5
5
  }
6
+ if (page.author) {
7
+ page.header = 'auto';
8
+ }
9
+ function layoutArchiveList() {
10
+ var el = ''
11
+ if (page.author) {
12
+ page.title = page.author.name
13
+ el += partial('_partial/main/navbar/author_banner')
14
+ } else {
15
+ page.title = __('btn.archives')
16
+ el += partial('_partial/main/navbar/list_post')
17
+ }
18
+ el += `<div class="post-list archives">`
19
+ var years = []
20
+ site.posts.sort('date', -1).each(function(post) {
21
+ post.year = date(post.date, 'YYYY')
22
+ if (post.year && (years.includes(post.year) == false) && (post.title || post.date)) {
23
+ years.push(post.year)
24
+ }
25
+ })
26
+ for (let year of years) {
27
+ el += `<article class="${scrollreveal()}" id="archive">`
28
+ el += `<div class='archive-header h4'>${year}</div>`
29
+ site.posts.sort('date', -1).filter(function (post) {
30
+ post.year = date(post.date, 'YYYY')
31
+ return post.year == year
32
+ }).each(function(post) {
33
+ el += `<div class="archive-list">`
34
+ el +=`<a class='post fs14' href="${url_for(post.link || post.path)}">`
35
+ el += `<time>${date(post.date, 'MM-DD')}</time>`
36
+ el += `<span>`
37
+ if (post.title) {
38
+ el += post.title
39
+ } else if (post.date) {
40
+ el += date(post.date, config.date_format)
41
+ }
42
+ el += `</span>`
43
+ el += `</a>`
44
+ el += `</div>`
45
+ })
46
+ el += `</article>`
47
+ }
48
+ el += `</div>`
49
+ return el
50
+ }
51
+ function layoutDiv() {
52
+ if (page.posts && (is_category() || is_tag())) {
53
+ return partial('index')
54
+ } else {
55
+ return layoutArchiveList()
56
+ }
57
+ }
6
58
  %>
7
- <% if (page.posts && (is_category() || is_tag())) { %>
8
- <%- partial('index') %>
9
- <% } else { %>
10
- <% page.title = __('btn.archives'); %>
11
- <%- partial('_partial/main/navbar/list_post') %>
12
- <div class='post-list'>
13
- <% var years = []; %>
14
- <% site.posts.sort('date', -1).each(function(post) { %>
15
- <% post.year = date(post.date, 'YYYY'); %>
16
- <% if (post.year && (years.includes(post.year) == false) && (post.title || post.date)) { %>
17
- <% years.push(post.year); %>
18
- <% } %>
19
- <% }); %>
20
- <% years.forEach((year, i) => { %>
21
- <article class='<%- scrollreveal() %>' id='archive'>
22
- <div class='archive-header h4'><%= year %></div>
23
- <% site.posts.sort('date', -1).filter(function (post) { %>
24
- <% post.year = date(post.date, 'YYYY'); %>
25
- <% return post.year == year; %>
26
- <% }).each(function(post) { %>
27
- <div class='archive-list'>
28
- <a class='post fs14' href="<%= url_for(post.link || post.path) %>">
29
- <time><%= date(post.date, 'MM-DD') %></time>
30
- <span>
31
- <% if (post.title) { %>
32
- <%- post.title %>
33
- <% } else if (post.date) { %>
34
- <%= date(post.date, config.date_format) %>
35
- <% } %>
36
- </span>
37
- </a>
38
- </div>
39
- <% }); %>
40
- </article>
41
- <% }); %>
42
- </div>
43
- <% } %>
59
+
60
+ <%- layoutDiv() %>
package/layout/page.ejs CHANGED
@@ -1,6 +1,6 @@
1
1
  <%
2
2
  function layoutTitle() {
3
- const title = page.h1 || page.title;
3
+ const title = page.h1 != null ? page.h1 : page.title;
4
4
  if (title && title.length > 0) {
5
5
  return '<h1 class="article-title"><span>' + title + '</span></h1>';
6
6
  } else {
@@ -12,9 +12,6 @@ function layoutDiv() {
12
12
  if (page.post_list) {
13
13
  el += partial('_partial/main/navbar/list_post');
14
14
  }
15
- if (page.mermaid == true) {
16
- el += partial('mermaid');
17
- }
18
15
  if (page.h1 || page.title || (page.content && page.content.length > 0)) {
19
16
  el += partial('_partial/main/navbar/breadcrumb');
20
17
  }
package/layout/post.ejs CHANGED
@@ -6,7 +6,7 @@ if (page.header == undefined) {
6
6
  page.header = 'auto';
7
7
  }
8
8
  function layoutTitle() {
9
- const title = page.h1 || page.title;
9
+ const title = page.h1 != null ? page.h1 : page.title;
10
10
  if (title && title.length > 0) {
11
11
  return '<h1 class="article-title"><span>' + title + '</span></h1>';
12
12
  } else {
@@ -19,12 +19,6 @@ if (theme.plugins.heti && theme.plugins.heti.enable) {
19
19
  heti = ' heti';
20
20
  }
21
21
  %>
22
- <% if (page.mathjax == true){ %>
23
- <%- partial('mathjax') %>
24
- <% } %>
25
- <% if (page.mermaid == true){ %>
26
- <%- partial('mermaid') %>
27
- <% } %>
28
22
  <%- partial('_partial/main/navbar/breadcrumb') %>
29
23
  <article class='md-text content<%- heti %> <%- post.layout %><%- post.indent ? ' indent' : '' %><%- scrollreveal() %>'>
30
24
  <%- layoutTitle() %>
package/layout/wiki.ejs CHANGED
@@ -13,7 +13,7 @@ if (page.title == undefined) {
13
13
  }
14
14
  }
15
15
  function layoutTitle() {
16
- const title = page.h1 || page.title;
16
+ const title = page.h1 != null ? page.h1 : page.title;
17
17
  if (title && title.length > 0) {
18
18
  return '<h1 class="article-title"><span>' + title + '</span></h1>';
19
19
  } else {
@@ -29,9 +29,6 @@ function layoutTitle() {
29
29
  page.header = 'auto';
30
30
  }
31
31
  %>
32
- <% if (page.mermaid == true){ %>
33
- <%- partial('mermaid') %>
34
- <% } %>
35
32
  <%- partial('_partial/main/navbar/breadcrumb') %>
36
33
  <article class='md-text content <%- page.layout %><%- page.indent ? ' indent' : '' %><%- scrollreveal() %>'>
37
34
  <%- layoutTitle() %>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-stellar",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "description": "Elegant and powerful theme for Hexo.",
5
5
  "main": "package.json",
6
6
  "scripts": {
@@ -5,6 +5,8 @@
5
5
  hexo.on('generateBefore', () => {
6
6
  // Merge config.
7
7
  require('./lib/config')(hexo);
8
+ require('./lib/links')(hexo);
9
+ require('./lib/authors')(hexo);
8
10
  require('./lib/doc_tree')(hexo);
9
11
  require('./lib/utils')(hexo);
10
12
  });
@@ -0,0 +1,21 @@
1
+ /**
2
+ * authors.js v2 | https://github.com/xaoxuu/hexo-theme-stellar/
3
+ */
4
+
5
+ 'use strict';
6
+
7
+ module.exports = ctx => {
8
+ var authors = ctx.locals.get('data').authors || {}
9
+ let basePath = ctx.config.author_dir || 'author'
10
+ // url
11
+ for (let key of Object.keys(authors)) {
12
+ let author = authors[key]
13
+ author.path = `${basePath}/${key}/index.html`
14
+ }
15
+ // default author
16
+ const keys = Object.keys(authors)
17
+ if (keys.length > 0) {
18
+ ctx.theme.config.default_author = authors[keys[0]]
19
+ }
20
+ ctx.theme.config.authors = authors
21
+ }