hexo-theme-volantis 5.0.0-rc.9 → 5.2.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 (62) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +2 -1
  3. package/_config.yml +69 -46
  4. package/layout/_meta/counter.ejs +27 -5
  5. package/layout/_meta/walinecount.ejs +2 -1
  6. package/layout/_partial/article.ejs +2 -2
  7. package/layout/_partial/head.ejs +29 -28
  8. package/layout/_partial/header.ejs +1 -1
  9. package/layout/_partial/scripts/content-visibility-scroll-fix.ejs +71 -69
  10. package/layout/_partial/scripts/global.ejs +47 -23
  11. package/layout/_partial/scripts/index.ejs +22 -9
  12. package/layout/_partial/scripts/toc.ejs +61 -38
  13. package/layout/_plugins/_page_plugins/indent/index.ejs +1 -1
  14. package/layout/_plugins/_page_plugins/index.ejs +27 -7
  15. package/layout/_plugins/_page_plugins/snackbar/index.ejs +1 -1
  16. package/layout/_plugins/analytics/script.ejs +11 -1
  17. package/layout/_plugins/aplayer/script.ejs +1 -1
  18. package/layout/_plugins/comments/artalk/script.ejs +38 -11
  19. package/layout/_plugins/comments/beaudar/script.ejs +2 -2
  20. package/layout/_plugins/comments/discuss/script.ejs +30 -0
  21. package/layout/_plugins/comments/hashover/script.ejs +2 -2
  22. package/layout/_plugins/comments/index.ejs +4 -4
  23. package/layout/_plugins/comments/twikoo/script.ejs +1 -1
  24. package/layout/_plugins/comments/waline/script.ejs +40 -22
  25. package/layout/_plugins/parallax/script.ejs +1 -1
  26. package/layout/_plugins/pjax/index.ejs +4 -1
  27. package/layout/_plugins/rightmenu/layout.ejs +2 -2
  28. package/layout/_plugins/rightmenus/layout.ejs +17 -17
  29. package/layout/_widget/lastupdate.ejs +27 -27
  30. package/layout/_widget/webinfo.ejs +7 -7
  31. package/layout/layout.ejs +20 -3
  32. package/layout/tag.ejs +1 -1
  33. package/package.json +1 -1
  34. package/scripts/events/lib/check-configuration.js +43 -0
  35. package/scripts/events/lib/check-environment.js +20 -1
  36. package/scripts/events/lib/config.js +3 -0
  37. package/scripts/events/lib/render-stylus.js +1 -1
  38. package/scripts/filters/content-visibility.js +2 -2
  39. package/scripts/helpers/custom-files.js +3 -1
  40. package/scripts/helpers/head/generate_seo.js +1 -1
  41. package/scripts/helpers/structured-data/lib/blogposting.js +18 -6
  42. package/scripts/helpers/structured-data/lib/breadcrumblist.js +25 -1
  43. package/scripts/helpers/structured-data/lib/index.js +1 -9
  44. package/scripts/tags/fancybox.js +1 -1
  45. package/scripts/tags/tabs.js +85 -86
  46. package/source/css/_defines/AutoPrefixCSS.styl +16 -16
  47. package/source/css/_first/base_first.styl +6 -0
  48. package/source/css/_first/navbar_first.styl +1 -1
  49. package/source/css/_style/_base/base.styl +1 -1
  50. package/source/css/_style/_layout/toc.styl +2 -2
  51. package/source/css/_style/_plugins/_dark/dark_async.styl +1 -1
  52. package/source/css/_style/_plugins/_dark/dark_plugins.styl +8 -4
  53. package/source/css/_style/_plugins/_rightmenu/reading.styl +2 -2
  54. package/source/css/_style/_plugins/_rightmenu/rightmenu.styl +1 -1
  55. package/source/css/_style/_plugins/fontcolor.styl +1 -1
  56. package/source/css/first.styl +5 -7
  57. package/source/js/app.js +32 -35
  58. package/source/js/plugins/aplayer.js +1 -3
  59. package/source/js/plugins/rightMenu.js +22 -22
  60. package/source/js/plugins/rightMenus.js +115 -78
  61. package/source/js/search/hexo.js +3 -0
  62. package/layout/_partial/scripts/import.ejs +0 -3
