hexo-theme-solitude 3.0.20 → 4.0.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 (143) hide show
  1. package/.github/FUNDING.yml +3 -3
  2. package/README.md +11 -1
  3. package/README_en-US.md +11 -1
  4. package/_config.yml +16 -7
  5. package/languages/default.yml +56 -36
  6. package/languages/en.yml +90 -69
  7. package/languages/es.yml +94 -73
  8. package/languages/zh-CN.yml +56 -34
  9. package/languages/zh-TW.yml +80 -57
  10. package/layout/archive.pug +60 -14
  11. package/layout/category.pug +13 -11
  12. package/layout/includes/body/gadsense.pug +2 -2
  13. package/layout/includes/console.pug +71 -72
  14. package/layout/includes/footer.pug +38 -24
  15. package/layout/includes/head/config.pug +83 -39
  16. package/layout/includes/head/mode.pug +7 -7
  17. package/layout/includes/head/page_config.pug +20 -11
  18. package/layout/includes/inject/body.pug +18 -40
  19. package/layout/includes/keyboard.pug +3 -3
  20. package/layout/includes/loading.pug +1 -37
  21. package/layout/includes/mixins/articleSort.pug +3 -3
  22. package/layout/includes/mixins/common.pug +8 -4
  23. package/layout/includes/mixins/pace.pug +1 -1
  24. package/layout/includes/mixins/pagination.pug +3 -3
  25. package/layout/includes/nav.pug +5 -4
  26. package/layout/includes/page/about.pug +9 -8
  27. package/layout/includes/page/brevity.pug +2 -2
  28. package/layout/includes/page/links.pug +23 -11
  29. package/layout/includes/page/music.pug +0 -5
  30. package/layout/includes/rightmenu.pug +20 -20
  31. package/layout/includes/sidebar.pug +2 -2
  32. package/layout/includes/widgets/aside/asideInfoCard.pug +2 -2
  33. package/layout/includes/widgets/aside/asideTag.pug +2 -2
  34. package/layout/includes/widgets/home/bbTimeList.pug +3 -3
  35. package/layout/includes/widgets/home/categoryBar.pug +30 -15
  36. package/layout/includes/widgets/home/hometop.pug +113 -8
  37. package/layout/includes/widgets/home/postList.pug +1 -2
  38. package/layout/includes/widgets/home/topGroup.pug +3 -7
  39. package/layout/includes/widgets/nav/group.pug +4 -2
  40. package/layout/includes/widgets/nav/menu.pug +6 -4
  41. package/layout/includes/widgets/nav/right.pug +7 -6
  42. package/layout/includes/widgets/page/about/award.pug +67 -38
  43. package/layout/includes/widgets/page/about/hobbies.pug +12 -3
  44. package/layout/includes/widgets/page/banner.pug +1 -1
  45. package/layout/includes/widgets/page/kit/content.pug +2 -2
  46. package/layout/includes/widgets/page/links/banner.pug +30 -19
  47. package/layout/includes/widgets/page/message/artalk.pug +3 -3
  48. package/layout/includes/widgets/page/message/content.pug +3 -3
  49. package/layout/includes/widgets/page/message/twikoo.pug +3 -3
  50. package/layout/includes/widgets/page/message/valine.pug +4 -4
  51. package/layout/includes/widgets/page/message/waline.pug +3 -3
  52. package/layout/includes/widgets/page/recentcomment/artalk.pug +5 -9
  53. package/layout/includes/widgets/page/recentcomment/twikoo.pug +5 -9
  54. package/layout/includes/widgets/page/recentcomment/valine.pug +6 -10
  55. package/layout/includes/widgets/page/recentcomment/waline.pug +5 -9
  56. package/layout/includes/widgets/post/award.pug +1 -28
  57. package/layout/includes/widgets/post/copyright.pug +10 -10
  58. package/layout/includes/widgets/post/postInfo.pug +10 -11
  59. package/layout/includes/widgets/post/postMeta.pug +3 -2
  60. package/layout/includes/widgets/rightside/hide.pug +5 -5
  61. package/layout/includes/widgets/rightside/show.pug +7 -7
  62. package/layout/includes/widgets/third-party/comments/artalk.pug +9 -9
  63. package/layout/includes/widgets/third-party/comments/giscus.pug +2 -2
  64. package/layout/includes/widgets/third-party/comments/twikoo.pug +5 -5
  65. package/layout/includes/widgets/third-party/comments/valine.pug +6 -6
  66. package/layout/includes/widgets/third-party/comments/waline.pug +6 -6
  67. package/layout/includes/widgets/third-party/hot/index.pug +1 -1
  68. package/layout/includes/widgets/third-party/hot/twikoo.pug +1 -1
  69. package/layout/includes/widgets/third-party/music.pug +9 -5
  70. package/layout/includes/widgets/third-party/news-comment/artalk.pug +6 -6
  71. package/layout/includes/widgets/third-party/news-comment/twikoo.pug +7 -7
  72. package/layout/includes/widgets/third-party/news-comment/valine.pug +8 -8
  73. package/layout/includes/widgets/third-party/news-comment/waline.pug +7 -7
  74. package/layout/includes/widgets/third-party/pjax.pug +16 -10
  75. package/layout/includes/widgets/third-party/search/algolia-search.pug +2 -2
  76. package/layout/includes/widgets/third-party/search/docsearch.pug +3 -3
  77. package/layout/includes/widgets/third-party/search/index.pug +1 -3
  78. package/layout/includes/widgets/third-party/search/local-search.pug +9 -9
  79. package/layout/index.pug +10 -8
  80. package/package.json +8 -7
  81. package/plugins.yml +22 -21
  82. package/scripts/event/cdn.js +11 -6
  83. package/scripts/event/friend_links.js +30 -0
  84. package/scripts/event/merge_config.js +15 -7
  85. package/scripts/filter/comment.js +2 -2
  86. package/scripts/filter/default.js +1 -1
  87. package/scripts/helper/inject_head_js.js +79 -33
  88. package/scripts/helper/related_post.js +16 -21
  89. package/scripts/tags/chart.js +1 -1
  90. package/scripts/tags/typeit.js +1 -1
  91. package/source/css/_components/capsule.styl +259 -168
  92. package/source/css/_components/rightside.styl +98 -242
  93. package/source/css/_global/animation.styl +1 -10
  94. package/source/css/_global/index.styl +27 -1
  95. package/source/css/_layout/aside.styl +7 -1
  96. package/source/css/_layout/console.styl +144 -163
  97. package/source/css/_layout/header.styl +238 -47
  98. package/source/css/_layout/pagination.styl +176 -132
  99. package/source/css/_layout/rightmenu.styl +11 -2
  100. package/source/css/_layout/sidebar.styl +39 -17
  101. package/source/css/_mode/index.styl +7 -1
  102. package/source/css/_page/_about/about.styl +18 -2
  103. package/source/css/_page/_about/buff.styl +1 -1
  104. package/source/css/_page/_about/contentinfo.styl +2 -1
  105. package/source/css/_page/_about/game.styl +57 -1
  106. package/source/css/_page/_about/like.styl +7 -2
  107. package/source/css/_page/_about/maxim.styl +1 -1
  108. package/source/css/_page/_about/reward.styl +226 -108
  109. package/source/css/_page/_about/skills.styl +5 -3
  110. package/source/css/_page/_home/category-bar.styl +162 -88
  111. package/source/css/_page/_home/home-top.styl +309 -263
  112. package/source/css/_page/_home/home.styl +34 -7
  113. package/source/css/_page/archive.styl +412 -0
  114. package/source/css/_page/category.styl +27 -1
  115. package/source/css/_page/index.styl +2 -0
  116. package/source/css/_page/links.styl +190 -0
  117. package/source/css/_page/other.styl +37 -0
  118. package/source/css/_post/index.styl +2 -1
  119. package/source/css/_post/meta.styl +245 -217
  120. package/source/css/_search/local-search.styl +158 -82
  121. package/source/css/var.styl +2 -2
  122. package/source/js/archive-page.js +191 -0
  123. package/source/js/core/actions.js +48 -0
  124. package/source/js/core/api.js +32 -0
  125. package/source/js/core/config.js +13 -0
  126. package/source/js/core/lifecycle.js +52 -0
  127. package/source/js/core/preloader.js +34 -0
  128. package/source/js/core/resources.js +65 -0
  129. package/source/js/covercolor/api.js +13 -103
  130. package/source/js/covercolor/ave.js +14 -77
  131. package/source/js/covercolor/local.js +22 -116
  132. package/source/js/covercolor/shared.js +102 -0
  133. package/source/js/friend_links.js +502 -0
  134. package/source/js/main.js +793 -177
  135. package/source/js/music.js +24 -14
  136. package/source/js/post_ai.js +13 -2
  137. package/source/js/right_menu.js +44 -24
  138. package/source/js/search/algolia.js +29 -21
  139. package/source/js/search/local.js +231 -266
  140. package/source/js/tw_cn.js +37 -12
  141. package/source/js/utils.js +37 -25
  142. package/layout/includes/widgets/randomlink.pug +0 -43
  143. package/scripts/filter/randomPosts.js +0 -16
