hexo-theme-volantis 4.3.1 → 5.0.0-alpha.112

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 (309) hide show
  1. package/README.md +6 -4
  2. package/_config.yml +599 -246
  3. package/languages/en.yml +7 -0
  4. package/languages/zh-CN.yml +13 -2
  5. package/languages/zh-TW.yml +7 -0
  6. package/layout/404.ejs +1 -1
  7. package/layout/_meta/author.ejs +4 -4
  8. package/layout/_meta/category.ejs +11 -8
  9. package/layout/_meta/counter.ejs +29 -7
  10. package/layout/_meta/date.ejs +1 -1
  11. package/layout/_meta/music.ejs +1 -1
  12. package/layout/_meta/share.ejs +1 -1
  13. package/layout/_meta/tags.ejs +3 -0
  14. package/layout/_meta/thumbnail.ejs +3 -1
  15. package/layout/_meta/updated.ejs +1 -1
  16. package/layout/_meta/walinecount.ejs +2 -1
  17. package/layout/{_cover → _partial/_cover}/blank.ejs +0 -0
  18. package/layout/{_cover → _partial/_cover}/dock.ejs +1 -1
  19. package/layout/{_cover → _partial/_cover}/featured.ejs +1 -1
  20. package/layout/{_cover → _partial/_cover}/focus.ejs +1 -1
  21. package/layout/_partial/_cover/layout.ejs +8 -0
  22. package/layout/{_cover → _partial/_cover}/search.ejs +2 -2
  23. package/layout/_partial/archive.ejs +2 -2
  24. package/layout/_partial/article.ejs +21 -16
  25. package/layout/_partial/categories.ejs +1 -1
  26. package/layout/_partial/cover.ejs +8 -28
  27. package/layout/_partial/footer.ejs +19 -11
  28. package/layout/_partial/head.ejs +70 -116
  29. package/layout/_partial/header.ejs +17 -11
  30. package/layout/_partial/meta.ejs +18 -4
  31. package/layout/_partial/post.ejs +35 -9
  32. package/layout/_partial/scripts/_ctrl/cdnCtrl.ejs +126 -0
  33. package/layout/_partial/scripts/{coverCtrl.ejs → _ctrl/coverCtrl.ejs} +17 -25
  34. package/layout/_partial/scripts/_ctrl.ejs +2 -0
  35. package/layout/_partial/scripts/content-visibility-scroll-fix.ejs +88 -0
  36. package/layout/_partial/scripts/global.ejs +422 -109
  37. package/layout/_partial/scripts/index.ejs +91 -46
  38. package/layout/_partial/scripts/toc.ejs +98 -68
  39. package/layout/_partial/side.ejs +4 -1
  40. package/layout/_plugins/_page_plugins/artitalk/index.ejs +15 -0
  41. package/layout/_plugins/_page_plugins/bbtalk/index.ejs +10 -0
  42. package/layout/_plugins/_page_plugins/fcircle/index.ejs +12 -0
  43. package/layout/_plugins/_page_plugins/gitter/index.ejs +14 -0
  44. package/layout/_plugins/_page_plugins/indent/index.ejs +16 -0
  45. package/layout/_plugins/_page_plugins/index.ejs +27 -0
  46. package/layout/_plugins/_page_plugins/katex/index.ejs +13 -0
  47. package/layout/{_third-party/math/mathjax/script.ejs → _plugins/_page_plugins/mathjax/index.ejs} +2 -2
  48. package/layout/_plugins/_page_plugins/snackbar/index.ejs +55 -0
  49. package/layout/{_partial/scripts/counter.ejs → _plugins/analytics/LCCounter.ejs} +0 -0
  50. package/layout/{_third-party → _plugins}/analytics/script.ejs +43 -5
  51. package/layout/{_third-party → _plugins}/aplayer/layout.ejs +0 -0
  52. package/layout/_plugins/aplayer/script.ejs +74 -0
  53. package/layout/_plugins/chat/gitter/script.ejs +17 -0
  54. package/layout/_plugins/chat/index.ejs +1 -0
  55. package/layout/_plugins/chat/tidio/script.ejs +1 -0
  56. package/layout/_plugins/comments/artalk/script.ejs +59 -0
  57. package/layout/_plugins/comments/beaudar/script.ejs +61 -0
  58. package/layout/_plugins/comments/discuss/script.ejs +30 -0
  59. package/layout/_plugins/comments/disqus/script.ejs +98 -0
  60. package/layout/_plugins/comments/disqusjs/script.ejs +35 -0
  61. package/layout/_plugins/comments/giscus/script.ejs +47 -0
  62. package/layout/_plugins/comments/gitalk/script.ejs +24 -0
  63. package/layout/_plugins/comments/hashover/script.ejs +5 -0
  64. package/layout/{_third-party → _plugins}/comments/index.ejs +10 -3
  65. package/layout/_plugins/comments/isso/script.ejs +27 -0
  66. package/layout/_plugins/comments/livere/script.ejs +15 -0
  67. package/layout/_plugins/comments/twikoo/script.ejs +40 -0
  68. package/layout/_plugins/comments/utterances/script.ejs +43 -0
  69. package/layout/_plugins/comments/vssue/script.ejs +37 -0
  70. package/layout/_plugins/comments/waline/script.ejs +62 -0
  71. package/layout/_plugins/comments/z-custom/script.ejs +1 -0
  72. package/layout/_plugins/darkmode/script.ejs +114 -0
  73. package/layout/{_third-party → _plugins}/end-of-support/script.ejs +25 -8
  74. package/layout/_plugins/github-api/script.ejs +27 -0
  75. package/layout/_plugins/highlight/highlightjs/script.ejs +26 -0
  76. package/layout/_plugins/highlight/prismjs/script.ejs +25 -0
  77. package/layout/_plugins/highlight/script.ejs +1 -0
  78. package/layout/{_third-party → _plugins}/lazyload/script.ejs +1 -1
  79. package/layout/{_third-party → _plugins}/nodewaves/script.ejs +1 -1
  80. package/layout/_plugins/parallax/script.ejs +74 -0
  81. package/layout/{_third-party → _plugins}/pjax/animate.ejs +31 -31
  82. package/layout/_plugins/pjax/index.ejs +73 -0
  83. package/layout/_plugins/pjax/pdata.ejs +56 -0
  84. package/layout/{_third-party → _plugins}/preload/script.ejs +3 -3
  85. package/layout/_plugins/rightmenu/layout.ejs +119 -0
  86. package/layout/_plugins/rightmenus/layout.ejs +137 -0
  87. package/layout/_plugins/scrollreveal/script.ejs +25 -0
  88. package/layout/_plugins/search/script.ejs +50 -0
  89. package/layout/{_third-party → _plugins}/share/layout.ejs +0 -0
  90. package/layout/_plugins/swiper/script.ejs +37 -0
  91. package/layout/_pre.ejs +2 -2
  92. package/layout/_widget/_pre.ejs +5 -0
  93. package/layout/_widget/blogger.ejs +1 -1
  94. package/layout/_widget/category.ejs +2 -2
  95. package/layout/_widget/copyright.ejs +1 -1
  96. package/layout/_widget/grid.ejs +3 -3
  97. package/layout/_widget/lastupdate.ejs +27 -0
  98. package/layout/_widget/list.ejs +2 -2
  99. package/layout/_widget/load.ejs +18 -0
  100. package/layout/_widget/music.ejs +3 -2
  101. package/layout/_widget/page.ejs +1 -1
  102. package/layout/_widget/qrcode.ejs +1 -1
  103. package/layout/_widget/related_posts.ejs +1 -1
  104. package/layout/_widget/tagcloud.ejs +1 -1
  105. package/layout/_widget/text.ejs +1 -1
  106. package/layout/_widget/toc.ejs +6 -2
  107. package/layout/_widget/webinfo.ejs +13 -76
  108. package/layout/archive.ejs +4 -4
  109. package/layout/category.ejs +9 -4
  110. package/layout/docs.ejs +1 -1
  111. package/layout/friends.ejs +6 -25
  112. package/layout/index.ejs +1 -1
  113. package/layout/layout.ejs +30 -12
  114. package/layout/list.ejs +1 -1
  115. package/layout/page.ejs +1 -1
  116. package/layout/post.ejs +1 -1
  117. package/layout/tag.ejs +8 -3
  118. package/package.json +5 -3
  119. package/scripts/events/index.js +13 -0
  120. package/scripts/events/lib/check-configuration.js +43 -0
  121. package/scripts/events/lib/check-environment.js +74 -0
  122. package/scripts/events/lib/config.js +34 -9
  123. package/scripts/events/lib/render-stylus.js +78 -0
  124. package/scripts/events/lib/stellar-tag-utils.js +76 -0
  125. package/scripts/filters/content-visibility.js +25 -0
  126. package/scripts/{render → filters}/img.js +0 -0
  127. package/scripts/filters/replace.js +15 -0
  128. package/scripts/{z-lazyload/lib/process.js → filters/z-lazyload.js} +6 -3
  129. package/scripts/helpers/custom-files.js +165 -0
  130. package/scripts/helpers/first-style.js +19 -0
  131. package/scripts/helpers/head/autoCanonical.js +15 -0
  132. package/scripts/helpers/head/generate_preload_fontfamily.js +22 -0
  133. package/scripts/helpers/head/generate_seo.js +24 -0
  134. package/scripts/helpers/head/generate_title__keywords__description.js +101 -0
  135. package/scripts/{related_posts/index.js → helpers/related-posts.js} +1 -1
  136. package/scripts/helpers/revisioned.js +158 -0
  137. package/scripts/helpers/structured-data/index.js +2 -0
  138. package/scripts/helpers/structured-data/lib/blogposting.js +77 -0
  139. package/scripts/helpers/structured-data/lib/breadcrumblist.js +152 -0
  140. package/scripts/helpers/structured-data/lib/config.js +31 -0
  141. package/scripts/helpers/structured-data/lib/index.js +30 -0
  142. package/scripts/helpers/structured-data/lib/organization.js +15 -0
  143. package/scripts/helpers/structured-data/lib/person.js +16 -0
  144. package/scripts/helpers/structured-data/lib/website.js +42 -0
  145. package/scripts/tags/btn.js +6 -1
  146. package/scripts/tags/btns.js +7 -2
  147. package/scripts/tags/checkbox.js +12 -2
  148. package/scripts/tags/contributors.js +100 -0
  149. package/scripts/tags/dropmenu.js +18 -3
  150. package/scripts/tags/fancybox.js +44 -10
  151. package/scripts/tags/folding.js +6 -1
  152. package/scripts/tags/frame.js +6 -1
  153. package/scripts/tags/friends.js +99 -0
  154. package/scripts/tags/ghcard.js +6 -1
  155. package/scripts/tags/image.js +14 -2
  156. package/scripts/tags/link.js +6 -1
  157. package/scripts/tags/md.js +59 -0
  158. package/scripts/tags/media.js +25 -1
  159. package/scripts/tags/note.js +36 -3
  160. package/scripts/tags/site.js +87 -51
  161. package/scripts/tags/span.js +12 -2
  162. package/scripts/tags/swiper.js +38 -0
  163. package/scripts/tags/tabs.js +33 -3
  164. package/scripts/tags/timeline.js +6 -1
  165. package/source/css/Readme.md +28 -0
  166. package/source/css/_defines/AutoPrefixCSS.styl +347 -0
  167. package/source/css/_defines/Readme.md +3 -0
  168. package/source/css/_defines/color.styl +41 -1
  169. package/source/css/_defines/effect.styl +0 -13
  170. package/source/css/_defines/fonts.styl +17 -18
  171. package/source/css/_defines/func.styl +12 -30
  172. package/source/css/_first/base_first.styl +118 -0
  173. package/source/css/_first/{cover.styl → cover_first.styl} +113 -87
  174. package/source/css/_first/dark_first.styl +76 -0
  175. package/source/css/_first/fontfamily_first.styl +17 -0
  176. package/source/css/_first/{navbar.styl → navbar_first.styl} +4 -10
  177. package/source/css/_first/search_first.styl +12 -0
  178. package/source/css/{_base/index.styl → _style/_base/base.styl} +9 -93
  179. package/source/css/_style/_base/fontfamily_async.styl +8 -0
  180. package/source/css/{_layout → _style/_layout}/archive.styl +0 -0
  181. package/source/css/{_layout → _style/_layout}/article.styl +3 -30
  182. package/source/css/{_layout → _style/_layout}/footer.styl +0 -0
  183. package/source/css/_style/_layout/friends-simpleuser.styl +23 -0
  184. package/source/css/_style/_layout/friends-traditional.styl +81 -0
  185. package/source/css/{_layout → _style/_layout}/img.styl +0 -0
  186. package/source/css/_style/_layout/loading.styl +14 -0
  187. package/source/css/{_layout → _style/_layout}/main.styl +19 -7
  188. package/source/css/{_layout → _style/_layout}/md.styl +0 -0
  189. package/source/css/{_layout → _style/_layout}/pagination.styl +1 -1
  190. package/source/css/{_layout → _style/_layout}/posts.styl +2 -0
  191. package/source/css/{_first → _style/_layout}/search.styl +0 -103
  192. package/source/css/{_layout → _style/_layout}/sidebar.styl +23 -3
  193. package/source/css/{_layout → _style/_layout}/snackbar.styl +0 -0
  194. package/source/css/{_layout → _style/_layout}/toc.styl +3 -3
  195. package/source/css/{_layout → _style/_layout}/video.styl +0 -0
  196. package/source/css/_style/_plugins/_dark/dark_async.styl +41 -0
  197. package/source/css/_style/_plugins/_dark/dark_plugins.styl +136 -0
  198. package/source/css/_style/_plugins/_highlight/highlightjs/clipboard.styl +36 -0
  199. package/source/css/_style/_plugins/_highlight/highlightjs/color.styl +96 -0
  200. package/source/css/_style/_plugins/_highlight/highlightjs/index.styl +102 -0
  201. package/source/css/_style/_plugins/_highlight/highlightjs/language.styl +63 -0
  202. package/source/css/_style/_plugins/_highlight/index.styl +1 -0
  203. package/source/css/_style/_plugins/_highlight/prismjs/clipboard.styl +33 -0
  204. package/source/css/_style/_plugins/_highlight/prismjs/index.styl +8 -0
  205. package/source/css/_style/_plugins/_highlight/prismjs/language.styl +63 -0
  206. package/source/css/_style/_plugins/_rightmenu/reading.styl +56 -0
  207. package/source/css/{_plugins → _style/_plugins/_rightmenu}/rightmenu.styl +22 -2
  208. package/source/css/{_plugins → _style/_plugins}/aplayer.styl +8 -1
  209. package/source/css/{_plugins → _style/_plugins}/cursor.styl +49 -19
  210. package/source/css/_style/_plugins/fontcolor.styl +84 -0
  211. package/source/css/{_plugins → _style/_plugins}/gitalk.styl +0 -0
  212. package/source/css/_style/_plugins/index.styl +24 -0
  213. package/source/css/{_plugins → _style/_plugins}/mathjax.styl +0 -0
  214. package/source/css/_style/_plugins/message.styl +14 -0
  215. package/source/css/{_plugins → _style/_plugins}/pjaxanimate.styl +0 -0
  216. package/source/css/_style/_tag-plugins/Readme.md +6 -0
  217. package/source/css/{_tag-plugins → _style/_tag-plugins}/btns.styl +0 -0
  218. package/source/css/{_tag-plugins → _style/_tag-plugins}/checkbox.styl +0 -0
  219. package/source/css/{_tag-plugins → _style/_tag-plugins}/dropmenu.styl +0 -0
  220. package/source/css/{_plugins → _style/_tag-plugins}/fancybox.styl +8 -9
  221. package/source/css/{_tag-plugins → _style/_tag-plugins}/folding.styl +0 -0
  222. package/source/css/{_tag-plugins → _style/_tag-plugins}/frame.styl +0 -0
  223. package/source/css/_style/_tag-plugins/friends.styl +72 -0
  224. package/source/css/{_tag-plugins → _style/_tag-plugins}/ghcard.styl +0 -0
  225. package/source/css/{_tag-plugins → _style/_tag-plugins}/image.styl +0 -0
  226. package/source/css/{_tag-plugins → _style/_tag-plugins}/link.styl +0 -0
  227. package/source/css/{_tag-plugins → _style/_tag-plugins}/media.styl +0 -0
  228. package/source/css/{_tag-plugins → _style/_tag-plugins}/note.styl +0 -0
  229. package/source/css/_style/_tag-plugins/sites.styl +87 -0
  230. package/source/css/{_tag-plugins → _style/_tag-plugins}/span.styl +0 -0
  231. package/source/css/_style/_tag-plugins/swiper.styl +44 -0
  232. package/source/css/{_tag-plugins → _style/_tag-plugins}/table.styl +0 -0
  233. package/source/css/{_tag-plugins → _style/_tag-plugins}/tabs.styl +0 -0
  234. package/source/css/_style/_tag-plugins/tag.json +35 -0
  235. package/source/css/_style/_tag-plugins/text.styl +31 -0
  236. package/source/css/{_tag-plugins → _style/_tag-plugins}/timeline.styl +0 -0
  237. package/source/css/_style/index.styl +8 -0
  238. package/source/css/first.styl +17 -6
  239. package/source/css/style.styl +9 -7
  240. package/source/js/app.js +1051 -278
  241. package/source/js/plugins/aplayer.js +186 -0
  242. package/source/js/plugins/parallax.js +191 -0
  243. package/source/js/plugins/rightMenu.js +577 -0
  244. package/source/js/plugins/rightMenus.js +616 -0
  245. package/source/js/plugins/tags/contributors.js +92 -0
  246. package/source/js/plugins/tags/friends.js +93 -0
  247. package/source/js/plugins/tags/sites.js +96 -0
  248. package/source/js/search/hexo.js +180 -373
  249. package/.eslintrc.json +0 -111
  250. package/layout/_meta/valinecount.ejs +0 -15
  251. package/layout/_partial/rightmenu.ejs +0 -199
  252. package/layout/_partial/scripts/cover.ejs +0 -45
  253. package/layout/_partial/scripts/darkmode.ejs +0 -85
  254. package/layout/_partial/scripts/import.ejs +0 -3
  255. package/layout/_partial/scripts/issues.ejs +0 -18
  256. package/layout/_partial/scripts/search.ejs +0 -62
  257. package/layout/_partial/snackbar.ejs +0 -22
  258. package/layout/_third-party/aplayer/script.ejs +0 -26
  259. package/layout/_third-party/clipboard/script.ejs +0 -54
  260. package/layout/_third-party/comments/disqus/layout.ejs +0 -5
  261. package/layout/_third-party/comments/disqus/script.ejs +0 -90
  262. package/layout/_third-party/comments/disqusjs/layout.ejs +0 -1
  263. package/layout/_third-party/comments/disqusjs/script.ejs +0 -34
  264. package/layout/_third-party/comments/gitalk/layout.ejs +0 -1
  265. package/layout/_third-party/comments/gitalk/script.ejs +0 -22
  266. package/layout/_third-party/comments/hashover/layout.ejs +0 -2
  267. package/layout/_third-party/comments/hashover/script.ejs +0 -1
  268. package/layout/_third-party/comments/isso/layout.ejs +0 -1
  269. package/layout/_third-party/comments/isso/script.ejs +0 -1
  270. package/layout/_third-party/comments/livere/layout.ejs +0 -3
  271. package/layout/_third-party/comments/livere/script.ejs +0 -10
  272. package/layout/_third-party/comments/minivaline/layout.ejs +0 -3
  273. package/layout/_third-party/comments/minivaline/script.ejs +0 -34
  274. package/layout/_third-party/comments/twikoo/layout.ejs +0 -3
  275. package/layout/_third-party/comments/twikoo/script.ejs +0 -32
  276. package/layout/_third-party/comments/valine/layout.ejs +0 -3
  277. package/layout/_third-party/comments/valine/script.ejs +0 -49
  278. package/layout/_third-party/comments/vssue/layout.ejs +0 -1
  279. package/layout/_third-party/comments/vssue/script.ejs +0 -21
  280. package/layout/_third-party/comments/waline/layout.ejs +0 -3
  281. package/layout/_third-party/comments/waline/script.ejs +0 -33
  282. package/layout/_third-party/fancybox/script.ejs +0 -61
  283. package/layout/_third-party/highlightjs/script.ejs +0 -11
  284. package/layout/_third-party/pjax/index.ejs +0 -78
  285. package/layout/_third-party/pjax/pdata.ejs +0 -53
  286. package/layout/_third-party/scrollreveal/script.ejs +0 -21
  287. package/layout/_third-party/tidio/script.ejs +0 -3
  288. package/layout/artitalk.ejs +0 -13
  289. package/layout/bb.ejs +0 -10
  290. package/package-lock.json +0 -916
  291. package/scripts/tags/issues.js +0 -41
  292. package/scripts/z-lazyload/index.js +0 -4
  293. package/source/css/_highlight/index.styl +0 -316
  294. package/source/css/_layout/friends.styl +0 -79
  295. package/source/css/_plugins/clipboard.styl +0 -37
  296. package/source/css/_plugins/dark.styl +0 -149
  297. package/source/css/_plugins/darkmode.styl +0 -9
  298. package/source/css/_plugins/index.styl +0 -18
  299. package/source/css/_plugins/twikoo.styl +0 -21
  300. package/source/css/_plugins/valine.styl +0 -183
  301. package/source/css/_tag-plugins/simpleuser.styl +0 -21
  302. package/source/css/_tag-plugins/site-card.styl +0 -70
  303. package/source/js/aplayer.js +0 -167
  304. package/source/js/issues.js +0 -186
  305. package/source/js/search/algolia.js +0 -344
  306. package/source/js/search/azure.js +0 -355
  307. package/source/js/search/baidu.js +0 -340
  308. package/source/js/search/google.js +0 -339
  309. package/source/js/valine.js +0 -5137
