hexo-theme-volantis 5.0.0-rc.7 → 5.1.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 (72) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +4 -4
  3. package/_config.yml +173 -69
  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 -25
  8. package/layout/_partial/header.ejs +1 -1
  9. package/layout/_partial/scripts/_ctrl/cdnCtrl.ejs +1 -0
  10. package/layout/_partial/scripts/content-visibility-scroll-fix.ejs +71 -69
  11. package/layout/_partial/scripts/global.ejs +49 -23
  12. package/layout/_partial/scripts/index.ejs +26 -9
  13. package/layout/_partial/scripts/toc.ejs +61 -38
  14. package/layout/_plugins/_page_plugins/indent/index.ejs +1 -1
  15. package/layout/_plugins/_page_plugins/index.ejs +27 -7
  16. package/layout/_plugins/_page_plugins/snackbar/index.ejs +1 -1
  17. package/layout/_plugins/analytics/script.ejs +11 -1
  18. package/layout/_plugins/aplayer/script.ejs +2 -2
  19. package/layout/_plugins/comments/artalk/script.ejs +17 -11
  20. package/layout/_plugins/comments/beaudar/script.ejs +2 -2
  21. package/layout/_plugins/comments/discuss/script.ejs +30 -0
  22. package/layout/_plugins/comments/hashover/script.ejs +2 -2
  23. package/layout/_plugins/comments/index.ejs +4 -4
  24. package/layout/_plugins/comments/twikoo/script.ejs +1 -1
  25. package/layout/_plugins/comments/waline/script.ejs +40 -22
  26. package/layout/_plugins/parallax/script.ejs +1 -1
  27. package/layout/_plugins/pjax/index.ejs +3 -4
  28. package/layout/_plugins/pjax/pdata.ejs +0 -1
  29. package/layout/_plugins/rightmenu/layout.ejs +2 -2
  30. package/layout/_plugins/rightmenus/layout.ejs +137 -0
  31. package/layout/_plugins/search/script.ejs +14 -7
  32. package/layout/_widget/lastupdate.ejs +27 -27
  33. package/layout/_widget/webinfo.ejs +7 -7
  34. package/layout/layout.ejs +20 -3
  35. package/layout/tag.ejs +1 -1
  36. package/package.json +1 -1
  37. package/scripts/events/index.js +1 -0
  38. package/scripts/events/lib/check-configuration.js +43 -0
  39. package/scripts/events/lib/check-environment.js +74 -0
  40. package/scripts/events/lib/render-stylus.js +1 -1
  41. package/scripts/filters/content-visibility.js +2 -2
  42. package/scripts/helpers/custom-files.js +3 -1
  43. package/scripts/helpers/head/generate_seo.js +1 -1
  44. package/scripts/helpers/head/generate_title__keywords__description.js +14 -4
  45. package/scripts/helpers/structured-data/lib/blogposting.js +18 -6
  46. package/scripts/helpers/structured-data/lib/breadcrumblist.js +25 -1
  47. package/scripts/helpers/structured-data/lib/index.js +1 -9
  48. package/scripts/tags/fancybox.js +1 -1
  49. package/scripts/tags/note.js +24 -1
  50. package/scripts/tags/tabs.js +85 -86
  51. package/source/css/_defines/AutoPrefixCSS.styl +16 -16
  52. package/source/css/_defines/color.styl +23 -2
  53. package/source/css/_first/base_first.styl +5 -0
  54. package/source/css/_first/dark_first.styl +30 -29
  55. package/source/css/_first/navbar_first.styl +1 -1
  56. package/source/css/_style/_base/base.styl +2 -2
  57. package/source/css/_style/_layout/toc.styl +2 -2
  58. package/source/css/_style/_plugins/_dark/dark_async.styl +1 -1
  59. package/source/css/_style/_plugins/_dark/dark_plugins.styl +21 -5
  60. package/source/css/_style/_plugins/_highlight/highlightjs/clipboard.styl +1 -1
  61. package/source/css/_style/_plugins/_rightmenu/reading.styl +2 -2
  62. package/source/css/_style/_plugins/_rightmenu/rightmenu.styl +3 -2
  63. package/source/css/_style/_plugins/fontcolor.styl +1 -1
  64. package/source/css/_style/_plugins/index.styl +1 -1
  65. package/source/css/first.styl +5 -7
  66. package/source/js/app.js +69 -41
  67. package/source/js/plugins/aplayer.js +1 -3
  68. package/source/js/plugins/rightMenu.js +22 -22
  69. package/source/js/plugins/rightMenus.js +616 -0
  70. package/source/js/search/hexo.js +3 -0
  71. package/layout/_partial/scripts/import.ejs +0 -3
  72. package/scripts/filters/CSP.js +0 -74
@@ -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>
@@ -5,6 +5,7 @@
5
5
  volantis.dom = {}; // 页面Dom see: /source/js/app.js etc.
6
6
 
7
7
  volantis.GLOBAL_CONFIG ={
8
+ debug: <%- JSON.stringify(theme.debug) %>,
8
9
  cdn: <%- JSON.stringify(theme.cdn.map) %>,
9
10
  default: <%- JSON.stringify(theme.default) %>,
10
11
  lastupdate: new Date(<%- theme.getStartTime %>),
@@ -34,7 +35,8 @@
34
35
  layout: <%- JSON.stringify(theme.rightmenu.layout) %>,
35
36
  music_alwaysShow: <%- JSON.stringify(theme.rightmenu.music.alwaysShow) %>,
36
37
  customPicUrl: <%- JSON.stringify(theme.rightmenu.customPicUrl) %>
37
- }
38
+ },
39
+ rightmenus: <%- JSON.stringify(theme.rightmenus) %>
38
40
  }