@@ -35,7 +35,7 @@
35
35
  layout: <%- JSON.stringify(theme.rightmenu.layout) %>,
36
36
  music_alwaysShow: <%- JSON.stringify(theme.rightmenu.music.alwaysShow) %>,
37
37
  customPicUrl: <%- JSON.stringify(theme.rightmenu.customPicUrl) %>
38
- },
38
+ },
39
39
  rightmenus: <%- JSON.stringify(theme.rightmenus) %>
40
40
  }
41
41
  }
@@ -181,12 +181,21 @@
181
181
  error: new RunItem(),
182
182
  send: new RunItem(),
183
183
  };
184
- volantis.pjax = {
185
- ...volantis.pjax,
184
+ volantis.pjax = Object.assign(volantis.pjax, {
186
185
  push: volantis.pjax.method.complete.push,
187
186
  error: volantis.pjax.method.error.push,
188
187
  send: volantis.pjax.method.send.push,
189
- };
188
+ });
189
+ /******************** RightMenu ********************************/
190
+ // volantis.rightmenu.handle(callBack[,"callBackName"]) 外部菜单项控制
191
+ // 可在 volantis.mouseEvent 处获取右键事件
192
+ volantis.rightmenu = {};
193
+ volantis.rightmenu.method = {
194
+ handle: new RunItem(),
195
+ }
196
+ volantis.rightmenu = Object.assign(volantis.rightmenu, {
197
+ handle: volantis.rightmenu.method.handle.push,
198
+ });
190
199
  /******************** Dark Mode ********************************/
191
200
  // /layout/_partial/scripts/darkmode.ejs
192
201
  // volantis.dark.mode 当前模式 dark or light
@@ -196,10 +205,9 @@
196
205
  volantis.dark.method = {
197
206
  toggle: new RunItem(),
198
207
  };
199
- volantis.dark = {
200
- ...volantis.dark,
208
+ volantis.dark = Object.assign(volantis.dark, {
201
209
  push: volantis.dark.method.toggle.push,
202
- };
210
+ });
203
211
  /******************** Message ********************************/
204
212
  // VolantisApp.message
205
213
  /******************** isMobile ********************************/
@@ -309,10 +317,9 @@
309
317
  engine: new RunItem(),
310
318
  unengine: new RunItem(),
311
319
  };
312
- volantis.scroll = {
313
- ...volantis.scroll,
320
+ volantis.scroll = Object.assign(volantis.scroll, {
314
321
  push: volantis.scroll.engine.push,
315
- };
322
+ });
316
323
  // 滚动条距离顶部的距离
317
324
  volantis.scroll.getScrollTop = () =>{
318
325
  let scrollPos;
@@ -339,6 +346,8 @@
339
346
  // } else {
340
347
  // console.log("向上滚动");
341
348
  // }
349
+ // 注销过期的unengine未滚动事件
350
+ volantis.scroll.unengine.list=[]
342
351
  volantis.scroll.engine.start();
343
352
  }else{
344
353
  volantis.scroll.unengine.start();
@@ -366,24 +375,39 @@
366
375
  opt.top += option.addTop
367
376
  }
368
377
  if (!("observerDic" in option)) {
369
- option.observerDic = 25
378
+ option.observerDic = 100
370
379
  }
371
380
  // 滚动
372
381
  window.scrollTo(opt);
373
382
  // 监视器
374
- // 监视并矫正元素滚动到指定位置
375
- // 目前用于处理 toc 部分 lazyload 引起的 cls 导致的定位失败问题 [存在Bug]
376
- // if (option.observer) {
377
- // volantis.scroll.unengine.push(()=>{
378
- // let me = ele.getBoundingClientRect().top
379
- // if(!(me >= -option.observerDic && me <= option.observerDic)){
380
- // volantis.scroll.to(ele, option)
381
- // }else{
382
- // volantis.scroll.unengine.remove("unengineObserver")
383
- // }
384
- // },"unengineObserver")
385
- // }
383
+ // 监视并矫正元素滚动到指定位置
384
+ // 用于处理 lazyload 引起的 cls 导致的定位失败问题
385
+ // option.observer = false
386
+ if (option.observer) {
387
+ setTimeout(()=>{
388
+ volantis.scroll.unengine.push(()=>{
389
+ let me = ele.getBoundingClientRect().top
390
+ if(!(me >= -option.observerDic && me <= option.observerDic)){
391
+ volantis.scroll.to(ele, option)
392
+ }
393
+ volantis.scroll.unengine.remove("unengineObserver")
394
+ },"unengineObserver")
395
+ },1000)
396
+ }
386
397
  }
