hexo-theme-shokax 0.4.6-dev2 → 0.4.6-dev3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. package/package.json +1 -1
  2. package/toolbox/lib.mjs +38 -24
  3. package/scripts/filters/locals.js +0 -52
  4. package/scripts/filters/post.js +0 -5
  5. package/scripts/generaters/archive.js +0 -133
  6. package/scripts/generaters/config.js +0 -51
  7. package/scripts/generaters/images.js +0 -23
  8. package/scripts/generaters/index.js +0 -107
  9. package/scripts/generaters/pages.js +0 -15
  10. package/scripts/generaters/script.js +0 -156
  11. package/scripts/helpers/asset.js +0 -73
  12. package/scripts/helpers/engine.js +0 -177
  13. package/scripts/helpers/list_categories.js +0 -80
  14. package/scripts/helpers/summary_ai.js +0 -107
  15. package/scripts/helpers/symbols_count_time.js +0 -69
  16. package/scripts/plugin/check.js +0 -32
  17. package/scripts/plugin/index.js +0 -81
  18. package/scripts/plugin/lib/injects-point.js +0 -20
  19. package/scripts/plugin/lib/injects.js +0 -89
  20. package/scripts/tags/links.js +0 -44
  21. package/scripts/tags/media.js +0 -19
  22. package/scripts/utils.js +0 -13
  23. package/source/js/_app/components/comments.js +0 -59
  24. package/source/js/_app/components/sidebar.js +0 -244
  25. package/source/js/_app/components/tcomments.js +0 -47
  26. package/source/js/_app/globals/handles.js +0 -105
  27. package/source/js/_app/library/loadFile.js +0 -43
  28. package/source/js/_app/library/vue.js +0 -52
  29. package/source/js/_app/page/common.js +0 -45
  30. package/source/js/_app/page/fancybox.js +0 -70
  31. package/source/js/_app/page/post.js +0 -253
  32. package/source/js/_app/page/search.js +0 -111
  33. package/source/js/_app/pjax/domInit.js +0 -80
  34. package/source/js/_app/pjax/refresh.js +0 -137
  35. package/source/js/_app/pjax/siteInit.js +0 -115
  36. package/source/js/_app/player.js +0 -777
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.4.6-dev2",
3
+ "version": "0.4.6-dev3",
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",
package/toolbox/lib.mjs CHANGED
@@ -1,15 +1,29 @@
1
1
  import fs from "fs/promises";
2
- import path from "node:path";
3
- import {promisify} from "node:util";
4
2
  import child_process from "child_process";
3
+ import { dirname, resolve } from 'path';
5
4
 