@@ -5,6 +5,8 @@
5
5
  include ./mixins/common.pug
6
6
 
7
7
  - const { information, group } = theme.footer
8
+ - const hexoUrl = 'https://hexo.io/'
9
+ - const themeRepoUrl = 'https://github.com/everfu/hexo-theme-solitude'
8
10
 
9
11
  //- 文章页脚栏组件
10
12
  mixin postFooterBar()
@@ -39,7 +41,8 @@ mixin footerDeals()
39
41
  - const [url, iconClass] = value.split('||')
40
42
  +link(trim(url), '', {
41
43
  class: 'deal_link',
42
- title: label
44
+ title: label,
45
+ heotip: label
43
46
  })
44
47
  +icon(iconClass)
45
48
 
@@ -47,7 +50,8 @@ mixin footerDeals()
47
50
  +conditionalWrapper(information.author)
48
51
  #footer_mini_logo.nolazyload.footer_mini_logo(
49
52
  title=_p('nav.backtop')
50
- onclick="sco.toTop()"
53
+ heotip=_p('nav.backtop')
54
+ data-solitude-action="toTop"
51
55
  )
52
56
  img(src=information.author, alt=_p('nav.backtop'))
53
57
 
@@ -56,7 +60,8 @@ mixin footerDeals()
56
60
  - const [url, iconClass] = value.split('||')
