hexo-theme-stellar 1.26.8 → 1.28.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 (154) hide show
  1. package/_config.yml +139 -95
  2. package/_data/icons.yml +8 -1
  3. package/_data/widgets.yml +19 -7
  4. package/languages/en.yml +5 -2
  5. package/languages/zh-CN.yml +4 -1
  6. package/languages/zh-TW.yml +5 -2
  7. package/layout/404.ejs +1 -1
  8. package/layout/_partial/{plugins/comments → comments}/artalk/script.ejs +2 -2
  9. package/layout/_partial/{plugins/comments/utterances → comments/giscus}/layout.ejs +5 -2
  10. package/layout/_partial/{plugins/comments → comments}/giscus/script.ejs +1 -4
  11. package/layout/_partial/{plugins/comments → comments}/layout.ejs +14 -9
  12. package/layout/_partial/{plugins/comments → comments}/twikoo/script.ejs +1 -1
  13. package/layout/_partial/comments/waline/script.ejs +43 -0
  14. package/layout/_partial/head.ejs +2 -2
  15. package/layout/_partial/main/article/article_footer.ejs +1 -1
  16. package/layout/_partial/main/footer.ejs +1 -1
  17. package/layout/_partial/main/navbar/article_banner.ejs +81 -17
  18. package/layout/_partial/main/navbar/ghinfo.ejs +1 -1
  19. package/layout/_partial/main/post_list/post_card.ejs +1 -1
  20. package/layout/_partial/menubtn.ejs +6 -3
  21. package/layout/_partial/scripts/defines.ejs +31 -0
  22. package/layout/_partial/scripts/services.ejs +29 -0
  23. package/layout/_partial/scripts/sidebar.ejs +25 -0
  24. package/layout/_partial/scripts/utils.ejs +158 -0
  25. package/layout/_partial/scripts.ejs +32 -0
  26. package/layout/_partial/sidebar/{index.ejs → index_leftbar.ejs} +22 -20
  27. package/layout/_partial/sidebar/index_rightbar.ejs +84 -0
  28. package/layout/_partial/sidebar/logo.ejs +1 -1
  29. package/layout/_partial/widgets/author.ejs +37 -0
  30. package/layout/_partial/widgets/components/edit.ejs +24 -0
  31. package/layout/_partial/widgets/ghissues.ejs +1 -1
  32. package/layout/_partial/widgets/ghrepo.ejs +2 -2
  33. package/layout/_partial/widgets/ghuser.ejs +2 -2
  34. package/layout/_partial/widgets/markdown.ejs +1 -1
  35. package/layout/_partial/widgets/recent.ejs +1 -5
  36. package/layout/_partial/widgets/related.ejs +1 -1
  37. package/layout/_partial/widgets/timeline.ejs +1 -1
  38. package/layout/_partial/widgets/toc.ejs +38 -85
  39. package/layout/_partial/widgets/tree.ejs +71 -0
  40. package/layout/_plugins/copycode.ejs +13 -0
  41. package/layout/_plugins/fancybox.ejs +32 -0
  42. package/layout/_plugins/heti.ejs +21 -0
  43. package/layout/_plugins/index.ejs +24 -0
  44. package/layout/_plugins/lazyload.ejs +21 -0
  45. package/layout/{_partial/plugins/parser/mathjax/script.ejs → _plugins/mathjax.ejs} +1 -1
  46. package/layout/_plugins/mermaid.ejs +29 -0
  47. package/layout/_plugins/preload.ejs +9 -0
  48. package/layout/_plugins/scrollreveal.ejs +15 -0
  49. package/layout/_plugins/search/algolia_search.ejs +13 -0
  50. package/layout/_plugins/search/local_search.ejs +8 -0
  51. package/layout/_plugins/swiper.ejs +26 -0
  52. package/layout/_plugins/tianli_gpt.ejs +14 -0
  53. package/layout/archive.ejs +9 -2
  54. package/layout/layout.ejs +9 -6
  55. package/layout/page.ejs +2 -10
  56. package/package.json +1 -1
  57. package/scripts/events/lib/doc_tree.js +8 -8
  58. package/scripts/events/lib/topic_tree.js +3 -0
  59. package/scripts/generators/author.js +3 -2
  60. package/scripts/helpers/parse_config.js +6 -5
  61. package/scripts/tags/lib/albums.js +2 -2
  62. package/scripts/tags/lib/button.js +1 -1
  63. package/scripts/tags/lib/emoji.js +1 -1
  64. package/scripts/tags/lib/friends.js +1 -1
  65. package/scripts/tags/lib/icon.js +10 -5
  66. package/scripts/tags/lib/link.js +2 -2
  67. package/scripts/tags/lib/md.js +1 -1
  68. package/scripts/tags/lib/posters.js +2 -2
  69. package/scripts/tags/lib/sites.js +1 -1
  70. package/scripts/tags/lib/timeline.js +2 -2
  71. package/source/css/_common/button.styl +8 -2
  72. package/source/css/_common/device.styl +39 -12
  73. package/source/css/_custom.styl +15 -16
  74. package/source/css/_defines/const.styl +1 -1
  75. package/source/css/_defines/func.styl +14 -4
  76. package/source/css/_defines/theme.styl +38 -27
  77. package/source/css/_layout/layout.styl +62 -27
  78. package/source/css/_layout/list.styl +1 -1
  79. package/source/css/_layout/main.styl +1 -4
  80. package/source/css/_layout/md.styl +16 -2
  81. package/source/css/_layout/pages/archives.styl +4 -0
  82. package/source/css/_layout/partial/article-banner.styl +14 -15
  83. package/source/css/_layout/partial/article-footer.styl +0 -5
  84. package/source/css/_layout/partial/footer.styl +9 -6
  85. package/source/css/_layout/partial/related.styl +4 -0
  86. package/source/css/_layout/sidebar/footer.styl +3 -1
  87. package/source/css/_layout/sidebar/logo.styl +3 -1
  88. package/source/css/_layout/sidebar/menu.styl +1 -1
  89. package/source/css/_layout/sidebar/nav-area.styl +1 -1
  90. package/source/css/_layout/sidebar/sidebar.styl +25 -16
  91. package/source/css/_layout/tag-plugins/banner.styl +1 -8
  92. package/source/css/_layout/tag-plugins/common.styl +10 -5
  93. package/source/css/_layout/tag-plugins/emoji.styl +1 -0
  94. package/source/css/_layout/tag-plugins/icon.styl +6 -0
  95. package/source/css/_layout/tag-plugins/image.styl +1 -1
  96. package/source/css/_layout/tag-plugins/quot.styl +1 -1
  97. package/source/css/_layout/tag-plugins/timeline.styl +26 -27
  98. package/source/css/_layout/widgets/ghrepo.styl +1 -1
  99. package/source/css/_layout/widgets/ghuser.styl +9 -5
  100. package/source/css/_layout/widgets/list.styl +4 -3
  101. package/source/css/_layout/widgets/related.styl +0 -1
  102. package/source/css/_layout/widgets/timeline.styl +27 -21
  103. package/source/css/_layout/widgets/toc.styl +182 -0
  104. package/source/css/_layout/widgets/tree.styl +0 -0
  105. package/source/css/_layout/widgets/widgets.styl +26 -7
  106. package/source/css/_plugins/comments/twikoo.styl +103 -59
  107. package/source/css/_plugins/comments/waline.styl +13 -10
  108. package/source/css/_plugins/index.styl +2 -0
  109. package/source/css/_plugins/katex.styl +5 -0
  110. package/source/css/_plugins/mermaid.styl +49 -59
  111. package/source/css/_plugins/tianli_gpt.styl +208 -151
  112. package/source/js/main.js +52 -251
  113. package/source/js/plugins/copycode.js +28 -41
  114. package/source/js/search/algolia-search.js +75 -0
  115. package/source/js/search/local-search.js +32 -0
  116. package/source/js/services/fcircle.js +36 -0
  117. package/source/js/services/friends.js +27 -0
  118. package/source/js/services/ghinfo.js +33 -0
  119. package/source/js/services/mdrender.js +10 -0
  120. package/source/js/services/memos.js +73 -0
  121. package/source/js/services/siteinfo.js +38 -0
  122. package/source/js/services/sites.js +30 -0
  123. package/source/js/services/timeline.js +106 -0
  124. package/source/js/services/weibo.js +60 -0
  125. package/layout/_partial/main/navbar/article_top_area.ejs +0 -35
  126. package/layout/_partial/main/navbar/author_banner.ejs +0 -29
  127. package/layout/_partial/plugins/ai/tianli_gpt.ejs +0 -9
  128. package/layout/_partial/plugins/comments/waline/script.ejs +0 -39
  129. package/layout/_partial/plugins/parser/head.ejs +0 -3
  130. package/layout/_partial/plugins/parser/katex/head.ejs +0 -3
  131. package/layout/_partial/plugins/parser/katex/script.ejs +0 -4
  132. package/layout/_partial/plugins/parser/mermaid/script.ejs +0 -29
  133. package/layout/_partial/plugins/parser/script.ejs +0 -9
  134. package/layout/_partial/scripts/index.ejs +0 -176
  135. package/source/css/_layout/widgets/toc_blog.styl +0 -3
  136. package/source/css/_layout/widgets/toc_common.styl +0 -92
  137. package/source/css/_layout/widgets/toc_wiki.styl +0 -62
  138. package/source/js/plugins/fcircle.js +0 -92
  139. package/source/js/plugins/friends.js +0 -84
  140. package/source/js/plugins/ghinfo.js +0 -85
  141. package/source/js/plugins/linkcard.js +0 -48
  142. package/source/js/plugins/marked.js +0 -50
  143. package/source/js/plugins/memos.js +0 -132
  144. package/source/js/plugins/sites.js +0 -87
  145. package/source/js/plugins/timeline.js +0 -162
  146. package/source/js/plugins/weibo.js +0 -116
  147. /package/layout/_partial/{plugins/comments → comments}/artalk/layout.ejs +0 -0
  148. /package/layout/_partial/{plugins/comments → comments}/beaudar/layout.ejs +0 -0
  149. /package/layout/_partial/{plugins/comments → comments}/beaudar/script.ejs +0 -0
  150. /package/layout/_partial/{plugins/comments → comments}/script.ejs +0 -0
  151. /package/layout/_partial/{plugins/comments → comments}/twikoo/layout.ejs +0 -0
  152. /package/layout/_partial/{plugins/comments/giscus → comments/utterances}/layout.ejs +0 -0
  153. /package/layout/_partial/{plugins/comments → comments}/utterances/script.ejs +0 -0
  154. /package/layout/_partial/{plugins/comments → comments}/waline/layout.ejs +0 -0