6
- const execShell = promisify(child_process.exec)
5
+ async function findScaffoldsDir(startPath) {
6
+ let currentPath = resolve(startPath);
7
7
 
8
- let hexoRoot = path.join(import.meta.url, './../../../../').trim()
9
- if (hexoRoot.startsWith('file:/')) {
10
- hexoRoot = hexoRoot.slice(5); // 去除 'file://'
11
- } else if (hexoRoot.startsWith('file:\\')) {
12
- hexoRoot = hexoRoot.slice(8); // 去除 'file:\'
8
+ while (currentPath !== dirname(currentPath)) {
9
+ const scaffoldsPath = resolve(currentPath, 'scaffolds');
10
+
11
+ try {
12
+ const stat = await fs.stat(scaffoldsPath);
13
+ if (stat.isDirectory()) {
14
+ return currentPath;
15
+ }
16
+ } catch (err) {
17
+ // If the error is because the file/directory does not exist, continue to the parent directory
18
+ if (err.code !== 'ENOENT') {
19
+ throw err;
20
+ }
21
+ }
22
+
23
+ currentPath = dirname(currentPath);
24
+ }
25
+
26
+ return null;
13
27
  }
14
28
 
15
29
  async function checkFileAccessible(file) {
@@ -22,7 +36,6 @@ async function checkFileAccessible(file) {
22
36
  }
23
37
 
24
38
  export async function hoistDeps() {
25
- console.log(process.cwd())
26
39
  let pm
27
40
  if (await checkFileAccessible('pnpm-lock.yml') || await checkFileAccessible('pnpm-lock.yaml') || await checkFileAccessible('enable_pnpm')) {
28
41
  pm = "pnpm add"
@@ -31,19 +44,20 @@ export async function hoistDeps() {
31
44
  } else {
32
45
  pm = "npm install"
33
46
  }
34
- try {
35
- // TODO 使用本地 package.json 解析
36
- const res = await (await fetch('https://registry.npmmirror.com/hexo-theme-shokax')).json()
37
- const latestV = res['dist-tags'].latest
38
- const deps = res.versions[latestV].dependencies
39
- const depsList = Object.keys(deps).map(d => `${d}@${deps[d]}`)
40
- child_process.exec(`${pm} ${depsList.join(' ')}`.trim(), {
41
- cwd: hexoRoot
42
- }, async (code, stdout, stderr) => {
43
-
44
- })
45
- } catch (e) {
46
- throw e
47
- // console.log('Skipping hoisting dependencies.')
48
- }
47
+ console.log(`Using ${pm} to hoist dependencies.`)
48
+ // TODO 使用本地 package.json 解析
49
+ const res = await (await fetch('https://registry.npmmirror.com/hexo-theme-shokax')).json()
50
+ const latestV = res['dist-tags'].latest
51
+ const deps = res.versions[latestV].dependencies
52
+ const depsList = Object.keys(deps).map(d => `${d}@${deps[d]}`)
53
+ const hexoRoot = await findScaffoldsDir(process.cwd())
54
+ child_process.exec(`${pm} ${depsList.join(' ')}`.trim(), {
55
+ cwd: hexoRoot
56
+ }, (code, stdout, stderr) => {
57
+ if (stderr) {
58
+ console.error(stderr)
59
+ } else {
60
+ console.log(stdout)
61
+ }
62
+ })
49
63
  }
@@ -1,52 +0,0 @@
1
- // @ts-ignore
2
- const fmtNum = (num) => {
3
- return num < 10 ? '0' + num : num;
4
- };
5
- hexo.extend.filter.register('template_locals', (locals) => {
6
- const { config } = hexo;
7
- const { __, theme } = locals;
8
- // @ts-ignore
9
- const { i18n } = hexo.theme;
10
- const pangu = {
11
- spacing: (data) => {
12
- return data;
13
- }
14
- };
15
- // Language & Config
16
- // 根据主题配置的 Creative Commons 许可证生成链接
17
- locals.alternate = theme.alternate;
18
- locals.title = pangu.spacing(__('title') !== 'title' ? __('title') : config.title);
19
- locals.subtitle = pangu.spacing(__('subtitle') !== 'subtitle' ? __('subtitle') : config.subtitle);
20
- locals.author = __('author') !== 'author' ? __('author') : config.author;
21
- locals.description = pangu.spacing(__('description') !== 'description' ? __('description') : config.description);
22
- locals.languages = [...i18n.languages];
23
- locals.languages.splice(locals.languages.indexOf('default'), 1);
24
- locals.page.lang = locals.page.lang || locals.page.language;
25
- locals.hostname = new URL(config.url).hostname || config.url;
26
- // Creative Commons
27
- // 根据主题配置的 Creative Commons 许可证生成链接
28
- if (theme.creative_commons.license === 'zero') {
29
- locals.ccURL = 'https://creativecommons.org/' + 'publicdomain/zero/1.0/' + (theme.creative_commons.language || '');
30
- }
31
- else {
32
- locals.ccURL = 'https://creativecommons.org/' + 'licenses/' + theme.creative_commons.license + '/4.0/' + (theme.creative_commons.language || '');
33
- }
34
- if (locals.page.title) {
35
- locals.page.title = pangu.spacing(locals.page.title);
36
- }
37
- locals.page.lastcat = '';
38
- if (locals.page.categories) {
39
- locals.page.categories.map((cat) => {
40
- if (cat.name) {
41
- cat.name = locals.page.lastcat = pangu.spacing(cat.name);
42
- }
43
- return cat;
44
- });
45
- }
46
- if (locals.page.category) {
47
- locals.page.title = pangu.spacing(locals.page.category);
48
- }
49
- if (locals.page.month) {
50
- locals.page.month = fmtNum(locals.page.month);
51
- }
52
- });
@@ -1,5 +0,0 @@
1
- /* global hexo */
2
- hexo.extend.filter.register('after_post_render', (data) => {
3
- // 使用正则表达式将<img>标签的src属性替换为data-src属性
4
- data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 loading="lazy" data-src=');
5
- }, 0);
@@ -1,133 +0,0 @@
1
- /* global hexo */
2
- 'use strict';
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- // @ts-ignore
8
- const hexo_pagination_1 = __importDefault(require("hexo-pagination"));
9
- // @ts-ignore
10
- const fmtNum = (num) => {
11
- return num < 10 ? '0' + num : num;
12
- };
13
- if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
14
- // when archive disabled pagination, per_page should be 0.
15
- let per_page;
16
- if (hexo.config.archive === 1) {
17
- per_page = 0;
18
- }
19
- else if (typeof hexo.config.per_page === 'undefined') {
20
- per_page = 10;
21
- }
22
- else {
23
- per_page = hexo.config.per_page;
24
- }
25
- hexo.config.archive_generator = Object.assign({
26
- per_page,
27
- yearly: true,
28
- monthly: true,
29
- daily: false
30
- }, hexo.config.archive_generator);
31
- hexo.extend.generator.register('archive', function (locals) {
32
- const config = hexo.config;
33
- let archiveDir = config.archive_dir;
34
- const paginationDir = config.pagination_dir || 'page';
35
- // @ts-ignore
36
- const allPosts = locals.posts.sort(config.archive_generator.order_by || '-date');
37
- const perPage = config.archive_generator.per_page;
38
- let result = [];
39
- if (!allPosts.length)
40
- return;
41
- if (archiveDir[archiveDir.length - 1] !== '/')
42
- archiveDir += '/';
43
- function generate(path, posts, options) {
44
- options = options || {};
45
- options.archive = true;
46
- result = result.concat((0, hexo_pagination_1.default)(path, posts, {
47
- perPage: path === archiveDir ? 0 : perPage,
48
- layout: ['archive', 'index'],
49
- format: paginationDir + '/%d/',
50
- data: options
51
- }));
52
- }
53
- generate(archiveDir, allPosts);
54
- if (!config.archive_generator.yearly)
55
- return result;
56
- const posts = {};
57
- // 按日期对文章进行分类
58
- allPosts.forEach(post => {
59
- const date = post.date;
60
- const year = date.year();
61
- const month = date.month() + 1; // month is started from 0
62
- if (!Object.prototype.hasOwnProperty.call(posts, year)) {
63
- // 13个数组. 第一个数组是给这一年的文章准备的
64
- // 其他则是各个月份的文章
65
- posts[year] = [
66
- [],
67
- [],
68
- [],
69
- [],
70
- [],
71
- [],
72
- [],
73
- [],
74
- [],
75
- [],
76
- [],
77
- [],
78
- []
79
- ];
80
- }
81
- posts[year][0].push(post);
82
- posts[year][month].push(post);
83
- // Daily
84
- if (config.archive_generator.daily) {
85
- const day = date.date();
86
- if (!Object.prototype.hasOwnProperty.call(posts[year][month], 'day')) {
87
- posts[year][month].day = {};
88
- }
89
- (posts[year][month].day[day] || (posts[year][month].day[day] = [])).push(post);
90
- }
91
- });
92
- const Query = this.model('Post').Query;
93
- const years = Object.keys(posts);
94
- let year, data, month, monthData, url;
95
- // Yearly
96
- for (let i = 0, len = years.length; i < len; i++) {
97
- year = +years[i];
98
- data = posts[year];
99
- url = archiveDir + year + '/';
100
- if (!data[0].length)
101
- continue;
102
- generate(url, new Query(data[0]), { year });
103
- if (!config.archive_generator.monthly && !config.archive_generator.daily)
104
- continue;
105
- // Monthly
106
- for (month = 1; month <= 12; month++) {
107
- monthData = data[month];
108
- if (!monthData.length)
109
- continue;
110
- if (config.archive_generator.monthly) {
111
- generate(url + fmtNum(month) + '/', new Query(monthData), {
112
- year,
113
- month
114
- });
115
- }
116
- if (!config.archive_generator.daily)
117
- continue;
118
- // Daily
119
- for (let day = 1; day <= 31; day++) {
120
- const dayData = monthData.day[day];
121
- if (!dayData || !dayData.length)
122
- continue;
123
- generate(url + fmtNum(month) + '/' + fmtNum(day) + '/', new Query(dayData), {
124
- year,
125
- month,
126
- day
127
- });
128
- }
129
- }
130
- }
131
- return result;
132
- });
133
- }
@@ -1,51 +0,0 @@
1
- 'use strict';
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /* global hexo */
7
- const hexo_util_1 = require("hexo-util");
8
- const node_fs_1 = __importDefault(require("node:fs"));
9
- const path_1 = __importDefault(require("path"));
10
- const js_yaml_1 = __importDefault(require("js-yaml"));
11
- hexo.extend.filter.register('before_generate', () => {
12
- if (hexo.config.theme_config) {
13
- // @ts-ignore
14
- hexo.theme.config = (0, hexo_util_1.deepMerge)(hexo.theme.config, hexo.config.theme_config);
15
- }
16
- const data = hexo.locals.get('data');
17
- if (data.languages) {
18
- // @ts-ignore
19
- const { i18n } = hexo.theme;
20
- const mergeLang = lang => {
21
- if (data.languages[lang]) { // @ts-ignore
22
- i18n.set(lang, (0, hexo_util_1.deepMerge)(i18n.get([lang]), data.languages[lang]));
23
- }
24
- };
25
- for (const lang of ['en', 'ja', 'zh-CN', 'zh-HK', 'zh-TW']) {
26
- mergeLang(lang);
27
- }
28
- }
29
- hexo.theme.config.style = {};
30
- for (const style of ['iconfont', 'colors', 'custom']) {
31
- const custom_file = 'source/_data/' + style + '.styl';
32
- if (node_fs_1.default.existsSync(custom_file)) {
33
- hexo.theme.config.style[style] = path_1.default.resolve(hexo.base_dir, custom_file);
34
- }
35
- }
36
- if (data.images && data.images.length > 0) {
37
- hexo.theme.config.image_list = data.images;
38
- }
39
- else {
40
- hexo.theme.config.image_list = js_yaml_1.default.load(node_fs_1.default.readFileSync(path_1.default.join(__dirname, '../../_images.yml'), { encoding: 'utf-8' }));
41
- }
42
- if (data.images_index && data.images_index.length > 0) {
43
- hexo.theme.config.index_images = data.images_index;
44
- }
45
- else if (node_fs_1.default.existsSync(path_1.default.join(__dirname, '../../_images_index.yml'))) {
46
- hexo.theme.config.index_images = js_yaml_1.default.load(node_fs_1.default.readFileSync(path_1.default.join(__dirname, '../../_images_index.yml'), { encoding: 'utf-8' }));
47
- }
48
- else {
49
- hexo.theme.config.index_images = data.index_images || [];
50
- }
51
- });
@@ -1,23 +0,0 @@
1
- /* global hexo */
2
- 'use strict';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- // @ts-ignore
5
- const fs = require("hexo-fs");
6
- hexo.extend.generator.register('images', function (locals) {
7
- const theme = hexo.theme.config;
8
- const dir = 'source/_data/' + theme.assets + '/';
9
- if (!fs.existsSync(dir)) {
10
- return;
11
- }
12
- const result = [];
13
- const files = fs.listDirSync(dir);
14
- files.forEach((file) => {
15
- result.push({
16
- path: theme.assets + '/' + file,
17
- data: function () {
18
- return fs.createReadStream(dir + file);
19
- }
20
- });
21
- });
22
- return result;
23
- });
@@ -1,107 +0,0 @@
1
- // @ts-nocheck
2
- /* global hexo */
3
- 'use strict';
4
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
6
- };
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- const fs = require("hexo-fs");
9
- const hexo_pagination_1 = __importDefault(require("hexo-pagination"));
10
- hexo.config.index_generator = Object.assign({
11
- per_page: typeof hexo.config.per_page === 'undefined' ? 10 : hexo.config.per_page,
12
- order_by: '-date'
13
- }, hexo.config.index_generator);
14
- hexo.extend.generator.register('index', function (locals) {
15
- const covers = [];
16
- const catlist = [];
17
- let pages;
18
- const config = hexo.config;
19
- const sticky = locals.posts.find({ sticky: true }).sort(config.index_generator.order_by);
20
- const posts = locals.posts.find({ sticky: { $in: [false, undefined] } }).sort(config.index_generator.order_by);
21
- const paginationDir = config.pagination_dir || 'page';
22
- const path = config.index_generator.path || '';
23
- const categories = locals.categories;
24
- const getTopcat = function (cat) {
25
- if (cat.parent) {
26
- const pCat = categories.findOne({ _id: cat.parent });
27
- return getTopcat(pCat);
28
- }
29
- else {
30
- return cat;
31
- }
32
- };
33
- if (categories && categories.length) {
34
- categories.forEach((cat) => {
35
- const cover = `source/_posts/${cat.slug}`;
36
- if (fs.existsSync(cover + '/cover.avif')) {
37
- covers.push({
38
- path: cat.slug + '/cover.avif',
39
- data: function () {
40
- return fs.createReadStream(cover + '/cover.avif');
41
- }
42
- });
43
- }
44
- else if (fs.existsSync(cover + '/cover.webp')) {
45
- covers.push({
46
- path: cat.slug + '/cover.webp',
47
- data: function () {
48
- return fs.createReadStream(cover + '/cover.webp');
49
- }
50
- });
51
- }
52
- else if (fs.existsSync(cover + '/cover.jpg')) {
53
- covers.push({
54
- path: cat.slug + '/cover.jpg',
55
- data: function () {
56
- return fs.createReadStream(cover + '/cover.jpg');
57
- }
58
- });
59
- const topcat = getTopcat(cat);
60
- if (topcat._id !== cat._id) {
61
- cat.top = topcat;
62
- }
63
- const child = categories.find({ parent: cat._id });
64
- let pl = 6;
65
- if (child.length !== 0) {
66
- cat.child = child.length;
67
- cat.subs = child.sort({ name: 1 }).limit(6).toArray();
68
- pl = Math.max(0, pl - child.length);
69
- if (pl > 0) {
70
- cat.subs.push(...cat.posts.sort({ title: 1 })
71
- .filter(function (item, i) { return item.categories.last()._id === cat._id; })
72
- .limit(pl).toArray());
73
- }
74
- }
75
- else {
76
- cat.subs = cat.posts.sort({ title: 1 }).limit(6).toArray();
77
- }
78
- catlist.push(cat);
79
- }
80
- });
81
- }
82
- if (posts.length > 0) {
83
- pages = (0, hexo_pagination_1.default)(path, posts, {
84
- perPage: config.index_generator.per_page,
85
- layout: ['index', 'archive'],
86
- format: paginationDir + '/%d/',
87
- data: {
88
- __index: true,
89
- catlist,
90
- sticky
91
- }
92
- });
93
- }
94
- else {
95
- pages = [{
96
- path,
97
- layout: ['index', 'archive'],
98
- data: {
99
- __index: true,
100
- catlist,
101
- sticky,
102
- current: 1,
103
- }
104
- }];
105
- }
106
- return [...covers, ...pages];
107
- });
@@ -1,15 +0,0 @@
1
- hexo.extend.generator.register('pages', function () {
2
- const config = hexo.config;
3
- return [
4
- {
5
- path: config.category_dir + '/index.html',
6
- data: { type: 'categories' },
7
- layout: 'page'
8
- },
9
- {
10
- path: config.tag_dir + '/index.html',
11
- data: { type: 'tags' },
12
- layout: 'page'
13
- }
14
- ];
15
- });
@@ -1,156 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /* global hexo */
7
- const package_json_1 = __importDefault(require("../../package.json"));
8
- const node_fs_1 = __importDefault(require("node:fs"));
9
- const esbuild_1 = require("esbuild");
10
- const utils_1 = require("../utils");
11
- hexo.extend.generator.register('script', function (locals) {
12
- const config = hexo.config;
13
- const theme = hexo.theme.config;
14
- const siteConfig = {
15
- version: package_json_1.default.version,
16
- hostname: config.url,
17
- root: config.root,
18
- statics: theme.statics,
19
- favicon: {
20
- normal: theme.assets + '/favicon.ico',
21
- hidden: theme.assets + '/failure.ico'
22
- },
23
- darkmode: theme.darkmode,
24
- auto_dark: theme.auto_dark,
25
- auto_scroll: theme.auto_scroll,
26
- js: {
27
- copy_tex: (0, utils_1.getVendorLink)(hexo, theme.vendors.async_js.copy_tex),
28
- fancybox: (0, utils_1.getVendorLink)(hexo, theme.vendors.async_js.fancybox)
29
- },
30
- css: {
31
- katex: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.katex),
32
- mermaid: theme.css + '/mermaid.css',
33
- fancybox: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.fancybox),
34
- justifiedGallery: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.justifiedGallery)
35
- },
36
- loader: theme.loader,
37
- search: null,
38
- outime: {
39
- enable: theme.outime.enable,
40
- days: theme.outime.days
41
- },
42
- quicklink: {
43
- timeout: theme.quicklink.timeout,
44
- priority: theme.quicklink.priority
45
- },
46
- playerAPI: theme.playerAPI,
47
- audio: undefined,
48
- fireworks: (theme.fireworks && theme.fireworks.enable && theme.fireworks.options)
49
- ? theme.fireworks.options
50
- : undefined,
51
- waline: {
52
- serverURL: theme.waline.serverURL,
53
- lang: theme.waline.lang,
54
- locale: theme.waline.locale,
55
- emoji: theme.waline.emoji,
56
- meta: theme.waline.meta,
57
- requiredMeta: theme.waline.requiredMeta,
58
- wordLimit: theme.waline.wordLimit,
59
- pageSize: theme.waline.pageSize,
60
- pageview: theme.waline.pageview
61
- },
62
- twikoo: {
63
- envId: theme.twikoo.envId,
64
- region: theme.twikoo.region
65
- }
66
- };
67
- if (config?.algolia) {
68
- siteConfig.search = {
69
- appID: config.algolia.appId,
70
- apiKey: config.algolia.apiKey,
71
- indexName: config.algolia.indexName,
72
- hits: theme.search.hits
73
- };
74
- }
75
- if (theme?.audio) {
76
- siteConfig.audio = theme.audio;
77
- }
78
- let enterPoint;
79
- if (node_fs_1.default.existsSync('themes/shokaX/source/js/_app/pjax/siteInit.ts')) {
80
- enterPoint = 'themes/shokaX/source/js/_app/pjax/siteInit.ts';
81
- }
82
- else {
83
- enterPoint = 'node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.ts';
84
- }
85
- (0, esbuild_1.buildSync)({
86
- entryPoints: [enterPoint],
87
- bundle: true,
88
- outdir: 'shokaxTemp',
89
- tsconfigRaw: {
90
- compilerOptions: {
91
- target: 'ES2022',
92
- esModuleInterop: true,
93
- module: 'ESNext',
94
- moduleResolution: 'Node',
95
- skipLibCheck: true
96
- }
97
- },
98
- platform: 'browser',
99
- format: 'esm',
100
- target: ['es2022'],
101
- minify: true,
102
- legalComments: 'linked',
103
- mainFields: ['module', 'browser', 'main'],
104
- splitting: true,
105
- define: {
106
- __UNLAZY_LOGGING__: 'false',
107
- __UNLAZY_HASH_DECODING__: theme.modules.unlazyHash ? 'true' : 'false',
108
- __shokax_player__: theme.modules.player ? 'true' : 'false',
109
- __shokax_VL__: theme.modules.visibilityListener ? 'true' : 'false',
110
- __shokax_fireworks__: (theme.fireworks && theme.fireworks.enable && theme.fireworks.options && theme.modules.fireworks) ? 'true' : 'false',
111
- __shokax_search__: config?.algolia ? 'true' : 'false',
112
- __shokax_outime__: theme.outime.enable ? 'true' : 'false',
113
- __shokax_tabs__: theme.modules.tabs ? 'true' : 'false',
114
- __shokax_quiz__: theme.modules.quiz ? 'true' : 'false',
115
- __shokax_fancybox__: theme.modules.fancybox ? 'true' : 'false',
116
- __shokax_waline__: theme.waline.enable ? 'true' : 'false',
117
- __shokax_twikoo__: theme.twikoo.enable ? 'true' : 'false',
118
- shokax_CONFIG: JSON.stringify(siteConfig),
119
- shokax_siteURL: "'" + config.url + "'"
120
- },
121
- alias: {
122
- 'algoliasearch/lite': 'algoliasearch/dist/algoliasearch-lite.esm.browser.js'
123
- }
124
- });
125
- const res = [];
126
- node_fs_1.default.readdirSync('./shokaxTemp').forEach((file) => {
127
- const fileText = node_fs_1.default.readFileSync(`./shokaxTemp/${file}`, { encoding: 'utf-8' });
128
- if (file.endsWith('js')) {
129
- const result = hexo.render.renderSync({ text: fileText, engine: 'js' });
130
- res.push({
131
- path: theme.js + '/' + file,
132
- data: function () {
133
- return result;
134
- }
135
- });
136
- }
137
- else if (file.endsWith('css')) {
138
- const result = hexo.render.renderSync({ text: fileText, engine: 'css' });
139
- res.push({
140
- path: theme.css + '/' + file,
141
- data: function () {
142
- return result;
143
- }
144
- });
145
- }
146
- else {
147
- res.push({
148
- path: theme.js + '/' + file,
149
- data: function () {
150
- return fileText;
151
- }
152
- });
153
- }
154
- });
155
- return res;
156
- });