57
61
  +link(trim(url), '', {
58
62
  class: 'deal_link',
59
- title: label
63
+ title: label,
64
+ heotip: label
60
65
  })
61
66
  +icon(iconClass)
62
67
 
@@ -75,13 +80,14 @@ mixin footerGroups()
75
80
  })
76
81
 
77
82
  //- 随机友链
78
- +conditionalWrapper(theme.footer && theme.footer.randomlink)
83
+ if theme.footer && theme.footer.randomlink
79
84
  .footer-group
80
85
  .footer-title-group
81
86
  h3.footer-title= _p('footer.randomlink')
82
87
  button.random-friends-btn(
83
- onclick='randomLinksList()'
88
+ data-solitude-action='randomLinksList'
84
89
  title=_p('footer.randomlink')
90
+ heotip=_p('footer.randomlink')
85
91
  )
86
92
  +icon('fas fa-arrows-rotate')
87
93
  .footer-links#friend-links-in-footer
@@ -91,10 +97,8 @@ mixin copyrightInfo()
91
97
  - const currentYear = new Date().getFullYear()
92
98
  - const yearRange = startYear === currentYear ? startYear : `${startYear} - ${currentYear}`
93
99
 
94
- .copyright © #{yearRange} By 
100
+ .copyright © #{yearRange} By
95
101
  +link('/', config.author, { class: 'footer-bar-link' })
96
- img.author-avatar(src=url_for(theme.site.icon))
97
- = config.author
98
102
 
99
103
  //- 备案信息组件
100
104
  mixin beianInfo()
@@ -104,31 +108,41 @@ mixin beianInfo()
104
108
  each item in beian
105
109
  +link(item.url, '', {
106
110
  class: 'footer-bar-link',
107
- title: item.name
111
+ title: item.name,
112
+ heotip: item.name
108
113
  })
109
114
  +conditionalWrapper(item.icon)
110
- img.beian-icon(src=url_for(item.icon), alt=item.name)
115
+ if item.icon
116
+ img.beian-icon(src=url_for(item.icon), alt=item.name)
111
117
  span.beian-name= item.name
112
118
 
113
- +link(_p('hexo'), _p('framework_by') + 'Hexo', { class: 'footer-bar-link' })
114
- +link(_p('repo'), _p('theme_by') + 'Solitude', { class: 'footer-bar-link' })
119
+ +link(hexoUrl, _p('framework_by') + 'Hexo', {
120
+ class: 'footer-bar-link',
121
+ heotip: _p('framework_by') + 'Hexo'
122
+ })
123
+ +link(themeRepoUrl, _p('theme_by') + 'Solitude', {
124
+ class: 'footer-bar-link',
125
+ heotip: _p('theme_by') + 'Solitude'
126
+ })
115
127
 
116
128
  //- 页脚右侧链接组件
117
129
  mixin footerRightLinks()
118
130
  +conditionalWrapper(theme.footer.links)
119
131
  .footer-bar-right
120
- each item in theme.footer.links
121
- +link(item.url, '', {
122
- class: 'footer-bar-link',
123
- alt: item.name
124
- })
125
- if item.icon
126
- each icon in item.icon
127
- +icon(icon)
128
- else if item.img
129
- img(src=url_for(item.img), alt=item.name)
130
- else
131
- != item.name
132
+ if theme.footer.links && theme.footer.links.length > 0
133
+ each item in theme.footer.links
134
+ +link(item.url, '', {
135
+ class: 'footer-bar-link',
136
+ title: item.name,
137
+ heotip: item.name
138
+ })
139
+ if item.icon
140
+ each icon in item.icon
141
+ +icon(icon)
142
+ else if item.img
143
+ img(src=url_for(item.img), alt=item.name)
144
+ else
145
+ != item.name
132
146
 
133
147
  //- 页脚底部栏组件
134
148
  mixin footerBar()
@@ -1,28 +1,28 @@
1
1
  -