@@ -0,0 +1,84 @@
1
+ <%
2
+
3
+ const wiki = theme.wiki.tree[page.wiki]
4
+ const topic = theme.topic.tree[page.topic]
5
+
6
+ if (page.rightbar == null) {
7
+ const { site_tree } = theme
8
+ var sidebar
9
+ if (is_home()) {
10
+ sidebar = site_tree.home.rightbar
11
+ } else if (is_category() || is_tag() || is_archive() || ['categories', 'tags', 'archives'].includes(page.layout)) {
12
+ sidebar = site_tree.index_blog.rightbar
13
+ } else if (page.layout === 'index_topic') {
14
+ // 专栏列表页等同于博客列表页
15
+ sidebar = site_tree.index_blog.rightbar
16
+ } else if (page.topic?.length > 0) {
17
+ // 专栏文章内页等同于普通文章内页
18
+ sidebar = site_tree.post.rightbar
19
+ } else if (page.layout === 'index_wiki') {
20
+ sidebar = site_tree.index_wiki.rightbar
21
+ } else if (page.wiki?.length > 0) {
22
+ sidebar = site_tree.wiki.rightbar
23
+ } else if (page.layout === '404') {
24
+ sidebar = site_tree.error_page.rightbar
25
+ } else if (page.layout === 'page') {
26
+ sidebar = site_tree.page.rightbar
27
+ } else if (page.layout === 'post') {
28
+ sidebar = site_tree.post.rightbar
29
+ } else if (page.layout == null) {
30
+ sidebar = site_tree.page.rightbar
31
+ } else {
32
+ sidebar = []
33
+ }
34
+
35
+ if (topic?.rightbar) {
36
+ sidebar = topic.rightbar
37
+ }
38
+ if (wiki?.rightbar) {
39
+ sidebar = wiki.rightbar
40
+ }
41
+
42
+ page.rightbar = sidebar
43
+ }
44
+
45
+
46
+ // parse array string
47
+ if (typeof page.rightbar == 'string') {
48
+ page.rightbar = page.rightbar.replace(/ /g, '').split(',');
49
+ }
50
+
51
+ function layoutWidgets() {
52
+ if (page.rightbar == null || page.rightbar.length == 0) {
53
+ return ''
54
+ }
55
+ var el = ''
56
+ if (page.rightbar) {
57
+ page.rightbar.forEach((w, i) => {
58
+ let name = ''
59
+ let widget = {}
60
+ if (typeof w == 'string') {
61
+ name = w
62
+ } else if (typeof w == 'object' && w.override) {
63
+ name = w.override
64
+ }
65
+ if (name in theme.widgets) {
66
+ Object.assign(widget, theme.widgets[name])
67
+ }
68
+ if (typeof w == 'object' && (w.override || w.layout)) {
69
+ Object.assign(widget, w)
70
+ }
71
+ if (widget && widget.layout) {
72
+ el += partial('../widgets/' + widget.layout, {item: widget})
73
+ }
74
+ });
75
+ }
76
+ if (el.trim().length > 0) {
77
+ return `<div class="widgets">${el}</div>`
78
+ } else {
79
+ return ''
80
+ }
81
+ }
82
+
83
+ %>
84
+ <%- layoutWidgets() %>
@@ -67,7 +67,7 @@ function layoutDiv() {
67
67
  const main = md_text(logo.title)
68
68
  if (main) {
69
69
  let url = md_link(logo.title)
70
- el += layoutTitle(main, url, logo.subtitle)
70
+ el += layoutTitle(main, url, md_text(logo.subtitle))
71
71
  }
72
72
  el += `</div>`
73
73
  el += '</header>'
@@ -0,0 +1,37 @@
1
+ <%
2
+
3
+ var author = null
4
+ if (theme.authors) {
5
+ if (page.author?.length > 0 && theme.authors[page.author] != null) {
6
+ author = theme.authors[page.author]
7
+ } else {
8
+ author = theme.default_author
9
+ }
10
+ }
11
+
12
+ function layoutDiv() {
13
+ if (author == null) {
14
+ return ''
15
+ }
16
+ var el = ''
17
+ el += `<widget class="widget-wrapper${scrollreveal(' ')} user-card author">`
18
+ // body
19
+ el += `<div class="widget-body">`
20
+ if (item.avatar) {
21
+ el += `<div class="avatar"><img type="img" id="avatar_url" src="${author.avatar}"></div>`
22
+ }
23
+ // username
24
+ el += `<p class="username" ff="title" type="text" id="name">${author.name}</p>`
25
+ el += `<p class="bio" type="text" id="bio">${author.desc || author.description}</p>`
26
+
27
+ // homepage
28
+ el += `<a class="follow" href="${url_for(author.path)}">`
29
+ el += icon('solar:documents-bold-duotone')
30
+ el += __('btn.all_posts')
31
+ el += `</a>`
32
+ el += `</div>`
33
+ el += `</widget>`
34
+ return el
35
+ }
36
+ %>
37
+ <%- layoutDiv() %>
@@ -0,0 +1,24 @@
1
+ <%
2
+ function parseURL() {
3
+ const source = page.source || ''
4
+ var url
5
+ for (let id of Object.keys(map)) {
6
+ if (source.startsWith(id) && map[id]) {
7
+ return source.replace(id, map[id])
8
+ }
9
+ }
10
+ }
11
+ function layoutDiv() {
12
+ const url = parseURL()
13
+ if (url == null) {
14
+ return ''
15
+ }
16
+ var el = ''
17
+ el += `<a class="edit" href="${url_for(url)}">`
18
+ el += icon('default:edit')
19
+ el += `<span>${__('btn.edit')}</span>`
20
+ el += `</a>`
21
+ return el
22
+ }
23
+ %>
24
+ <%- layoutDiv() %>
@@ -26,7 +26,7 @@ function layoutDiv() {
26
26
  el += '</div>';
27
27
  }
28
28
  el += '<div class="widget-body fs14">';
29
- el += '<div class="tag-plugin timeline stellar-timeline-api"';
29
+ el += '<div class="tag-plugin timeline ds-timeline"';
30
30
  ['api', 'user'].forEach(key => {
31
31
  if (item[key]) {
32
32
  el += ' ' + key + '="' + item[key] + '"';
@@ -19,7 +19,7 @@ function layoutDiv() {
19
19
  el += `<widget class="widget-wrapper${scrollreveal(' ')} ghrepo">`
20
20
  // body
21
21
  el += '<div class="widget-body">';
22
- el += '<div class="items stellar-ghinfo-api" api="' + theme.api_host.ghapi + '/repos/' + repo + '">';
22
+ el += '<div class="items ds-ghinfo" api="' + theme.api_host.ghapi + '/repos/' + repo + '">';
23
23
  el += '<a class="repo" href="https://github.com/' + repo + '" target="_blank" rel="external nofollow noopener noreferrer">';
24
24
  el += '<div class="repo-name flex-row">';
25
25
  el += icon('github:repo')
@@ -35,7 +35,7 @@ function layoutDiv() {
35
35
  el += icon('github:fork')
36
36
  el += '<span type="text" id="forks_count"></span>';
37
37
  el += '</div>';
38
- el += '<div class="flex-row stellar-ghinfo-api" index="0" api="' + theme.api_host.ghapi + '/repos/' + repo + '/tags">';
38
+ el += '<div class="flex-row ds-ghinfo" index="0" api="' + theme.api_host.ghapi + '/repos/' + repo + '/tags">';
39
39
  el += icon('github:tag')
40
40
  el += '<span type="text" id="latest-tag-name">0</span>';
41
41
  el += '</div>';
@@ -22,9 +22,9 @@ function layoutDiv() {
22
22
  return el;
23
23
  }
24
24
 
25
- el += `<widget class="widget-wrapper${scrollreveal(' ')} ghuser">`
25
+ el += `<widget class="widget-wrapper${scrollreveal(' ')} user-card ghuser">`
26
26
  // body
27
- el += '<div class="widget-body stellar-ghinfo-api" api="' + theme.api_host.ghapi + '/users/' + item.username + '">';
27
+ el += '<div class="widget-body ds-ghinfo" api="' + theme.api_host.ghapi + '/users/' + item.username + '">';
28
28
  if (item.avatar) {
29
29
  el += '<div class="avatar" ><img no-lazy type="img" id="avatar_url" src="' + config.avatar + '"></div>';
30
30
  }
@@ -13,7 +13,7 @@ function layoutDiv() {
13
13
  el += markdown(item.content);
14
14
  }
15
15
  if (item.src) {
16
- el += `<div class="stellar-marked-api md-marked" src="${item.src}"></div>`
16
+ el += `<div class="ds-mdrender" src="${item.src}"></div>`
17
17
  }
18
18
  if (item.linklist) {
19
19
  el += partial('components/linklist', {item: item.linklist})
@@ -30,8 +30,7 @@ function layoutDiv() {
30
30
  arr.length = item.limit
31
31
  arr.forEach(post => {
32
32
  if (!post) { return }
33
- const isActive = post.path == page.path
34
- el += `<a class="item title${post.path == page.path ? ' active' : ''}" href="${url_for(post.link || post.path)}">`
33
+ el += `<a class="item title" href="${url_for(post.link || post.path)}">`
35
34
  el += '<span class="title">'
36
35
  if (post.wiki) {
37
36
  const proj = theme.wiki.tree[post.wiki];
@@ -41,9 +40,6 @@ function layoutDiv() {
41
40
  }
42
41
  }
43
42
  el += post.title + '</span>';
44
- if (isActive) {
45
- el += icon('default:bookmark.active')
46
- }
47
43
  el += '</a>';
48
44
  el += '';
49
45
  });
@@ -31,7 +31,7 @@ function relatedWiki() {
31
31
  if (thisItemObject == null) {
32
32
  return ''
33
33
  }
34
- const relatedItems = thisItemObject.relatedItems
34
+ const relatedItems = thisItemObject.relatedItems || []
35
35
  var el = ''
36
36
  for (let relatedItem of relatedItems) {
37
37
  el += `<widget class="widget-wrapper${scrollreveal(' ')} post-card">`
@@ -11,7 +11,7 @@ function layoutDiv() {
11
11
  el += '</div>';
12
12
  }
13
13
  el += '<div class="widget-body fs14">';
14
- el += '<div class="tag-plugin timeline stellar-' + (item.type || "timeline") + '-api"';
14
+ el += `<div class="tag-plugin timeline ds-${(item.type || 'timeline')}"`;
15
15
  ['api', 'user', 'hide', 'limit'].forEach(key => {
16
16
  if (item[key]) {
17
17
  el += ' ' + key + '="' + item[key] + '"';
@@ -1,16 +1,13 @@
1
1
  <%
2
- const proj = theme.wiki.tree[page.wiki]
3
- var hasTOC = true
2
+
4
3
  function layoutTocBody() {
5
4
  if (toc(page.content).length > 0) {
6
- hasTOC = true
7
5
  return toc(page.content, {
8
6
  list_number: item.list_number,
9
7
  min_depth: item.min_depth,
10
8
  max_depth: item.max_depth
11
- });
9
+ })
12
10
  }
13
- hasTOC = false
14
11
  return ''
15
12
  }
16
13
 
@@ -18,98 +15,54 @@ function layoutTocHeader(title) {
18
15
  var el = ''
19
16
  el += `<div class="widget-header dis-select">`
20
17
  el += `<span class="name">${title || __("meta.toc")}</span>`
18
+ el += `<a class="cap-action" onclick="sidebar.toggleTOC()" >${icon('default:rightbar')}</a>`
21
19
  el += `</div>`
22
20
  return el
23
21
  }
24
22
 
25
- function layoutDocTree(pages) {
26
- var el = ''
27
- for (let p of pages) {
28
- if (p.title == null || p.title.length == 0) {
29
- continue
30
- }
31
- let isActive = ''
32
- if (p.path === page.path) {
33
- isActive += ' active'
34
- }
35
- el += `<div class="doc-tree${isActive}">`
36
- if (proj.pages.length > 1) {
37
- let href = url_for(p.path);
38
- if (p.is_homepage) {
39
- href += '#start'
40
- }
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>`
47
- }
48
- if (p.path === page.path) {
49
- el += layoutTocBody()
50
- }
51
- el += `</div>`
23
+ function layoutToc(fallback) {
24
+ const tocBody = layoutTocBody()
25
+ if (tocBody.length == 0) {
26
+ return ''
52
27
  }
28
+ var el = ''
29
+ el += `<widget class="widget-wrapper${scrollreveal(' ')} toc" id="data-toc" collapse="${item.collapse}">`
30
+ el += layoutTocHeader()
31
+ el += `<div class="widget-body">`
32
+ el += tocBody
33
+ el += `</div>`
34
+ el += `</widget>`
53
35
  return el
54
36
  }
55
37
 
56
-
57
38
  function layoutDiv(fallback) {
58
- var type = ''
59
- if (proj?.pages) {
60
- type = proj.pages.length > 1 ? 'multi' : 'single'
61
- } else {
62
- let toc_content = toc(page.content)
63
- if (toc_content && toc_content.length > 0) {
64
- type = 'single'
65
- }
39
+ const editBtn = partial('components/edit', {map: item.edit_this_page})
40
+ const tocBody = layoutTocBody()
41
+ if (tocBody.trim().length == 0 && editBtn.trim().length == 0) {
42
+ return ''
66
43
  }
67
-
68
44
  var el = ''
69
- if (type.length > 0) {
70
- el += `<widget class="widget-wrapper${scrollreveal(' ')} toc ${type}" id="data-toc" collapse="${item.collapse}">`
71
- if (proj) {
72
- // wiki 布局
73
- if (proj.sections && proj.sections.length > 0 && proj.pages.length > 1) { // 多 pages
74
- for (let sec of proj.sections) {
75
- if (sec.pages.length == 0) {
76
- continue
77
- }
78
- if (sec.title?.length > 0) {
79
- el += layoutTocHeader(sec.title)
80
- }
81
- el += `<div class="widget-body fs14">`
82
- el += layoutDocTree(sec.pages)
83
- el += `</div>`
84
- }
85
- } else { // 单 page
86
- if (proj.pages.length == 1) {
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 ''
94
- }
95
- }
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>`
109
- } else if (item.fallback) {
110
- const fallback = theme.widgets[item.fallback]
111
- el += partial(fallback.layout, {item: fallback})
45
+ el += `<widget class="widget-wrapper${scrollreveal(' ')} toc" id="data-toc" collapse="${item.collapse}">`
46
+ if (tocBody.length > 0) {
47
+ el += layoutTocHeader()
48
+ el += `<div class="widget-body">`
49
+ el += tocBody
50
+ el += `</div>`
112
51
  }
52
+ el += `<div class="widget-footer">`
53
+ el += editBtn
54
+ el += `<a class="top" onclick="util.scrollTop()">`
55
+ el += icon('default:upup')
56
+ el += `<span>${__('btn.top')}</span>`
57
+ el += `</a>`
58
+ if (page.comments) {
59
+ el += `<a class="buttom" onclick="util.scrollComment()">`
60
+ el += icon('default:tocomment')
61
+ el += `<span>${__('btn.comments')}</span>`
62
+ el += `</a>`
63
+ }
64
+ el += `</div>`
65
+ el += `</widget>`
113
66
  return el
114
67
  }
115
68
 
@@ -0,0 +1,71 @@
1
+ <%
2
+ const proj = theme.wiki.tree[page.wiki]
3
+
4
+ function layoutTocHeader(title) {
5
+ var el = ''
6
+ el += `<div class="widget-header dis-select">`
7
+ el += `<span class="name">${title || __("meta.toc")}</span>`
8
+ el += `</div>`
9
+ return el
10
+ }
11
+
12
+ function layoutDocTree(pages) {
13
+ var el = ''
14
+ for (let p of pages) {
15
+ if (p.title == null || p.title.length == 0) {
16
+ continue
17
+ }
18
+ let isActive = ''
19
+ if (p.path === page.path) {
20
+ isActive += ' active'
21
+ }
22
+ if (proj.pages.length > 1) {
23
+ let href = url_for(p.path);
24
+ if (p.is_homepage) {
25
+ href += '#start'
26
+ }
27
+ el += `<a class="link${isActive}" href="${href}">`
28
+ el += `<span class="toc-text">${p.title}</span>`
29
+ if (isActive.length > 0) {
30
+ el += icon('default:bookmark.active')
31
+ }
32
+ el += `</a>`
33
+ }
34
+ }
35
+ return el
36
+ }
37
+
38
+
39
+ function layoutDiv(fallback) {
40
+ if (proj == null) {
41
+ return ''
42
+ }
43
+ if (proj.pages == null || proj.pages.length == 0) {
44
+ return ''
45
+ }
46
+ if (proj.sections == null || proj.sections.length == 0) {
47
+ return ''
48
+ }
49
+ var el = ''
50
+ for (let sec of proj.sections) {
51
+ if (sec.pages.length == 0) {
52
+ continue
53
+ }
54
+ if (sec.title?.length > 0) {
55
+ el += layoutTocHeader(sec.title)
56
+ }
57
+ const docTree = layoutDocTree(sec.pages)
58
+ if (docTree.trim().length > 0) {
59
+ el += `<div class="widget-body fs14">${docTree}</div>`
60
+ }
61
+ }
62
+ if (el.trim().length > 0) {
63
+ return `<widget class="widget-wrapper${scrollreveal(' ')} post-list">${el}</widget>`
64
+ } else {
65
+ return ''
66
+ }
67
+ }
68
+
69
+ %>
70
+
71
+ <%- layoutDiv() %>
@@ -0,0 +1,13 @@
1
+ <script>
2
+ document.addEventListener('DOMContentLoaded', function () {
3
+ window.codeElements = document.querySelectorAll('.code');
4
+ if (window.codeElements.length > 0) {
5
+ ctx.copycode = {
6
+ default_text: `<%- conf.default_text %>`,
7
+ success_text: `<%- conf.success_text %>`,
8
+ toast: `<%- conf.toast %>`,
9
+ };
10
+ utils.js('/js/plugins/copycode.js');
11
+ }
12
+ });
13
+ </script>
@@ -0,0 +1,32 @@
1
+ <script>
2
+ ctx.fancybox = {
3
+ selector: `<%- conf.selector %>`,
4
+ css: `<%- conf.css %>`,
5
+ js: `<%- conf.js %>`
6
+ };
7
+ var selector = '[data-fancybox]:not(.error)';
8
+ if (ctx.fancybox.selector) {
9
+ selector += `, ${ctx.fancybox.selector}`
10
+ }
11
+ var needFancybox = document.querySelectorAll(selector).length !== 0;
12
+ if (!needFancybox) {
13
+ const els = document.getElementsByClassName('ds-memos');
14
+ if (els != undefined && els.length > 0) {
15
+ needFancybox = true;
16
+ }
17
+ }
18
+ if (needFancybox) {
19
+ utils.css(ctx.fancybox.css);
20
+ utils.js(ctx.fancybox.js, { defer: true }).then(function () {
21
+ Fancybox.bind(selector, {
22
+ hideScrollbar: false,
23
+ Thumbs: {
24
+ autoStart: false,
25
+ },
26
+ caption: (fancybox, slide) => {
27
+ return slide.triggerEl.alt || null
28
+ }
29
+ });
30
+ })
31
+ }
32
+ </script>
@@ -0,0 +1,21 @@
1
+ <script>
2
+ utils.css(`<%- conf.css %>`);
3
+ utils.js(`<%- conf.js %>`, { defer: true }).then(function () {
4
+ const heti = new Heti('.heti');
5
+
6
+ // Copied from heti.autoSpacing() without DOMContentLoaded.
7
+ // https://github.com/sivan/heti/blob/eadee6a3b748b3b7924a9e7d5b395d4bce479c9a/js/heti-addon.js
8
+ //
9
+ // We managed to minimize the code modification to ensure .autoSpacing()
10
+ // is synced with upstream; therefore, we use `.bind()` to emulate the
11
+ // behavior of .autoSpacing() so we can even modify almost no code.
12
+ void (function () {
13
+ const $$rootList = document.querySelectorAll(this.rootSelector)
14
+
15
+ for (let $$root of $$rootList) {
16
+ this.spacingElement($$root)
17
+ }
18
+ }).bind(heti)();
19
+
20
+ });
21
+ </script>
@@ -0,0 +1,24 @@
1
+ <%
2
+ function loadPlugins() {
3
+ var el = ''
4
+
5
+ // search
6
+ if (theme.search[theme.search.service]) {
7
+ el += partial(`search/${theme.search.service}`, {conf: theme.search[theme.search.service]});
8
+ }
9
+
10
+ // others
11
+ for (let id of Object.keys(theme.plugins)) {
12
+ const conf = Object.assign({}, theme.plugins[id], page[id])
13
+ if (page[id] == true || conf.enable) {
14
+ if (conf.inject?.length > 0) {
15
+ el += conf.inject
16
+ } else {
17
+ el += partial(`${id}`, {conf: conf})
18
+ }
19
+ }
20
+ }
21
+ return el
22
+ }
23
+ %>
24
+ <%- loadPlugins() %>
@@ -0,0 +1,21 @@
1
+ <script defer src="<%- conf.js %>"></script>
2
+ <script>
3
+ // https://www.npmjs.com/package/vanilla-lazyload
4
+ // Set the options globally
5
+ // to make LazyLoad self-initialize
6
+ window.lazyLoadOptions = {
7
+ elements_selector: ".lazy",
8
+ };
9
+ // Listen to the initialization event
10
+ // and get the instance of LazyLoad
11
+ window.addEventListener(
12
+ "LazyLoad::Initialized",
13
+ function (event) {
14
+ window.lazyLoadInstance = event.detail.instance;
15
+ },
16
+ false
17
+ );
18
+ document.addEventListener('DOMContentLoaded', function () {
19
+ window.lazyLoadInstance?.update();
20
+ });
21
+ </script>
@@ -1,4 +1,4 @@
1
- <script type="text/javascript" src="<%- theme.plugins.mathjax.js %>"></script>
1
+ <script type="text/javascript" src="<%- conf.js %>"></script>
2
2
  <script type="text/x-mathjax-config">
3
3
  MathJax.Hub.Config({
4
4
  tex2jax: {
@@ -0,0 +1,29 @@
1
+ <script defer type="text/javascript" src="<%- conf.js %>"></script>
2
+ <script>
3
+ window.addEventListener('DOMContentLoaded', (event) => {
4
+ var mermaid_config = {
5
+ startOnLoad: true,
6
+ theme:
7
+ "<%- theme.style.darkmode %>" == "auto" &&
8
+ window.matchMedia("(prefers-color-scheme: dark)").matches
9
+ ? "dark"
10
+ : "<%- conf.theme %>",
11
+ logLevel: 3,
12
+ themeVariables: {
13
+ darkMode: true
14
+ },
15
+ flowchart: {
16
+ useMaxWidth: false,
17
+ htmlLabels: true,
18
+ curve: "linear"
19
+ },
20
+ gantt: {
21
+ axisFormat: "%Y/%m/%d"
22
+ },
23
+ sequence: {
24
+ actorMargin: 50
25
+ }
26
+ }
27
+ mermaid.initialize(mermaid_config);
28
+ });
29
+ </script>
@@ -0,0 +1,9 @@
1
+ <script>
2
+ window.FPConfig = {
3
+ delay: 0,
4
+ ignoreKeywords: [],
5
+ maxRPS: 5,
6
+ hoverDelay: 25
7
+ };
8
+ </script>
9
+ <script defer src="<%- conf.flying_pages %>"></script>
@@ -0,0 +1,15 @@
1
+ <script defer src="<%- conf.js %>"></script>
2
+ <script>
3
+ window.addEventListener('DOMContentLoaded', (event) => {
4
+ const slideUp = {
5
+ distance: `<%- conf.distance %>`,
6
+ duration: `<%- conf.duration %>`,
7
+ interval: `<%- conf.interval %>`,
8
+ scale: `<%- conf.scale %>`,
9
+ opacity: 0,
10
+ easing: "ease-out"
11
+ };
12
+ ScrollReveal().reveal('.l_left .slide-up', slideUp);
13
+ ScrollReveal().reveal('.l_main .slide-up', slideUp);
14
+ });
15
+ </script>
@@ -0,0 +1,13 @@
1
+ <script>
2
+ window.addEventListener('DOMContentLoaded', (event) => {
3
+ window.searchConfig = {
4
+ appId: '<%- conf.appId %>',
5
+ apiKey: '<%- conf.apiKey %>',
6
+ indexName: '<%- conf.indexName %>',
7
+ hitsPerPage: 100,
8
+ };
9
+ utils.js('https://gcore.jsdelivr.net/algoliasearch/3/algoliasearch.min.js', { defer: true });
10
+ utils.js('/js/search/algolia-search.js', { defer: true });
11
+ });
12
+ </script>
13
+