hexo-theme-stellar 1.24.1 → 1.26.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 (136) hide show
  1. package/_config.yml +122 -50
  2. package/_data/icons.yml +33 -0
  3. package/_data/widgets.yml +2 -16
  4. package/languages/en.yml +2 -1
  5. package/languages/zh-CN.yml +3 -2
  6. package/languages/zh-TW.yml +3 -2
  7. package/layout/404.ejs +2 -4
  8. package/layout/_partial/cover/index.ejs +5 -5
  9. package/layout/_partial/cover/post_cover.ejs +1 -1
  10. package/layout/_partial/cover/wiki_cover.ejs +2 -2
  11. package/layout/_partial/head.ejs +6 -9
  12. package/layout/_partial/main/article/article_footer.ejs +16 -24
  13. package/layout/_partial/main/article/read_next.ejs +13 -13
  14. package/layout/_partial/main/article/related_posts.ejs +1 -1
  15. package/layout/_partial/main/footer.ejs +1 -1
  16. package/layout/_partial/main/navbar/article_top_area.ejs +35 -0
  17. package/layout/_partial/main/navbar/author_banner.ejs +1 -3
  18. package/layout/_partial/main/navbar/breadcrumb/blog.ejs +34 -0
  19. package/layout/_partial/main/navbar/breadcrumb/page.ejs +10 -0
  20. package/layout/_partial/main/navbar/breadcrumb/wiki.ejs +20 -0
  21. package/layout/_partial/main/navbar/dateinfo.ejs +32 -0
  22. package/layout/_partial/main/navbar/ghinfo.ejs +25 -0
  23. package/layout/_partial/main/navbar/{list_post.ejs → nav_tabs_blog.ejs} +15 -7
  24. package/layout/_partial/main/navbar/{list_wiki.ejs → nav_tabs_wiki.ejs} +15 -1
  25. package/layout/_partial/main/post_list/paginator.ejs +1 -1
  26. package/layout/_partial/main/post_list/post_card.ejs +4 -15
  27. package/layout/_partial/main/post_list/topic_card.ejs +16 -0
  28. package/layout/_partial/menubtn.ejs +1 -1
  29. package/layout/_partial/plugins/ai/tianli_gpt.ejs +4 -3
  30. package/layout/_partial/plugins/comments/artalk/layout.ejs +1 -1
  31. package/layout/_partial/plugins/comments/artalk/script.ejs +1 -1
  32. package/layout/_partial/plugins/comments/beaudar/layout.ejs +1 -1
  33. package/layout/_partial/plugins/comments/giscus/layout.ejs +1 -1
  34. package/layout/_partial/plugins/comments/layout.ejs +3 -3
  35. package/layout/_partial/plugins/comments/twikoo/layout.ejs +1 -1
  36. package/layout/_partial/plugins/comments/utterances/layout.ejs +1 -1
  37. package/layout/_partial/plugins/comments/waline/layout.ejs +1 -1
  38. package/layout/_partial/sidebar/index.ejs +92 -83
  39. package/layout/_partial/sidebar/logo.ejs +87 -0
  40. package/layout/_partial/sidebar/menu.ejs +23 -18
  41. package/layout/_partial/sidebar/search.ejs +42 -0
  42. package/layout/_partial/widgets/components/link.ejs +21 -0
  43. package/layout/_partial/widgets/components/linklist.ejs +27 -0
  44. package/layout/_partial/widgets/ghissues.ejs +7 -9
  45. package/layout/_partial/widgets/ghrepo.ejs +10 -12
  46. package/layout/_partial/widgets/ghuser.ejs +2 -6
  47. package/layout/_partial/widgets/linklist.ejs +17 -0
  48. package/layout/_partial/widgets/markdown.ejs +5 -2
  49. package/layout/_partial/widgets/recent.ejs +12 -8
  50. package/layout/_partial/widgets/related.ejs +51 -20
  51. package/layout/_partial/widgets/search.ejs +0 -40
  52. package/layout/_partial/widgets/tagcloud.ejs +2 -2
  53. package/layout/_partial/widgets/timeline.ejs +2 -2
  54. package/layout/_partial/widgets/toc.ejs +61 -53
  55. package/layout/archive.ejs +3 -3
  56. package/layout/categories.ejs +2 -2
  57. package/layout/index.ejs +10 -62
  58. package/layout/index_topic.ejs +28 -0
  59. package/layout/index_wiki.ejs +42 -0
  60. package/layout/layout.ejs +53 -21
  61. package/layout/page.ejs +60 -13
  62. package/layout/tags.ejs +2 -2
  63. package/package.json +2 -2
  64. package/scripts/events/index.js +5 -0
  65. package/scripts/events/lib/authors.js +1 -1
  66. package/scripts/events/lib/config.js +28 -24
  67. package/scripts/events/lib/doc_tree.js +27 -19
  68. package/scripts/events/lib/merge_posts.js +46 -0
  69. package/scripts/events/lib/topic_tree.js +45 -0
  70. package/scripts/generators/404.js +8 -3
  71. package/scripts/generators/author.js +4 -2
  72. package/scripts/generators/categories.js +4 -4
  73. package/scripts/generators/tags.js +4 -4
  74. package/scripts/generators/topic.js +21 -0
  75. package/scripts/generators/wiki.js +30 -28
  76. package/scripts/helpers/category_color.js +1 -1
  77. package/scripts/helpers/icon.js +16 -0
  78. package/scripts/helpers/parse_config.js +20 -18
  79. package/scripts/helpers/scrollreveal.js +6 -6
  80. package/scripts/tags/lib/audio.js +9 -4
  81. package/scripts/tags/lib/navbar.js +1 -1
  82. package/scripts/tags/lib/toc.js +1 -1
  83. package/scripts/tags/lib/video.js +8 -8
  84. package/source/css/_common/blur.styl +5 -9
  85. package/source/css/_common/cap.styl +1 -1
  86. package/source/css/_common/device.styl +2 -2
  87. package/source/css/_common/highlight.styl +3 -2
  88. package/source/css/_common/layout.styl +6 -0
  89. package/source/css/_common/svg.styl +3 -0
  90. package/source/css/_custom.styl +9 -2
  91. package/source/css/_defines/theme.styl +10 -0
  92. package/source/css/_layout/layout.styl +17 -4
  93. package/source/css/_layout/list.styl +5 -2
  94. package/source/css/_layout/main.styl +5 -4
  95. package/source/css/_layout/md.styl +12 -11
  96. package/source/css/_layout/partial/paginator.styl +2 -2
  97. package/source/css/_layout/partial/related.styl +3 -0
  98. package/source/css/_layout/sidebar/footer.styl +4 -31
  99. package/source/css/_layout/sidebar/{header.styl → logo.styl} +11 -41
  100. package/source/css/_layout/sidebar/menu.styl +53 -0
  101. package/source/css/_layout/sidebar/nav-area.styl +2 -0
  102. package/source/css/_layout/sidebar/search.styl +106 -0
  103. package/source/css/_layout/sidebar/sidebar.styl +21 -31
  104. package/source/css/_layout/tag-plugins/banner.styl +9 -7
  105. package/source/css/_layout/tag-plugins/frame.styl +1 -1
  106. package/source/css/_layout/tag-plugins/okr.styl +0 -1
  107. package/source/css/_layout/tag-plugins/tabs.styl +2 -2
  108. package/source/css/_layout/tag-plugins/toc.styl +1 -1
  109. package/source/css/_layout/widgets/components.styl +49 -0
  110. package/source/css/_layout/widgets/ghrepo.styl +0 -1
  111. package/source/css/_layout/widgets/ghuser.styl +0 -23
  112. package/source/css/_layout/widgets/list.styl +28 -0
  113. package/source/css/_layout/widgets/markdown.styl +20 -0
  114. package/source/css/_layout/widgets/related.styl +36 -5
  115. package/source/css/_layout/widgets/timeline.styl +21 -2
  116. package/source/css/_layout/widgets/toc_blog.styl +1 -1
  117. package/source/css/_layout/widgets/toc_common.styl +12 -12
  118. package/source/css/_layout/widgets/toc_wiki.styl +38 -25
  119. package/source/css/_layout/widgets/widgets.styl +25 -20
  120. package/source/css/_plugins/comments/twikoo.styl +9 -9
  121. package/source/css/_plugins/scrollreveal.styl +1 -1
  122. package/source/css/_plugins/tianli_gpt.styl +12 -14
  123. package/source/js/main.js +5 -2
  124. package/source/js/plugins/copycode.js +3 -3
  125. package/source/js/plugins/fcircle.js +1 -1
  126. package/source/js/plugins/friends.js +1 -1
  127. package/source/js/plugins/memos.js +1 -1
  128. package/source/js/plugins/sites.js +2 -2
  129. package/source/js/plugins/weibo.js +1 -1
  130. package/layout/_partial/main/header/index.ejs +0 -3
  131. package/layout/_partial/main/navbar/breadcrumb.ejs +0 -139
  132. package/layout/_partial/sidebar/header.ejs +0 -59
  133. package/layout/post.ejs +0 -33
  134. package/layout/wiki.ejs +0 -43
  135. package/source/css/_layout/widgets/recent.styl +0 -15
  136. package/source/css/_layout/widgets/search.styl +0 -102