2
2
  if (theme.search.enable) {
3
- var localSearch = 'undefined';
4
- var algolia = 'undefined';
3
+ var localSearch = null;
4
+ var algolia = null;
5
5
  switch (theme.search.type) {
6
6
  case 'local':
7
- localSearch = JSON.stringify({
7
+ localSearch = {
8
8
  preload: theme.search.local.preload,
9
9
  path: theme?.search?.local?.CDN || '/search.xml'
10
- });
10
+ };
11
11
  break;
12
12
  case 'algolia':
13
- algolia = JSON.stringify({
13
+ algolia = {
14
14
  appId: config.algolia.appId || config.algolia.applicationID,
15
15
  apiKey: config.algolia.apiKey,
16
16
  indexName: config.algolia.indexName,
17
17
  hits: {
18
18
  per_page: theme?.search?.algolia?.hits?.per_page || 10
19
19
  }
20
- });
20
+ };
21
21
  break;
22
22
  }
23
23
  }
24
24
 
25
- const witty_words = theme.aside?.my_card?.witty_words?.map(item => `"${item}"`) || [];
25
+ const witty_words = theme.aside?.my_card?.witty_words || [];
26
26
  const [hello_prefix, hello_back] = [_p('aside.hello'), _p('aside.back')];
27
27
 
28
28
  let comment = false
@@ -36,13 +36,13 @@
36
36
 
37
37
  let copyright = false;
38
38
  if (theme.copy.enable && theme.copy.copyright.enable) {
39
- copyright = JSON.stringify({
39
+ copyright = {
40
40
  limit: theme.copy.copyright.limit,
41
41
  author: _p("copy_copyright.author") + ': ' + config.author,
42
42
  link: _p("copy_copyright.link") + ': ',
43
43
  source: _p("copy_copyright.source") + ': ' + config.title,
44
44
  info: _p("copy_copyright.info")
45
- })
45
+ }
46
46
  }
47
47
 
48
48
  let lang = false
@@ -116,7 +116,11 @@
116
116
  if (theme.translate.enable) {
117
117
  translate = {
118
118
  translateDelay: theme.translate.translateDelay,
119
- defaultEncoding: theme.translate.defaultEncoding
119
+ defaultEncoding: theme.translate.defaultEncoding,
120
+ toSimplified: _p('right_menu.cht_to_chs'),
121
+ toTraditional: _p('right_menu.chs_to_cht'),
122
+ switchedToSimplified: _p('right_menu.converted_to_chs'),
123
+ switchedToTraditional: _p('right_menu.converted_to_cht')
120
124
  }
121
125
  }
122
126
 
@@ -148,41 +152,81 @@
148
152
  }
149
153
  }
150
154
 