@@ -0,0 +1,88 @@
1
+ <script>
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/
7
+
8
+ // 备注 目前已知的问题:
9
+ // 动态修改导致的内容高度变化(例如评论框异步渲染的外部盒子高度变化) 无法提前获知, 进而导致的首次滚动条跳动无法去除 (wontfix) 事实上不使用 content-visibility 也会有跳动, 不过是比使用 content-visibility 跳动提前
10
+ // scrollreveal 插件潜在问题 目前尚不明确
11
+
12
+ let eqIsh = (a, b, fuzz = 2) => {
13
+ return Math.abs(a - b) <= fuzz;
14
+ };
15
+
16
+ let rectNotEQ = (a, b) => {
17
+ return !eqIsh(a.width, b.width) || !eqIsh(a.height, b.height);
18
+ };
19
+
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();
25
+
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
+ };
36
+
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) => {
50
+ entries.forEach((entry) => {
51
+ reserveSpace(entry.target, entry.contentRect);
52
+ });
53
+ });
54
+
55
+ let resizeResilientDeferredRendering = (Selector) => {
56
+ let articles = document.querySelectorAll(Selector);
57
+
58
+ if (articles.length) {
59
+ articles.forEach((el) => {
60
+ iObs.observe(el);
61
+ rObs.observe(el);
62
+ });
63
+
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
+ requestAnimationFrame(() => {
70
+ requestAnimationFrame(() => {
71
+ articles[0].style["content-visibility"] = "auto";
72
+ });
73
+ });
74
+ }
75
+ };
76
+
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
+ }
88
+ </script>
@@ -1,110 +1,423 @@
1
1
  <script>