398
+ /********************** Content Visibility ********************************/
399
+ // 见 source/css/first.styl 如果遇到任何问题 删除 .post-story 即可
400
+ // 一个元素被声明 content-visibility 属性后 如果元素不在 viewport 中 浏览器不会计算其后代元素样式和属性 从而节省 Style & Layout 耗时
401
+ // content-visibility 的副作用: 锚点失效 等等(实验初期 暂不明确), 使用此方法清除样式
402
+ volantis.cleanContentVisibility = ()=>{
403
+ if (document.querySelector(".post-story")) {
404
+ console.log("cleanContentVisibility");
405
+ document.querySelectorAll(".post-story").forEach(e=>{
406
+ e.classList.remove("post-story")
407
+ })
408
+ }
409
+ }
410
+ /******************************************************************************/
387
411
  /******************************************************************************/
388
412
  /******************************************************************************/
389
413
  //图像加载出错时的处理
@@ -64,9 +64,27 @@
64
64
  <%- partial('../../_plugins/aplayer/script') %>
65
65
  <% } %>
66
66
 
67
- <% if (theme.comments.service && theme.comments.service.length > 0) { %>
68
- <%- partial('../../_plugins/comments/' + theme.comments.service + '/script') %>
69
- <% } %>
67
+ <%
68
+ if (theme.comments.service && theme.comments.service.length > 0) {
69
+ try { %>
70
+ <%- partial('../../_plugins/comments/' + theme.comments.service + '/script') %>
71
+ <% } catch (e) {
72
+ // error friendly
73
+ console.log(`
74
+ ===============================================================================
75
+ 没有找到评论插件:${theme.comments.service}
76
+ 请检查是否存在该插件,或者检查插件名称是否正确:${theme.comments.service}
77
+ see: https://volantis.js.org/v5/theme-settings/#选择评论系统
78
+ ================================================================================
79
+ There is no comments plugin: ${theme.comments.service}
80
+ Please check if the plugin exists, or check the plugin name is correct: ${theme.comments.service}
81
+ see: https://volantis.js.org/v5/theme-settings/#选择评论系统
82
+ =================================================================================`)
83
+ }
84
+ }
85
+ %>
86
+
87
+
70
88
 
71
89
  <% if (theme.analytics.busuanzi) { %>
72
90
  <script defer src="<%- theme.analytics.busuanzi %>" data-pjax></script>
@@ -93,7 +111,7 @@
93
111
  <%- partial('../../_plugins/analytics/LCCounter') %>
94
112
  <% } %>
95
113
 
96
- <% if (config.google_analytics_key || config.baidu_analytics_key || config.tencent_aegis_id) { %>
114
+ <% if (config.google_analytics_key || config.baidu_analytics_key || config.tencent_aegis_id || config.v6_51_la) { %>
97
115
  <%- partial('../../_plugins/analytics/script') %>
98
116
  <% } %>
99
117
 
@@ -124,8 +142,3 @@
124
142
  <%- structured_data() %>
125
143
  <% } %>
126
144
 