@@ -1,34 +1,65 @@
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 ''
9
+ }
10
+ var el = ''
11
+ el += `<widget class="widget-wrapper${scrollreveal(' ')} post-list">`
12
+ el += `<div class="widget-header dis-select">`
13
+ el += `<span class="name">${__('btn.topic') + __('symbol.colon') + topic.name}</span>`
14
+ el += `</div>`
15
+ el += `<div class="widget-body">`
16
+ for (let post of topic.pages) {
17
+ const isActive = post.path == page.path
18
+ el += `<a class="item${isActive ? ' active' : ''}" href="${url_for(post.path)}">`
19
+ el += `<span class="title">${post.title}</span>`
20
+ if (isActive) {
21
+ el += icon('default:bookmark.active')
22
+ }
23
+ el += `</a>`
5
24
  }
6
- let thisItemObject = theme.wiki.tree[page.wiki];
25
+ el += `</div>`
26
+ el += `</widget>`
27
+ return el
28
+ }
29
+ function relatedWiki() {
30
+ let thisItemObject = theme.wiki.tree[page.wiki]
7
31
  if (thisItemObject == null) {
8
- return '';
32
+ return ''
9
33
  }
10
- const relatedItems = thisItemObject.relatedItems;
11
- var el = '';
34
+ const relatedItems = thisItemObject.relatedItems
35
+ var el = ''
12
36
  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">';
37
+ el += `<widget class="widget-wrapper${scrollreveal(' ')} post-card">`
38
+ el += `<div class="widget-header dis-select">`
39
+ el += `<span class="name">${__('meta.more') + __('symbol.colon') + relatedItem.name}</span>`
40
+ el += `</div>`
41
+ el += `<div class="widget-body">`
18
42
  for (let id of relatedItem.items) {
19
43
  // 同一个分组中的其它项目
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>';
44
+ let item = theme.wiki.tree[id]
45
+ el += `<a class="item wiki" href="${url_for(item.homepage?.path)}">`
46
+ el += `<span class="title">${item.title}</span>`
23
47
  if (item.description && item.description.length > 0) {
24
- el += '<span class="excerpt">' + item.description + '</span>';
48
+ el += `<span class="excerpt">${item.description}</span>`
25
49
  }
26
- el += '</a>';
50
+ el += `</a>`
27
51
  }
28
- el += '</div>';
29
- el += '</widget>';
52
+ el += `</div>`
53
+ el += `</widget>`
54
+ }
55
+ return el
56
+ }
57
+ function layoutDiv() {
58
+ if (page.wiki?.length > 0) {
59
+ return relatedWiki()
60
+ } else if (page.topic?.length > 0) {
61
+ return relatedPostsInTopic()
30
62
  }
31
- return el;
32
63
  }
