hexo-theme-volantis 5.0.0-rc.4 → 5.0.0-rc.5

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.
package/_config.yml CHANGED
@@ -18,7 +18,7 @@ default:
18
18
  ############################### Volantis ###############################
19
19
  info:
20
20
  theme_name: Volantis # This is theme's name.
21
- theme_version: '5.0.0-rc.4' # This is theme's version.
21
+ theme_version: '5.0.0-rc.5' # This is theme's version.
22
22
  theme_docs: https://volantis.js.org/ # This is theme's URL.
23
23
  theme_repo: https://github.com/volantis-x/hexo-theme-volantis
24
24
  # Debug 调试模式
@@ -59,7 +59,7 @@ cdn:
59
59
  # CDN 前缀,为空使用默认值,链接最后不加 "/",
60
60
  # 例如: https://cdn.jsdelivr.net/gh/volantis-x/volantis-x.github.io@gh-page 填写最后编译生成的源码CDN地址前缀,此路径下应该含有/js与/css目录,
61
61
  # 该配置默认值是:"https://cdn.jsdelivr.net/npm/hexo-theme-volantis@"+ theme.info.theme_version +"/source"
62
- prefix: https://npm.elemecdn.com/hexo-theme-volantis@5.0.0-rc.4/source
62
+ prefix: https://npm.elemecdn.com/hexo-theme-volantis@5.0.0-rc.5/source
63
63
  # 以下配置可以覆盖 cdn.prefix,配置项的值可以为空,但是要使用CDN必须依据路径填写配置项的键
64
64
  set:
65
65
  js:
@@ -244,10 +244,7 @@ article:
244
244
  counter:
245
245
  icon: fa-solid fa-eye
246
246
  unit: '次浏览'
247
- # 文章评论数量:支持 valine和waline
248
- valinecount:
249
- icon: fa-solid fa-comment-dots
250
- desc: '' # 条评论
247
+ # waline 文章评论数量
251
248
  walinecount:
252
249
  icon: fa-solid fa-comment-dots
253
250
  desc: '' # 条评论
@@ -341,36 +338,6 @@ comments:
341
338
  dark: github-dark
342
339
  label: ✨💬✨
343
340
 
344
- # Valine
345
- # https://valine.js.org/
346
- valine:
347
- js: https://cdn.jsdelivr.net/npm/valine@1.4/dist/Valine.min.js
348
- emojiCDN: https://cdn.jsdelivr.net/gh/volantis-x/cdn-emoji/valine/
349
- path: # 全局评论地址 目前设置全局评论地址后visitor失效,这是valine的问题
350
- placeholder: 快来评论吧~ # 评论占位提示
351
- # 其他配置项按照yml格式继续填写即可 除了 [el path placeholder emojiCDN emojiMaps] 选项
352
- appId: # your appId
353
- appKey: # your appKey
354
- meta: [nick,mail,link] # valine comment header info
355
- requiredFields: [nick,mail]
356
- enableQQ: true # Unstable avatar link
357
- recordIP: false # Record commenter IP
358
- avatar: robohash # gravatar style https://valine.js.org/avatar
359
- pageSize: 10 # comment list page size
360
- lang: zh-cn
361
- highlight: true
362
- mathJax: false
363
-
364
- # MiniValine
365
- # https://github.com/MiniValine/MiniValine
366
- minivaline:
367
- js: https://cdn.jsdelivr.net/npm/minivaline@latest
368
- path: # 全局评论地址
369
- placeholder: 快来评论吧~ # 全局评论占位提示
370
- # 更多选项 https://minivaline.js.org/docs/cn/#/Options 按照yml格式继续填写即可 (除了 [el path placeholder] 选项)
371
- # 下面是一个例子:
372
- serverURL: https://hello.com
373
-
374
341
  # Disqus
375
342
  # https://disqus.com
376
343
  disqus:
@@ -626,7 +593,7 @@ site_footer:
626
593
  <span id="lc-sv">本站总访问量为 <span id='number'><i class="fa-solid fa-circle-notch fa-spin fa-fw" aria-hidden="true"></i></span> 次</span>
