hexo-theme-stellar 1.24.0 → 1.25.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 (61) hide show
  1. package/_config.yml +69 -45
  2. package/languages/en.yml +2 -1
  3. package/languages/zh-CN.yml +2 -1
  4. package/languages/zh-TW.yml +2 -1
  5. package/layout/404.ejs +1 -3
  6. package/layout/_partial/head.ejs +1 -1
  7. package/layout/_partial/main/article/article_footer.ejs +14 -14
  8. package/layout/_partial/main/article/read_next.ejs +10 -10
  9. package/layout/_partial/main/navbar/breadcrumb.ejs +36 -14
  10. package/layout/_partial/main/navbar/{list_post.ejs → nav_tabs_blog.ejs} +15 -7
  11. package/layout/_partial/main/navbar/{list_wiki.ejs → nav_tabs_wiki.ejs} +15 -1
  12. package/layout/_partial/main/post_list/post_card.ejs +2 -13
  13. package/layout/_partial/main/post_list/topic_card.ejs +16 -0
  14. package/layout/_partial/sidebar/header.ejs +6 -7
  15. package/layout/_partial/sidebar/index.ejs +37 -29
  16. package/layout/_partial/sidebar/menu.ejs +2 -2
  17. package/layout/_partial/widgets/related.ejs +47 -20
  18. package/layout/_partial/widgets/search.ejs +2 -2
  19. package/layout/_partial/widgets/toc.ejs +52 -44
  20. package/layout/archive.ejs +1 -1
  21. package/layout/categories.ejs +1 -1
  22. package/layout/index.ejs +6 -42
  23. package/layout/index_topic.ejs +28 -0
  24. package/layout/index_wiki.ejs +42 -0
  25. package/layout/page.ejs +2 -2
  26. package/layout/tags.ejs +1 -1
  27. package/layout/topic.ejs +28 -0
  28. package/layout/wiki.ejs +11 -22
  29. package/package.json +1 -1
  30. package/scripts/events/index.js +5 -0
  31. package/scripts/events/lib/authors.js +1 -1
  32. package/scripts/events/lib/config.js +2 -2
  33. package/scripts/events/lib/doc_tree.js +1 -1
  34. package/scripts/events/lib/merge_posts.js +47 -0
  35. package/scripts/events/lib/topic_tree.js +45 -0
  36. package/scripts/generators/404.js +8 -3
  37. package/scripts/generators/author.js +4 -2
  38. package/scripts/generators/categories.js +4 -4
  39. package/scripts/generators/tags.js +4 -4
  40. package/scripts/generators/topic.js +21 -0
  41. package/scripts/generators/wiki.js +29 -28
  42. package/scripts/helpers/parse_config.js +2 -2
  43. package/scripts/tags/lib/audio.js +10 -5
  44. package/scripts/tags/lib/navbar.js +1 -1
  45. package/scripts/tags/lib/video.js +13 -5
  46. package/source/css/_common/blur.styl +4 -1
  47. package/source/css/_common/highlight.styl +1 -0
  48. package/source/css/_common/media.styl +1 -6
  49. package/source/css/_layout/partial/paginator.styl +2 -2
  50. package/source/css/_layout/partial/related.styl +3 -0
  51. package/source/css/_layout/tag-plugins/banner.styl +4 -1
  52. package/source/css/_layout/tag-plugins/frame.styl +1 -1
  53. package/source/css/_layout/tag-plugins/media.styl +11 -0
  54. package/source/css/_layout/widgets/search.styl +21 -29
  55. package/source/js/main.js +1 -1
  56. package/source/js/plugins/fcircle.js +1 -1
  57. package/source/js/plugins/friends.js +1 -1
  58. package/source/js/plugins/memos.js +1 -1
  59. package/source/js/plugins/sites.js +2 -2
  60. package/source/js/plugins/weibo.js +1 -1
  61. package/source/js/search/local-search.js +4 -1