127
- <!-- more -->
128
- <% if (config.import && config.import.script) { %>
129
- <%- partial('import') %>
130
- <% } %>
131
-
@@ -2,11 +2,13 @@
2
2
  function listennSidebarTOC() {
3
3
  const navItems = document.querySelectorAll(".toc li");
4
4
  if (!navItems.length) return;
5
+ let targets = []
5
6
  const sections = [...navItems].map((element) => {
6
7
  const link = element.querySelector(".toc-link");
7
8
  const target = document.getElementById(
8
9
  decodeURI(link.getAttribute("href")).replace("#", "")
9
10
  );
11
+ targets.push(target)
10
12
  // 解除 a 标签 href 的 锚点定位, a 标签 href 的 锚点定位 会随机启用?? 产生错位???
11
13
  link.setAttribute("onclick","return false;")
12
14
  link.setAttribute("toc-action","toc-"+decodeURI(link.getAttribute("href")).replace("#", ""))
@@ -15,7 +17,7 @@
15
17
  link.addEventListener("click", (event) => {
16
18
  event.preventDefault();
17
19
  // 这里的 addTop 是通过错位使得 toc 自动展开.
18
- volantis.scroll.to(target,{addTop: 5, observer:false})
20
+ volantis.scroll.to(target,{addTop: 5, observer:true})
19
21
  // Anchor id
20
22
  history.pushState(null, document.title, "#" + target.id);
21
23
  });
@@ -36,46 +38,67 @@
36
38
  }
37
39
  }
38
40
 
39
- function findIndex(entries) {
40
- let index = 0;
41
- let entry = entries[index];
42
- if (entry.boundingClientRect.top > 0) {
43
- index = sections.indexOf(entry.target);
44
- return index === 0 ? 0 : index - 1;
45
- }
46
- for (; index < entries.length; index++) {
47
- if (entries[index].boundingClientRect.top <= 0) {
48
- entry = entries[index];
49
- } else {
50
- return sections.indexOf(entry.target);
51
- }
52
- }
53
- return sections.indexOf(entry.target);
54
- }
55
-
56
- function createIntersectionObserver(marginTop) {
57
- marginTop = Math.floor(marginTop + 10000);
58
- let intersectionObserver = new IntersectionObserver(
59
- (entries, observe) => {
60
- let scrollHeight = document.documentElement.scrollHeight;
61
- if (scrollHeight > marginTop) {
62
- observe.disconnect();
63
- createIntersectionObserver(scrollHeight);
64
- return;
41
+ // 方案一:
42
+ volantis.activateNavIndex=0
43
+ activateNavByIndex(navItems[volantis.activateNavIndex])
44
+ volantis.scroll.push(()=>{
45
+ if (targets[0].getBoundingClientRect().top >= 0) {
46
+ volantis.activateNavIndex = 0
47
+ }else if (targets[targets.length-1].getBoundingClientRect().top < 0) {
48
+ volantis.activateNavIndex = targets.length-1
49
+ } else {
50
+ for (let index = 0; index < targets.length; index++) {
51
+ const target0 = targets[index];
52
+ const target1 = targets[(index+1)%targets.length];
53
+ if (target0.getBoundingClientRect().top < 0&&target1.getBoundingClientRect().top >= 0) {
54
+ volantis.activateNavIndex=index
55
+ break;
65
56
  }
66
- let index = findIndex(entries);
67
- activateNavByIndex(navItems[index]);
68
- }, {
69
- rootMargin: marginTop + "px 0px -100% 0px",
70
- threshold: 0,
71
57
  }
72
- );
73
- sections.forEach((element) => {
74
- element && intersectionObserver.observe(element);
75
- });
76
- }
58
+ }
59
+ activateNavByIndex(navItems[volantis.activateNavIndex])
60
+ })
77
61
 
78
- createIntersectionObserver(document.documentElement.scrollHeight);
62
+ // 方案二:
63
+ // IntersectionObserver 不是完美精确到像素级别 也不是低延时性的
64
+ // function findIndex(entries) {
65
+ // let index = 0;
66
+ // let entry = entries[index];
67
+ // if (entry.boundingClientRect.top > 0) {
68
+ // index = sections.indexOf(entry.target);
69
+ // return index === 0 ? 0 : index - 1;
70
+ // }
71
+ // for (; index < entries.length; index++) {
72
+ // if (entries[index].boundingClientRect.top <= 0) {
73
+ // entry = entries[index];
74
+ // } else {
75
+ // return sections.indexOf(entry.target);
76
+ // }
77
+ // }
78
+ // return sections.indexOf(entry.target);
79
+ // }
80
+ // function createIntersectionObserver(marginTop) {
81
+ // marginTop = Math.floor(marginTop + 10000);
82
+ // let intersectionObserver = new IntersectionObserver(
83
+ // (entries, observe) => {
84
+ // let scrollHeight = document.documentElement.scrollHeight;
85
+ // if (scrollHeight > marginTop) {
86
+ // observe.disconnect();
87
+ // createIntersectionObserver(scrollHeight);
88
+ // return;
89
+ // }
90
+ // let index = findIndex(entries);
91
+ // activateNavByIndex(navItems[index]);
92
+ // }, {
93
+ // rootMargin: marginTop + "px 0px -100% 0px",
94
+ // threshold: 0,
95
+ // }
96
+ // );
97
+ // sections.forEach((element) => {
98
+ // element && intersectionObserver.observe(element);
99
+ // });
100
+ // }
101
+ // createIntersectionObserver(document.documentElement.scrollHeight);
79
102
  }
80
103
 
81
104
  document.addEventListener("DOMContentLoaded", ()=>{
@@ -9,7 +9,7 @@
9
9
  #post-body blockquote p,
10
10
  #post-body details p,
11
11
  #post-body p.p,
12
- #post-body .tab-pane .checkbox
12
+ #post-body .tab-pane .checkbox
13
13
  #post-body section p {
14
14
  text-indent: initial;
15
15
  }
@@ -1,7 +1,27 @@
1
- <%_(page.plugins||[]).forEach(function(item){ _%>
2
- <%_if (typeof item == "string") { _%>
3
- <%- partial( item + "/index") %>
4
- <%_}else if(typeof item == "object"){ _%>
5
- <%- partial( Object.keys(item)[0] + "/index", { pagePlugin:item }) %>
6
- <%_} _%>
7
- <%_ }) _%>
1
+ <%_
2
+ (page.plugins||[]).forEach(function(item){
3
+ try {
4
+ if (typeof item == "string") { _%>
5
+ <%- partial( item + "/index") %>
6
+ <%_ }else if(typeof item == "object"){ _%>
7
+ <%- partial( Object.keys(item)[0] + "/index", { pagePlugin:item }) %>
8
+ <%_ }
9
+ } catch (error) {
10
+ // error friendly
11
+ console.log(`
12
+ ===============================================================================
13
+ 没有找到页面插件:${item}
14
+ 请检查是否存在该插件,或者检查插件名称是否正确:${item}
15
+ 出问题的页面:${page.path}
16
+ see: https://volantis.js.org/v5/page-settings/#页面插件-page-plugins
17
+ ================================================================================
18
+ There is no page plugin: ${item}
19
+ Please check if the plugin exists, or check the plugin name is correct: ${item}
20
+ The page that has problem: ${page.path}
21
+ see: https://volantis.js.org/v5/page-settings/#页面插件-page-plugins
22
+ =================================================================================`);
23
+ }
24
+
25
+ })
26
+
27
+ _%>
@@ -1,4 +1,4 @@
1
- <% if (site.data.notification && (pagePlugin.snackbar in site.data.notification)) { %>
1
+ <% if (site.data.notification && (pagePlugin.snackbar in site.data.notification)) { %>
2
2
  <% let snackbar = site.data.notification[pagePlugin.snackbar] %>
3
3
  <% if (snackbar.position == 'bottom') { %>
4
4
  <div id="snackbar"></div>
@@ -35,6 +35,7 @@ var _hmt = _hmt || [];
35
35
  volantis.pjax.push(()=>{_hmt.push(['_trackPageview', document.location.pathname]);},'baidu_analytics')
36
36
  </script>
37
37
  <% } %>
38
+
38
39
  <% if (config.tencent_aegis_id) { %>
39
40
  <script>
40
41
  const genUuid = () => {
@@ -61,4 +62,13 @@ volantis.pjax.push(()=>{_hmt.push(['_trackPageview', document.location.pathname]
61
62
  }, 1000)
62
63
  </script>
63
64
  <% } %>
64
-
65
+
66
+ <% if (config.v6_51_la) { %>
67
+ <script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script>
68
+ <script>
69
+ volantis.js("https://sdk.51.la/js-sdk-pro.min.js").then(() => {
70
+ LA.init({id: "<%= config.v6_51_la %>",ck: "<%= config.v6_51_la %>",autoTrack:true,hashMode:true})
71
+ })
72
+ </script>
73
+ <% } %>
74
+
@@ -25,7 +25,7 @@
25
25
  Metings.forEach((item, index) => {
26
26
  const aplayerItem = item.aplayer; if(!aplayerItem) return;
27
27
  const rightAplayerCheck = '<%= theme.rightmenu.layout.includes("music") %>' === 'true'
28
- && item.meta.id === '<%= theme.plugins.aplayer.id %>';
28
+ && item.meta.id === '<%= theme.plugins.aplayer.id %>';
29
29
  if(rightAplayerCheck) RightMenuAplayer.checkAPlayer();
30
30
  if(aplayerItem.events.events.play.every(item => {return item.name !== 'messagePlay'})) {
31
31
  aplayerItem.on('play', function messagePlay() {
@@ -13,26 +13,51 @@
13
13
  if (path.length == 0) {
14
14
  path = '<%= theme.comments.artalk.path %>' || decodeURI(window.location.pathname);
15
15
  }
16
+ if(!'<%= config.permalink %>'.includes('/index.html')) {
17
+ path = path.replaceAll('/index.html', '/')
18
+ }
16
19
 
17
20
  volantis.artalk = new Artalk(Object.assign(<%- JSON.stringify(theme.comments.artalk) %>, {
18
21
  el: '#artalk_container',
19
22
  pageKey: path,
20
23
  pageTitle: document.title,
21
24
  placeholder: placeholder,
25
+ useBackendConf: true,
22
26
  site: '<%= config.title %>',
23
- darkMode: volantis.dark.mode === "dark"
27
+ darkMode: volantis.dark.mode === "dark",
28
+ pvEl: '#artalk_visitors',
29
+
30
+ <% if(!!theme.comments.artalk.imgUploader?.api){ %>
31
+ imgUploader: function(file) {
32
+ let headers = new Headers();
33
+ headers.set('Accept', 'application/json');
34
+ <% if(!!theme.comments.artalk.imgUploader?.token) { %>
35
+ headers.set('Authorization', '<%= theme.comments.artalk.imgUploader?.token %>')
36
+ <% } %>
37
+ let formData = new FormData();
38
+ formData.append('file', file);
39
+ return fetch('<%= theme.comments.artalk.imgUploader?.api %>',{
40
+ method: 'POST',
41
+ body: formData,
42
+ headers: headers
43
+ }).then((resp) => resp.json())
44
+ .then((resp) => resp.<%= theme.comments.artalk.imgUploader?.resp %>)
45
+ },
46
+ <% } %>
24
47
  }));
25
48
 
26
- volantis.artalk.on('comments-loaded', () => {
27
- if (typeof VolantisFancyBox === "undefined"){
28
- const checkFancyBox = setInterval(() => {
29
- if(typeof VolantisFancyBox === "undefined") return;
30
- clearInterval(checkFancyBox);
49
+ volantis.artalk.then(ctx => {
50
+ ctx.on('comments-loaded', () => {
51
+ if (typeof VolantisFancyBox === "undefined"){
52
+ const checkFancyBox = setInterval(() => {
53
+ if(typeof VolantisFancyBox === "undefined") return;
54
+ clearInterval(checkFancyBox);
55
+ VolantisFancyBox.groupBind('.atk-content img:not([atk-emoticon])', 'Comments');
56
+ })
57
+ } else {
31
58
  VolantisFancyBox.groupBind('.atk-content img:not([atk-emoticon])', 'Comments');
32
- })
33
- } else {
34
- VolantisFancyBox.groupBind('.atk-content img:not([atk-emoticon])', 'Comments');
35
- }
59
+ }
60
+ })
36
61
  })
37
62
  }
38
63
 
@@ -47,7 +72,9 @@
47
72
 
48
73
  function dark_artalk() {
49
74
  if(!document.querySelectorAll("#artalk_container")[0]) return;
50
- volantis.artalk.setDarkMode(volantis.dark.mode === "dark")
75
+ volantis.artalk.then(ctx => {
76
+ ctx.setDarkMode(volantis.dark.mode === "dark")
77
+ })
51
78
  }
52
79
  volantis.dark.push(dark_artalk);
53
80
  </script>
@@ -46,14 +46,14 @@
46
46
  const beaudarIframe = document.querySelector('iframe');
47
47
  beaudarIframe.contentWindow.postMessage(message, 'https://beaudar.lipk.org');
48
48
  }
49
-
49
+
50
50
  function check_beaudar_style() {
51
51
  // Beaudar 会往 HEAD 的首节点追加样式元素,而这个追加没有添加判断
52
52
  // 所以 Pjax 下会多次添加样式文件,略微麻烦。
53
53
  const checkStyle = document.querySelector('head').firstElementChild;
54
54
  if(checkStyle.innerText.includes('beaudar')) checkStyle.remove();
55
55
  }
56
-
56
+
57
57
  pjax_beaudar();
58
58
  volantis.pjax.push(check_beaudar_style);
59
59
  volantis.pjax.push(pjax_beaudar);
@@ -0,0 +1,30 @@
1
+ <script>
2
+ volantis.layoutHelper("comments",`<div id="discuss_container"><i class="fa-solid fa-cog fa-spin fa-fw fa-2x"></i></div>`)
3
+ function load_discuss() {
4
+ if(!document.querySelectorAll("#discuss_container")[0])return;
5
+ volantis.js("<%- theme.comments.discuss.js %>", pjax_discuss)
6
+ }
7
+ function pjax_discuss() {
8
+ if(!document.querySelectorAll("#discuss_container")[0])return;
9
+ let path = pdata.commentPath;
10
+ let placeholder = pdata.commentPlaceholder || "<%= theme.comments.discuss.ph %>" || "";
11
+ if (path.length == 0) {
12
+ let defaultPath = '<%= theme.comments.discuss.path %>';
13
+ path = defaultPath || decodeURI(window.location.pathname);
14
+ }
15
+
16
+ Discuss.init(Object.assign(Object.assign(<%- JSON.stringify(theme.comments.discuss) %>, {
17
+ el: '#discuss_container',
18
+ path: path,
19
+ ph: placeholder
20
+ }),pdata.commentConfig))
21
+ }
22
+ load_discuss();
23
+ volantis.pjax.push(()=>{
24
+ if (typeof Discuss == "undefined") {
25
+ load_discuss();
26
+ } else {
27
+ pjax_discuss();
28
+ }
29
+ },'discuss');
30
+ </script>
@@ -1,5 +1,5 @@
1
1
  <script>
2
2
  volantis.layoutHelper("comments",`<p>未注册者输入用户名和密码登录即相当于注册,之后以同一用户名和密码登录可以编辑自己之前的评论。留邮箱可接收回复通知。支持全匿名评论。</p>
3
3
  <div id="hashover"></div>`)
4
- </script>
5
- <script data-pjax type="text/javascript" src="<%= theme.comments.hashover.src %>"></script>
4
+ </script>
5
+ <script data-pjax type="text/javascript" src="<%= theme.comments.hashover.src %>"></script>
@@ -5,8 +5,8 @@
5
5
  }
6
6
  %>
7
7
  <% if (checkComment&&(theme.comments.service && theme.comments.service.length > 0)) { %>
8
-
9
- <article class="post white-box reveal <%- theme.custom_css.body.effect.join(' ') %>" id="comments">
8
+
9
+ <article class="post white-box <%- theme.custom_css.body.effect.join(' ') %>" id="comments">
10
10
  <span hidden>
11
11
  <meta itemprop="discussionUrl" content="<%- url_for(path) %>#comments">
12
12
  </span>
@@ -14,11 +14,11 @@
14
14
  <% if (theme.comments && theme.comments.subtitle) { %>
15
15
  <p cst><%- theme.comments.subtitle %></p>
16
16
  <% } %>
17
-
17
+
18
18
  <div id="layoutHelper-comments"></div>
19
19
 
20
20
  </article>
21
-
21
+
22
22
  <% } else { %>
23
23
  <% page.comments = false; %>
24
24
  <% } %>
@@ -10,7 +10,7 @@
10
10
  let placeholder = pdata.commentPlaceholder || "<%= theme.comments.twikoo.placeholder %>" || "";
11
11
  if (path.length == 0) {
12
12
  let defaultPath = '<%= theme.comments.twikoo.path %>';
13
- path = defaultPath || "decodeURI(window.location.pathname)"; //神奇的pathname 没错,twikoo这里就是字符串,不要乱动了
13
+ path = defaultPath || decodeURI(window.location.pathname);
14
14
  }
15
15
  twikoo.init(Object.assign(Object.assign(<%- JSON.stringify(theme.comments.twikoo) %>, {
16
16
  el: '#twikoo_container',
@@ -1,44 +1,62 @@
1
1
  <script>
2
2
  volantis.layoutHelper("comments",`<div id="waline"><i class="fa-solid fa-cog fa-spin fa-fw fa-2x"></i></div>`)
3
+
3
4
  function pjax_waline() {
4
5
  if(!document.querySelector("#waline"))return;
5
- let pagePlaceholder = pdata.commentPlaceholder || "<%= theme.comments.waline.placeholder %>";
6
+ let locale = {};
6
7
  let path = pdata.commentPath;
8
+ let pagePlaceholder = pdata.commentPlaceholder || "<%= theme.comments.waline.placeholder %>";
7
9
  if (path.length == 0) {
8
10
  let defaultPath = '<%= theme.comments.waline.path %>';
9
11
  path = defaultPath || decodeURI(window.location.pathname);
10
12
  }
11
- new Waline(Object.assign(Object.assign(<%- JSON.stringify(theme.comments.waline) %>, {
12
- el: '#waline',
13
- path: path,
14
- placeholder: pagePlaceholder,
15
-
16
- // https://github.com/volantis-x/hexo-theme-volantis/issues/713
17
- <% if(theme.comments.waline.imageHosting){ %>
18
- uploadImage: function(file) {
19
- const formData = new FormData();
20
- formData.append('image', file);
21
- return fetch('<%= theme.comments.waline.imageHosting %>', {
22
- method: 'POST',
23
- body: formData
24
- }).then(resp => resp.json()).then(resp => resp.data.url);
25
- }
26
- <% } %>
27
-
28
- }),pdata.commentConfig));
13
+ if(pagePlaceholder.length != 0) {
14
+ locale.placeholder = pagePlaceholder;
15
+ }
16
+
17
+ try {
18
+ Waline.init(Object.assign(Object.assign(<%- JSON.stringify(theme.comments.waline) %>, {
19
+ el: '#waline',
20
+ path: path,
21
+ // https://github.com/volantis-x/hexo-theme-volantis/issues/713
22
+ <% if(!!theme.comments.waline.imageUploader?.api){ %>
23
+ imageUploader: function(file) {
24
+ let headers = new Headers();
25
+ headers.set('Accept', 'application/json');
26
+ <% if(!!theme.comments.waline.imageUploader?.token) { %>
27
+ headers.set('Authorization', '<%= theme.comments.waline.imageUploader?.token %>')
28
+ <% } %>
29
+ let formData = new FormData();
30
+ formData.append('file', file);
31
+ return fetch('<%= theme.comments.waline.imageUploader?.api %>',{
32
+ method: 'POST',
33
+ body: formData,
34
+ headers: headers
35
+ }).then((resp) => resp.json())
36
+ .then((resp) => resp.<%= theme.comments.waline.imageUploader?.resp %>)
37
+ },
38
+ <% } %>
39
+ locale,
40
+ }),pdata.commentConfig));
41
+ } catch (error) {
42
+ alert(`Waline ${error}`)
43
+ }
29
44
  fancybox_waline()
30
45
  }
46
+
31
47
  function fancybox_waline() {
32
48
  if(typeof VolantisFancyBox === "undefined") {
33
49
  const checkFancyBox = setInterval(() => {
34
50
  if(typeof VolantisFancyBox === "undefined") return;
35
51
  clearInterval(checkFancyBox);
36
- VolantisFancyBox.bind('#waline .vcontent img:not(.vemoji)');
52
+ VolantisFancyBox.bind('#waline .wl-content img:not(.wl-emoji)');
37
53
  })
38
54
  } else {
39
- VolantisFancyBox.bind('#waline .vcontent img:not(.vemoji)');
55
+ VolantisFancyBox.bind('#waline .wl-content img:not(.wl-emoji)');
40
56
  }
41
57
  }
58
+
59
+ volantis.css('<%= theme.comments.waline.css %>')
42
60
  volantis.js('<%- theme.comments.waline.js %>').then(pjax_waline)
43
61
  volantis.pjax.push(pjax_waline);
44
- </script>
62
+ </script>
@@ -1,5 +1,5 @@
1
1
  <%_
2
- theme.plugins.parallax.images = theme.plugins.parallax.images || page.images;
2
+ theme.plugins.parallax.images = theme.plugins.parallax.images || page.images;
3
3
  if (theme.plugins.parallax.shuffle) {
4
4
  // shuffle 只一次 防止 hash 变化
5
5
  if (typeof theme.plugins.parallax.shuffle_end==='undefined') {