627
594
  <span id="lc-uv">访客数为 <span id='number'><i class="fa-solid fa-circle-notch fa-spin fa-fw" aria-hidden="true"></i></span> 人</span>
628
595
  # site copyright
629
- copyright: '[Copyright © 2017-2020 XXX](/)'
596
+ copyright: '[Copyright © since 2017 XXX](/)'
630
597
  # You can add your own property here. (Support markdown, for example: br: '<br>')
631
598
  br: '<br>'
632
599
  ############################### Site Footer ############################### > end
@@ -861,24 +828,6 @@ plugins:
861
828
  appKey: HwCiWuxfpvKiLm4teCUgTIba # your appKEY
862
829
  serverURLs: https://bbapi.heson10.com # Request Api 域名
863
830
 
864
- # HexoPlusPlus
865
- # https://github.com/HexoPlusPlus/HexoPlusPlus
866
- # https://hexoplusplus.js.org/
867
- # 无服务器Hexo后端,支持文章编辑,自带图床功能.目标:解决静态博客所有痛点[文章编辑、图片上传、博主活跃信息统计、博主说说、Twikoo加强版、阅读量统计等
868
- hpp:
869
- # 说说功能
870
- # Set `plugins: ["hpptalk"]` to enable in front-matter
871
- # 支持 Pjax
872
- hpp_talk:
873
- css: https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@latest/talk.css # 建议锁定版本
874
- js: https://cdn.jsdelivr.net/gh/HexoPlusPlus/HexoPlusPlus@latest/talk_user.js # 建议锁定版本
875
- limit: 10
876
- start: 0
877
- # 配置项按照yml格式继续填写即可
878
- # domain:
879
- # themecss:
880
- # HexoPlusPlus其他功能暂未集成
881
-
882
831
  # 友链朋友圈 hexo-circle-of-friends
883
832
  # https://github.com/Rock-Candy-Tea/hexo-circle-of-friends
884
833
  # https://fcircle-doc.js.cool/
@@ -918,17 +867,6 @@ plugins:
918
867
  rightmenu:
919
868
  enable: true # 是否开启右键模块的消息通知
920
869
  notice: true # 唤醒原右键菜单的通知
921
-
922
- # 标签插件样式按需加载
923
- # 注意这个配置是带缓存的, 如果修改标签插件样式每次调试需要刷新两次页面, 建议开发者关闭该配置
924
- tag_plugin_load_on_demand:
925
- enable: #true
926
- # 每个页面强制加载以下标签插件样式
927
- plugins:
928
- - note
929
- - btns
930
- - p
931
- - gallery
932
870
 
933
871
  # 聊天功能
934
872
  chat_service: # tidio or gitter
@@ -26,26 +26,6 @@
26
26
  </p>
27
27
  </a>
28
28
  </div>