2
- /************这个文件存放不需要重载的全局变量和全局函数*********/
3
- window.volantis={};
4
- window.volantis.loadcss=document.getElementById("loadcss");
5
- /******************** Pjax ********************************/
6
- function VPjax(){
7
- this.list=[] // 存放回调函数
8
- this.start=()=>{
9
- for(var i=0;i<this.list.length;i++){
10
- this.list[i].run();
11
- }
12
- }
13
- this.push=(fn,name)=>{
14
- var f=new PjaxItem(fn,name);
15
- this.list.push(f);
16
- }
17
- // 构造一个可以run的对象
18
- function PjaxItem(fn,name){
19
- // 函数名称
20
- this.name = name || fn.name
21
- // run方法
22
- this.run=()=>{
23
- fn()
24
- }
25
- }
26
- }
27
- volantis.pjax={}
28
- volantis.pjax.method={
29
- complete: new VPjax(),
30
- error: new VPjax(),
31
- send: new VPjax()
32
- }
33
- volantis.pjax={
34
- ...volantis.pjax,
35
- push: volantis.pjax.method.complete.push,
36
- error: volantis.pjax.method.error.push,
37
- send: volantis.pjax.method.send.push
38
- }
39
- /********************脚本懒加载函数********************************/
40
- // 已经加入了setTimeout
41
- function loadScript(src, cb) {
42
- setTimeout(function() {
43
- var HEAD = document.getElementsByTagName('head')[0] || document.documentElement;
44
- var script = document.createElement('script');
45
- script.setAttribute('type','text/javascript');
46
- if (cb) script.onload = cb;
47
- script.setAttribute('src', src);
48
- HEAD.appendChild(script);
49
- });
50
- }
51
- //https://github.com/filamentgroup/loadCSS
52
- var loadCSS = function( href, before, media, attributes ){
53
- var doc = window.document;
54
- var ss = doc.createElement( "link" );
55
- var ref;
56
- if( before ){
57
- ref = before;
58
- }
59
- else {
60
- var refs = ( doc.body || doc.getElementsByTagName( "head" )[ 0 ] ).childNodes;
61
- ref = refs[ refs.length - 1];
62
- }
63
- var sheets = doc.styleSheets;
64
- if( attributes ){
65
- for( var attributeName in attributes ){
66
- if( attributes.hasOwnProperty( attributeName ) ){
67
- ss.setAttribute( attributeName, attributes[attributeName] );
68
- }
69
- }
70
- }
71
- ss.rel = "stylesheet";
72
- ss.href = href;
73
- ss.media = "only x";
74
- function ready( cb ){
75
- if( doc.body ){
76
- return cb();
77
- }
78
- setTimeout(function(){
79
- ready( cb );
80
- });
81
- }
82
- ready( function(){
83
- ref.parentNode.insertBefore( ss, ( before ? ref : ref.nextSibling ) );
84
- });
85
- var onloadcssdefined = function( cb ){
86
- var resolvedHref = ss.href;
87
- var i = sheets.length;
88
- while( i-- ){
89
- if( sheets[ i ].href === resolvedHref ){
90
- return cb();
91
- }
92
- }
93
- setTimeout(function() {
94
- onloadcssdefined( cb );
95
- });
96
- };
97
- function loadCB(){
98
- if( ss.addEventListener ){
99
- ss.removeEventListener( "load", loadCB );
100
- }
101
- ss.media = media || "all";
102
- }
103
- if( ss.addEventListener ){
104
- ss.addEventListener( "load", loadCB);
105
- }
106
- ss.onloadcssdefined = onloadcssdefined;
107
- onloadcssdefined( loadCB );
108
- return ss;
109
- };
110
- </script>
2
+ /************这个文件存放不需要重载的全局变量和全局函数*********/
3
+ window.volantis = {}; // volantis 全局变量
4
+ volantis.debug = <%- theme.debug %>; // 开启调试模式
5
+ volantis.dom = {}; // 页面Dom see: /source/js/app.js etc.
6
+
7
+ volantis.GLOBAL_CONFIG ={
8
+ debug: <%- JSON.stringify(theme.debug) %>,
9
+ cdn: <%- JSON.stringify(theme.cdn.map) %>,
10
+ default: <%- JSON.stringify(theme.default) %>,
11
+ lastupdate: new Date(<%- theme.getStartTime %>),
12
+ sidebar: {
13
+ for_page: <%- JSON.stringify(theme.sidebar.for_page) %>,
14
+ for_post: <%- JSON.stringify(theme.sidebar.for_post) %>,
15
+ webinfo: {
16
+ lastupd: {
17
+ enable: <%- JSON.stringify(theme.sidebar.widget_library.webinfo.type.lastupd.enable) %>,
18
+ friendlyShow: <%- JSON.stringify(theme.sidebar.widget_library.webinfo.type.lastupd.friendlyShow) %>
19
+ },
20
+ runtime: {
21
+ data: <%- JSON.stringify(theme.sidebar.widget_library.webinfo.type.runtime.data) %>,
22
+ unit: <%- JSON.stringify(theme.sidebar.widget_library.webinfo.type.runtime.unit) %>
23
+ }
24
+ }
25
+ },
26
+ plugins: {
27
+ message: <%- JSON.stringify(theme.plugins.message) %>,
28
+ fancybox: <%- JSON.stringify(theme.plugins.fancybox) %>,
29
+ aplayer: {
30
+ id: <%- JSON.stringify(theme.plugins.aplayer.id) %>,
31
+ enable:<%- JSON.stringify(theme.plugins.aplayer.enable) %>
32
+ },
33
+ rightmenu: {
34
+ faicon: <%- JSON.stringify(theme.rightmenu.faicon) %>,
35
+ layout: <%- JSON.stringify(theme.rightmenu.layout) %>,
36
+ music_alwaysShow: <%- JSON.stringify(theme.rightmenu.music.alwaysShow) %>,
37
+ customPicUrl: <%- JSON.stringify(theme.rightmenu.customPicUrl) %>
38
+ },
39
+ rightmenus: <%- JSON.stringify(theme.rightmenus) %>
40
+ }
41
+ }
42
+
43
+ /******************** volantis.EventListener ********************************/
44
+ // 事件监听器 see: /source/js/app.js
45
+ volantis.EventListener = {}
46
+ // 这里存放pjax切换页面时将被移除的事件监听器
47
+ volantis.EventListener.list = []
48
+ //构造方法
49
+ function volantisEventListener(type, f, ele) {
50
+ this.type = type
51
+ this.f = f
52
+ this.ele = ele
53
+ }
54
+ // 移除事件监听器
55
+ volantis.EventListener.remove = () => {
56
+ volantis.EventListener.list.forEach(function (i) {
57
+ i.ele.removeEventListener(i.type, i.f, false)
58
+ })
59
+ volantis.EventListener.list = []
60
+ }
61
+ /******************** volantis.dom.$ ********************************/
62
+ // 注:这里没有选择器,也没有forEach一次只处理一个dom,这里重新封装主题常用的dom方法,返回的是dom对象,对象包含了以下方法,同时保留dom的原生API
63
+ function volantisDom(ele) {
64
+ if (!ele) ele = document.createElement("div")
65
+ this.ele = ele;
66
+ // ==============================================================
67
+ this.ele.find = (c) => {
68
+ let q = this.ele.querySelector(c)
69
+ if (q)
70
+ return new volantisDom(q)
71
+ }
72
+ // ==============================================================
73
+ this.ele.hasClass = (c) => {
74
+ return this.ele.className.match(new RegExp('(\\s|^)' + c + '(\\s|$)'));
75
+ }
76
+ this.ele.addClass = (c) => {
77
+ this.ele.classList.add(c);
78
+ return this.ele
79
+ }
80
+ this.ele.removeClass = (c) => {
81
+ this.ele.classList.remove(c);
82
+ return this.ele
83
+ }
84
+ this.ele.toggleClass = (c) => {
85
+ if (this.ele.hasClass(c)) {
86
+ this.ele.removeClass(c)
87
+ } else {
88
+ this.ele.addClass(c)
89
+ }
90
+ return this.ele
91
+ }
92
+ // ==============================================================
93
+ // 参数 r 为 true 表示pjax切换页面时事件监听器将被移除,false不移除
94
+ this.ele.on = (c, f, r = 1) => {
95
+ this.ele.addEventListener(c, f, false)
96
+ if (r) {
97
+ volantis.EventListener.list.push(new volantisEventListener(c, f, this.ele))
98
+ }
99
+ return this.ele
100
+ }
101
+ this.ele.click = (f, r) => {
102
+ this.ele.on("click", f, r)
103
+ return this.ele
104
+ }
105
+ this.ele.scroll = (f, r) => {
106
+ this.ele.on("scroll", f, r)
107
+ return this.ele
108
+ }
109
+ // ==============================================================
110
+ this.ele.html = (c) => {
111
+ // if(c=== undefined){
112
+ // return this.ele.innerHTML
113
+ // }else{
114
+ this.ele.innerHTML = c
115
+ return this.ele
116
+ // }
117
+ }
118
+ // ==============================================================
119
+ this.ele.hide = (c) => {
120
+ this.ele.style.display = "none"
121
+ return this.ele
122
+ }
123
+ this.ele.show = (c) => {
124
+ this.ele.style.display = "block"
125
+ return this.ele
126
+ }
127
+ // ==============================================================
128
+ return this.ele
129
+ }
130
+ volantis.dom.$ = (ele) => {
131
+ return !!ele ? new volantisDom(ele) : null;
132
+ }
133
+ /******************** RunItem ********************************/
134
+ function RunItem() {
135
+ this.list = []; // 存放回调函数
136
+ this.start = () => {
137
+ for (var i = 0; i < this.list.length; i++) {
138
+ this.list[i].run();
139
+ }
140
+ };
141
+ this.push = (fn, name, setRequestAnimationFrame = true) => {
142
+ let myfn = fn
143
+ if (setRequestAnimationFrame) {
144
+ myfn = ()=>{
145
+ volantis.requestAnimationFrame(fn)
146
+ }
147
+ }
148
+ var f = new Item(myfn, name);
149
+ this.list.push(f);
150
+ };
151
+ this.remove = (name) =>{
152
+ for (let index = 0; index < this.list.length; index++) {
153
+ const e = this.list[index];
154
+ if (e.name == name) {
155
+ this.list.splice(index,1);
156
+ }
157
+ }
158
+ }
159
+ // 构造一个可以run的对象
160
+ function Item(fn, name) {
161
+ // 函数名称
162
+ this.name = name || fn.name;
163
+ // run方法
164
+ this.run = () => {
165
+ try {
166
+ fn()
167
+ } catch (error) {
168
+ console.log(error);
169
+ }
170
+ };
171
+ }
172
+ }
173
+ /******************** Pjax ********************************/
174
+ // /layout/_plugins/pjax/index.ejs
175
+ // volantis.pjax.send(callBack[,"callBackName"]) 传入pjax:send回调函数
176
+ // volantis.pjax.push(callBack[,"callBackName"]) 传入pjax:complete回调函数
177
+ // volantis.pjax.error(callBack[,"callBackName"]) 传入pjax:error回调函数
178
+ volantis.pjax = {};
179
+ volantis.pjax.method = {
180
+ complete: new RunItem(),
181
+ error: new RunItem(),
182
+ send: new RunItem(),
183
+ };
184
+ volantis.pjax = Object.assign(volantis.pjax, {
185
+ push: volantis.pjax.method.complete.push,
186
+ error: volantis.pjax.method.error.push,
187
+ send: volantis.pjax.method.send.push,
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
+ });
199
+ /******************** Dark Mode ********************************/
200
+ // /layout/_partial/scripts/darkmode.ejs
201
+ // volantis.dark.mode 当前模式 dark or light
202
+ // volantis.dark.toggle() 暗黑模式触发器
203
+ // volantis.dark.push(callBack[,"callBackName"]) 传入触发器回调函数
204
+ volantis.dark = {};
205
+ volantis.dark.method = {
206
+ toggle: new RunItem(),
207
+ };
208
+ volantis.dark = Object.assign(volantis.dark, {
209
+ push: volantis.dark.method.toggle.push,
210
+ });
211
+ /******************** Message ********************************/
212
+ // VolantisApp.message
213
+ /******************** isMobile ********************************/
214
+ // /source/js/app.js
215
+ // volantis.isMobile
216
+ // volantis.isMobileOld
217
+ /********************脚本动态加载函数********************************/
218
+ // volantis.js(src, cb) cb 可以传入onload回调函数 或者 JSON对象 例如: volantis.js("src", ()=>{}) 或 volantis.js("src", {defer:true,onload:()=>{}})
219
+ // volantis.css(src)
220
+
221
+ // 返回Promise对象,如下方法同步加载资源,这利于处理文件资源之间的依赖关系,例如:APlayer 需要在 MetingJS 之前加载
222
+ // (async () => {
223
+ // await volantis.js("...theme.plugins.aplayer.js.aplayer...")
224
+ // await volantis.js("...theme.plugins.aplayer.js.meting...")
225
+ // })();
226
+
227
+ // 已经加入了setTimeout
228
+ volantis.js = (src, cb) => {
229
+ return new Promise(resolve => {
230
+ setTimeout(function () {
231
+ var HEAD = document.getElementsByTagName("head")[0] || document.documentElement;
232
+ var script = document.createElement("script");
233
+ script.setAttribute("type", "text/javascript");
234
+ if (cb) {
235
+ if (JSON.stringify(cb)) {
236
+ for (let p in cb) {
237
+ if (p == "onload") {
238
+ script[p] = () => {
239
+ cb[p]()
240
+ resolve()
241
+ }
242
+ } else {
243
+ script[p] = cb[p]
244
+ script.onload = resolve
245
+ }
246
+ }
247
+ } else {
248
+ script.onload = () => {
249
+ cb()
250
+ resolve()
251
+ };
252
+ }
253
+ } else {
254
+ script.onload = resolve
255
+ }
256
+ script.setAttribute("src", src);
257
+ HEAD.appendChild(script);
258
+ });
259
+ });
260
+ }
261
+ volantis.css = (src) => {
262
+ return new Promise(resolve => {
263
+ setTimeout(function () {
264
+ var link = document.createElement('link');
265
+ link.rel = "stylesheet";
266
+ link.href = src;
267
+ link.onload = resolve;
268
+ document.getElementsByTagName("head")[0].appendChild(link);
269
+ });
270
+ });
271
+ }
272
+ /********************按需加载的插件********************************/
273
+ // volantis.import.jQuery().then(()=>{})
274
+ volantis.import = {
275
+ jQuery: () => {
276
+ if (typeof jQuery == "undefined") {
277
+ return volantis.js("<%- theme.plugins.jquery %>")
278
+ } else {
279
+ return new Promise(resolve => {
280
+ resolve()
281
+ });
282
+ }
283
+ }
284
+ }
285
+ /********************** requestAnimationFrame ********************************/
286
+ // 1、requestAnimationFrame 会把每一帧中的所有 DOM 操作集中起来,在一次重绘或回流中就完成,并且重绘或回流的时间间隔紧紧跟随浏览器的刷新频率,一般来说,这个频率为每秒60帧。
287
+ // 2、在隐藏或不可见的元素中,requestAnimationFrame 将不会进行重绘或回流,这当然就意味着更少的的 cpu,gpu 和内存使用量。
288
+ volantis.requestAnimationFrame = (fn)=>{
289
+ if (!window.requestAnimationFrame) {
290
+ window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame;
291
+ }
292
+ window.requestAnimationFrame(fn)
293
+ }
294
+ /************************ layoutHelper *****************************************/
295
+ volantis.layoutHelper = (helper, html, opt)=>{
296
+ opt = Object.assign({clean:false, pjax:true}, opt)
297
+ function myhelper(helper, html, clean) {
298
+ volantis.tempDiv = document.createElement("div");
299
+ volantis.tempDiv.innerHTML = html;
300
+ let layoutHelper = document.querySelector("#layoutHelper-"+helper)
301
+ if (layoutHelper) {
302
+ if (clean) {
303
+ layoutHelper.innerHTML = ""
304
+ }
305
+ layoutHelper.append(volantis.tempDiv);
306
+ }
307
+ }
308
+ myhelper(helper, html, opt.clean)
309
+ if (opt.pjax) {
310
+ volantis.pjax.push(()=>{
311
+ myhelper(helper, html, opt.clean)
312
+ },"layoutHelper-"+helper)
313
+ }
314
+ }
315
+ /****************************** 滚动事件处理 ****************************************/
316
+ volantis.scroll = {
317
+ engine: new RunItem(),
318
+ unengine: new RunItem(),
319
+ };
320
+ volantis.scroll = Object.assign(volantis.scroll, {
321
+ push: volantis.scroll.engine.push,
322
+ });
323
+ // 滚动条距离顶部的距离
324
+ volantis.scroll.getScrollTop = () =>{
325
+ let scrollPos;
326
+ if (window.pageYOffset) {
327
+ scrollPos = window.pageYOffset;
328
+ } else if (document.compatMode && document.compatMode != 'BackCompat') {
329
+ scrollPos = document.documentElement.scrollTop;
330
+ } else if (document.body) {
331
+ scrollPos = document.body.scrollTop;
332
+ }
333
+ return scrollPos;
334
+ }
335
+ // 使用 requestAnimationFrame 处理滚动事件
336
+ // `volantis.scroll.del` 中存储了一个数值, 该数值检测一定时间间隔内滚动条滚动的位移, 数值的检测频率是浏览器的刷新频率. 数值为正数时, 表示向下滚动. 数值为负数时, 表示向上滚动.
337
+ volantis.scroll.handleScrollEvents = () => {
338
+ volantis.scroll.lastScrollTop = volantis.scroll.getScrollTop()
339
+ function loop() {
340
+ const scrollTop = volantis.scroll.getScrollTop();
341
+ if (volantis.scroll.lastScrollTop !== scrollTop) {
342
+ volantis.scroll.del = scrollTop - volantis.scroll.lastScrollTop;
343
+ volantis.scroll.lastScrollTop = scrollTop;
344
+ // if (volantis.scroll.del > 0) {
345
+ // console.log("向下滚动");
346
+ // } else {
347
+ // console.log("向上滚动");
348
+ // }
349
+ // 注销过期的unengine未滚动事件
350
+ volantis.scroll.unengine.list=[]
351
+ volantis.scroll.engine.start();
352
+ }else{
353
+ volantis.scroll.unengine.start();
354
+ }
355
+ volantis.requestAnimationFrame(loop)
356
+ }
357
+ volantis.requestAnimationFrame(loop)
358
+ }
359
+ volantis.scroll.handleScrollEvents()
360
+ // 触发页面滚动至目标元素位置
361
+ volantis.scroll.to = (ele, option = {}) =>{
362
+ // 默认配置
363
+ opt = {
364
+ top: ele.getBoundingClientRect().top + document.documentElement.scrollTop,
365
+ behavior: "<%- theme.scroll_smooth ? 'smooth' : 'instant' %>"
366
+ }
367
+ // 定义配置
368
+ if ("top" in option) {
369
+ opt.top = option.top
370
+ }
371
+ if ("behavior" in option) {
372
+ opt.behavior = option.behavior
373
+ }
374
+ if ("addTop" in option) {
375
+ opt.top += option.addTop
376
+ }
377
+ if (!("observerDic" in option)) {
378
+ option.observerDic = 100
379
+ }
380
+ // 滚动
381
+ window.scrollTo(opt);
382
+ // 监视器
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
+ }
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
+ /******************************************************************************/
411
+ /******************************************************************************/
412
+ /******************************************************************************/
413
+ //图像加载出错时的处理
414
+ function errorImgAvatar(img) {
415
+ img.src = "<%- theme.default.avatar %>";
416
+ img.onerror = null;
417
+ }
418
+ function errorImgCover(img) {
419
+ img.src = "<%- theme.default.cover %>";
420
+ img.onerror = null;
421
+ }
422
+ /******************************************************************************/
423
+ </script>