hexo-theme-volantis 5.8.1 → 6.0.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.
- package/CHANGELOG.md +5 -39
- package/_cdn.yml +449 -0
- package/_config.yml +155 -157
- package/languages/en.yml +9 -10
- package/languages/zh-CN.yml +11 -15
- package/languages/zh-TW.yml +10 -11
- package/layout/_meta/category.ejs +10 -5
- package/layout/_meta/counter.ejs +14 -17
- package/layout/_meta/tags.ejs +3 -0
- package/layout/_meta/walinecount.ejs +1 -1
- package/layout/_partial/article.ejs +14 -9
- package/layout/_partial/cover.ejs +4 -4
- package/layout/_partial/footer.ejs +1 -1
- package/layout/_partial/head.ejs +7 -18
- package/layout/_partial/header.ejs +6 -6
- package/layout/_partial/post.ejs +4 -4
- package/layout/_partial/scripts/_ctrl.ejs +43 -2
- package/layout/_partial/scripts/config.ejs +69 -0
- package/layout/_partial/scripts/global.ejs +136 -60
- package/layout/_partial/scripts/index.ejs +16 -23
- package/layout/_plugins/_page_plugins/artitalk/index.ejs +1 -1
- package/layout/_plugins/_page_plugins/bbtalk/index.ejs +1 -1
- package/layout/_plugins/_page_plugins/fcircle/index.ejs +9 -8
- package/layout/_plugins/_page_plugins/katex/index.ejs +3 -3
- package/layout/_plugins/_page_plugins/mathjax/index.ejs +1 -1
- package/layout/_plugins/aplayer/layout.ejs +31 -23
- package/layout/_plugins/aplayer/script.ejs +93 -65
- package/layout/_plugins/comments/artalk/script.ejs +31 -40
- package/layout/_plugins/comments/discuss/script.ejs +1 -1
- package/layout/_plugins/comments/disqusjs/script.ejs +2 -2
- package/layout/_plugins/comments/gitalk/script.ejs +1 -1
- package/layout/_plugins/comments/twikoo/script.ejs +1 -1
- package/layout/_plugins/comments/vssue/script.ejs +3 -3
- package/layout/_plugins/comments/waline/script.ejs +2 -2
- package/layout/_plugins/github-api/script.ejs +3 -3
- package/layout/_plugins/lazyload/script.ejs +1 -1
- package/layout/_plugins/nodewaves/script.ejs +1 -1
- package/layout/_plugins/pace/script.ejs +15 -0
- package/layout/_plugins/parallax/script.ejs +1 -1
- package/layout/_plugins/pjax/index.ejs +66 -11
- package/layout/_plugins/pjax/pdata.ejs +5 -5
- package/layout/_plugins/preload/script.ejs +2 -2
- package/layout/_plugins/rightmenus/layout.ejs +4 -4
- package/layout/_plugins/scrollreveal/script.ejs +2 -2
- package/layout/_plugins/search/script.ejs +11 -8
- package/layout/_plugins/swiper/script.ejs +2 -2
- package/layout/{_partial/scripts/toc.ejs → _plugins/toc/script.ejs} +40 -36
- package/layout/_widget/blogger.ejs +4 -4
- package/layout/_widget/webinfo.ejs +13 -14
- package/layout/friends.ejs +2 -2
- package/layout/layout.ejs +1 -15
- package/package.json +4 -4
- package/scripts/events/lib/cdn.js +206 -0
- package/scripts/events/lib/check-configuration.js +7 -7
- package/scripts/events/lib/check-environment.js +17 -17
- package/scripts/events/lib/config.js +0 -24
- package/scripts/events/lib/render-stylus.js +5 -5
- package/scripts/events/lib/stellar-tag-utils.js +2 -2
- package/scripts/filters/hexo-blog-encrypt-callback.js +44 -0
- package/scripts/filters/img.js +1 -1
- package/scripts/filters/replace.js +3 -3
- package/scripts/filters/z-lazyload.js +3 -5
- package/scripts/helpers/first-style.js +2 -2
- package/scripts/helpers/head/generate_seo.js +24 -10
- package/scripts/helpers/head/generate_title__keywords__description.js +28 -9
- package/scripts/helpers/related-posts.js +3 -3
- package/scripts/helpers/structured-data/lib/blogposting.js +1 -1
- package/scripts/helpers/structured-data/lib/breadcrumblist.js +1 -1
- package/scripts/helpers/structured-data/lib/config.js +1 -1
- package/scripts/helpers/structured-data/lib/website.js +1 -1
- package/scripts/helpers//346/226/207/347/253/240/346/216/250/350/215/220.js +184 -0
- package/scripts/tags/btn.js +2 -2
- package/scripts/tags/btns.js +3 -3
- package/scripts/tags/checkbox.js +6 -6
- package/scripts/tags/contributors.js +7 -7
- package/scripts/tags/dropmenu.js +8 -8
- package/scripts/tags/fancybox.js +6 -6
- package/scripts/tags/folding.js +5 -5
- package/scripts/tags/frame.js +3 -3
- package/scripts/tags/friends.js +8 -8
- package/scripts/tags/ghcard.js +7 -7
- package/scripts/tags/image.js +6 -6
- package/scripts/tags/inline-labels.js +6 -6
- package/scripts/tags/link.js +5 -5
- package/scripts/tags/md.js +4 -4
- package/scripts/tags/media.js +5 -5
- package/scripts/tags/note.js +12 -12
- package/scripts/tags/pandown.js +29 -29
- package/scripts/tags/site.js +4 -4
- package/scripts/tags/span.js +4 -4
- package/scripts/tags/table.js +2 -2
- package/scripts/tags/tabs.js +23 -23
- package/scripts/tags/timeline.js +5 -5
- package/source/css/_first/base_first.styl +1 -1
- package/source/css/_style/_layout/article.styl +43 -0
- package/source/css/_style/_layout/main.styl +1 -1
- package/source/css/_style/_layout/search.styl +206 -14
- package/source/css/_style/_plugins/index.styl +1 -3
- package/source/js/app.js +133 -160
- package/source/js/plugins/parallax.js +1 -1
- package/source/js/plugins/rightMenus.js +24 -20
- package/source/js/search/algolia.js +239 -0
- package/source/js/search/hexo.js +8 -2
- package/source/js/search/meilisearch.js +220 -0
- package/layout/_partial/scripts/_ctrl/cdnCtrl.ejs +0 -127
- package/layout/_partial/scripts/_ctrl/coverCtrl.ejs +0 -43
- package/layout/_plugins/analytics/LCCounter.ejs +0 -207
- package/layout/_plugins/pjax/animate.ejs +0 -31
- package/layout/_plugins/rightmenu/layout.ejs +0 -119
- package/scripts/helpers/revisioned.js +0 -167
- package/source/css/_style/_plugins/pjaxanimate.styl +0 -160
- package/source/js/plugins/rightMenu.js +0 -577
- /package/layout/{_partial/scripts/content-visibility-scroll-fix.ejs → _plugins/content-visibility/script.ejs} +0 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
async function loadSearchScript() {
|
|
3
|
+
<% if(theme.search.service === 'algolia') { %>
|
|
4
|
+
await volantis.js("<%- theme.cdn.algolia_search_v4 %>")
|
|
5
|
+
await volantis.js("<%- theme.cdn.instantsearch_v4 %>")
|
|
6
|
+
<% } %>
|
|
7
|
+
|
|
8
|
+
<% if(theme.search.service === 'meilisearch') { %>
|
|
9
|
+
await volantis.js("<%- theme.cdn.instantsearch_v4 %>")
|
|
10
|
+
await volantis.js("<%- theme.cdn.instant_meilisearch %>")
|
|
11
|
+
<% } %>
|
|
12
|
+
return volantis.js("<%- theme.cdn['volantis_search_' + theme.search.service] %>");
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
function loadSearchService() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
function load_swiper() {
|
|
3
3
|
if (!document.querySelectorAll(".swiper-container")[0]) return;
|
|
4
|
-
volantis.css("<%- theme.
|
|
5
|
-
volantis.js("<%- theme.
|
|
4
|
+
volantis.css("<%- theme.cdn.swiper_css %>");
|
|
5
|
+
volantis.js("<%- theme.cdn.swiper_js %>").then(() => {
|
|
6
6
|
pjax_swiper();
|
|
7
7
|
});
|
|
8
8
|
}
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
function
|
|
2
|
+
function listenSidebarTOC() {
|
|
3
3
|
const navItems = document.querySelectorAll(".toc li");
|
|
4
4
|
if (!navItems.length) return;
|
|
5
|
-
|
|
6
|
-
const sections =
|
|
5
|
+
const targets = []
|
|
6
|
+
const sections = Array.from(navItems).forEach((element) => {
|
|
7
7
|
const link = element.querySelector(".toc-link");
|
|
8
8
|
const target = document.getElementById(
|
|
9
|
-
decodeURI(link.getAttribute("href")).replace("#", "")
|
|
9
|
+
link.getAttribute("href") ? decodeURI(link.getAttribute("href")).replace("#", "") : link.getAttribute("toc-action").split("toc-")[1] // 兼容 hexo-blog-encrypt
|
|
10
10
|
);
|
|
11
11
|
targets.push(target)
|
|
12
12
|
// 解除 a 标签 href 的 锚点定位, a 标签 href 的 锚点定位 会随机启用?? 产生错位???
|
|
13
|
-
link.
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (link.getAttribute("href")) {
|
|
14
|
+
link.setAttribute("toc-action", "toc-" + decodeURI(link.getAttribute("href")).replace("#", ""))
|
|
15
|
+
link.removeAttribute("href")
|
|
16
|
+
}
|
|
16
17
|
// 配置 点击 触发新的锚点定位
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
if (target && target.id) {
|
|
19
|
+
link.addEventListener("click", (event) => {
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
// 这里的 addTop 是通过错位使得 toc 自动展开.
|
|
22
|
+
volantis.scroll.to(target, { addTop: 5, observer: true })
|
|
23
|
+
// Anchor id
|
|
24
|
+
history.pushState(null, document.title, "#" + target.id);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
24
27
|
return target;
|
|
25
28
|
});
|
|
26
29
|
|
|
@@ -39,25 +42,27 @@
|
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
// 方案一:
|
|
42
|
-
volantis.activateNavIndex=0
|
|
45
|
+
volantis.activateNavIndex = 0
|
|
43
46
|
activateNavByIndex(navItems[volantis.activateNavIndex])
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
if (targets[0]) {
|
|
48
|
+
volantis.scroll.push(() => {
|
|
49
|
+
if (targets[0].getBoundingClientRect().top >= 0) {
|
|
50
|
+
volantis.activateNavIndex = 0
|
|
51
|
+
} else if (targets[targets.length - 1].getBoundingClientRect().top < 0) {
|
|
52
|
+
volantis.activateNavIndex = targets.length - 1
|
|
53
|
+
} else {
|
|
54
|
+
for (let index = 0; index < targets.length; index++) {
|
|
55
|
+
const target0 = targets[index];
|
|
56
|
+
const target1 = targets[(index + 1) % targets.length];
|
|
57
|
+
if (target0.getBoundingClientRect().top < 0 && target1.getBoundingClientRect().top >= 0) {
|
|
58
|
+
volantis.activateNavIndex = index
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
63
|
+
activateNavByIndex(navItems[volantis.activateNavIndex])
|
|
64
|
+
})
|
|
65
|
+
}
|
|
61
66
|
|
|
62
67
|
// 方案二:
|
|
63
68
|
// IntersectionObserver 不是完美精确到像素级别 也不是低延时性的
|
|
@@ -101,10 +106,9 @@
|
|
|
101
106
|
// createIntersectionObserver(document.documentElement.scrollHeight);
|
|
102
107
|
}
|
|
103
108
|
|
|
104
|
-
document.addEventListener("DOMContentLoaded", ()=>{
|
|
105
|
-
volantis.requestAnimationFrame(
|
|
106
|
-
});
|
|
107
|
-
document.addEventListener("pjax:success", ()=>{
|
|
108
|
-
volantis.requestAnimationFrame(listennSidebarTOC)
|
|
109
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
110
|
+
volantis.requestAnimationFrame(listenSidebarTOC)
|
|
109
111
|
});
|
|
110
|
-
|
|
112
|
+
volantis.pjax.push(listenSidebarTOC);
|
|
113
|
+
</script>
|
|
114
|
+
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
<% if (item.avatar) { %>
|
|
5
5
|
<% if (item.url) { %>
|
|
6
6
|
<a class='avatar flat-box <%- item.shape %>' href='<%- url_for(item.url) %>'>
|
|
7
|
-
<img no-lazy src='<%- item.avatar %>'/>
|
|
7
|
+
<img no-lazy src='<%- item.avatar %>' alt='avatar' />
|
|
8
8
|
</a>
|
|
9
9
|
<% } else { %>
|
|
10
10
|
<div class='avatar'>
|
|
11
|
-
<img no-lazy src='<%- item.avatar %>'/>
|
|
11
|
+
<img no-lazy src='<%- item.avatar %>' alt='avatar' />
|
|
12
12
|
</div>
|
|
13
13
|
<% } %>
|
|
14
14
|
<% } %>
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
target="_blank"
|
|
36
36
|
rel="external nofollow noopener noreferrer">
|
|
37
37
|
<% if (value.img) { %>
|
|
38
|
-
<img src="<%- value.img %>"/>
|
|
38
|
+
<img src="<%- value.img %>" alt='social' />
|
|
39
39
|
<% } else if (value.avatar) { %>
|
|
40
|
-
<img src="<%- value.avatar %>" style="border-radius:120px"/>
|
|
40
|
+
<img src="<%- value.avatar %>" alt='social' style="border-radius:120px"/>
|
|
41
41
|
<% } %>
|
|
42
42
|
</a>
|
|
43
43
|
<% } %>
|
|
@@ -25,25 +25,24 @@
|
|
|
25
25
|
</div>
|
|
26
26
|
<% } %>
|
|
27
27
|
|
|
28
|
-
<% if (item.type.visitcounter.
|
|
28
|
+
<% if (item.type.visitcounter.enable && theme.plugins.busuanzi.enable) { %>
|
|
29
29
|
<div class="webinfo-item">
|
|
30
30
|
<div><%= item.type.visitcounter.siteuv.text %></div>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
<div>
|
|
32
|
+
<span id="busuanzi_value_site_uv">
|
|
33
|
+
<i class="fa-solid fa-fan fa-spin fa-fw" aria-hidden="true"></i>
|
|
34
|
+
</span>
|
|
35
|
+
<%= item.type.visitcounter.siteuv.unit %>
|
|
36
|
+
</div>
|
|
36
37
|
</div>
|
|
37
|
-
<% } %>
|
|
38
|
-
|
|
39
|
-
<% if (item.type.visitcounter.sitepv.enable && (!!theme.analytics.busuanzi || !!theme.analytics.leancloud.app_id)) { %>
|
|
40
38
|
<div class="webinfo-item">
|
|
41
39
|
<div><%= item.type.visitcounter.sitepv.text %></div>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
<div>
|
|
41
|
+
<span id="busuanzi_value_site_pv">
|
|
42
|
+
<i class="fa-solid fa-fan fa-spin fa-fw" aria-hidden="true"></i>
|
|
43
|
+
</span>
|
|
44
|
+
<%= item.type.visitcounter.sitepv.unit %>
|
|
45
|
+
</div>
|
|
47
46
|
</div>
|
|
48
47
|
<% } %>
|
|
49
48
|
|
package/layout/friends.ejs
CHANGED
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
<%- page.more %>
|
|
63
63
|
<%- partial('_partial/meta',{post: page, position: 'bottom'}) %>
|
|
64
64
|
</article>
|
|
65
|
-
|
|
65
|
+
<% if (page.comments == undefined || page.comments != false) { %>
|
|
66
66
|
<%- partial('_plugins/comments/index',{post: page}) %>
|
|
67
|
-
|
|
67
|
+
<% } %>
|
|
68
68
|
</div>
|
|
69
69
|
<%- partial('_partial/side') %>
|
package/layout/layout.ejs
CHANGED
|
@@ -13,13 +13,6 @@
|
|
|
13
13
|
<!-- Custom Files bodyBegin begin-->
|
|
14
14
|
<%- volantis_inject('bodyBegin') %>
|
|
15
15
|
<!-- Custom Files bodyBegin end-->
|
|
16
|
-
<!-- front-matter body_begin begin -->
|
|
17
|
-
<%_ if (page.import && page.import.body_begin){ _%>
|
|
18
|
-
<%_ getList(page.import.body_begin).forEach(function(item){ _%>
|
|
19
|
-
<%- item %>
|
|
20
|
-
<%_ }) _%>
|
|
21
|
-
<%_ } _%>
|
|
22
|
-
<!-- front-matter body_begin end -->
|
|
23
16
|
<%- partial('_partial/header', null, {cache: false, path: path}) %>
|
|
24
17
|
<div id="l_body">
|
|
25
18
|
<%- partial('_partial/cover') %>
|
|
@@ -29,7 +22,7 @@
|
|
|
29
22
|
<%- partial('_plugins/pjax/pdata') %>
|
|
30
23
|
</div>
|
|
31
24
|
<%- partial('_partial/footer', null, {cache: !config.relative_link}) %>
|
|
32
|
-
<a id="s-top" class="fa-solid fa-arrow-up fa-fw"
|
|
25
|
+
<a id="s-top" class="fa-solid fa-arrow-up fa-fw" title="top"></a>
|
|
33
26
|
</div>
|
|
34
27
|
</div>
|
|
35
28
|
<div>
|
|
@@ -48,12 +41,5 @@
|
|
|
48
41
|
<!-- Custom Files bodyEnd begin-->
|
|
49
42
|
<%- volantis_inject('bodyEnd') %>
|
|
50
43
|
<!-- Custom Files bodyEnd end-->
|
|
51
|
-
<!-- front-matter body_end begin -->
|
|
52
|
-
<%_ if (page.import && page.import.body_end){ _%>
|
|
53
|
-
<%_ getList(page.import.body_end).forEach(function(item){ _%>
|
|
54
|
-
<%- item %>
|
|
55
|
-
<%_ }) _%>
|
|
56
|
-
<%_ } _%>
|
|
57
|
-
<!-- front-matter body_end end -->
|
|
58
44
|
</body>
|
|
59
45
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hexo-theme-volantis",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "Elegant and powerful theme for Hexo.",
|
|
5
5
|
"main": "package.json",
|
|
6
6
|
"scripts": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"url": "https://github.com/volantis-x/hexo-theme-volantis/issues"
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://volantis.js.org",
|
|
24
|
-
"
|
|
25
|
-
"hexo": "^
|
|
26
|
-
"hexo-renderer-stylus": "^
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"hexo": "^8.1.1",
|
|
26
|
+
"hexo-renderer-stylus": "^3.0.1",
|
|
27
27
|
"hexo-renderer-ejs": "^2.0.0",
|
|
28
28
|
"hexo-generator-json-content": "^4.2.3"
|
|
29
29
|
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/* Getting the version of the theme. */
|
|
2
|
+
const { version } = require('../../../package.json');
|
|
3
|
+
const theme_version = version;
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const site_root = hexo.config.root;
|
|
6
|
+
// _cdn.yml
|
|
7
|
+
/* It's reading the `_cdn.yml` file in the theme directory. */
|
|
8
|
+
const cdn_info = hexo.render.renderSync({ path: path.join(hexo.theme_dir, '/_cdn.yml'), engine: 'yaml' })
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* If the item is an object and not an array, then it's an object.
|
|
12
|
+
* @param item - The item to test.
|
|
13
|
+
*/
|
|
14
|
+
function isObject(item) {
|
|
15
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* It takes two objects and merges the second object into the first object
|
|
20
|
+
* @param target - The object that will be modified.
|
|
21
|
+
* @param source - The object to merge into the target.
|
|
22
|
+
* @returns The merged object.
|
|
23
|
+
*/
|
|
24
|
+
function merge(target, source) {
|
|
25
|
+
for (const key in source) {
|
|
26
|
+
if (isObject(target[key]) && isObject(source[key])) {
|
|
27
|
+
merge(target[key], source[key]);
|
|
28
|
+
} else {
|
|
29
|
+
target[key] = source[key];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// volantis_cdn_system_prefix
|
|
36
|
+
// 在本配置文件中 匹配以 "volantis-local/npm/static/cdnjs" 开头的链接路径替换为该格式的前缀开头 prefix
|
|
37
|
+
/**
|
|
38
|
+
* It will replace the prefix of the source with the prefix you set in the configuration file
|
|
39
|
+
* @param source - the source object to be processed
|
|
40
|
+
* @param hexo - The hexo object.
|
|
41
|
+
*/
|
|
42
|
+
function volantis_cdn_system_prefix(source, hexo) {
|
|
43
|
+
const prefix_list = ["local", "npm", "static", "cdnjs"];
|
|
44
|
+
for (const key in source) {
|
|
45
|
+
if (isObject(source[key])) {
|
|
46
|
+
volantis_cdn_system_prefix(source[key], hexo);
|
|
47
|
+
} else if (source[key] && typeof source[key] == "string") {
|
|
48
|
+
for (const prefix of prefix_list) {
|
|
49
|
+
if (source[key].match(new RegExp(`^volantis-${prefix}\/`, "g"))) {
|
|
50
|
+
const my_prefix = hexo.theme.config.cdn_system.system_config[prefix].prefix.replace(/\$\{site_root\}/g, site_root)
|
|
51
|
+
source[key] = my_prefix + source[key].replace(new RegExp(`^volantis-${prefix}`, "g"), "")
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} else if (source[key] && Array.isArray(source[key]) && source[key].length > 0) {
|
|
56
|
+
source[key].forEach((item, index) => {
|
|
57
|
+
if (item && typeof item == "string") {
|
|
58
|
+
for (const prefix of prefix_list) {
|
|
59
|
+
if (item.match(new RegExp(`^volantis-${prefix}\/`, "g"))) {
|
|
60
|
+
const my_prefix = hexo.theme.config.cdn_system.system_config[prefix].prefix.replace(/\$\{site_root\}/g, site_root)
|
|
61
|
+
source[key][index] = my_prefix + item.replace(new RegExp(`^volantis-${prefix}`, "g"), "")
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} else if (isObject(item)) {
|
|
66
|
+
volantis_cdn_system_prefix(item, hexo);
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* It takes a file name and returns the same file name with the extension replaced with `.min` if the
|
|
75
|
+
* file name doesn't already end with `.min`
|
|
76
|
+
* @param file - The file name to be minified.
|
|
77
|
+
* @returns The file name with the extension replaced with .min.ext
|
|
78
|
+
*/
|
|
79
|
+
const minFile = (file) => {
|
|
80
|
+
return file.replace(/(?<!\.min)\.(js|css)$/g, ext => '.min' + ext)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 匹配 CDN 资源
|
|
84
|
+
/**
|
|
85
|
+
* `match_cdn_source` is a function that takes a key as an argument and returns the CDN source of the
|
|
86
|
+
* corresponding key.
|
|
87
|
+
*
|
|
88
|
+
* The function first checks if the key is valid and if the corresponding CDN source exists. If so, it
|
|
89
|
+
* will then check the priority of the CDN source. If the priority is `custom`, it will check if the
|
|
90
|
+
* custom CDN source exists. If the priority is not `custom`, it will check if the corresponding CDN
|
|
91
|
+
* source is enabled. If so, it will then return the CDN source.
|
|
92
|
+
*
|
|
93
|
+
* The `format` variable is the format of the CDN source. The `value` variable is the value of the CDN
|
|
94
|
+
* source. The `value` variable is a JavaScript object that contains the following properties:
|
|
95
|
+
*
|
|
96
|
+
* - `version`: the version of the CDN source
|
|
97
|
+
* - `name`: the name of the CDN source
|
|
98
|
+
* -
|
|
99
|
+
* @param key - The name of the library in the _cdn.yml file.
|
|
100
|
+
* @returns The return value is a string.
|
|
101
|
+
*/
|
|
102
|
+
function match_cdn_source(key) {
|
|
103
|
+
if (key && cdn_info[key]) {
|
|
104
|
+
// _cdn.yml item
|
|
105
|
+
const info = cdn_info[key];
|
|
106
|
+
const system_config = hexo.theme.config.cdn_system.system_config;
|
|
107
|
+
for (const iterator of hexo.theme.config.cdn_system.priority) {
|
|
108
|
+
// priority item
|
|
109
|
+
if (iterator === "custom") {
|
|
110
|
+
if (system_config.custom) {
|
|
111
|
+
const r = system_config.custom[key];
|
|
112
|
+
if (r) {
|
|
113
|
+
return r;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
if (info[iterator] === true) {
|
|
118
|
+
const prefix = system_config[iterator].prefix?.replace(/\$\{site_root\}/g, site_root);
|
|
119
|
+
const format = system_config[iterator].format;
|
|
120
|
+
let name = info.name;
|
|
121
|
+
let file = info.file;
|
|
122
|
+
if (iterator === "cdnjs") {
|
|
123
|
+
if (info.cdnjs_name) {
|
|
124
|
+
name = info.cdnjs_name;
|
|
125
|
+
}
|
|
126
|
+
if (info.cdnjs_file) {
|
|
127
|
+
file = info.cdnjs_file;
|
|
128
|
+
} else {
|
|
129
|
+
file = file.replace(/^[lib|dist]*\/|browser\//g, '');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (info.local === true) {
|
|
133
|
+
file = file.replace(/^source\//g, '')
|
|
134
|
+
}
|
|
135
|
+
let min_file = minFile(file)
|
|
136
|
+
if (iterator === "cdnjs") {
|
|
137
|
+
if (info.cdnjs_no_min_file) {
|
|
138
|
+
min_file = file;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
let version = info.version;
|
|
142
|
+
if (info.local === true) {
|
|
143
|
+
version = theme_version
|
|
144
|
+
}
|
|
145
|
+
const timestamp = hexo.theme.config.getStartTime;
|
|
146
|
+
const value = {
|
|
147
|
+
version,
|
|
148
|
+
name,
|
|
149
|
+
file,
|
|
150
|
+
min_file,
|
|
151
|
+
prefix,
|
|
152
|
+
timestamp,
|
|
153
|
+
}
|
|
154
|
+
let res = format;
|
|
155
|
+
let p = 0;
|
|
156
|
+
while (/\$\{(.+?)\}/g.test(res)) {
|
|
157
|
+
res = res?.replace(/\$\{(.+?)\}/g, (match, $1) => value[$1] ? value[$1] : eval($1)) || null
|
|
158
|
+
// 防止死循环。。。
|
|
159
|
+
p++;
|
|
160
|
+
if (p > 20) {
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return res
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 收集 CDN 资源
|
|
173
|
+
/**
|
|
174
|
+
* `hexo.theme.config.cdn` is an object that contains the CDN source for each library.
|
|
175
|
+
*
|
|
176
|
+
* The `cdn_info` object is defined in the `_cdn.yml` file. It contains the name of the library, the
|
|
177
|
+
* version, and the CDN source etc.
|
|
178
|
+
*
|
|
179
|
+
* The `match_cdn_source` function returns the CDN source for
|
|
180
|
+
* the library.
|
|
181
|
+
*
|
|
182
|
+
* The `collect_cdn_source` function is called in the `_cdn.yml` file. It loops through the
|
|
183
|
+
* `cdn_info` object and adds the CDN source for each library to the `hexo.theme.config.cdn` object.
|
|
184
|
+
*
|
|
185
|
+
* The `hexo.theme.config.debug` variable is defined in the `_config.yml` file. It is set to `true`
|
|
186
|
+
*/
|
|
187
|
+
function collect_cdn_source() {
|
|
188
|
+
hexo.theme.config.cdn = {}
|
|
189
|
+
Object.keys(cdn_info).forEach(e => {
|
|
190
|
+
hexo.theme.config.cdn[e] = match_cdn_source(e)
|
|
191
|
+
})
|
|
192
|
+
if (hexo.theme.config.debug == "cdn")
|
|
193
|
+
console.log(hexo.theme.config.cdn);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
hexo.on('generateBefore', () => {
|
|
197
|
+
/* It's replacing the prefix of the source with the prefix you set in the configuration file. */
|
|
198
|
+
volantis_cdn_system_prefix(hexo.theme.config, hexo);
|
|
199
|
+
// 可以在 source/_data/cdn.yml 覆盖 theme/_cdn.yml
|
|
200
|
+
const data = hexo.locals.get('data');
|
|
201
|
+
if (data.cdn) {
|
|
202
|
+
merge(cdn_info, data.cdn);
|
|
203
|
+
}
|
|
204
|
+
/* Collecting the CDN source for each library. */
|
|
205
|
+
collect_cdn_source();
|
|
206
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module.exports =(hexo) => {
|
|
1
|
+
module.exports = (hexo) => {
|
|
2
2
|
try {
|
|
3
3
|
let config = hexo.config;
|
|
4
4
|
let themeConfig = hexo.theme.config;
|
|
@@ -17,9 +17,9 @@ description主要用于SEO,告诉搜索引擎一个关于您站点的简单描
|
|
|
17
17
|
see: https://hexo.io/zh-cn/docs/configuration
|
|
18
18
|
description is not configured!`);
|
|
19
19
|
}
|
|
20
|
-
if (themeConfig?.search?.service
|
|
21
|
-
return `原 google,
|
|
22
|
-
The google,
|
|
20
|
+
if (themeConfig?.search?.service === `google` || themeConfig?.search?.service === `azure` || themeConfig?.search?.service === `baidu`) {
|
|
21
|
+
return `原 google, azure, baidu 站内搜索 系祖传代码, 且文档丢失, 不便后续维护 在 5.0 版本被移除
|
|
22
|
+
The google, azure, baidu site search is ancestral code, and the document is lost, which is inconvenient for subsequent maintenance. It was removed in version 5.0
|
|
23
23
|
see: https://volantis.js.org/v5/theme-settings/#站内搜索`
|
|
24
24
|
}
|
|
25
25
|
if (`backstretch` in themeConfig?.plugins) {
|
|
@@ -27,17 +27,17 @@ see: https://volantis.js.org/v5/theme-settings/#站内搜索`
|
|
|
27
27
|
jquery.backstretch was removed in version 5.0, replaced by parallax
|
|
28
28
|
see: https://volantis.js.org/v5/theme-settings/#幻灯片背景-视差滚动效果`
|
|
29
29
|
}
|
|
30
|
-
if ("valinecount" in themeConfig?.article?.body?.top_meta||"valinecount" in themeConfig?.article?.body?.bottom_meta||"valinecount" in themeConfig?.article?.body?.meta_library) {
|
|
30
|
+
if ("valinecount" in themeConfig?.article?.body?.top_meta || "valinecount" in themeConfig?.article?.body?.bottom_meta || "valinecount" in themeConfig?.article?.body?.meta_library) {
|
|
31
31
|
return `ValineCount 在 5.0 版本被移除
|
|
32
32
|
ValineCount has been removed in version 5.0
|
|
33
33
|
see: https://volantis.js.org/v5/theme-settings/#文章布局配置`
|
|
34
34
|
}
|
|
35
|
-
if (themeConfig?.comments?.service=="valine"||themeConfig?.comments?.service=="minivaline") {
|
|
35
|
+
if (themeConfig?.comments?.service == "valine" || themeConfig?.comments?.service == "minivaline") {
|
|
36
36
|
return `Valine 在 5.0 版本被移除
|
|
37
37
|
Valine has been removed in version 5.0
|
|
38
38
|
see: https://volantis.js.org/v5/theme-settings/#选择评论系统`
|
|
39
39
|
}
|
|
40
|
-
} catch (error) {}
|
|
40
|
+
} catch (error) { }
|
|
41
41
|
hexo.log.info(`Check environment configuration success!`);
|
|
42
42
|
return true;
|
|
43
43
|
};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
// 环境配置检查可以避免一些奇葩的报错
|
|
2
2
|
|
|
3
3
|
const exec = require('child_process').exec;
|
|
4
|
-
module.exports =(hexo) => {
|
|
4
|
+
module.exports = (hexo) => {
|
|
5
5
|
if (!hexo.checkEnvironment) {
|
|
6
|
-
hexo.checkEnvironment=1;
|
|
6
|
+
hexo.checkEnvironment = 1;
|
|
7
7
|
hexo.log.info(`Checking environment configuration...`);
|
|
8
8
|
|
|
9
9
|
// Checking environment
|
|
10
10
|
exec('node -v', (err, stdout, stderr) => {
|
|
11
11
|
if (err) {
|
|
12
|
-
CheckError(hexo
|
|
12
|
+
CheckError(hexo, `node.js: ${err}`);
|
|
13
13
|
}
|
|
14
14
|
let nodeVersion = stdout.match(/v(\d*)/)[1];
|
|
15
|
-
if (nodeVersion<16) {
|
|
15
|
+
if (nodeVersion < 16) {
|
|
16
16
|
hexo.log.info(`node.js 版本:${stdout}`);
|
|
17
|
-
CheckError(hexo
|
|
18
|
-
}else{
|
|
17
|
+
CheckError(hexo, `node.js 版本过低,请升级至 v16.x 及以上版本!`);
|
|
18
|
+
} else {
|
|
19
19
|
exec('hexo -v', (err, stdout, stderr) => {
|
|
20
20
|
if (err) {
|
|
21
|
-
CheckError(hexo
|
|
21
|
+
CheckError(hexo, `hexo-cli: ${err}`);
|
|
22
22
|
}
|
|
23
23
|
let hexoVersion1 = stdout.match(/hexo:\s*(\d*)/)[1];
|
|
24
24
|
let hexoVersion2 = stdout.match(/hexo:\s*\d*\.(\d*)/)[1];
|
|
25
|
-
if (hexoVersion1<5 || (hexoVersion1==5 && hexoVersion2<4)) {
|
|
25
|
+
if (hexoVersion1 < 5 || (hexoVersion1 == 5 && hexoVersion2 < 4)) {
|
|
26
26
|
hexo.log.info(`hexo 版本:${stdout}`);
|
|
27
|
-
CheckError(hexo
|
|
28
|
-
}else{
|
|
27
|
+
CheckError(hexo, `hexo 版本过低,请升级至 5.4 以上版本!`);
|
|
28
|
+
} else {
|
|
29
29
|
let hexoClVersion1 = stdout.match(/hexo-cli:\s*(\d*)/)[1];
|
|
30
30
|
let hexoClVersion2 = stdout.match(/hexo-cli:\s*\d*\.(\d*)/)[1];
|
|
31
|
-
if (hexoClVersion1<4 || (hexoClVersion1==4 && hexoClVersion2<1)) {
|
|
31
|
+
if (hexoClVersion1 < 4 || (hexoClVersion1 == 4 && hexoClVersion2 < 1)) {
|
|
32
32
|
hexo.log.info(`hexo-cli 版本:${stdout}`);
|
|
33
|
-
CheckError(hexo
|
|
34
|
-
}else{
|
|
33
|
+
CheckError(hexo, `hexo-cli 版本过低,请升级至 4.1 以上版本!`);
|
|
34
|
+
} else {
|
|
35
35
|
// Checking configuration
|
|
36
36
|
let checkConfiguration = require('./check-configuration')(hexo);
|
|
37
|
-
if (checkConfiguration!==true) {
|
|
38
|
-
CheckConfError(hexo,checkConfiguration);
|
|
37
|
+
if (checkConfiguration !== true) {
|
|
38
|
+
CheckConfError(hexo, checkConfiguration);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -45,7 +45,7 @@ module.exports =(hexo) => {
|
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
function CheckError(hexo,msg) {
|
|
48
|
+
function CheckError(hexo, msg) {
|
|
49
49
|
hexo.log.error(`
|
|
50
50
|
============================================================
|
|
51
51
|
环境配置检查失败!| Environment configuration check failed!
|
|
@@ -65,7 +65,7 @@ debug: env
|
|
|
65
65
|
throw new Error('环境配置检查失败!| Environment configuration check failed!');
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function CheckConfError(hexo,msg) {
|
|
68
|
+
function CheckConfError(hexo, msg) {
|
|
69
69
|
hexo.log.error(`
|
|
70
70
|
============================================================
|
|
71
71
|
配置文件检查失败!| Configuration check failed!
|
|
@@ -17,29 +17,6 @@ function merge(target, source) {
|
|
|
17
17
|
return target;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
// volantis_static_cdn
|
|
21
|
-
function volantis_static_cdn(source,hexo) {
|
|
22
|
-
for (const key in source) {
|
|
23
|
-
if (isObject(source[key])) {
|
|
24
|
-
volantis_static_cdn(source[key],hexo);
|
|
25
|
-
} else if(source[key] && typeof source[key] =="string") {
|
|
26
|
-
if(source[key].match(/^volantis-static\//g)){
|
|
27
|
-
source[key] = hexo.theme.config.volantis_static_cdn + source[key].replace(/^volantis-static\//g,"")
|
|
28
|
-
}
|
|
29
|
-
} else if(source[key] && Array.isArray(source[key]) && source[key].length>0) {
|
|
30
|
-
source[key].forEach((item,index)=>{
|
|
31
|
-
if(item && typeof item =="string") {
|
|
32
|
-
if(item.match(/^volantis-static\//g)){
|
|
33
|
-
source[key][index] = hexo.theme.config.volantis_static_cdn + item.replace(/^volantis-static\//g,"")
|
|
34
|
-
}
|
|
35
|
-
}else if (isObject(item)){
|
|
36
|
-
volantis_static_cdn(item,hexo);
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
20
|
module.exports = hexo => {
|
|
44
21
|
if (!hexo.locals.get) return;
|
|
45
22
|
|
|
@@ -86,6 +63,5 @@ module.exports = hexo => {
|
|
|
86
63
|
mergeLang(language);
|
|
87
64
|
}
|
|
88
65
|
}
|
|
89
|
-
volantis_static_cdn(hexo.theme.config,hexo);
|
|
90
66
|
hexo.theme.config.info.theme_version = version;
|
|
91
67
|
};
|
|
@@ -69,10 +69,10 @@ function merge(target, source) {
|
|
|
69
69
|
}
|
|
70
70
|
return target;
|
|
71
71
|
}
|
|
72
|
-
function getType(file){
|
|
73
|
-
var filename=file;
|
|
74
|
-
var index1=filename.lastIndexOf(".");
|
|
75
|
-
var index2=filename.length;
|
|
76
|
-
var type=filename.substring(index1+1,index2);
|
|
72
|
+
function getType(file) {
|
|
73
|
+
var filename = file;
|
|
74
|
+
var index1 = filename.lastIndexOf(".");
|
|
75
|
+
var index2 = filename.length;
|
|
76
|
+
var type = filename.substring(index1 + 1, index2);
|
|
77
77
|
return type;
|
|
78
78
|
}
|