29
- <% } else if (
30
- (theme.comments.service=='valine' && theme.comments.valine.visitor) ||
31
- (theme.comments.service=='minivaline' && theme.comments.minivaline.visitor) ||
32
- (theme.comments.service=='waline' && theme.comments.waline.visitor)) { %>
33
- <div class="new-meta-item browse">
34
- <a class='notlink'>
35
- <i class="<%- theme.article.body.meta_library.counter.icon %> fa-fw" aria-hidden="true"></i>
36
- <%
37
- var path = post.path || page.path;
38
- if (path.length > 9 && (path.substring(path.length - 10) == 'index.html')) {
39
- path = path.substring(0, path.length - 10);
40
- }
41
- %>
42
- <span id="<%- url_for(path) %>" class="leancloud_visitors" data-flag-title="<%- post.title || page.title %>">
43
- <p>
44
- <span class="leancloud-visitors-count"></span>
45
- </p>
46
- </span>
47
- </a>
48
- </div>
49
29
  <% } else if (theme.comments.service=='twikoo' && !!page.comments) { %>
50
30
  <div class="new-meta-item browse">
51
31
  <a class='notlink'>
@@ -55,14 +55,6 @@
55
55
  /* 首屏样式 */
56
56
  <%- FirstCSS() %>
57
57
  </style>
58
- <%_ if (theme.plugins.tag_plugin_load_on_demand.enable) { _%>
59
- <pjax>
60
- <style>
61
- /* 按需加载的标签插件样式 */
62
- <%- TagCSS(page) %>
63
- </style>
64
- </pjax>
65
- <%_ } _%>
66
58
  <link rel="stylesheet" href="<%- theme.cdn.map.css.style %>" media="print" onload="this.media='all';this.onload=null">
67
59
  <noscript><link rel="stylesheet" href="<%- theme.cdn.map.css.style %>"></noscript>
68
60
  <%_ if (theme.plugins.darkmode.enable) { _%>
@@ -7,7 +7,7 @@
7
7
  volantis.GLOBAL_CONFIG ={
8
8
  cdn: <%- JSON.stringify(theme.cdn.map) %>,
9
9
  default: <%- JSON.stringify(theme.default) %>,
10
- lastupdate: new Date('<%- theme.getStartTime %>'),
10
+ lastupdate: new Date(<%- theme.getStartTime %>),
11
11
  sidebar: {
12
12
  for_page: <%- JSON.stringify(theme.sidebar.for_page) %>,
13
13
  for_post: <%- JSON.stringify(theme.sidebar.for_post) %>,
@@ -370,17 +370,17 @@
370
370
  window.scrollTo(opt);
371
371
  // 监视器
372
372
  // 监视并矫正元素滚动到指定位置
373
- // 目前用于处理 toc 部分 lazyload 引起的 cls 导致的定位失败问题
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
- }
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
+ // }
384
384
  }
385
385
  /******************************************************************************/
386
386
  /******************************************************************************/
@@ -394,4 +394,4 @@
394
394
  img.onerror = null;
395
395
  }
396
396
  /******************************************************************************/
397
- </script>
397
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-volantis",
3
- "version": "5.0.0-rc.4",
3
+ "version": "5.0.0-rc.5",
4
4
  "description": "Elegant and powerful theme for Hexo.",
5
5
  "main": "package.json",
6
6
  "scripts": {
@@ -7,15 +7,6 @@ async_dark()
7
7
  --text-p3: mix($c-text-light, $c-site-bg-light, 60)
8
8
  --card: $c-card-light
9
9
 
10
- // minivaline v6 or ohhho Dark Color
11
- if hexo-config('comments.service') == 'minivaline' || hexo-config('comments.service') == 'ohhho'
12
- --ohhho-color-p: var(--color-p) !important
13
- --ohhho-color-text: var(--color-text) !important
14
- --ohhho-color-card: var(--color-card) !important
15
- --ohhho-color-block: var(--color-block) !important
16
- --ohhho-expand-before-background: linear-gradient(180deg, rgba(246,246,246,0), rgba(0,0,0,0.9)) !important
17
- --ohhho-expand-after-background: rgba(0,0,0,0.9) !important
18
-
19
10
  // waline Dark Color https://github.com/volantis-x/hexo-theme-volantis/issues/633
20
11
  if hexo-config('comments.service')=='waline'
21
12
  --waline-white: #000 !important
@@ -69,34 +69,6 @@ if hexo-config('comments.service')=='gitalk'
69
69
  .gt-container .gt-comment-admin .gt-comment-content
70
70
  background-color: var(--color-card)
71
71
 
72
- if hexo-config('comments.service')== 'minivaline' || hexo-config('comments.service')== 'ohhho'
73
- // minivaline v6 or ohhho Dark Color
74
- .ohhho pre
75
- background: var(--color-meta)
76
- border: 1px solid var(--color-block)
77
- .ohhho .vlist .vcard .vcomment-body .vhead
78
- filter: brightness(85%)
79
- ////// minivaline v5 Dark Color //////////////
80
- // .MiniValine .vpage .more
81
- // background: var(--color-site-bg)
82
- // .MiniValine .vlist .vcard .vcomment-body .text-wrapper .vcomment.expand:before
83
- // background: linear-gradient(180deg, rgba(246,246,246,0), rgba(0,0,0,0.9))
84
- // .MiniValine .vlist .vcard .vcomment-body .text-wrapper .vcomment.expand:after
85
- // background: rgba(0,0,0,0.9)
86
- // .MiniValine .vlist .vcard .vcomment-body .text-wrapper .vcomment pre
87
- // background: var(--color-site-bg)
88
- // border: 1px solid var(--color-site-bg)
89
- // .MiniValine .vinputs-area .vextra-area .vsmile-icons
90
- // background: transparent
91
- // .MiniValine .vlist .vcard .vcomment-body .vhead
92
- // filter: brightness(85%)
93
- // .MiniValine .vbtn
94
- // background: var(--color-card)
95
- // &:hover
96
- // background: var(--color-block)
97
- // .MiniValine .vpage .more:hover
98
- // background: var(--color-card)
99
-
100
72
  if hexo-config('plugins.aplayer.enable')
101
73
  .aplayer
102
74
  background: var(--color-site-bg)
@@ -117,16 +89,6 @@ if hexo-config('plugins.aplayer.enable')
117
89
  .aplayer.aplayer-withlist .aplayer-info
118
90
  border-bottom: 1px solid var(--color-block)
119
91
 
120
- if hexo-config('comments.service')=='valine'
121
- #valine_container button
122
- background-color: var(--color-block) !important
123
- #valine_container .vcards .vcontent.expand:before
124
- background: none !important
125
- #valine_container .vcards .vcontent.expand:after
126
- background: #393c40 !important
127
- .v[data-class=v] code, .v[data-class=v] pre
128
- background-color: #332828 !important
129
-
130
92
  if hexo-config('comments.service')=='twikoo'
131
93
  .OwO
132
94
  .OwO-body
@@ -4,6 +4,3 @@
4
4
 
5
5
  tag.json 索引 tag 标签名称和使用的样式文件的对应关系
6
6
 
7
- tag 标签 样式 按需加载依赖 tag.json
8
-
9
- 按需加载自动化方案 see: scripts/helpers/tag-plugins-style/index.js
@@ -2,8 +2,7 @@
2
2
 
3
3
  @import '_layout/*'
4
4
 
5
- if not hexo-config('plugins.tag_plugin_load_on_demand.enable')
6
- @import '_tag-plugins/*'
5
+ @import '_tag-plugins/*'
7
6
 
8
7
  // 暗黑模式样式放到最后加载
9
8
  @import '_plugins/index'
@@ -1,15 +0,0 @@
1
- <% if (theme.comments.service == 'valine'){ %>
2
- <div class="new-meta-item comments-count">
3
- <%
4
- var path = post.path || page.path;
5
- if (path.length > 9 && (path.substring(path.length - 10) == 'index.html')) {
6
- path = path.substring(0, path.length - 10);
7
- }
8
- %>
9
- <a href="<%- url_for(path) %>#comments">
10
- <i class="<%- theme.article.body.meta_library.valinecount.icon %> fa-fw"></i>
11
- <span class="valine-comment-count" data-xid="<%- url_for(path) %>">0</span>
12
- <span class="leancloud-comments-count">&nbsp;<%- theme.article.body.meta_library.valinecount.desc %></span>
13
- </a>
14
- </div>
15
- <% } %>
@@ -1,14 +0,0 @@
1
- <script>
2
- volantis.layoutHelper("page-plugins",`<div id="hpp_talk"></div>`,{pjax:false}) // 外层有 pjax 标签
3
- volantis.css("<%= theme.plugins.hpp.hpp_talk.css %>")
4
- volantis.js("<%= theme.plugins.hpp.hpp_talk.js %>").then(() => {
5
- new hpp_talk(Object.assign( <%- JSON.stringify(theme.plugins.hpp.hpp_talk) %> , {
6
- id: "hpp_talk", //容器id
7
- }));
8
- })
9
- </script>
10
- <style>
11
- .hpp_talk_img {
12
- display: inline !important;
13
- }
14
- </style>
@@ -1,45 +0,0 @@
1
- <script>
2
- volantis.layoutHelper("comments",`<div id="minivaline_container"><i class="fa-solid fa-cog fa-spin fa-fw fa-2x"></i></div>`)
3
- function load_minivaline() {
4
- if(!document.querySelector("#minivaline_container"))return;
5
- volantis.js("<%- theme.comments.minivaline.js %>", pjax_minivaline)
6
- };
7
- function pjax_minivaline() {
8
- if(!document.querySelector("#minivaline_container"))return;
9
- let pagePlaceholder = pdata.commentPlaceholder || "<%= theme.comments.minivaline.placeholder %>";
10
- let path = pdata.commentPath;
11
- if (path.length == 0) {
12
- let defaultPath = '<%= theme.comments.minivaline.path %>';
13
- path = defaultPath || decodeURI(window.location.pathname);
14
- }
15
- new MiniValine(
16
- Object.assign(
17
- Object.assign(<%- JSON.stringify(theme.comments.minivaline) %>, {
18
- el: '#minivaline_container',
19
- pathname: path,
20
- placeholder: pagePlaceholder,
21
- }),
22
- pdata.commentConfig)
23
- );
24
- fancybox_minivaline()
25
- }
26
- function fancybox_minivaline() {
27
- if(typeof VolantisFancyBox === "undefined") {
28
- const checkFancyBox = setInterval(() => {
29
- if(typeof VolantisFancyBox === "undefined") return;
30
- clearInterval(checkFancyBox);
31
- VolantisFancyBox.bind('#minivaline_container .vcomment img');
32
- })
33
- } else {
34
- VolantisFancyBox.bind('#minivaline_container .vcomment img');
35
- }
36
- }
37
- load_minivaline();
38
- volantis.pjax.push(()=>{
39
- if (typeof MiniValine == "undefined") {
40
- load_minivaline();
41
- } else {
42
- pjax_minivaline();
43
- }
44
- },"MiniValine");
45
- </script>
@@ -1,53 +0,0 @@
1
- <script>
2
- volantis.layoutHelper("comments",`<div id="valine_container"><i class="fa-solid fa-cog fa-spin fa-fw fa-2x"></i></div>`)
3
- function emoji(path, idx, ext) {
4
- return path + "/" + path + "-" + idx + "." + ext;
5
- }
6
- var emojiMaps = {};
7
- for (var i = 1; i <= 54; i++) {
8
- emojiMaps['tieba-' + i] = emoji('tieba', i, 'png');
9
- }
10
- for (var i = 1; i <= 101; i++) {
11
- emojiMaps['qq-' + i] = emoji('qq', i, 'gif');
12
- }
13
- for (var i = 1; i <= 116; i++) {
14
- emojiMaps['aru-' + i] = emoji('aru', i, 'gif');
15
- }
16
- for (var i = 1; i <= 125; i++) {
17
- emojiMaps['twemoji-' + i] = emoji('twemoji', i, 'png');
18
- }
19
- for (var i = 1; i <= 4; i++) {
20
- emojiMaps['weibo-' + i] = emoji('weibo', i, 'png');
21
- }
22
- function pjax_valine() {
23
- if(!document.querySelectorAll("#valine_container")[0])return;
24
- let pagePlaceholder = pdata.commentPlaceholder || "<%= theme.comments.valine.placeholder %>";
25
- let path = pdata.commentPath;
26
- if (path.length == 0) {
27
- let defaultPath = '<%= theme.comments.valine.path %>';
28
- path = defaultPath || decodeURI(window.location.pathname);
29
- }
30
- var valine = new Valine();
31
- valine.init(Object.assign(Object.assign(<%- JSON.stringify(theme.comments.valine) %>, {
32
- el: '#valine_container',
33
- path: path,
34
- placeholder: pagePlaceholder,
35
- emojiCDN: '<%= theme.comments.valine.emojiCDN %>',
36
- emojiMaps: emojiMaps,
37
- }),pdata.commentConfig))
38
- fancybox_valine()
39
- }
40
- function fancybox_valine() {
41
- if(typeof VolantisFancyBox === "undefined") {
42
- const checkFancyBox = setInterval(() => {
43
- if(typeof VolantisFancyBox === "undefined") return;
44
- clearInterval(checkFancyBox);
45
- VolantisFancyBox.bind('#valine_container .vcontent img:not(.vemoji)');
46
- })
47
- } else {
48
- VolantisFancyBox.bind('#valine_container .vcontent img:not(.vemoji)');
49
- }
50
- }
51
- volantis.js('<%- theme.cdn.map.js.valine %>').then(pjax_valine)
52
- volantis.pjax.push(pjax_valine);
53
- </script>
@@ -1,9 +0,0 @@
1
- // 'use strict';
2
-
3
- // hexo.extend.generator.register('volantis-init-config', () => {
4
- // debugger;
5
- // return [
6
- // { path: 'volantis-webconfig.json', data: hexo.config },
7
- // { path: 'volantis-themeconfig.json', data: hexo.theme.config }
8
- // ]
9
- // });
@@ -1,199 +0,0 @@
1
- // 标签插件样式按需加载
2
- const fs = require("hexo-fs");
3
- const Database = require('warehouse'); // https://hexojs.github.io/warehouse/
4
-
5
- hexo.database.model("TagPluginCSS", new Database.Schema({
6
- _id: { type: String, required: true },
7
- data: { type: String }
8
- }));
9
-
10
- hexo.database.model("TagPluginOfPost", new Database.Schema({
11
- _id: { type: String, required: true },
12
- tags: { type: Array }
13
- }));
14
-
15
- const findTags = (data) => {
16
- dataList = data.match(/{% (\w*?)\W.*?%}/g)
17
- let tagSet = new Set()
18
- if (dataList) {
19
- dataList.forEach(e => {
20
- let tag = /{% (\w*?)\W.*?%}/g.exec(e)
21
- if (tag && tag[1].indexOf('end') != 0) {
22
- tagSet.add(tag[1])
23
- }
24
- });
25
- }
26
- return Array.from(tagSet)
27
- }
28
-
29
- const renderStyl = (styList, callback) => {
30
- let stySet = new Set(styList)
31
- let tagPageStyleDir = "_style/_tag-plugins/"
32
- let tagPageStyle = `@import '_defines/*'\n`
33
- stySet.forEach(e => {
34
- tagPageStyle += `@import '` + tagPageStyleDir + e + `'` + "\n"
35
- })
36
- hexo.renderStylus(tagPageStyle).then(callback)
37
- }
38
- function getTagPluginCSSInfo() {
39
- let info = hexo.locals.get('TagPluginCSSInfo')
40
- if (!info) {
41
- info = fs.readFileSync(
42
- hexo.theme.context.theme_dir + "source/css/_style/_tag-plugins/tag.json"
43
- );
44
- info = JSON.parse(info)
45
- hexo.locals.set('TagPluginCSSInfo', function () {
46
- return info
47
- });
48
- }
49
- return info
50
- }
51
-
52
- function setTagPluginCSS(uuidTagCSS, css) {
53
- let TagPluginCSS = hexo.locals.get('TagPluginCSS')
54
- if (!TagPluginCSS) {
55
- TagPluginCSS = {}
56
- }
57
- TagPluginCSS[uuidTagCSS] = css
58
- hexo.locals.set('TagPluginCSS', function () {
59
- return TagPluginCSS
60
- });
61
- }
62
- function renderTagCSSAllPage(info) {
63
- let styListAllPage = []
64
- hexo.theme.config.plugins.tag_plugin_load_on_demand.plugins.forEach(e => {
65
- if (e in info) {
66
- info[e].forEach(x => {
67
- styListAllPage.push(x)
68
- })
69
- }
70
- })
71
- renderStyl(styListAllPage, (css) => {
72
- setTagPluginCSS("AllPage", css)
73
- })
74
-
75
- }
76
- function insertTagCSS(uuidTagCSS, tagList) {
77
- let info = getTagPluginCSSInfo()
78
- let styList = []
79
- let tagListSave = []
80
- if (tagList) {
81
- tagList.forEach(e => {
82
- if (e in info) {
83
- info[e].forEach(x => {
84
- styList.push(x)
85
- })
86
- tagListSave.push(e)
87
- }
88
- })
89
- }
90
- hexo.theme.config.plugins.tag_plugin_load_on_demand.plugins.forEach(e => {
91
- if (e in info) {
92
- info[e].forEach(x => {
93
- styList.push(x)
94
- })
95
- tagListSave.push(e)
96
- }
97
- })
98
- renderStyl(styList, (css) => {
99
- setTagPluginCSS(uuidTagCSS, css)
100
- })
101
- if (!hexo.locals.get('TagCSSAllPageFlag') && hexo.theme.config.plugins.tag_plugin_load_on_demand.plugins) {
102
- hexo.locals.set('TagCSSAllPageFlag', function () {
103
- return 1
104
- });
105
- renderTagCSSAllPage(info)
106
- }
107
- hexo.database.model('TagPluginOfPost').insert({
108
- _id: uuidTagCSS,
109
- tags: tagListSave,
110
- })
111
- }
112
-
113
- function updateTagCSS(uuidTagCSS) {
114
- // 这里在第二次刷新页面时生效
115
- let arg = process.argv[2];
116
- if (arg != "s" && arg != "server") {
117
- return
118
- }
119
- let info = getTagPluginCSSInfo()
120
- let res = hexo.database.model('TagPluginOfPost').find({ _id: uuidTagCSS })
121
- if (res && res.data && res.data[0] && res.data[0].tags) {
122
- let tags = res.data[0].tags;
123
- let styList = []
124
- tags.forEach(e => {
125
- if (e in info) {
126
- info[e].forEach(x => {
127
- styList.push(x)
128
- })
129
- }
130
- })
131
- renderStyl(styList, (css) => {
132
- setTagPluginCSS(uuidTagCSS, css)
133
- })
134
- } else {
135
- renderTagCSSAllPage(info)
136
- }
137
- }
138
-
139
- function generateTagCSS(data) {
140
- if (!hexo.theme.config.plugins.tag_plugin_load_on_demand.enable) {
141
- return data
142
- }
143
- let uuidTagCSS = hexo.createUuid()
144
- data.uuidTagCSS = uuidTagCSS
145
- let tagList = findTags(data._content)
146
- insertTagCSS(uuidTagCSS, tagList)
147
- return data;
148
- }
149
-
150
- function getTagCSS(page) {
151
- if (!hexo.theme.config.plugins.tag_plugin_load_on_demand.enable) {
152
- return
153
- }
154
- updateTagCSS(page.uuidTagCSS)
155
- let TagPluginCSS = hexo.locals.get('TagPluginCSS')
156
- if (TagPluginCSS) {
157
- if (TagPluginCSS[page.uuidTagCSS]) {
158
- return TagPluginCSS[page.uuidTagCSS]
159
- } else {
160
- return TagPluginCSS["AllPage"]
161
- }
162
- }
163
- }
164
- hexo.extend.filter.register("before_generate", function () {
165
- if (!hexo.theme.config.plugins.tag_plugin_load_on_demand.enable) {
166
- return
167
- }
168
- let arg = process.argv[2];
169
- if (arg != "s" && arg != "server") {
170
- return
171
- }
172
- // 只执行一次
173
- if (hexo.locals.get('TagCSSbeforeFlag')) {
174
- return
175
- }
176
- hexo.locals.set('TagCSSbeforeFlag', function () {
177
- return 1
178
- });
179
- let info = getTagPluginCSSInfo()
180
- hexo.database.model('TagPluginOfPost').forEach(x => {
181
- if (x.tags) {
182
- let tags = x.tags;
183
- let styList = []
184
- tags.forEach(e => {
185
- if (e in info) {
186
- info[e].forEach(x => {
187
- styList.push(x)
188
- })
189
- }
190
- })
191
- renderStyl(styList, (css) => {
192
- setTagPluginCSS(x._id, css)
193
- })
194
- }
195
- })
196
- renderTagCSSAllPage(info)
197
- });
198
- hexo.extend.filter.register('before_post_render', generateTagCSS)
199
- hexo.extend.helper.register("TagCSS", getTagCSS);