39
41
  }
40
42
 
@@ -179,12 +181,21 @@
179
181
  error: new RunItem(),
180
182
  send: new RunItem(),
181
183
  };
182
- volantis.pjax = {
183
- ...volantis.pjax,
184
+ volantis.pjax = Object.assign(volantis.pjax, {
184
185
  push: volantis.pjax.method.complete.push,
185
186
  error: volantis.pjax.method.error.push,
186
187
  send: volantis.pjax.method.send.push,
187
- };
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
+ });
188
199
  /******************** Dark Mode ********************************/
189
200
  // /layout/_partial/scripts/darkmode.ejs
190
201
  // volantis.dark.mode 当前模式 dark or light
@@ -194,10 +205,9 @@
194
205
  volantis.dark.method = {
195
206
  toggle: new RunItem(),
196
207
  };
197
- volantis.dark = {
198
- ...volantis.dark,
208
+ volantis.dark = Object.assign(volantis.dark, {
199
209
  push: volantis.dark.method.toggle.push,
200
- };
210
+ });
201
211
  /******************** Message ********************************/
202
212
  // VolantisApp.message
203
213
  /******************** isMobile ********************************/
@@ -307,10 +317,9 @@
307
317
  engine: new RunItem(),
308
318
  unengine: new RunItem(),
309
319
  };
310
- volantis.scroll = {
311
- ...volantis.scroll,
320
+ volantis.scroll = Object.assign(volantis.scroll, {
312
321
  push: volantis.scroll.engine.push,
313
- };
322
+ });
314
323
  // 滚动条距离顶部的距离
315
324
  volantis.scroll.getScrollTop = () =>{
316
325
  let scrollPos;
@@ -337,6 +346,8 @@
337
346
  // } else {
338
347
  // console.log("向上滚动");
339
348
  // }
349
+ // 注销过期的unengine未滚动事件
350
+ volantis.scroll.unengine.list=[]
340
351
  volantis.scroll.engine.start();
341
352
  }else{
342
353
  volantis.scroll.unengine.start();
@@ -364,24 +375,39 @@
364
375
  opt.top += option.addTop
365
376
  }
366
377
  if (!("observerDic" in option)) {
367
- option.observerDic = 25
378
+ option.observerDic = 100
368
379
  }
369
380
  // 滚动
370
381
  window.scrollTo(opt);
371
382
  // 监视器
372
- // 监视并矫正元素滚动到指定位置
373
- // 目前用于处理 toc 部分 lazyload 引起的 cls 导致的定位失败问题 [存在Bug]
374
- // if (option.observer) {
375
- // volantis.scroll.unengine.push(()=>{
376
- // let me = ele.getBoundingClientRect().top
377
- // if(!(me >= -option.observerDic && me <= option.observerDic)){
378
- // volantis.scroll.to(ele, option)
379
- // }else{
380
- // volantis.scroll.unengine.remove("unengineObserver")
381
- // }
382
- // },"unengineObserver")
383
- // }
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
+ }
384
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
+ /******************************************************************************/
385
411
  /******************************************************************************/
386
412
  /******************************************************************************/
387
413
  //图像加载出错时的处理
@@ -35,6 +35,10 @@
35
35
  <%- partial('../../_plugins/rightmenu/layout') %>
36
36
  <% } %>
37
37
 
38
+ <% if (theme.rightmenus.enable) { %>
39
+ <%- partial('../../_plugins/rightmenus/layout') %>
40
+ <% } %>
41
+
38
42
  <!-- rightmenu要在darkmode之前(ToggleButton) darkmode要在comments之前(volantis.dark.push)-->
39
43
  <% if (theme.plugins.darkmode.enable) { %>
40
44
  <%- partial('../../_plugins/darkmode/script') %>
@@ -60,9 +64,27 @@
60
64
  <%- partial('../../_plugins/aplayer/script') %>
61
65
  <% } %>
62
66
 
63
- <% if (theme.comments.service && theme.comments.service.length > 0) { %>
64
- <%- partial('../../_plugins/comments/' + theme.comments.service + '/script') %>
65
- <% } %>
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
+
66
88
 
67
89
  <% if (theme.analytics.busuanzi) { %>
68
90
  <script defer src="<%- theme.analytics.busuanzi %>" data-pjax></script>
@@ -89,7 +111,7 @@
89
111
  <%- partial('../../_plugins/analytics/LCCounter') %>
90
112
  <% } %>
91
113
 
92
- <% 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) { %>
93
115
  <%- partial('../../_plugins/analytics/script') %>
94
116
  <% } %>
95
117
 
@@ -120,8 +142,3 @@
120
142
  <%- structured_data() %>
121
143
  <% } %>
122
144
 
123
- <!-- more -->
124
- <% if (config.import && config.import.script) { %>
125
- <%- partial('import') %>
126
- <% } %>
127
-
@@ -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
+
@@ -4,7 +4,7 @@
4
4
  // APlayer 需要在 MetingJS 之前加载
5
5
  await volantis.js("<%- theme.plugins.aplayer.js.aplayer %>")
6
6
  await volantis.js("<%- theme.plugins.aplayer.js.meting %>")
7
- <% if (theme.rightmenu.enable && theme.rightmenu.layout.includes('music')) { %>
7
+ <% if ((theme.rightmenu.enable || theme.rightmenus.enable) && theme.rightmenu.layout.includes('music')) { %>
8
8
  // 右键 music 需要在 APlayer MetingJS 之后加载
9
9
  await volantis.js('<%- theme.cdn.addJS("plugins/aplayer") %>')
10
10
  <% } %>
@@ -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);