151
- script.
152
- const GLOBAL_CONFIG = {
153
- root: '!{config.root}',
154
- algolia: !{algolia ? algolia : 'undefined'},
155
- localsearch: !{localSearch ? localSearch : 'undefined'},
156
- runtime: '!{theme.aside.siteinfo.runtimeenable ? theme.aside.siteinfo.runtime : false}',
155
+ const friendLinksGroups = site.data.links && Array.isArray(site.data.links.links) ? site.data.links.links : []
156
+ const friendLinksTotal = friendLinksGroups.reduce((count, group) => count + (Array.isArray(group.link_list) ? group.link_list.length : 0), 0)
157
+ const configuredFriendLinksThreshold = Number(theme.page && theme.page.links && theme.page.links.async_threshold)
158
+ const friendLinksThreshold = Number.isInteger(configuredFriendLinksThreshold) && configuredFriendLinksThreshold >= 0 ? configuredFriendLinksThreshold : 200
159
+ const friendLinks = {
160
+ async: friendLinksTotal > friendLinksThreshold,
161
+ path: url_for('/links.json'),
162
+ total: friendLinksTotal,
163
+ placeholder: theme.lazyload.placeholder ? url_for(theme.lazyload.placeholder) : '',
164
+ default_avatar: url_for('/img/default_avatar.avif'),
165
+ more_url: url_for('/links/'),
166
+ loading: _p('link.loading'),
167
+ error: _p('link.error'),
168
+ retry: _p('link.retry'),
169
+ random: _p('link.random'),
170
+ to: _p('link.to'),
171
+ more: _p('more'),
172
+ default_sort: _p('link.default_sort'),
173
+ random_sort: _p('link.random_sort'),
174
+ sort_label: _p('link.sort_label'),
175
+ scroll_left: _p('link.scroll_left'),
176
+ scroll_right: _p('link.scroll_right')
177
+ }
178
+
179
+ -
180
+ const globalConfig = {
181
+ root: config.root,
182
+ algolia,
183
+ localsearch: localSearch,
184
+ runtime: theme.aside.siteinfo.runtimeenable ? theme.aside.siteinfo.runtime : false,
157
185
  lazyload: {
158
- enable: !{theme.lazyload.enable},
159
- error: '!{theme.lazyload.errorimg}'
186
+ enable: theme.lazyload.enable,
187
+ error: theme.lazyload.errorimg
160
188
  },
161
- copyright: !{copyright},
162
- highlight: !{highlight ? JSON.stringify(highlight) : false},
163
- randomlink: !{theme.footer.randomlink},
164
- lang: !{JSON.stringify(lang)},
189
+ copyright,
190
+ highlight,
191
+ friend_links: friendLinks,
192
+ random_posts: site.posts.filter(post => post.random !== false).map(post => post.path),
193
+ randomlink: theme.footer.randomlink,
194
+ feature_modules: {
195
+ search: theme.search.enable ? theme.search.type : false,
196
+ post_ai: theme.post.ai.enable,
197
+ friend_links: friendLinks.total > 0,
198
+ music: theme.capsule.enable || theme.music.enable || (theme.brevity.enable && theme.brevity.music),
199
+ right_menu: theme.right_menu.enable,
200
+ translate: theme.translate.enable,
201
+ covercolor: theme.post.covercolor.enable ? theme.post.covercolor.mode : false
202
+ },
203
+ lang,
165
204
  aside: {
166
205
  state: {
167
- morning: "!{theme.aside.my_card.state.morning}",
168
- noon: "!{theme.aside.my_card.state.noon}",
169
- afternoon: "!{theme.aside.my_card.state.afternoon}",
170
- night: "!{theme.aside.my_card.state.night}",
171
- goodnight: "!{theme.aside.my_card.state.goodnight}",
206
+ morning: theme.aside.my_card.state.morning,
207
+ noon: theme.aside.my_card.state.noon,
208
+ afternoon: theme.aside.my_card.state.afternoon,
209
+ night: theme.aside.my_card.state.night,
210
+ goodnight: theme.aside.my_card.state.goodnight
172
211
  },
173
- witty_words: [!{witty_words}],
212
+ witty_words,
174
213
  witty_comment: {
175
- prefix: '!{hello_prefix}',
176
- back: '!{hello_back}',
177
- },
214
+ prefix: hello_prefix,
215
+ back: hello_back
216
+ }
178
217
  },
179
218
  covercolor: {
180
- enable: !{theme.post.covercolor.enable}
219
+ enable: theme.post.covercolor.enable,
220
+ mode: theme.post.covercolor.mode,
221
+ api: theme.post.covercolor.api,
222
+ time: theme.post.covercolor.time
181
223
  },
182
- comment: !{comment ? JSON.stringify(comment) : false},
183
- lightbox: '!{ theme.mediumZoom ? "mediumZoom" : (theme.fancybox ? "fancybox" : "null")}',
184
- right_menu: !{rightMenu ? JSON.stringify(rightMenu) : false},
185
- translate: !{translate ? JSON.stringify(translate) : false},
186
- lure: !{lure ? JSON.stringify(lure) : false},
187
- expire: !{expire ? JSON.stringify(expire) : false},
188
- };
224
+ comment,
225
+ lightbox: theme.mediumZoom ? "mediumZoom" : (theme.fancybox ? "fancybox" : null),
226
+ right_menu: rightMenu,
227
+ translate,
228
+ lure,
229
+ expire
230
+ };
231
+
232
+ template#site-config!= JSON.stringify(globalConfig).replace(/</g, '\\u003c')
@@ -3,7 +3,7 @@ case theme.display_mode.type
3
3
  script.
4
4
  initTheme = () => {
5
5
  let isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
6
- const cachedMode = utils.saveToLocal.get('theme');
6
+ const cachedMode = Solitude.saveToLocal.get('theme');
7
7
  if (cachedMode === undefined) {
8
8
  const nowMode =
9
9
  isDarkMode ? 'dark' : 'light'
@@ -11,28 +11,28 @@ case theme.display_mode.type
11
11
  } else {
12
12
  document.documentElement.setAttribute('data-theme', cachedMode);
13
13
  }
14
- typeof rm === 'object' && rm.mode(cachedMode === 'dark' && isDarkMode)
14
+ Solitude.rightMenu?.mode(cachedMode === 'dark' && isDarkMode)
15
15
  }
16
16
  initTheme()
17
17
  when "dark"
18
18
  script.
19
19
  initTheme = () => {
20
- const cachedMode = utils.saveToLocal.get('theme');
20
+ const cachedMode = Solitude.saveToLocal.get('theme');
21
21
  if (cachedMode === undefined)
22
22
  document.documentElement.setAttribute('data-theme', 'dark');
23
23
  else
24
24
  document.documentElement.setAttribute('data-theme', cachedMode);
25
- typeof rm === 'object' && rm.mode(cachedMode === undefined || cachedMode === 'dark')
25
+ Solitude.rightMenu?.mode(cachedMode === undefined || cachedMode === 'dark')
26
26
  }
27
27
  initTheme()
28
28
  when "light"
29
29
  script.