@@ -6,8 +6,8 @@ function layoutDiv() {
6
6
  el += ' mobile-hidden';
7
7
  }
8
8
  el += '">';
9
- for (let id of Object.keys(theme.sidebar.menu)) {
10
- let item = theme.sidebar.menu[id];
9
+ for (let id of Object.keys(theme.menu)) {
10
+ let item = theme.menu[id];
11
11
  if (item == undefined || item.length == 0) {
12
12
  continue;
13
13
  }
@@ -1,34 +1,61 @@
1
1
  <%
2
- function layoutDiv() {
3
- if (page.layout !== "wiki") {
4
- return '';
2
+ function relatedPostsInTopic() {
3
+ if (page.topic?.length == 0) {
4
+ return ''
5
+ }
6
+ const topic = theme.topic.tree[page.topic]
7
+ if (topic == null) {
8
+ return ''
5
9
  }
6
- let thisItemObject = theme.wiki.tree[page.wiki];
10
+ var el = ''
11
+ el += `<widget class="widget-wrapper recent">`
12
+ el += `<div class="widget-header cap theme dis-select">`
13
+ el += `<span class="name">${__('btn.topic') + __('symbol.colon') + topic.name}</span>`
14
+ el += `</div>`
15
+ el += `<div class="widget-body related-posts">`
16
+ for (let post of topic.pages) {
17
+ el += `<a class="item${post.path == page.path ? ' active' : ''}" href="${url_for(post.path)}">`
18
+ el += `<span class="title">${post.title}</span>`
19
+ el += `</a>`
20
+ }
21
+ el += `</div>`
22
+ el += `</widget>`
23
+ return el
24
+ }
25
+ function relatedWiki() {
26
+ let thisItemObject = theme.wiki.tree[page.wiki]
7
27
  if (thisItemObject == null) {
8
- return '';
28
+ return ''
9
29
  }
10
- const relatedItems = thisItemObject.relatedItems;
11
- var el = '';
30
+ const relatedItems = thisItemObject.relatedItems
31
+ var el = ''
12
32
  for (let relatedItem of relatedItems) {
13
- el += '<widget class="widget-wrapper related">';
14
- el += '<div class="widget-header cap theme dis-select">';
15
- el += '<span class="name">' + __('meta.more', relatedItem.name) + '</span>';
16
- el += '</div>';
17
- el += '<div class="widget-body related-posts">';
33
+ el += `<widget class="widget-wrapper related">`
34
+ el += `<div class="widget-header cap theme dis-select">`
35
+ el += `<span class="name">${__('meta.more') + __('symbol.colon') + relatedItem.name}</span>`
36
+ el += `</div>`
37
+ el += `<div class="widget-body related-posts">`
18
38
  for (let id of relatedItem.items) {
19
39
  // 同一个分组中的其它项目
20
- let item = theme.wiki.tree[id];
21
- el += '<a class="item wiki" href="' + url_for(item.homepage?.path) + '">';
22
- el += '<span class="title">' + item.title + '</span>';
40
+ let item = theme.wiki.tree[id]
41
+ el += `<a class="item wiki" href="${url_for(item.homepage?.path)}">`
42
+ el += `<span class="title">${item.title}</span>`
23
43
  if (item.description && item.description.length > 0) {
24
- el += '<span class="excerpt">' + item.description + '</span>';
44
+ el += `<span class="excerpt">${item.description}</span>`
25
45
  }
26
- el += '</a>';
46
+ el += `</a>`
27
47
  }
28
- el += '</div>';
29
- el += '</widget>';
48
+ el += `</div>`
49
+ el += `</widget>`
50
+ }
51
+ return el
52
+ }
53
+ function layoutDiv() {
54
+ if (page.layout == 'wiki') {
55
+ return relatedWiki()
56
+ } else if (page.layout == 'topic') {
57
+ return relatedPostsInTopic()
30
58
  }
31
- return el;
32
59
  }
33
60
  %>
34
61
  <%- layoutDiv() %>
@@ -2,7 +2,7 @@
2
2
  function layoutDiv() {
3
3
  var el = '<widget class="widget-wrapper search">'
4
4
  el += '<div class="widget-body">'
5
- el += '<div class="search-wrapper" id="search">'
5
+ el += '<div class="search-wrapper" id="search-wrapper">'
6
6
  el += '<form class="search-form">'
7
7
  var filter = ''
8
8
  if (item.filter == 'auto') {
@@ -27,7 +27,7 @@ function layoutDiv() {
27
27
  } else {
28
28
  el += ' placeholder="' + (item.placeholder || __('search.search')) + '">'
29
29
  }
30
- el += '<svg t="1670596976048" class="icon search-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2676" width="200" height="200"><path d="M938.2 832.6L723.8 618.1c-2.5-2.5-5.3-4.4-7.9-6.4 36.2-55.6 57.3-121.8 57.3-193.1C773.3 222.8 614.6 64 418.7 64S64 222.8 64 418.6c0 195.9 158.8 354.6 354.6 354.6 71.3 0 137.5-21.2 193.2-57.4 2 2.7 3.9 5.4 6.3 7.8L832.5 938c14.6 14.6 33.7 21.9 52.8 21.9 19.1 0 38.2-7.3 52.8-21.8 29.2-29.1 29.2-76.4 0.1-105.5M418.7 661.3C284.9 661.3 176 552.4 176 418.6 176 284.9 284.9 176 418.7 176c133.8 0 242.6 108.9 242.6 242.7 0 133.7-108.9 242.6-242.6 242.6" p-id="2677"></path></svg>'
30
+ el += '<svg t="1705074644177" class="icon search-icon" viewBox="0 0 1025 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1560" width="200" height="200"><path d="M1008.839137 935.96571L792.364903 719.491476a56.783488 56.783488 0 0 0-80.152866 0 358.53545 358.53545 0 1 1 100.857314-335.166073 362.840335 362.840335 0 0 1-3.689902 170.145468 51.248635 51.248635 0 1 0 99.217358 26.444296 462.057693 462.057693 0 1 0-158.255785 242.303546l185.930047 185.725053a51.248635 51.248635 0 0 0 72.568068 0 51.248635 51.248635 0 0 0 0-72.978056z" p-id="1561"></path><path d="M616.479587 615.969233a50.428657 50.428657 0 0 0-61.498362-5.534852 174.655348 174.655348 0 0 1-177.525271 3.484907 49.403684 49.403684 0 0 0-58.833433 6.76482l-3.074918 2.869923a49.403684 49.403684 0 0 0 8.609771 78.10292 277.767601 277.767601 0 0 0 286.992355-5.739847 49.403684 49.403684 0 0 0 8.404776-76.667958z" p-id="1562"></path></svg>'
31
31
  el += '</form>'
32
32
  el += '<div id="search-result"></div>'
33
33
  el += '<div class="search-no-result">' + __('search.no_results') + '</div>'
@@ -1,108 +1,116 @@
1
1
  <%
2
2
  let proj = theme.wiki.tree[page.wiki];
3
-
4
- function layoutToc() {
3
+ var hasTOC = true
4
+ function layoutTocBody() {
5
5
  if (toc(page.content).length > 0) {
6
+ hasTOC = true
6
7
  return toc(page.content, {
7
8
  list_number: item.list_number,
8
9
  min_depth: item.min_depth,
9
10
  max_depth: item.max_depth
10
11
  });
11
12
  }
12
- return '';
13
+ hasTOC = false
14
+ return ''
13
15
  }
14
16
 
15
17
  function layoutTocHeader(title) {
16
- var el = '';
17
- el += '<div class="widget-header cap dis-select">';
18
- el += '<span class="name">' + (title || page.title || __("meta.toc")) + '</span>';
19
- el += '</div>';
20
- return el;
18
+ var el = ''
19
+ el += `<div class="widget-header cap dis-select">`
20
+ el += `<span class="name">${title || __("meta.toc")}</span>`
21
+ el += `</div>`
22
+ return el
21
23
  }
22
24
 
23
25
  function layoutDocTree(pages) {
24
- var el = '';
26
+ var el = ''
25
27
  for (let p of pages) {
26
28
  if (p.title == null || p.title.length == 0) {
27
- continue;
29
+ continue
28
30
  }
29
- let isActive = '';
31
+ let isActive = ''
30
32
  if (p.path === page.path) {
31
- isActive += ' active';
33
+ isActive += ' active'
32
34
  }
33
- el += '<div class="doc-tree' + isActive + '">';
35
+ el += `<div class="doc-tree${isActive}">`
34
36
  if (proj.pages.length > 1) {
35
37
  let href = url_for(p.path);
36
38
  if (p.is_homepage) {
37
39
  href += '#start'
38
40
  }
39
- el += '<a class="doc-tree-link' + isActive + '" href="' + href + '">';
40
- el += '<span class="toc-text">' + p.title + '</span>';
41
- el += '</a>';
41
+ el += `<a class="doc-tree-link${isActive}" href="${href}">`
42
+ el += `<span class="toc-text">${p.title}</span>`
43
+ el += `</a>`
42
44
  }
43
45
  if (p.path === page.path) {
44
- el += layoutToc();
46
+ el += layoutTocBody()
45
47
  }
46
- el += '</div>';
48
+ el += `</div>`
47
49
  }
48
- return el;
50
+ return el
49
51
  }
50
52
 
51
53
 
52
54
  function layoutDiv(fallback) {
53
- var type = '';
55
+ var type = ''
54
56
  if (proj && proj.pages) {
55
57
  if (proj.pages.length > 1) {
56
- type = 'multi';
58
+ type = 'multi'
57
59
  } else {
58
- type = 'single';
60
+ type = 'single'
59
61
  }
60
62
  } else {
61
- let toc_content = toc(page.content);
63
+ let toc_content = toc(page.content)
62
64
  if (toc_content && toc_content.length > 0) {
63
- type = 'single';
65
+ type = 'single'
64
66
  }
65
67
  }
66
68
 
67
- var el = '';
69
+ var el = ''
68
70
  if (type.length > 0) {
69
- el += `<widget class="widget-wrapper toc ${type}" id="data-toc" collapse="${item.collapse}">`;
71
+ el += `<widget class="widget-wrapper toc ${type}" id="data-toc" collapse="${item.collapse}">`
70
72
  if (page.layout !== 'wiki') {
71
73
  // post 布局
72
- el += layoutTocHeader(page.toc_title);
73
- el += '<div class="widget-body fs14">';
74
- el += '<div class="doc-tree active">';
75
- el += layoutToc();
76
- el += '</div>';
77
- el += '</div>';
74
+ el += layoutTocHeader(page.toc_title)
75
+ el += `<div class="widget-body fs14">`
76
+ el += `<div class="doc-tree active">`
77
+ el += layoutTocBody()
78
+ el += `</div>`
79
+ el += `</div>`
80
+ if (hasTOC == false) {
81
+ return ''
82
+ }
78
83
  } else if (proj) {
79
84
  // wiki 布局
80
85
  if (proj.sections && proj.sections.length > 0 && proj.pages.length > 1) { // 多 pages
81
86
  for (let sec of proj.sections) {
82
87
  if (sec.pages.length == 0) {
83
- continue;
88
+ continue
84
89
  }
85
90
  if (sec.title?.length > 0) {
86
- el += layoutTocHeader(sec.title);
91
+ el += layoutTocHeader(sec.title)
87
92
  }
88
- el += '<div class="widget-body fs14">';
89
- el += layoutDocTree(sec.pages);
90
- el += '</div>';
93
+ el += `<div class="widget-body fs14">`
94
+ el += layoutDocTree(sec.pages)
95
+ el += `</div>`
91
96
  }
92
97
  } else { // 单 page
93
98
  if (proj.pages.length == 1) {
94
- el += layoutTocHeader(page.toc_title);
99
+ el += layoutTocHeader(page.toc_title)
100
+ }
101
+ el += `<div class="widget-body fs14">`
102
+ el += layoutDocTree(proj.pages)
103
+ el += `</div>`
104
+ if (hasTOC == false) {
105
+ return ''
95
106
  }
96
- el += '<div class="widget-body fs14">';
97
- el += layoutDocTree(proj.pages);
98
- el += '</div>';
99
107
  }
100
108
  }
101
- el += '</widget>';
109
+ el += `</widget>`
102
110
  } else if (item.fallback) {
103
- el += partial(item.fallback, {item: theme.data.widgets[item.fallback]});
111
+ el += partial(item.fallback, {item: theme.data.widgets[item.fallback]})
104
112
  }
105
- return el;
113
+ return el
106
114
  }
107
115
 
108
116
  %>
@@ -13,7 +13,7 @@ function layoutArchiveList() {
13
13
  el += partial('_partial/main/navbar/author_banner')
14
14
  } else {
15
15
  page.title = __('btn.archives')
16
- el += partial('_partial/main/navbar/list_post')
16
+ el += partial('_partial/main/navbar/nav_tabs_blog')
17
17
  }
18
18
  el += `<div class="post-list archives">`
19
19
  var years = []
@@ -7,7 +7,7 @@ if (page.menu_id == undefined) {
7
7
  <% if (site.categories.length) { %>
8
8
  <% page.title = __('btn.categories'); %>
9
9
  <% page.layout = 'categories'; %>
10
- <%- partial('_partial/main/navbar/list_post') %>
10
+ <%- partial('_partial/main/navbar/nav_tabs_blog') %>
11
11
  <div class='post-list'>
12
12
  <article class='<%- scrollreveal() %>' id='cats'>
13
13
  <% site.categories.sort('path').each(function(category){ %>
package/layout/index.ejs CHANGED
@@ -1,10 +1,6 @@
1
1
  <%
2
2
  if (page.menu_id == undefined) {
3
- if (page.layout === 'wiki_index' && page.wiki) {
4
- page.menu_id = 'wiki';
5
- } else {
6
- page.menu_id = 'post';
7
- }
3
+ page.menu_id = 'post';
8
4
  }
9
5
  if (page.title && page.wiki) {
10
6
  page.robots = 'noindex,follow';
@@ -48,42 +44,10 @@ function layout_post_list(partial) {
48
44
  return el;
49
45
  }
50
46
 
51
- function layout_wiki_list(partial) {
52
- var el = '';
53
- const { shelf, tree } = theme.wiki;
54
- for (let pid of shelf) {
55
- let proj = tree[pid];
56
- if (proj == null) {
57
- continue;
58
- }
59
- if (proj.pages == undefined || proj.pages.length === 0) {
60
- continue;
61
- }
62
- if (page.filter === false) {
63
- // wikiList
64
- el += '<div class="post-list wiki">';
65
- el += layout_post_card('wiki', proj.homepage, partial(proj));
66
- el += '</div>';
67
- } else if (proj.tags && proj.tags.includes(page.tagName) === true) {
68
- // filtered wikiList
69
- el += '<div class="post-list wiki filter">';
70
- el += layout_post_card('wiki', proj.homepage, partial(proj));
71
- el += '</div>';
72
- }
73
- }
74
- return el;
75
- }
76
47
  %>
77
48
 
78
- <% if (page.menu_id === 'post') { %>
79
- <%- partial('_partial/main/navbar/list_post') %>
80
- <%- layout_post_list(function(post){
81
- return partial('_partial/main/post_list/post_card', {post: post})
82
- }) %>
83
- <%- partial('_partial/main/post_list/paginator') %>
84
- <% } else if (page.menu_id === 'wiki') { %>
85
- <%- partial('_partial/main/navbar/list_wiki') %>
86
- <%- layout_wiki_list(function(proj){
87
- return partial('_partial/main/post_list/wiki_card', {proj: proj})
88
- }) %>
89
- <% } %>
49
+ <%- partial('_partial/main/navbar/nav_tabs_blog') %>
50
+ <%- layout_post_list(function(post){
51
+ return partial('_partial/main/post_list/post_card', {post: post})
52
+ }) %>
53
+ <%- partial('_partial/main/post_list/paginator') %>
@@ -0,0 +1,28 @@
1
+ <%
2
+ function layout_topic_list(partial) {
3
+ var el = ''
4
+ const { publish_list, tree } = theme.topic
5
+ for (let id of publish_list) {
6
+ const topic = tree[id]
7
+ if (topic == null) {
8
+ continue
9
+ }
10
+ el += `<div class="post-list wiki topic">`
11
+ el += `<a class="post-card wiki topic ${scrollreveal()}" href="${url_for(topic.homepage?.path || '/')}">`
12
+ el += partial(topic)
13
+ el += `</a>`
14
+ el += `</div>`
15
+ }
16
+ return el
17
+ }
18
+ function layoutDiv() {
19
+ var el = ''
20
+ el += partial('_partial/main/navbar/nav_tabs_blog')
21
+ el += layout_topic_list(function(topic) {
22
+ return partial('_partial/main/post_list/topic_card', {topic: topic})
23
+ })
24
+ return el
25
+ }
26
+ %>
27
+
28
+ <%- layoutDiv() %>
@@ -0,0 +1,42 @@
1
+ <%
2
+ function layout_wiki_list(partial) {
3
+ var el = ''
4
+ const { shelf, tree } = theme.wiki
5
+ for (let pid of shelf) {
6
+ let proj = tree[pid]
7
+ if (proj == null) {
8
+ continue
9
+ }
10
+ if (proj.pages == undefined || proj.pages.length === 0) {
11
+ continue
12
+ }
13
+ if (page.filter === false) {
14
+ // wikiList
15
+ el += `<div class="post-list wiki">`
16
+ el += `<a class="post-card wiki ${scrollreveal()}" href="${url_for(proj.homepage?.path || '/')}">`
17
+ el += partial(proj)
18
+ el += `</a>`
19
+ el += `</div>`
20
+ } else if (proj.tags && proj.tags.includes(page.tagName) === true) {
21
+ // filtered wikiList
22
+ el += `<div class="post-list wiki filter">`
23
+ el += `<a class="post-card wiki ${scrollreveal()}" href="${url_for(proj.homepage?.path || '/')}">`
24
+ el += partial(proj)
25
+ el += `</a>`
26
+ el += `</div>`
27
+ }
28
+ }
29
+ return el
30
+ }
31
+
32
+ function layoutDiv() {
33
+ var el = ''
34
+ el += partial('_partial/main/navbar/nav_tabs_wiki')
35
+ el += layout_wiki_list(function(proj) {
36
+ return partial('_partial/main/post_list/wiki_card', {proj: proj})
37
+ })
38
+ return el
39
+ }
40
+ %>
41
+
42
+ <%- layoutDiv() %>
package/layout/page.ejs CHANGED
@@ -9,8 +9,8 @@ function layoutTitle() {
9
9
  }
10
10
  function layoutDiv() {
11
11
  var el = '';
12
- if (page.post_list) {
13
- el += partial('_partial/main/navbar/list_post');
12
+ if (page.nav_tabs) {
13
+ el += partial('_partial/main/navbar/nav_tabs_blog');
14
14
  }
15
15
  if (page.h1 || page.title || (page.content && page.content.length > 0)) {
16
16
  el += partial('_partial/main/navbar/breadcrumb');
package/layout/tags.ejs CHANGED
@@ -7,7 +7,7 @@ if (page.menu_id == undefined) {
7
7
  <% if (site.tags.length) { %>
8
8
  <% page.title = __('btn.tags'); %>
9
9
  <% page.layout = 'tags'; %>
10
- <%- partial('_partial/main/navbar/list_post') %>
10
+ <%- partial('_partial/main/navbar/nav_tabs_blog') %>
11
11
  <div class='post-list'>
12
12
  <article class='<%- scrollreveal() %>' id='tags'>
13
13
  <% site.tags.sort('length', -1).each(function(tag){ %>
@@ -0,0 +1,28 @@
1
+ <%
2
+ if (page.menu_id == undefined) {
3
+ page.menu_id = 'post'
4
+ }
5
+ if (page.title == undefined) {
6
+ page.title = __('btn.topic')
7
+ }
8
+ function layoutTitle() {
9
+ const title = page.h1 != null ? page.h1 : page.title;
10
+ if (title && title.length > 0) {
11
+ return '<h1 class="article-title"><span>' + title + '</span></h1>';
12
+ } else {
13
+ return '';
14
+ }
15
+ }
16
+ %>
17
+
18
+ <%- partial('_partial/main/navbar/breadcrumb') %>
19
+ <article class='md-text content <%- page.layout %><%- page.indent ? ' indent' : '' %><%- scrollreveal() %>'>
20
+ <%- layoutTitle() %>
21
+ <%- markdown(page.content) %>
22
+ <% if (theme.plugins.tianli_gpt.enable && ['all', 'topic'].includes(theme.plugins.tianli_gpt.field)) { %>
23
+ <%- partial('_partial/plugins/ai/tianli_gpt') %>
24
+ <% } %>
25
+ <%- partial('_partial/main/article/article_footer') %>
26
+ </article>
27
+ <%- partial('_partial/main/article/read_next') %>
28
+ <%- partial('_partial/plugins/comments/layout') %>
package/layout/wiki.ejs CHANGED
@@ -2,9 +2,6 @@
2
2
  if (page.menu_id == undefined) {
3
3
  page.menu_id = 'wiki';
4
4
  }
5
- if (page.layout == undefined) {
6
- page.layout = 'wiki_index';
7
- }
8
5
  if (page.title == undefined) {
9
6
  if (page.tagName) {
10
7
  page.title = page.tagName;
@@ -21,23 +18,15 @@ function layoutTitle() {
21
18
  }
22
19
  }
23
20
  %>
24
- <% if (page.layout === 'wiki_index') { %>
25
- <%- partial('index') %>
26
- <% } else { %>
27
- <%
28
- if (page.header == undefined) {
29
- page.header = 'auto';
30
- }
31
- %>
32
- <%- partial('_partial/main/navbar/breadcrumb') %>
33
- <article class='md-text content <%- page.layout %><%- page.indent ? ' indent' : '' %><%- scrollreveal() %>'>
34
- <%- layoutTitle() %>
35
- <%- page.content %>
36
- <% if (theme.plugins.tianli_gpt.enable && ['all', 'wiki'].includes(theme.plugins.tianli_gpt.field)) { %>
37
- <%- partial('_partial/plugins/ai/tianli_gpt') %>
38
- <% } %>
39
- <%- partial('_partial/main/article/article_footer') %>
40
- </article>
41
- <%- partial('_partial/main/article/read_next') %>
42
- <%- partial('_partial/plugins/comments/layout') %>
21
+
22
+ <%- partial('_partial/main/navbar/breadcrumb') %>
23
+ <article class='md-text content <%- page.layout %><%- page.indent ? ' indent' : '' %><%- scrollreveal() %>'>
24
+ <%- layoutTitle() %>
25
+ <%- page.content %>
26
+ <% if (theme.plugins.tianli_gpt.enable && ['all', 'wiki'].includes(theme.plugins.tianli_gpt.field)) { %>
27
+ <%- partial('_partial/plugins/ai/tianli_gpt') %>
43
28
  <% } %>
29
+ <%- partial('_partial/main/article/article_footer') %>
30
+ </article>
31
+ <%- partial('_partial/main/article/read_next') %>
32
+ <%- partial('_partial/plugins/comments/layout') %>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-stellar",
3
- "version": "1.24.0",
3
+ "version": "1.25.0",
4
4
  "description": "Elegant and powerful theme for Hexo.",
5
5
  "main": "package.json",
6
6
  "scripts": {
@@ -8,9 +8,14 @@ hexo.on('generateBefore', () => {
8
8
  require('./lib/links')(hexo);
9
9
  require('./lib/authors')(hexo);
10
10
  require('./lib/doc_tree')(hexo);
11
+ require('./lib/topic_tree')(hexo);
11
12
  require('./lib/utils')(hexo);
12
13
  });
13
14
 
15
+ hexo.on('generateAfter', () => {
16
+ require('./lib/merge_posts')(hexo);
17
+ });
18
+
14
19
  hexo.on('ready', () => {
15
20
  const { version, homepage, repository } = require('../../package.json');
16
21
  hexo.log.info(`Welcome to Stellar ${version}
@@ -6,7 +6,7 @@
6
6
 
7
7
  module.exports = ctx => {
8
8
  var authors = ctx.locals.get('data').authors || {}
9
- let basePath = ctx.config.author_dir || 'author'
9
+ let basePath = ctx.theme.config.site_tree.author.base_dir
10
10
  // url
11
11
  for (let key of Object.keys(authors)) {
12
12
  let author = authors[key]
@@ -56,8 +56,8 @@ module.exports = hexo => {
56
56
  hexo.theme.config.data['widgets'] = widgets;
57
57
 
58
58
  // default menu
59
- if (hexo.theme.config.sidebar.menu == undefined) {
60
- hexo.theme.config.sidebar.menu = [];
59
+ if (hexo.theme.config.menu == undefined) {
60
+ hexo.theme.config.menu = {};
61
61
  }
62
62
 
63
63
  };
@@ -177,7 +177,7 @@ module.exports = ctx => {
177
177
  }
178
178
  all_tags[tag_name] = {
179
179
  name: tag_name,
180
- path: (ctx.config.wiki_dir || 'wiki') + '/tags/' + tag_name + '/index.html',
180
+ path: (ctx.theme.config.site_tree.wiki.base_dir) + '/tags/' + tag_name + '/index.html',
181
181
  items: items
182
182
  }
183
183
  })
@@ -0,0 +1,47 @@
1
+ /**
2
+ * merge_posts.js v1 | https://github.com/xaoxuu/hexo-theme-stellar/
3
+ *
4
+ */
5
+
6
+ 'use strict';
7
+
8
+ class RelatedPage {
9
+ constructor(page) {
10
+ this.id = page._id
11
+ this.wiki = page.wiki
12
+ this.topic = page.topic
13
+ this.title = page.title
14
+ this.seo_title = page.seo_title
15
+ this.path = page.path
16
+ this.path_key = page.path.replace('.html', '')
17
+ this.layout = page.layout
18
+ this.date = page.date
19
+ this.updated = page.updated
20
+ }
21
+ }
22
+
23
+ module.exports = ctx => {
24
+ var topic = ctx.theme.config.topic
25
+ const posts = ctx.locals.get('posts')
26
+ posts.sort('date').each(function(post) {
27
+ let obj = new RelatedPage(post)
28
+ // 合并拥有共同 topic 的文章到 topic.tree
29
+ if (post.topic?.length > 0) {
30
+ var topicObject = topic.tree[post.topic]
31
+ if (topicObject) {
32
+ obj.page_number = topicObject.pages.length + 1
33
+ topicObject.pages.push(obj)
34
+ }
35
+ }
36
+ })
37
+
38
+ // topic homepage
39
+ for (let tid of Object.keys(topic.tree)) {
40
+ let topicObject = topic.tree[tid]
41
+ if (topicObject.order_by == '-date') {
42
+ topicObject.pages = topicObject.pages.reverse()
43
+ }
44
+ topicObject.homepage = topicObject.pages[0]
45
+ }
46
+
47
+ }