hexo-theme-volantis 5.0.0-rc.8 → 5.1.1

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 (64) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +5 -4
  3. package/_config.yml +73 -60
  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 +17 -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/index.js +1 -0
  35. package/scripts/events/lib/check-configuration.js +43 -0
  36. package/scripts/events/lib/check-environment.js +74 -0
  37. package/scripts/events/lib/config.js +3 -0
  38. package/scripts/events/lib/render-stylus.js +1 -1
  39. package/scripts/filters/content-visibility.js +2 -2
  40. package/scripts/helpers/custom-files.js +3 -1
  41. package/scripts/helpers/head/generate_seo.js +1 -1
  42. package/scripts/helpers/structured-data/lib/blogposting.js +18 -6
  43. package/scripts/helpers/structured-data/lib/breadcrumblist.js +25 -1
  44. package/scripts/helpers/structured-data/lib/index.js +1 -9
  45. package/scripts/tags/fancybox.js +1 -1
  46. package/scripts/tags/note.js +24 -1
  47. package/scripts/tags/tabs.js +85 -86
  48. package/source/css/_defines/AutoPrefixCSS.styl +16 -16
  49. package/source/css/_first/base_first.styl +6 -0
  50. package/source/css/_first/navbar_first.styl +1 -1
  51. package/source/css/_style/_base/base.styl +1 -1
  52. package/source/css/_style/_layout/toc.styl +2 -2
  53. package/source/css/_style/_plugins/_dark/dark_async.styl +1 -1
  54. package/source/css/_style/_plugins/_dark/dark_plugins.styl +8 -4
  55. package/source/css/_style/_plugins/_rightmenu/reading.styl +2 -2
  56. package/source/css/_style/_plugins/_rightmenu/rightmenu.styl +1 -1
  57. package/source/css/_style/_plugins/fontcolor.styl +1 -1
  58. package/source/css/first.styl +5 -7
  59. package/source/js/app.js +32 -35
  60. package/source/js/plugins/aplayer.js +1 -3
  61. package/source/js/plugins/rightMenu.js +22 -22
  62. package/source/js/plugins/rightMenus.js +115 -78
  63. package/source/js/search/hexo.js +3 -0
  64. package/layout/_partial/scripts/import.ejs +0 -3
@@ -1,86 +1,88 @@
1
1
  <script>