30
30
  initTheme = () => {
31
- const cachedMode = utils.saveToLocal.get('theme');
31
+ const cachedMode = Solitude.saveToLocal.get('theme');
32
32
  if (cachedMode === undefined)
33
33
  document.documentElement.setAttribute('data-theme', 'light');
34
34
  else
35
35
  document.documentElement.setAttribute('data-theme', cachedMode);
36
- typeof rm === 'object' && rm.mode(cachedMode === 'dark')
36
+ Solitude.rightMenu?.mode(cachedMode === 'dark')
37
37
  }
38
- initTheme()
38
+ initTheme()
@@ -1,13 +1,22 @@
1
1
  - var showToc = !!page.toc && (toc(page.content) !== '' || page.encrypt === true);
2
2
 
3
- script#config-diff.
4
- var PAGE_CONFIG = {
5
- is_post: !{is_post()},
6
- is_page: !{!is_post() && !is_home()},
7
- is_home: !{is_home()},
8
- page: '!{page.type}',
9
- toc: !{showToc},
10
- comment: !{!!page.comment},
11
- ai_text: !{is_post && theme.post.ai.enable && page.ai_text ? "'"+ page.ai_text+"'" : false},
12
- color: !{page.color ? "'"+ page.color+"'" : false},
13
- }
3
+ -
4
+ const pageConfig = {
5
+ is_post: is_post(),
6
+ is_page: !is_post() && !is_home(),
7
+ is_home: is_home(),
8
+ page: is_post()
9
+ ? 'post'
10
+ : (is_home()
11
+ ? 'solitude'
12
+ : (is_archive()
13
+ ? 'archive'
14
+ : (is_category()
15
+ ? 'category'
16
+ : (is_tag() ? 'tag' : (page.type || page.layout || 'page'))))),
17
+ toc: showToc,
18
+ comment: !!page.comment,
19
+ ai_text: is_post() && theme.post.ai.enable && page.ai_text ? page.ai_text : false,
20
+ color: page.color || false
21
+ }
22
+ template#config-diff!= JSON.stringify(pageConfig).replace(/</g, '\\u003c')
@@ -1,4 +1,9 @@
1
1
  - page.type = is_post() ? 'post' : page.type
2
+ - const bodyFriendLinksGroups = site.data.links && Array.isArray(site.data.links.links) ? site.data.links.links : []
3
+ - const bodyFriendLinksTotal = bodyFriendLinksGroups.reduce((count, group) => count + (Array.isArray(group.link_list) ? group.link_list.length : 0), 0)
4
+ - const configuredBodyFriendLinksThreshold = Number(theme.page && theme.page.links && theme.page.links.async_threshold)
5
+ - const bodyFriendLinksThreshold = Number.isInteger(configuredBodyFriendLinksThreshold) && configuredBodyFriendLinksThreshold >= 0 ? configuredBodyFriendLinksThreshold : 200
6
+ - const bodyFriendLinksAsync = bodyFriendLinksTotal > bodyFriendLinksThreshold
2
7
 
3
8
  mixin katex
4
9
  if theme.katex.copytex
@@ -6,17 +11,16 @@ mixin katex
6
11
  script.
7
12
  (() => {
8
13
  document.querySelectorAll('.article-container span.katex-display').forEach(item => {
9
- utils.wrap(item, 'div', {class: 'katex-wrap'})
14
+ Solitude.wrap(item, 'div', {class: 'katex-wrap'})
10
15
  })
11
16
  })();
12
17
 
13
18
  div
14
19
  // Critical scripts loaded synchronously
15
20
  script(src=url_for(theme.cdn.utils))
16
- script(src=url_for(theme.cdn.main))
17
21
 
18
22
  // Non-critical scripts loaded asynchronously
19
- script(async src=url_for(theme.cdn.waterfall))
23
+ script(defer src=url_for(theme.cdn.waterfall))
20
24
  script(src=url_for(theme.cdn.pjax))
21
25
 
22
26
  // Feature-specific scripts loaded asynchronously
@@ -39,9 +43,6 @@ div
39
43
  if (typeof dark === 'function') dark();
40
44
  });
41
45
 
42
- if theme.translate.enable
43
- script(defer src=url_for(theme.cdn.translate_js))
44
-
45
46
  if theme.katex && theme.katex.enable
46
47
  if theme.katex.per_page && (is_post() || is_page())
47
48
  +katex
@@ -50,18 +51,15 @@ div
50
51
 
51
52
  // UI enhancement scripts
52
53
  if theme.lazyload.enable
53
- script(async src=url_for(theme.cdn.lazyload))
54
+ script(src=url_for(theme.cdn.lazyload))
54
55
  script(defer src=url_for(theme.cdn.snackbar))
55
56
  if theme.lightbox
56
57
  if theme.mediumZoom
57
- script(defer src=url_for(theme.cdn.medium_zoom))
58
+ script(src=url_for(theme.cdn.medium_zoom))
58
59
  if theme.fancybox
