hexo-theme-shokax 0.3.10 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- package/_config.yml +47 -57
- package/layout/_mixin/comment.pug +1 -1
- package/layout/_partials/head/head.pug +2 -7
- package/layout/_partials/layout.pug +5 -5
- package/package.json +16 -21
- package/scripts/filters/locals.js +6 -0
- package/scripts/filters/post.js +2 -0
- package/scripts/generaters/archive.js +13 -1
- package/scripts/generaters/config.js +4 -1
- package/scripts/generaters/images.js +2 -0
- package/scripts/generaters/index.js +2 -0
- package/scripts/generaters/pages.js +0 -2
- package/scripts/generaters/script.js +37 -11
- package/scripts/helpers/asset.js +17 -71
- package/scripts/helpers/engine.js +24 -1
- package/scripts/helpers/list_categories.js +4 -0
- package/scripts/helpers/summary_ai.js +4 -0
- package/scripts/helpers/symbols_count_time.js +14 -8
- package/scripts/plugin/check.js +5 -3
- package/scripts/plugin/index.js +39 -23
- package/scripts/plugin/lib/injects.js +15 -0
- package/scripts/tags/media.js +1 -0
- package/scripts/utils.js +14 -0
- package/source/js/_app/components/sidebar.js +54 -56
- package/source/js/_app/fireworks.js +6 -137
- package/source/js/_app/globals/globalVars.js +80 -96
- package/source/js/_app/globals/handles.js +81 -60
- package/source/js/_app/globals/themeColor.js +30 -26
- package/source/js/_app/globals/thirdparty.js +25 -24
- package/source/js/_app/globals/tools.js +36 -30
- package/source/js/_app/library/anime.js +30 -15
- package/source/js/_app/library/dom.js +12 -5
- package/source/js/_app/library/loadFile.js +10 -12
- package/source/js/_app/library/proto.js +59 -7
- package/source/js/_app/library/scriptPjax.js +14 -9
- package/source/js/_app/library/storage.js +2 -4
- package/source/js/_app/library/vue.js +16 -19
- package/source/js/_app/page/comment.js +10 -11
- package/source/js/_app/page/common.js +8 -12
- package/source/js/_app/page/fancybox.js +14 -14
- package/source/js/_app/page/post.js +43 -45
- package/source/js/_app/page/search.js +20 -20
- package/source/js/_app/page/tab.js +7 -10
- package/source/js/_app/pjax/domInit.js +29 -29
- package/source/js/_app/pjax/refresh.js +44 -50
- package/source/js/_app/pjax/siteInit.js +27 -31
- package/source/js/_app/player.js +44 -27
- package/test/dom.test.js +0 -86
package/_config.yml
CHANGED
@@ -83,13 +83,34 @@ polyfill:
|
|
83
83
|
- fetch
|
84
84
|
|
85
85
|
# 显示的动画(烟花)
|
86
|
+
# 参阅 https://github.com/D-Sketon/mouse-firework
|
86
87
|
fireworks:
|
87
88
|
enable: true
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
options:
|
90
|
+
excludeElements: ["a"]
|
91
|
+
particles:
|
92
|
+
- shape: circle
|
93
|
+
move: ["emit"]
|
94
|
+
easing: easeOutExpo
|
95
|
+
colors:
|
96
|
+
- "rgba(255,182,185,.9)"
|
97
|
+
- "rgba(250,227,217,.9)"
|
98
|
+
- "rgba(187,222,214,.9)"
|
99
|
+
- "rgba(138,198,209,.9)"
|
100
|
+
number: 30
|
101
|
+
duration: [1200, 1800]
|
102
|
+
shapeOptions:
|
103
|
+
radius: [16, 32]
|
104
|
+
- shape: circle
|
105
|
+
move: ["diffuse"]
|
106
|
+
easing: easeOutExpo
|
107
|
+
colors: ["#fff"]
|
108
|
+
number: 1
|
109
|
+
duration: [1200, 1800]
|
110
|
+
shapeOptions:
|
111
|
+
radius: 20
|
112
|
+
alpha: 0.5
|
113
|
+
lineWidth: 6
|
93
114
|
|
94
115
|
font:
|
95
116
|
enable: true
|
@@ -327,58 +348,27 @@ quicklink:
|
|
327
348
|
#! DO NOT EDIT THE FOLLOWING `vendors` SETTINGS
|
328
349
|
#! UNLESS YOU KNOW WHAT YOU ARE DOING
|
329
350
|
#! ---------------------------------------------------------------
|
330
|
-
advVendors:
|
331
|
-
enable: true
|
332
|
-
github: "https://cdn.jsdelivr.net/gh/"
|
333
|
-
combine: "https://cdn.jsdelivr.net/"
|
334
|
-
npm: "https://unpkg.com/"
|
335
|
-
js:
|
336
|
-
pace:
|
337
|
-
src: bytedance:pace/1.0.2/pace.min.js
|
338
|
-
fetch:
|
339
|
-
src: npm:whatwg-fetch@3.4.0/dist/fetch.umd.js
|
340
|
-
algolia:
|
341
|
-
src: bytedance:algoliasearch/4.12.1/algoliasearch-lite.umd.min.js
|
342
|
-
instantsearch:
|
343
|
-
src: bytedance:instantsearch.js/4.39.0/instantsearch.production.min.js
|
344
|
-
quicklink:
|
345
|
-
src: bytedance:quicklink/2.2.0/quicklink.umd.min.js
|
346
|
-
fancybox:
|
347
|
-
src: bytedance:??jquery/3.5.1/jquery.min.js,fancybox/3.5.7/jquery.fancybox.min.js,justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js
|
348
|
-
async: true
|
349
|
-
copy_tex:
|
350
|
-
src: bytedance:KaTeX/0.15.2/contrib/copy-tex.min.js
|
351
|
-
async: true
|
352
|
-
css:
|
353
|
-
katex:
|
354
|
-
src: npm:katex@0.16.7/dist/katex.min.css
|
355
|
-
comment:
|
356
|
-
src: css/comment.css
|
357
|
-
fancybox:
|
358
|
-
src: combine:npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css,npm/justifiedGallery@3.8.1/dist/css/justifiedGallery.min.css
|
359
|
-
vendorsList:
|
360
|
-
js:
|
361
|
-
- pace
|
362
|
-
- algolia
|
363
|
-
- instantsearch
|
364
|
-
- quicklink
|
365
|
-
- fancybox
|
366
|
-
- copy_tex
|
367
|
-
|
368
351
|
vendors:
|
352
|
+
cdns:
|
353
|
+
npm_webcache: https://npm.webcache.cn
|
354
|
+
bytedance: https://lf9-cdn-tos.bytecdntp.com/cdn/expire-6-M
|
355
|
+
cdnjs_webcache: https://cdnjs.webstatic.cn/ajax/libs
|
356
|
+
cdnjs: https://cdnjs.cloudflare.com/ajax/libs
|
357
|
+
unpkg: https://unpkg.com
|
358
|
+
js:
|
359
|
+
pace: bytedance|pace/1.2.4/pace.min.js
|
360
|
+
# pjax: npm_webcache|theme-shokax-pjax@0.0.3/pjax.shokax.min.js
|
361
|
+
# anime: npm_webcache|theme-shokax-anime@0.0.6/anime.shokax.min.js
|
362
|
+
# lozad: npm_webcache|lozad@1.16.0/dist/lozad.min.js
|
363
|
+
algolia: bytedance|algoliasearch/4.12.1/algoliasearch-lite.umd.min.js
|
364
|
+
instantsearch: bytedance|instantsearch.js/4.39.0/instantsearch.production.min.js
|
365
|
+
quicklink: npm_webcache|quicklink@2.3.0/dist/quicklink.umd.js
|
366
|
+
# mouse_firework: npm_webcache|mouse-firework@0.0.4/dist/index.umd.js
|
367
|
+
async_js:
|
368
|
+
fancybox: bytedance|??jquery/3.5.1/jquery.min.js,fancybox/3.5.7/jquery.fancybox.min.js,justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js
|
369
|
+
copy_tex: npm_webcache|katex@0.16.7/contrib/copy-tex.min.js
|
369
370
|
css:
|
370
|
-
katex:
|
371
|
+
katex: npm_webcache|katex@0.16.7/dist/katex.min.css
|
371
372
|
comment: css/comment.css
|
372
|
-
fancybox:
|
373
|
-
|
374
|
-
js:
|
375
|
-
pace: npm/pace-js@1.0.2/pace.min.js # ok
|
376
|
-
fetch: npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js # ok
|
377
|
-
algolia: npm/algoliasearch@4/dist/algoliasearch-lite.umd.js # ok
|
378
|
-
instantsearch: npm/instantsearch.js@4/dist/instantsearch.production.min.js # ok
|
379
|
-
quicklink: npm/quicklink@2/dist/quicklink.umd.js # ok
|
380
|
-
fancybox: combine/npm/jquery@3.5.1/dist/jquery.min.js,npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js,npm/justifiedGallery@3.8.1/dist/js/jquery.justifiedGallery.min.js # notok
|
381
|
-
# valine: gh/amehime/MiniValine@4.2.2-beta10/dist/MiniValine.min.js # TODO 弃用
|
382
|
-
copy_tex: npm/katex@0.16.7/dist/contrib/copy-tex.min.js # ok
|
383
|
-
chart: npm/frappe-charts@1.5.0/dist/frappe-charts.min.iife.min.js # ok
|
384
|
-
|
373
|
+
fancybox: npm_webcache|@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css
|
374
|
+
justifiedGallery: npm_webcache|justifiedGallery@3.8.1/dist/css/justifiedGallery.min.css
|
@@ -19,7 +19,7 @@ mixin CommentRender()
|
|
19
19
|
- var meta = JSON.stringify(theme.waline.meta)
|
20
20
|
- var requiredMeta = JSON.stringify(theme.waline.requiredMeta)
|
21
21
|
script(type="module" data-pjax).
|
22
|
-
import { init } from 'https://
|
22
|
+
import { init } from 'https://npm.webcache.cn/@waline/client@v2/dist/waline.mjs';
|
23
23
|
|
24
24
|
setTimeout(function () {
|
25
25
|
init({
|
@@ -43,17 +43,12 @@ if fontConfig
|
|
43
43
|
!= _vendor_font()
|
44
44
|
!= _css('app.css')
|
45
45
|
|
46
|
-
- var debugVue = theme?.experiments?.debug
|
47
|
-
if debugVue
|
48
|
-
script(src="https://cdn.staticfile.org/vue/3.2.45/vue.global.js")
|
49
|
-
else
|
50
|
-
script(src="https://cdn.staticfile.org/vue/3.2.45/vue.global.prod.js")
|
51
46
|
include pwa.pug
|
52
47
|
if tk
|
53
48
|
!= _css("twikoo.css")
|
54
|
-
script(src=theme.twikoo.link)
|
49
|
+
script(src=theme.twikoo.link )
|
55
50
|
else if wl
|
56
|
-
link(rel="stylesheet" href="https://
|
51
|
+
link(rel="stylesheet" href="https://npm.webcache.cn/@waline/client@v2/dist/waline.css" media="none" onload="this.media='all'")
|
57
52
|
|
58
53
|
- var qw = theme?.qweather?.enable
|
59
54
|
if qw
|
@@ -92,7 +92,6 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
92
92
|
empty: "!{__('search.empty')}",
|
93
93
|
stats: "!{__('search.stats')}"
|
94
94
|
},
|
95
|
-
chart: #{!!page.chart},
|
96
95
|
copy_tex: #{!!page.math},
|
97
96
|
katex: #{!!page.math},
|
98
97
|
mermaid: #{!!page.mermaid},
|
@@ -119,11 +118,12 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
119
118
|
if theme.polyfill.enable
|
120
119
|
script(src=`https://polyfill.io/v3/polyfill.min.js?features=${theme.polyfill.features}`)
|
121
120
|
|
122
|
-
|
123
|
-
|
124
|
-
|
121
|
+
- debugVue = theme?.experiments?.debug
|
122
|
+
if debugVue
|
123
|
+
script(src="https://cdn.bootcdn.net/ajax/libs/vue/3.3.4/vue.global.min.js")
|
125
124
|
else
|
126
|
-
|
125
|
+
script(src="https://cdn.bootcdn.net/ajax/libs/vue/3.3.4/vue.global.prod.min.js")
|
126
|
+
!= vendor_js()
|
127
127
|
!= _js('app.js')
|
128
128
|
!= partial('_partials/third-party/baidu-analytics.pug', {}, {cache: true})
|
129
129
|
!= partial('_partials/third-party/clarity.pug', {}, {cache: true})
|
package/package.json
CHANGED
@@ -1,49 +1,44 @@
|
|
1
1
|
{
|
2
2
|
"name": "hexo-theme-shokax",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.12",
|
4
4
|
"description": "a hexo theme based on shoka",
|
5
5
|
"main": "index.js",
|
6
6
|
"repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX",
|
7
7
|
"author": "zkz098",
|
8
8
|
"license": "AGPL-3.0-or-later",
|
9
9
|
"scripts": {
|
10
|
-
"test": "
|
11
|
-
"build": "
|
10
|
+
"test": "tsc --build --verbose",
|
11
|
+
"build": "cd ./source && tsc --build --verbose && cd ../scripts && tsc --build --verbose"
|
12
12
|
},
|
13
13
|
"devDependencies": {
|
14
|
-
"@types/chai": "^4.3.11",
|
15
14
|
"@types/fancybox": "^3.5.6",
|
16
|
-
"@types/hexo": "^3.8.12",
|
17
15
|
"@types/jquery": "^3.5.29",
|
18
16
|
"@types/js-yaml": "^4.0.9",
|
19
17
|
"@types/lozad": "^1.16.4",
|
20
|
-
"@types/
|
21
|
-
"@
|
22
|
-
"@typescript-eslint/
|
23
|
-
"@typescript-eslint/parser": "^6.17.0",
|
24
|
-
"chai": "^4.3.10",
|
18
|
+
"@types/node": "^20.11.5",
|
19
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
20
|
+
"@typescript-eslint/parser": "^6.19.0",
|
25
21
|
"eslint": "^8.56.0",
|
26
22
|
"eslint-config-standard": "~17",
|
27
|
-
"eslint-plugin-chai-friendly": "^0.7.2",
|
28
23
|
"eslint-plugin-import": "^2.29.1",
|
29
|
-
"eslint-plugin-n": "^16.6.
|
24
|
+
"eslint-plugin-n": "^16.6.2",
|
30
25
|
"eslint-plugin-promise": "^6.1.1",
|
31
|
-
"eslint-plugin-vue": "^9.
|
32
|
-
"
|
33
|
-
"hexo-util": "^3.1.0",
|
34
|
-
"instantsearch.js": "^4.63.0",
|
35
|
-
"jsdom": "^23.1.0",
|
36
|
-
"mocha": "^10.2.0",
|
26
|
+
"eslint-plugin-vue": "^9.20.1",
|
27
|
+
"instantsearch.js": "^4.64.0",
|
37
28
|
"typescript": "^5.3.3",
|
38
|
-
"vue": "^3.4.
|
29
|
+
"vue": "^3.4.15"
|
39
30
|
},
|
40
31
|
"dependencies": {
|
41
32
|
"esbuild": "^0.19.11",
|
42
|
-
"hexo": "
|
33
|
+
"hexo": "7.0.0",
|
34
|
+
"hexo-fs": "^4.1.1",
|
35
|
+
"hexo-pagination": "^3.0.0",
|
36
|
+
"hexo-util": "^3.2.0",
|
43
37
|
"js-yaml": "^4.1.0",
|
44
38
|
"lozad": "^1.16.0",
|
39
|
+
"mouse-firework": "^0.0.4",
|
45
40
|
"theme-shokax-anime": "^0.0.6",
|
46
|
-
"theme-shokax-pjax": "^0.0.
|
41
|
+
"theme-shokax-pjax": "^0.0.3"
|
47
42
|
},
|
48
43
|
"engines": {
|
49
44
|
"node": ">=18.0.0"
|
@@ -1,15 +1,19 @@
|
|
1
|
+
// @ts-ignore
|
1
2
|
const fmtNum = (num) => {
|
2
3
|
return num < 10 ? '0' + num : num;
|
3
4
|
};
|
4
5
|
hexo.extend.filter.register('template_locals', (locals) => {
|
5
6
|
const { config } = hexo;
|
6
7
|
const { __, theme } = locals;
|
8
|
+
// @ts-ignore
|
7
9
|
const { i18n } = hexo.theme;
|
8
10
|
const pangu = {
|
9
11
|
spacing: (data) => {
|
10
12
|
return data;
|
11
13
|
}
|
12
14
|
};
|
15
|
+
// Language & Config
|
16
|
+
// 根据主题配置的 Creative Commons 许可证生成链接
|
13
17
|
locals.alternate = theme.alternate;
|
14
18
|
locals.title = pangu.spacing(__('title') !== 'title' ? __('title') : config.title);
|
15
19
|
locals.subtitle = pangu.spacing(__('subtitle') !== 'subtitle' ? __('subtitle') : config.subtitle);
|
@@ -19,6 +23,8 @@ hexo.extend.filter.register('template_locals', (locals) => {
|
|
19
23
|
locals.languages.splice(locals.languages.indexOf('default'), 1);
|
20
24
|
locals.page.lang = locals.page.lang || locals.page.language;
|
21
25
|
locals.hostname = new URL(config.url).hostname || config.url;
|
26
|
+
// Creative Commons
|
27
|
+
// 根据主题配置的 Creative Commons 许可证生成链接
|
22
28
|
if (theme.creative_commons.license === 'zero') {
|
23
29
|
locals.ccURL = 'https://creativecommons.org/' + 'publicdomain/zero/1.0/' + (theme.creative_commons.language || '');
|
24
30
|
}
|
package/scripts/filters/post.js
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
+
/* global hexo */
|
1
2
|
'use strict';
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
5
|
};
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
7
|
+
// @ts-ignore
|
6
8
|
const hexo_pagination_1 = __importDefault(require("hexo-pagination"));
|
9
|
+
// @ts-ignore
|
7
10
|
const fmtNum = num => {
|
8
11
|
return num < 10 ? '0' + num : num;
|
9
12
|
};
|
10
13
|
if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
|
14
|
+
// when archive disabled pagination, per_page should be 0.
|
11
15
|
let per_page;
|
12
16
|
if (hexo.config.archive === 1) {
|
13
17
|
per_page = 0;
|
@@ -28,6 +32,7 @@ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
|
|
28
32
|
const config = hexo.config;
|
29
33
|
let archiveDir = config.archive_dir;
|
30
34
|
const paginationDir = config.pagination_dir || 'page';
|
35
|
+
// @ts-ignore
|
31
36
|
const allPosts = locals.posts.sort(config.archive_generator.order_by || '-date');
|
32
37
|
const perPage = config.archive_generator.per_page;
|
33
38
|
let result = [];
|
@@ -49,11 +54,14 @@ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
|
|
49
54
|
if (!config.archive_generator.yearly)
|
50
55
|
return result;
|
51
56
|
const posts = {};
|
57
|
+
// 按日期对文章进行分类
|
52
58
|
allPosts.forEach(post => {
|
53
59
|
const date = post.date;
|
54
60
|
const year = date.year();
|
55
|
-
const month = date.month() + 1;
|
61
|
+
const month = date.month() + 1; // month is started from 0
|
56
62
|
if (!Object.prototype.hasOwnProperty.call(posts, year)) {
|
63
|
+
// 13个数组. 第一个数组是给这一年的文章准备的
|
64
|
+
// 其他则是各个月份的文章
|
57
65
|
posts[year] = [
|
58
66
|
[],
|
59
67
|
[],
|
@@ -72,6 +80,7 @@ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
|
|
72
80
|
}
|
73
81
|
posts[year][0].push(post);
|
74
82
|
posts[year][month].push(post);
|
83
|
+
// Daily
|
75
84
|
if (config.archive_generator.daily) {
|
76
85
|
const day = date.date();
|
77
86
|
if (!Object.prototype.hasOwnProperty.call(posts[year][month], 'day')) {
|
@@ -83,6 +92,7 @@ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
|
|
83
92
|
const Query = this.model('Post').Query;
|
84
93
|
const years = Object.keys(posts);
|
85
94
|
let year, data, month, monthData, url;
|
95
|
+
// Yearly
|
86
96
|
for (let i = 0, len = years.length; i < len; i++) {
|
87
97
|
year = +years[i];
|
88
98
|
data = posts[year];
|
@@ -92,6 +102,7 @@ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
|
|
92
102
|
generate(url, new Query(data[0]), { year });
|
93
103
|
if (!config.archive_generator.monthly && !config.archive_generator.daily)
|
94
104
|
continue;
|
105
|
+
// Monthly
|
95
106
|
for (month = 1; month <= 12; month++) {
|
96
107
|
monthData = data[month];
|
97
108
|
if (!monthData.length)
|
@@ -104,6 +115,7 @@ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
|
|
104
115
|
}
|
105
116
|
if (!config.archive_generator.daily)
|
106
117
|
continue;
|
118
|
+
// Daily
|
107
119
|
for (let day = 1; day <= 31; day++) {
|
108
120
|
const dayData = monthData.day[day];
|
109
121
|
if (!dayData || !dayData.length)
|
@@ -3,19 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
/* global hexo */
|
6
7
|
const hexo_util_1 = require("hexo-util");
|
7
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
8
9
|
const path_1 = __importDefault(require("path"));
|
9
10
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
10
11
|
hexo.extend.filter.register('before_generate', () => {
|
11
12
|
if (hexo.config.theme_config) {
|
13
|
+
// @ts-ignore
|
12
14
|
hexo.theme.config = (0, hexo_util_1.deepMerge)(hexo.theme.config, hexo.config.theme_config);
|
13
15
|
}
|
14
16
|
const data = hexo.locals.get('data');
|
15
17
|
if (data.languages) {
|
18
|
+
// @ts-ignore
|
16
19
|
const { i18n } = hexo.theme;
|
17
20
|
const mergeLang = lang => {
|
18
|
-
if (data.languages[lang]) {
|
21
|
+
if (data.languages[lang]) { // @ts-ignore
|
19
22
|
i18n.set(lang, (0, hexo_util_1.deepMerge)(i18n.get([lang]), data.languages[lang]));
|
20
23
|
}
|
21
24
|
};
|
@@ -1,11 +1,36 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
27
|
};
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
/* global hexo */
|
6
30
|
const package_json_1 = __importDefault(require("../../package.json"));
|
7
|
-
const fs = require("hexo-fs");
|
8
|
-
const
|
31
|
+
const fs = __importStar(require("hexo-fs"));
|
32
|
+
const esbuild_1 = require("esbuild");
|
33
|
+
const utils_1 = require("../utils");
|
9
34
|
hexo.extend.generator.register('script', function (locals) {
|
10
35
|
const config = hexo.config;
|
11
36
|
const theme = hexo.theme.config;
|
@@ -22,14 +47,14 @@ hexo.extend.generator.register('script', function (locals) {
|
|
22
47
|
auto_dark: theme.auto_dark,
|
23
48
|
auto_scroll: theme.auto_scroll,
|
24
49
|
js: {
|
25
|
-
|
26
|
-
|
27
|
-
fancybox: theme.vendors.js.fancybox
|
50
|
+
copy_tex: (0, utils_1.getVendorLink)(hexo, theme.vendors.async_js.copy_tex),
|
51
|
+
fancybox: (0, utils_1.getVendorLink)(hexo, theme.vendors.async_js.fancybox)
|
28
52
|
},
|
29
53
|
css: {
|
30
|
-
katex: theme.vendors.css.katex,
|
54
|
+
katex: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.katex),
|
31
55
|
mermaid: theme.css + '/mermaid.css',
|
32
|
-
fancybox: theme.vendors.css.fancybox
|
56
|
+
fancybox: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.fancybox),
|
57
|
+
justifiedGallery: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.justifiedGallery)
|
33
58
|
},
|
34
59
|
loader: theme.loader,
|
35
60
|
search: null,
|
@@ -45,8 +70,8 @@ hexo.extend.generator.register('script', function (locals) {
|
|
45
70
|
disableVL: theme.disableVL,
|
46
71
|
noPlayer: theme.experiments?.noPlayer,
|
47
72
|
audio: undefined,
|
48
|
-
fireworks: (theme.fireworks && theme.fireworks.enable)
|
49
|
-
?
|
73
|
+
fireworks: (theme.fireworks && theme.fireworks.enable && theme.fireworks.options)
|
74
|
+
? theme.fireworks.options
|
50
75
|
: undefined
|
51
76
|
};
|
52
77
|
if (config?.algolia) {
|
@@ -69,12 +94,13 @@ hexo.extend.generator.register('script', function (locals) {
|
|
69
94
|
enterPoint = 'node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.js';
|
70
95
|
}
|
71
96
|
text = 'const CONFIG = ' + JSON.stringify(siteConfig) + ';';
|
72
|
-
|
97
|
+
(0, esbuild_1.buildSync)({
|
73
98
|
entryPoints: [enterPoint],
|
74
99
|
bundle: true,
|
75
100
|
outfile: 'shokax_temp.js',
|
76
101
|
platform: 'browser',
|
77
|
-
|
102
|
+
format: 'iife',
|
103
|
+
target: ['es2022'],
|
78
104
|
minify: true
|
79
105
|
});
|
80
106
|
text += fs.readFileSync('shokax_temp.js');
|
package/scripts/helpers/asset.js
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
"use strict";
|
2
|
+
/* global hexo */
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
5
|
};
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
7
|
const package_json_1 = __importDefault(require("../../package.json"));
|
7
8
|
const hexo_util_1 = require("hexo-util");
|
9
|
+
const utils_1 = require("../utils");
|
8
10
|
hexo.extend.helper.register('_new_comments', function (mode) {
|
9
11
|
const root = this.config.url.replace(/^(https?:\/\/)?[^\/]*/, '');
|
10
12
|
if (mode === 'twikoo') {
|
@@ -44,14 +46,14 @@ hexo.extend.helper.register('_new_comments', function (mode) {
|
|
44
46
|
return `
|
45
47
|
<script type="module" data-pjax>
|
46
48
|
let items = []
|
47
|
-
import { RecentComments } from 'https://
|
49
|
+
import { RecentComments } from 'https://npm.webcache.cn/@waline/client@v2/dist/waline.mjs'
|
48
50
|
RecentComments({
|
49
51
|
serverURL: '${hexo.theme.config.waline.serverURL.replace(/\/+$/, '')}',
|
50
52
|
count: 10,
|
51
53
|
}).then(({ comments }) => {
|
52
54
|
comments.forEach(function (item) {
|
53
55
|
let cText = (item.orig.length > 50) ? item.orig.substring(0,50)+'...' : item.orig
|
54
|
-
item.url = item.url
|
56
|
+
item.url = item.url.startsWith('/') ? item.url : '/' + item.url;
|
55
57
|
const siteLink = item.url + "#" + item.objectId
|
56
58
|
items.push({
|
57
59
|
href: siteLink,
|
@@ -95,6 +97,7 @@ hexo.extend.helper.register('_vendor_font', () => {
|
|
95
97
|
const fontSubset = '&subset=latin,latin-ext';
|
96
98
|
const fontStyles = ':300,300italic,400,400italic,700,700italic';
|
97
99
|
const fontHost = 'https://fonts.googleapis.com';
|
100
|
+
// Get a font list from config
|
98
101
|
let fontFamilies = ['global', 'logo', 'title', 'headings', 'posts', 'codes'].map(item => {
|
99
102
|
if (config[item] && config[item].family && config[item].external) {
|
100
103
|
return config[item].family + fontStyles;
|
@@ -102,8 +105,11 @@ hexo.extend.helper.register('_vendor_font', () => {
|
|
102
105
|
return '';
|
103
106
|
});
|
104
107
|
fontFamilies = fontFamilies.filter(item => item !== '');
|
108
|
+
// @ts-ignore
|
105
109
|
fontFamilies = [...new Set(fontFamilies)];
|
110
|
+
// @ts-ignore
|
106
111
|
fontFamilies = fontFamilies.join('|');
|
112
|
+
// Merge extra parameters to the final processed font string
|
107
113
|
return fontFamilies
|
108
114
|
? (0, hexo_util_1.htmlTag)('link', {
|
109
115
|
rel: 'stylesheet',
|
@@ -111,21 +117,6 @@ hexo.extend.helper.register('_vendor_font', () => {
|
|
111
117
|
})
|
112
118
|
: '';
|
113
119
|
});
|
114
|
-
hexo.extend.helper.register('_vendor_js', () => {
|
115
|
-
const config = hexo.theme.config.vendors.js;
|
116
|
-
if (!config)
|
117
|
-
return '';
|
118
|
-
let vendorJs = ['pace', 'pjax', 'fetch', 'anime', 'algolia', 'instantsearch', 'lazyload', 'quicklink'].map(item => {
|
119
|
-
if (config[item]) {
|
120
|
-
return config[item];
|
121
|
-
}
|
122
|
-
return '';
|
123
|
-
});
|
124
|
-
vendorJs = vendorJs.filter(item => item !== '');
|
125
|
-
vendorJs = [...new Set(vendorJs)];
|
126
|
-
vendorJs = vendorJs.join(',');
|
127
|
-
return vendorJs ? (0, hexo_util_1.htmlTag)('script', { src: `https://cdn.jsdelivr.net/combine/${vendorJs}` }, '') : '';
|
128
|
-
});
|
129
120
|
hexo.extend.helper.register('_css', function (...urls) {
|
130
121
|
const { statics, css } = hexo.theme.config;
|
131
122
|
return urls.map(url => (0, hexo_util_1.htmlTag)('link', {
|
@@ -137,61 +128,16 @@ hexo.extend.helper.register('_js', function (...urls) {
|
|
137
128
|
const { statics, js } = hexo.theme.config;
|
138
129
|
return urls.map(url => (0, hexo_util_1.htmlTag)('script', { src: hexo_util_1.url_for.call(this, `${statics}${js}/${url}?v=${package_json_1.default.version}`) }, '')).join('');
|
139
130
|
});
|
140
|
-
hexo.extend.helper.register('
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
const config = hexo.theme.config.advVendors.js[js_name];
|
146
|
-
const themeConfig = hexo.theme.config;
|
147
|
-
const src = config.src;
|
148
|
-
const publicCdns = {
|
149
|
-
npm: srcHelpers(themeConfig.advVendors.npm),
|
150
|
-
gh: srcHelpers(themeConfig.advVendors.github),
|
151
|
-
combine: srcHelpers(themeConfig.advVendors.combine),
|
152
|
-
bytedance: 'https://lf9-cdn-tos.bytecdntp.com/cdn/expire-6-M/',
|
153
|
-
baomitu: 'https://lib.baomitu.com/'
|
154
|
-
};
|
155
|
-
let result;
|
156
|
-
if (src.startsWith('http')) {
|
157
|
-
result = src;
|
158
|
-
}
|
159
|
-
else if (src.startsWith('combine:')) {
|
160
|
-
hexo.log.info('The combine feature is not recommended!');
|
161
|
-
result = publicCdns.combine + src;
|
162
|
-
}
|
163
|
-
else if (src.startsWith('npm:')) {
|
164
|
-
result = publicCdns.npm + src.substring(4);
|
165
|
-
}
|
166
|
-
else if (src.startsWith('gh:')) {
|
167
|
-
result = publicCdns.gh + src.substring(3);
|
168
|
-
}
|
169
|
-
else if (src.startsWith('bytedance:')) {
|
170
|
-
result = publicCdns.bytedance + src.substring(10);
|
171
|
-
}
|
172
|
-
else if (src.startsWith('baomitu:')) {
|
173
|
-
result = publicCdns.baomitu + src.substring(8);
|
174
|
-
}
|
175
|
-
else {
|
176
|
-
result = '/' + src;
|
177
|
-
}
|
178
|
-
const attr = {
|
179
|
-
src: result,
|
180
|
-
integrity: undefined,
|
181
|
-
async: undefined
|
182
|
-
};
|
183
|
-
if (config.async)
|
184
|
-
attr.async = 'async';
|
185
|
-
if (config['data-pjax'])
|
186
|
-
attr['data-pjax'] = 'data-pjax';
|
187
|
-
if (config['hash-value'])
|
188
|
-
attr.integrity = config['hash-value'];
|
189
|
-
if (config.deferLoad) {
|
190
|
-
return (0, hexo_util_1.htmlTag)('script', { 'data-pjax': true }, `
|
191
|
-
const script=document.createElement("script");script.src="${result}",script.async=true,document.body.appendChild(script)
|
192
|
-
`);
|
131
|
+
hexo.extend.helper.register('vendor_js', function () {
|
132
|
+
const vendors = hexo.theme.config.vendors;
|
133
|
+
let res = '';
|
134
|
+
for (const jsSync in vendors.js) {
|
135
|
+
res += (0, hexo_util_1.htmlTag)('script', { src: (0, utils_1.getVendorLink)(hexo, vendors.js[jsSync]) }, '');
|
193
136
|
}
|
194
|
-
|
137
|
+
// for (const jsAsync in vendors.async_js) {
|
138
|
+
// res += htmlTag('script', { src: getVendorLink(hexo, vendors.async_js[jsAsync]), async: true }, '')
|
139
|
+
// }
|
140
|
+
return res;
|
195
141
|
});
|
196
142
|
hexo.extend.helper.register('_striptags', function (data) {
|
197
143
|
return (0, hexo_util_1.stripHTML)(data);
|