2
- // https://web.dev/content-visibility/
3
- // https://www.caniuse.com/?search=content-visibility
4
- // https://infrequently.org/2020/12/content-visibility-scroll-fix/
5
- // https://infrequently.org/2020/12/resize-resilient-deferred-rendering/
2
+ try {
3
+ // https://web.dev/content-visibility/
4
+ // https://www.caniuse.com/?search=content-visibility
5
+ // https://infrequently.org/2020/12/content-visibility-scroll-fix/
6
+ // https://infrequently.org/2020/12/resize-resilient-deferred-rendering/
6
7
 
7
- // 备注 目前已知的问题:
8
- // 动态修改导致的内容高度变化(例如评论框异步渲染的外部盒子高度变化) 无法提前获知, 进而导致的首次滚动条跳动无法去除 (wontfix) 事实上不使用 content-visibility 也会有跳动, 不过是比使用 content-visibility 跳动提前
9
- // scrollreveal 插件潜在问题 目前尚不明确
8
+ // 备注 目前已知的问题:
9
+ // 动态修改导致的内容高度变化(例如评论框异步渲染的外部盒子高度变化) 无法提前获知, 进而导致的首次滚动条跳动无法去除 (wontfix) 事实上不使用 content-visibility 也会有跳动, 不过是比使用 content-visibility 跳动提前
10
+ // scrollreveal 插件潜在问题 目前尚不明确
10
11
 
11
- let eqIsh = (a, b, fuzz = 2) => {
12
- return Math.abs(a - b) <= fuzz;
13
- };
12
+ let eqIsh = (a, b, fuzz = 2) => {
13
+ return Math.abs(a - b) <= fuzz;
14
+ };
14
15
 
15
- let rectNotEQ = (a, b) => {
16
- return !eqIsh(a.width, b.width) || !eqIsh(a.height, b.height);
17
- };
16
+ let rectNotEQ = (a, b) => {
17
+ return !eqIsh(a.width, b.width) || !eqIsh(a.height, b.height);
18
+ };
18
19
 
19
- // Keep a map of elements and the dimensions of
20
- // their place-holders, re-setting the element's
21
- // intrinsic size when we get updated measurements
22
- // from observers.
23
- let spaced = new WeakMap();
20
+ // Keep a map of elements and the dimensions of
21
+ // their place-holders, re-setting the element's
22
+ // intrinsic size when we get updated measurements
23
+ // from observers.
24
+ let spaced = new WeakMap();
24
25
 
25
- // Only call this when known cheap, post layout
26
- let reserveSpace = (el, rect = el.getClientBoundingRect()) => {
27
- let old = spaced.get(el);
28
- // Set intrinsic size to prevent jumping on un-painting:
29
- // https://drafts.csswg.org/css-sizing-4/#intrinsic-size-override
30
- if (!old || rectNotEQ(old, rect)) {
31
- spaced.set(el, rect);
32
- el.style["contain-intrinsic-size"] = `${rect.width}px ${rect.height}px`;
33
- }
34
- };
26
+ // Only call this when known cheap, post layout
27
+ let reserveSpace = (el, rect = el.getClientBoundingRect()) => {
28
+ let old = spaced.get(el);
29
+ // Set intrinsic size to prevent jumping on un-painting:
30
+ // https://drafts.csswg.org/css-sizing-4/#intrinsic-size-override
31
+ if (!old || rectNotEQ(old, rect)) {
32
+ spaced.set(el, rect);
33
+ el.style["contain-intrinsic-size"] = `${rect.width}px ${rect.height}px`;
34
+ }
35
+ };
35
36
 
36
- let iObs = new IntersectionObserver(
37
- (entries, o) => {
37
+ let iObs = new IntersectionObserver(
38
+ (entries, o) => {
39
+ entries.forEach((entry) => {
40
+ // We don't care if the element is intersecting or
41
+ // has been laid out as our page structure ensures
42
+ // they'll get the right width.
43
+ reserveSpace(entry.target, entry.boundingClientRect);
44
+ });
45
+ },
46
+ { rootMargin: "500px 0px 500px 0px" }
47
+ );
48
+
49
+ let rObs = new ResizeObserver((entries, o) => {
38
50
  entries.forEach((entry) => {
39
- // We don't care if the element is intersecting or
40
- // has been laid out as our page structure ensures
41
- // they'll get the right width.
42
- reserveSpace(entry.target, entry.boundingClientRect);
51
+ reserveSpace(entry.target, entry.contentRect);
43
52
  });
44
- },
45
- { rootMargin: "500px 0px 500px 0px" }
46
- );
47
-
48
- let rObs = new ResizeObserver((entries, o) => {
49
- entries.forEach((entry) => {
50
- reserveSpace(entry.target, entry.contentRect);
51
53
  });
52
- });
53
54
 
54
- let resizeResilientDeferredRendering = (Selector) => {
55
- let articles = document.querySelectorAll(Selector);
55
+ let resizeResilientDeferredRendering = (Selector) => {
56
+ let articles = document.querySelectorAll(Selector);
56
57
 
57
- if (articles.length) {
58
- articles.forEach((el) => {
59
- iObs.observe(el);
60
- rObs.observe(el);
61
- });
58
+ if (articles.length) {
59
+ articles.forEach((el) => {
60
+ iObs.observe(el);
61
+ rObs.observe(el);
62
+ });
62
63
 
63
- // Workaround for Chrome bug, part 2.
64
- //
65
- // Re-enable browser management of rendering for the
66
- // first article after the first paint. Double-rAF
67
- // to ensure we get called after a layout.
68
- requestAnimationFrame(() => {
64
+ // Workaround for Chrome bug, part 2.
65
+ //
66
+ // Re-enable browser management of rendering for the
67
+ // first article after the first paint. Double-rAF
68
+ // to ensure we get called after a layout.
69
69
  requestAnimationFrame(() => {
70
- articles[0].style["content-visibility"] = "auto";
70
+ requestAnimationFrame(() => {
71
+ articles[0].style["content-visibility"] = "auto";
72
+ });
71
73
  });
72
- });
73
- }
74
- };
74
+ }
75
+ };
75
76
 
76
- let contentVisibilityScrollFix = () => {
77
- if (!("content-visibility" in document.documentElement.style)) {
78
- return;
79
- }
80
- resizeResilientDeferredRendering(".post-story");
81
- resizeResilientDeferredRendering("article");
82
- resizeResilientDeferredRendering(".post-wrapper");
83
- };
84
- contentVisibilityScrollFix();
85
- volantis.pjax.push(contentVisibilityScrollFix);
77
+ let contentVisibilityScrollFix = () => {
78
+ if (!("content-visibility" in document.documentElement.style)) {
79
+ return;
80
+ }
81
+ resizeResilientDeferredRendering(".post-story");
82
+ };
83
+ contentVisibilityScrollFix();
84
+ volantis.pjax.push(contentVisibilityScrollFix);
85
+ } catch (error) {
86
+ console.log(error);
87
+ }
86
88
  </script>
@@ -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() {
@@ -19,20 +19,24 @@
19
19
  pageKey: path,
20
20
  pageTitle: document.title,
21
21
  placeholder: placeholder,
22
+ useBackendConf: true,
22
23
  site: '<%= config.title %>',
23
- darkMode: volantis.dark.mode === "dark"
24
+ darkMode: volantis.dark.mode === "dark",
25
+ pvEl: '#artalk_visitors'
24
26
  }));
25
27
 
26
- volantis.artalk.on('comments-loaded', () => {
27
- if (typeof VolantisFancyBox === "undefined"){
28
- const checkFancyBox = setInterval(() => {
29
- if(typeof VolantisFancyBox === "undefined") return;
30
- clearInterval(checkFancyBox);
28
+ volantis.artalk.then(ctx => {
29
+ ctx.on('comments-loaded', () => {
30
+ if (typeof VolantisFancyBox === "undefined"){
31
+ const checkFancyBox = setInterval(() => {
32
+ if(typeof VolantisFancyBox === "undefined") return;
33
+ clearInterval(checkFancyBox);
34
+ VolantisFancyBox.groupBind('.atk-content img:not([atk-emoticon])', 'Comments');
35
+ })
36
+ } else {
31
37
  VolantisFancyBox.groupBind('.atk-content img:not([atk-emoticon])', 'Comments');
32
- })
33
- } else {
34
- VolantisFancyBox.groupBind('.atk-content img:not([atk-emoticon])', 'Comments');
35
- }
38
+ }
39
+ })
36
40
  })
37
41
  }
38
42
 
@@ -47,7 +51,9 @@
47
51
 
48
52
  function dark_artalk() {
49
53
  if(!document.querySelectorAll("#artalk_container")[0]) return;
50
- volantis.artalk.setDarkMode(volantis.dark.mode === "dark")
54
+ volantis.artalk.then(ctx => {
55
+ ctx.setDarkMode(volantis.dark.mode === "dark")
56
+ })
51
57
  }
52
58
  volantis.dark.push(dark_artalk);
53
59
  </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>