59
- script(defer src=url_for(theme.cdn.fancyapps_ui))
60
+ script(src=url_for(theme.cdn.fancyapps_ui))
60
61
  if (theme.brevity.home_mini && theme.brevity.enable)
61
- script(defer src=url_for(theme.cdn.swiper_js))
62
-
63
- if theme.post.ai.enable
64
- script(defer src=url_for(theme.cdn.post_ai))
62
+ script(src=url_for(theme.cdn.swiper_js))
65
63
 
66
64
  // Music player scripts
67
65
  if theme.capsule.enable || theme.music.enable || theme.brevity.enable && theme.brevity.music
@@ -71,24 +69,8 @@ div
71
69
  script(defer src=url_for(theme.cdn.meting_js))
72
70
 
73
71
  // Cover color processing scripts
74
- if theme.post.covercolor.enable
75
- case theme.post.covercolor.mode
76
- when 'local'
77
- script(defer src=url_for(theme.cdn.color_thief))
78
- script(defer src=url_for(theme.cdn.cover_local))
79
- when 'api'
80
- script.
81
- const coverColorConfig = {
82
- api: '!{theme.post.covercolor.api}',
83
- time: !{theme.post.covercolor.time}
84
- }
85
- script(defer src=url_for(theme.cdn.cover_api))
86
- when 'ave'
87
- script.
88
- const coverColorConfig = {
89
- time: !{theme.post.covercolor.time}
90
- }
91
- script(defer src=url_for(theme.cdn.cover_ave))
72
+ if theme.post.covercolor.enable && theme.post.covercolor.mode === 'local'
73
+ script(defer src=url_for(theme.cdn.color_thief))
92
74
 
93
75
  if theme.loading.pace
94
76
  include ../mixins/pace.pug
@@ -96,11 +78,9 @@ div
96
78
  // Search functionality
97
79
  if theme.search.enable && theme.search.type === "algolia"
98
80
  script(defer src=url_for(theme.cdn.instantsearch))
99
- script(defer src=url_for(theme.cdn.algolia_search))
100
81
 
101
- // Right menu functionality
102
- if theme.right_menu.enable
103
- script(defer src=url_for(theme.cdn.right_menu_js))
82
+ // Main module dynamically imports enabled first-party features.
83
+ script(type="module" src=url_for(theme.cdn.main))
104
84
 
105
85
  if theme.extends.body
106
86
  each item in theme.extends.body
@@ -109,11 +89,11 @@ div
109
89
  .js-pjax
110
90
  if is_home() && theme.brevity.enable && theme.brevity.home_mini
111
91
  script.
112
- sco.initbbtalk()
92
+ Solitude.initbbtalk()
113
93
  if page.type === 'brevity' && theme.brevity.enable
114
94
  script.
115
- GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll(".bber-content-img img"));
116
- sco.changeTimeFormat(document.querySelectorAll('.bber-info-time time'))
95
+ Solitude.config.lightbox && Solitude.lightbox(document.querySelectorAll(".bber-content-img img"));
96
+ Solitude.changeTimeFormat(document.querySelectorAll('.bber-info-time time'))
117
97
  if page.comment
118
98
  include ../widgets/third-party/comments/js
119
99
  if theme.mermaid
@@ -124,8 +104,6 @@ div
124
104
  script(defer pjax src=url_for(theme.cdn.busuanzi_js))
125
105
 
126
106
 
127
- if theme.footer.randomlink
128
- include ../widgets/randomlink.pug
129
107
 
130
108
  // pjax
131
109
  != partial("includes/widgets/third-party/pjax", {}, {cache: true})
@@ -30,12 +30,12 @@ script.
30
30
  }
31
31
  } else {
32
32
  if (e.key === keyboards[i].key) {
33
- pjax.loadUrl(keyboards[i].url);
33
+ Solitude.navigate(keyboards[i].url);
34
34
  }
35
35
  }
36
36
  } else if (keyboards[i].sco) {
37
37
  if (e.key === keyboards[i].key) {
38
- sco[keyboards[i].sco]();
38
+ Solitude[keyboards[i].sco]?.();
39
39
  }
40
40
  } else if (keyboards[i].func) {
41
41
  if (e.key === keyboards[i].key) {
@@ -63,4 +63,4 @@ script.
63
63
  openKeyboard();
64
64
  let keyboard = document.getElementById('consoleKeyboard');
65
65
  keyboard?.classList.add('on');
66
- }
66
+ }
@@ -1,39 +1,3 @@
1
- div(id="loading-box" onclick="preloader.endLoading();" style="zoom:1")
1
+ div(id="loading-box" data-solitude-action="endLoading" style="zoom:1")
2
2
  div.loading-bg
3
3
  img.loading-img.nolazyload(src=url_for(theme.loading.favicon || theme.site.icon), alt="loading image")