33
64
  %>
34
65
  <%- layoutDiv() %>
@@ -1,40 +0,0 @@
1
- <%
2
- function layoutDiv() {
3
- var el = '<widget class="widget-wrapper search">'
4
- el += '<div class="widget-body">'
5
- el += '<div class="search-wrapper" id="search-wrapper">'
6
- el += '<form class="search-form">'
7
- var filter = ''
8
- if (item.filter == 'auto') {
9
- if (page.layout == 'wiki') {
10
- let matches = page.path.match(/(.*?)\/(.*?)\//i)
11
- if (matches?.length > 0) {
12
- filter = matches[0]
13
- }
14
- }
15
- } else {
16
- if (item.filter?.length > 0) {
17
- filter = item.filter
18
- }
19
- }
20
- el += '<input type="text" class="search-input" id="search-input"'
21
- if (filter.length > 0) {
22
- if (!filter.startsWith('/')) {
23
- filter = '/' + filter
24
- }
25
- el += ' data-filter="' + filter + '"'
26
- el += ' placeholder="' + (item.placeholder || __('search.search_in', filter)) + '">'
27
- } else {
28
- el += ' placeholder="' + (item.placeholder || __('search.search')) + '">'
29
- }
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" fill="#111111" 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" fill="#00C569" p-id="1562"></path></svg>'
31
- el += '</form>'
32
- el += '<div id="search-result"></div>'
33
- el += '<div class="search-no-result">' + __('search.no_results') + '</div>'
34
- el += '</div>'
35
- el += '</div>'
36
- el += '</widget>'
37
- return el
38
- }
39
- %>
40
- <%- layoutDiv() %>
@@ -8,9 +8,9 @@ function layoutDiv() {
8
8
  delete opts['title'];
9
9
  delete opts['layout'];
10
10
  opts.class = 'tag ';
11
- el += '<widget class="widget-wrapper tagcloud">';
11
+ el += `<widget class="widget-wrapper${scrollreveal(' ')} tagcloud">`
12
12
  if (item.title) {
13
- el += '<div class="widget-header cap theme dis-select">';
13
+ el += '<div class="widget-header dis-select">';
14
14
  el += '<span class="name">' + item.title + '</span>';
15
15
  el += '</div>';
16
16
  }
@@ -4,9 +4,9 @@ function layoutDiv() {
4
4
  if (item.api == undefined) {
5
5
  return el;
6
6
  }
7
- el += '<widget class="widget-wrapper timeline">';
7
+ el += `<widget class="widget-wrapper${scrollreveal(' ')} timeline">`
8
8
  if (item.title) {
9
- el += '<div class="widget-header cap theme dis-select">';
9
+ el += '<div class="widget-header dis-select">';
10
10
  el += '<span class="name">' + item.title + '</span>';
11
11
  el += '</div>';
12
12
  }
@@ -1,108 +1,116 @@
1
1
  <%
2
- let proj = theme.wiki.tree[page.wiki];
3
-
4
- function layoutToc() {
2
+ const proj = theme.wiki.tree[page.wiki]
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 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
+ if (isActive.length > 0) {
44
+ el += icon('default:bookmark.active')
45
+ }
46
+ el += `</a>`
42
47
  }
43
48
  if (p.path === page.path) {
44
- el += layoutToc();
49
+ el += layoutTocBody()
45
50
  }
46
- el += '</div>';
51
+ el += `</div>`
47
52
  }
48
- return el;
53
+ return el
49
54
  }
50
55
 
51
56
 
52
57
  function layoutDiv(fallback) {
53
- var type = '';
54
- if (proj && proj.pages) {
55
- if (proj.pages.length > 1) {
56
- type = 'multi';
57
- } else {
58
- type = 'single';
59
- }
58
+ var type = ''
59
+ if (proj?.pages) {
60
+ type = proj.pages.length > 1 ? 'multi' : 'single'
60
61
  } else {
61
- let toc_content = toc(page.content);
62
+ let toc_content = toc(page.content)
62
63
  if (toc_content && toc_content.length > 0) {
63
- type = 'single';
64
+ type = 'single'
64
65
  }
65
66
  }
66
67
 
67
- var el = '';
68
+ var el = ''
68
69
  if (type.length > 0) {
69
- el += `<widget class="widget-wrapper toc ${type}" id="data-toc" collapse="${item.collapse}">`;
70
- if (page.layout !== 'wiki') {
71
- // 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>';
78
- } else if (proj) {
70
+ el += `<widget class="widget-wrapper${scrollreveal(' ')} toc ${type}" id="data-toc" collapse="${item.collapse}">`
71
+ if (proj) {
79
72
  // wiki 布局
80
73
  if (proj.sections && proj.sections.length > 0 && proj.pages.length > 1) { // 多 pages
81
74
  for (let sec of proj.sections) {
82
75
  if (sec.pages.length == 0) {
83
- continue;
76
+ continue
84
77
  }
85
78
  if (sec.title?.length > 0) {
86
- el += layoutTocHeader(sec.title);
79
+ el += layoutTocHeader(sec.title)
87
80
  }
88
- el += '<div class="widget-body fs14">';
89
- el += layoutDocTree(sec.pages);
90
- el += '</div>';
81
+ el += `<div class="widget-body fs14">`
82
+ el += layoutDocTree(sec.pages)
83
+ el += `</div>`
91
84
  }
92
85
  } else { // 单 page
93
86
  if (proj.pages.length == 1) {
94
- el += layoutTocHeader(page.toc_title);
87
+ el += layoutTocHeader()
88
+ }
89
+ el += `<div class="widget-body fs14">`
90
+ el += layoutDocTree(proj.pages)
91
+ el += `</div>`
92
+ if (hasTOC == false) {
93
+ return ''
95
94
  }
96
- el += '<div class="widget-body fs14">';
97
- el += layoutDocTree(proj.pages);
98
- el += '</div>';
99
95
  }
100
- }
101
- el += '</widget>';
96
+ } else {
97
+ // post 布局
98
+ el += layoutTocHeader()
99
+ el += `<div class="widget-body fs14">`
100
+ el += `<div class="doc-tree active">`
101
+ el += layoutTocBody()
102
+ el += `</div>`
103
+ el += `</div>`
104
+ if (hasTOC == false) {
105
+ return ''
106
+ }
107
+ }
108
+ el += `</widget>`
102
109
  } else if (item.fallback) {
103
- el += partial(item.fallback, {item: theme.data.widgets[item.fallback]});
110
+ const fallback = theme.widgets[item.fallback]
111
+ el += partial(fallback.layout, {item: fallback})
104
112
  }
105
- return el;
113
+ return el
106
114
  }
107
115
 
108
116
  %>
@@ -4,7 +4,7 @@ if (page.menu_id == undefined) {
4
4
  page.menu_id = 'post';
5
5
  }
6
6
  if (page.author) {
7
- page.header = 'auto';
7
+ page.header = false;
8
8
  }
9
9
  function layoutArchiveList() {
10
10
  var el = ''
@@ -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 = []
@@ -24,7 +24,7 @@ function layoutArchiveList() {
24
24
  }
25
25
  })
26
26
  for (let year of years) {
27
- el += `<article class="${scrollreveal()}" id="archive">`
27
+ el += `<article class="${scrollreveal('')}" id="archive">`
28
28
  el += `<div class='archive-header h4'>${year}</div>`
29
29
  site.posts.sort('date', -1).filter(function (post) {
30
30
  post.year = date(post.date, 'YYYY')
@@ -7,9 +7,9 @@ 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
- <article class='<%- scrollreveal() %>' id='cats'>
12
+ <article class='<%- scrollreveal("") %>' id='cats'>
13
13
  <% site.categories.sort('path').each(function(category){ %>
14
14
  <div>
15
15
  <a class="<%= category.parent ? 'cat child' : 'cat'%>" href="<%= url_for(category.path) %>">
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';
@@ -16,7 +12,7 @@ function layout_post_card(layout, post, content) {
16
12
  if (layout == 'post' && post.cover != undefined && post.poster != undefined) {
17
13
  layout += ' photo';
18
14
  }
19
- el += '<a class="post-card ' + layout + ' ' + scrollreveal() + '" href="' + url_for(post.link || post.path) + '">';
15
+ el += `<a class="post-card${scrollreveal(' ')} ${layout}" href="${url_for(post.link || post.path)}">`
20
16
  el += content;
21
17
  el += '</a>';
22
18
  return el;
@@ -25,65 +21,17 @@ function layout_post_card(layout, post, content) {
25
21
  function layout_post_list(partial) {
26
22
  var el = '';
27
23
  el += '<div class="post-list post">';
28
- if (is_home()) {
29
- // pinned posts
30
- if (page.current == 1) {
31
- var pinned = site.posts.filter(post => post.pin != undefined).sort((config.index_generator && config.index_generator.order_by) || '-date');
32
- pinned.forEach((post, i) => {
33
- el += layout_post_card('post', post, partial(post));
34
- });
35
- }
36
- // unpinned posts
37
- page.posts.each(function(post){
38
- if (post.pin == undefined) {
39
- el += layout_post_card('post', post, partial(post));
40
- }
41
- })
42
- } else {
43
- page.posts.each(function(post){
44
- el += layout_post_card('post', post, partial(post));
45
- })
46
- }
24
+ page.posts.each(function(post){
25
+ el += layout_post_card('post', post, partial(post));
26
+ })
47
27
  el += '</div>';
48
28
  return el;
49
29
  }
50
30
 
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
31
  %>
77
32
 
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
- <% } %>
33
+ <%- partial('_partial/main/navbar/nav_tabs_blog') %>
34
+ <%- layout_post_list(function(post){
35
+ return partial('_partial/main/post_list/post_card', {post: post})
36
+ }) %>
37
+ <%- 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/layout.ejs CHANGED
@@ -1,21 +1,53 @@
1
- <!DOCTYPE html>
2
- <html lang='<%- page.lang %>'>
3
- <%- partial('_partial/head') %>
4
- <body>
5
- <%- partial('_partial/cover/index') %>
6
- <div class='l_body' id='start'>
7
- <aside class='l_left' layout='<%- page.layout %>'>
8
- <%- partial('_partial/sidebar/index') %>
9
- </aside>
10
- <div class='l_main<%- page.content ? "" : " list" %>'>
11
- <%- partial('_partial/main/header/index') %>
12
- <%- body %>
13
- <%- partial('_partial/main/footer') %>
14
- <%- partial('_partial/menubtn') %>
15
- </div>
16
- </div>
17
- <div class='scripts'>
18
- <%- partial('_partial/scripts/index') %>
19
- </div>
20
- </body>
21
- </html>
1
+ <%
2
+ // 页面类型:索引页面还是内容页面
3
+ var page_type = 'index'
4
+ if (['post', 'page', 'wiki', null].includes(page.layout)) {
5
+ if (!page.nav_tabs) {
6
+ page_type = 'content'
7
+ }
8
+ }
9
+ // 文章类型:技术类文章/文学类文章
10
+ var article_type = theme.article.type
11
+ if (page.type?.length > 0) {
12
+ article_type = page.type
13
+ }
14
+ // 是否缩进
15
+ var indent = false
16
+ if (page.indent != null) {
17
+ indent = page.indent
18
+ } else if (theme.topic.tree[page.topic]?.indent != null) {
19
+ indent = theme.topic.tree[page.topic]?.indent
20
+ } else if (theme.wiki.tree[page.wiki]?.indent != null) {
21
+ indent = theme.wiki.tree[page.wiki]?.indent
22
+ } else if (theme.article.indent != null) {
23
+ indent = theme.article.indent
24
+ } else {
25
+ indent = article_type === 'story'
26
+ }
27
+
28
+ var html = `<!DOCTYPE html>`
29
+ html += `<html lang="${page.lang}">`
30
+ html += partial('_partial/head')
31
+ html += `<body>`
32
+ html += partial('_partial/cover/index')
33
+ html += `<div class="l_body ${page_type} ${article_type}" id="start" layout="${page.layout}" ${indent ? 'text-indent' : ''}>`
34
+ html += `<aside class="l_left">`
35
+ html += `<div class="sidebar-container${theme.style.sidebar?.blur ? ' sidebar-blur' : ''}">`
36
+ html += partial('_partial/sidebar/index')
37
+ html += `</div>`
38
+ html += `</aside>`
39
+ html += `<div class="l_main" id="main">`
40
+ html += partial('_partial/sidebar/logo', {where: 'main'})
41
+ html += body
42
+ html += partial('_partial/main/footer')
43
+ html += partial('_partial/menubtn')
44
+ html += `<div class="main-mask" onclick="sidebar.toggle()"></div>`
45
+ html += `</div>`
46
+ html += `</div>`
47
+ html += `<div class="scripts">`
48
+ html += partial('_partial/scripts/index')
49
+ html += `</div>`
50
+ html += `</body>`
51
+ html += `</html>`
52
+ %>
53
+ <%- html %>