4
-
5
- script.
6
- const preloader = {
7
- isLoaded: false,
8
- endLoading: () => {
9
- if (!preloader.isLoaded) {
10
- document.getElementById('loading-box').classList.add('loaded');
11
- preloader.isLoaded = true;
12
- preloader.togglePaceDone();
13
- }
14
- },
15
- initLoading: () => {
16
- document.getElementById('loading-box').classList.remove('loaded');
17
- preloader.isLoaded = false;
18
- preloader.togglePaceDone();
19
- },
20
- togglePaceDone: () => {
21
- document.getElementById('body').className = preloader.isLoaded ? 'pace-done' : '';
22
- }
23
- }
24
-
25
- window.addEventListener('load', () => {
26
- preloader.endLoading();
27
- });
28
-
29
- window.addEventListener('pjax:send', () => {
30
- preloader.initLoading();
31
- });
32
-
33
- document.addEventListener('pjax:complete', () => {
34
- preloader.endLoading();
35
- });
36
-
37
- setTimeout(() => {
38
- preloader.endLoading();
39
- }, 5000);
@@ -7,10 +7,10 @@ each post in page.posts.find({ parent: { $exists: false } }).data
7
7
  a.article-sort-item-img(href=url_for(post.path) title=post.title)
8
8
  img(src=url_for(post.cover) alt=post.title)
9
9
  .article-sort-item-info
10
- a.article-sort-item-title(href=url_for(post.path) title=post.title onclick="window.event.cancelBubble=true;") #{post.title}
10
+ a.article-sort-item-title(href=url_for(post.path) title=post.title data-solitude-action="noop" data-solitude-stop="true") #{post.title}
11
11
  .article-sort-item-tags
12
12
  each tags in post.tags.data
13
- a.article-meta__tags(href=url_for(tags.path) onclick="window.event.cancelBubble=true;")
13
+ a.article-meta__tags(href=url_for(tags.path) data-solitude-action="noop" data-solitude-stop="true")
14
14
  span.tags-punctuation
15
15
  i.solitude.fas.fa-hashtag
16
- =tags.name
16
+ =tags.name
@@ -16,14 +16,18 @@ mixin link(url, text, options)
16
16
  - var target = options.target
17
17
  - var className = options.class
18
18
  - var id = options.id
19
- - var onclick = options.onclick
19
+ - var action = options.action
20
+ - var stop = options.stop
21
+ - var heotip = options.heotip
20
22
  a(
21
23
  href=url_for(url)
22
24
  title=title
23
25
  target=target
24
26
  class=className
25
27
  id=id
26
- onclick=onclick
28
+ data-solitude-action=action
29
+ data-solitude-stop=stop
30
+ heotip=heotip
27
31
  )
28
32
  if text
29
33
  = text
@@ -93,7 +97,7 @@ mixin postMeta(post, options)
93
97
  if showTags && post.tags && post.tags.length > 0
94
98
  span.article-meta.tags
95
99
  each tag in post.tags.data
96
- - var linkOptions = { class: 'article-meta__tags', onclick: 'event.stopPropagation();' }
100
+ - var linkOptions = { class: 'article-meta__tags', action: 'noop', stop: 'true' }
97
101
  +link(tag.path, '', linkOptions)
98
102
  span.tags-punctuation
99
103
  +icon('fas fa-hashtag')
@@ -176,4 +180,4 @@ mixin shareButton(platform, url, title)
176
180
 
177
181
  - var linkOptions = { class: 'share-' + platform, target: '_blank', title: '分享到' + platform }
178
182
  +link(shareUrl, '', linkOptions)
179
- +icon('fab fa-' + platform)
183
+ +icon('fab fa-' + platform)
@@ -3,7 +3,7 @@ script.
3
3
  restartOnPushState: false
4
4
  }
5
5
 
6
- utils.addGlobalFn('pjaxSend', () => {
6
+ Solitude.addGlobalFn('pjaxSend', () => {
7
7
  Pace.restart()
8
8
  }, 'pace_restart')
9
9
 
@@ -3,6 +3,6 @@ nav#pagination
3
3
  - var options = {mid_size: 1,escape: false,next_text: `<div class="pagination_tips_next">${_p("pagination.next")}</div> <i class="solitude fas fa-chevron-right"></i>`,prev_text: `<i class="solitude fas fa-chevron-left"></i> <div class="pagination_tips_prev">${_p("pagination.prev")}</div>`}
4
4
  !=paginator(options)
5
5
  div.toPageGroup
6
- input#toPageText(oninput="value=value.replace(/[^0-9]/g,'')" maxlength="3" title=_p('pagination.to') onkeyup="if (this.value === '0') this.value = ''")
7
- a#toPageButton(onclick="sco.toPage()")
8
- i.solitude.fas.fa-angles-right
6
+ input#toPageText(inputmode="numeric" pattern="[0-9]*" maxlength="3" title=_p('pagination.to'))
7
+ a#toPageButton(data-solitude-action="toPage")
8
+ i.solitude.fas.fa-angles-right