hexo-theme-shokax 0.4.12 → 0.4.14

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.
@@ -1,107 +1,118 @@
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 };
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
6
15
  };
7
- Object.defineProperty(exports, "__esModule", { value: true });
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var import_hexo_pagination = __toESM(require("hexo-pagination"));
8
25
  const fs = require("hexo-fs");
9
- const hexo_pagination_1 = __importDefault(require("hexo-pagination"));
10
26
  hexo.config.index_generator = Object.assign({
11
- per_page: typeof hexo.config.per_page === 'undefined' ? 10 : hexo.config.per_page,
12
- order_by: '-date'
27
+ per_page: typeof hexo.config.per_page === "undefined" ? 10 : hexo.config.per_page,
28
+ order_by: "-date"
13
29
  }, 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
- });
30
+ hexo.extend.generator.register("index", function(locals) {
31
+ const covers = [];
32
+ const catlist = [];
33
+ let pages;
34
+ const config = hexo.config;
35
+ const sticky = locals.posts.find({ sticky: true }).sort(config.index_generator.order_by);
36
+ const posts = locals.posts.find({ sticky: { $in: [false, void 0] } }).sort(config.index_generator.order_by);
37
+ const paginationDir = config.pagination_dir || "page";
38
+ const path = config.index_generator.path || "";
39
+ const categories = locals.categories;
40
+ const getTopcat = function(cat) {
41
+ if (cat.parent) {
42
+ const pCat = categories.findOne({ _id: cat.parent });
43
+ return getTopcat(pCat);
44
+ } else {
45
+ return cat;
81
46
  }
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
- }
47
+ };
48
+ if (categories && categories.length) {
49
+ categories.forEach((cat) => {
50
+ const cover = `source/_posts/${cat.slug}`;
51
+ if (fs.existsSync(cover + "/cover.avif")) {
52
+ covers.push({
53
+ path: cat.slug + "/cover.avif",
54
+ data: function() {
55
+ return fs.createReadStream(cover + "/cover.avif");
56
+ }
92
57
  });
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];
58
+ } else if (fs.existsSync(cover + "/cover.webp")) {
59
+ covers.push({
60
+ path: cat.slug + "/cover.webp",
61
+ data: function() {
62
+ return fs.createReadStream(cover + "/cover.webp");
63
+ }
64
+ });
65
+ } else if (fs.existsSync(cover + "/cover.jpg")) {
66
+ covers.push({
67
+ path: cat.slug + "/cover.jpg",
68
+ data: function() {
69
+ return fs.createReadStream(cover + "/cover.jpg");
70
+ }
71
+ });
72
+ const topcat = getTopcat(cat);
73
+ if (topcat._id !== cat._id) {
74
+ cat.top = topcat;
75
+ }
76
+ const child = categories.find({ parent: cat._id });
77
+ let pl = 6;
78
+ if (child.length !== 0) {
79
+ cat.child = child.length;
80
+ cat.subs = child.sort({ name: 1 }).limit(6).toArray();
81
+ pl = Math.max(0, pl - child.length);
82
+ if (pl > 0) {
83
+ cat.subs.push(...cat.posts.sort({ title: 1 }).filter(function(item, i) {
84
+ return item.categories.last()._id === cat._id;
85
+ }).limit(pl).toArray());
86
+ }
87
+ } else {
88
+ cat.subs = cat.posts.sort({ title: 1 }).limit(6).toArray();
89
+ }
90
+ catlist.push(cat);
91
+ }
92
+ });
93
+ }
94
+ if (posts.length > 0) {
95
+ pages = (0, import_hexo_pagination.default)(path, posts, {
96
+ perPage: config.index_generator.per_page,
97
+ layout: ["index", "archive"],
98
+ format: paginationDir + "/%d/",
99
+ data: {
100
+ __index: true,
101
+ catlist,
102
+ sticky
103
+ }
104
+ });
105
+ } else {
106
+ pages = [{
107
+ path,
108
+ layout: ["index", "archive"],
109
+ data: {
110
+ __index: true,
111
+ catlist,
112
+ sticky,
113
+ current: 1
114
+ }
115
+ }];
116
+ }
117
+ return [...covers, ...pages];
107
118
  });
@@ -1,15 +1,15 @@
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
- ];
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
15
  });
@@ -1,160 +1,168 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
4
14
  };
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: {
33
- url: theme.css + '/mermaid.css',
34
- local: true,
35
- sri: ''
36
- },
37
- fancybox: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.fancybox),
38
- justifiedGallery: (0, utils_1.getVendorLink)(hexo, theme.vendors.css.justifiedGallery)
39
- },
40
- loader: theme.loader,
41
- search: null,
42
- outime: {
43
- enable: theme.outime.enable,
44
- days: theme.outime.days
45
- },
46
- quicklink: {
47
- timeout: theme.quicklink.timeout,
48
- priority: theme.quicklink.priority
49
- },
50
- playerAPI: theme.playerAPI,
51
- audio: undefined,
52
- fireworks: (theme.fireworks && theme.fireworks.enable && theme.fireworks.options)
53
- ? theme.fireworks.options
54
- : undefined,
55
- waline: {
56
- serverURL: theme.waline.serverURL,
57
- lang: theme.waline.lang,
58
- locale: theme.waline.locale,
59
- emoji: theme.waline.emoji,
60
- meta: theme.waline.meta,
61
- requiredMeta: theme.waline.requiredMeta,
62
- wordLimit: theme.waline.wordLimit,
63
- pageSize: theme.waline.pageSize,
64
- pageview: theme.waline.pageview
65
- },
66
- twikoo: {
67
- envId: theme.twikoo.envId,
68
- region: theme.twikoo.region
69
- }
70
- };
71
- if (config?.algolia) {
72
- siteConfig.search = {
73
- appID: config.algolia.appId,
74
- apiKey: config.algolia.apiKey,
75
- indexName: config.algolia.indexName,
76
- hits: theme.search.hits
77
- };
78
- }
79
- if (theme?.audio) {
80
- siteConfig.audio = theme.audio;
81
- }
82
- let enterPoint;
83
- if (node_fs_1.default.existsSync('themes/shokaX/source/js/_app/pjax/siteInit.ts')) {
84
- enterPoint = 'themes/shokaX/source/js/_app/pjax/siteInit.ts';
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var import_package = __toESM(require("../../package.json"));
24
+ var import_node_fs = __toESM(require("node:fs"));
25
+ var import_esbuild = require("esbuild");
26
+ var import_utils = require("../utils");
27
+ hexo.extend.generator.register("script", function(locals) {
28
+ const config = hexo.config;
29
+ const theme = hexo.theme.config;
30
+ const siteConfig = {
31
+ version: import_package.default.version,
32
+ hostname: config.url,
33
+ root: config.root,
34
+ statics: theme.statics,
35
+ favicon: {
36
+ normal: theme.assets + "/favicon.ico",
37
+ hidden: theme.assets + "/failure.ico"
38
+ },
39
+ darkmode: theme.darkmode,
40
+ auto_dark: theme.auto_dark,
41
+ auto_scroll: theme.auto_scroll,
42
+ js: {
43
+ copy_tex: (0, import_utils.getVendorLink)(hexo, theme.vendors.async_js.copy_tex),
44
+ fancybox: (0, import_utils.getVendorLink)(hexo, theme.vendors.async_js.fancybox)
45
+ },
46
+ css: {
47
+ katex: (0, import_utils.getVendorLink)(hexo, theme.vendors.css.katex),
48
+ mermaid: {
49
+ url: theme.css + "/mermaid.css",
50
+ local: true,
51
+ sri: ""
52
+ },
53
+ fancybox: (0, import_utils.getVendorLink)(hexo, theme.vendors.css.fancybox),
54
+ justifiedGallery: (0, import_utils.getVendorLink)(hexo, theme.vendors.css.justifiedGallery)
55
+ },
56
+ loader: theme.loader,
57
+ search: null,
58
+ outime: {
59
+ enable: theme.outime.enable,
60
+ days: theme.outime.days
61
+ },
62
+ quicklink: {
63
+ timeout: theme.quicklink.timeout,
64
+ priority: theme.quicklink.priority
65
+ },
66
+ playerAPI: theme.playerAPI,
67
+ audio: void 0,
68
+ fireworks: theme.fireworks && theme.fireworks.enable && theme.fireworks.options ? theme.fireworks.options : void 0,
69
+ waline: {
70
+ serverURL: theme.waline.serverURL,
71
+ lang: theme.waline.lang,
72
+ locale: theme.waline.locale,
73
+ emoji: theme.waline.emoji,
74
+ meta: theme.waline.meta,
75
+ requiredMeta: theme.waline.requiredMeta,
76
+ wordLimit: theme.waline.wordLimit,
77
+ pageSize: theme.waline.pageSize,
78
+ pageview: theme.waline.pageview
79
+ },
80
+ twikoo: {
81
+ envId: theme.twikoo.envId,
82
+ region: theme.twikoo.region
85
83
  }
86
- else {
87
- enterPoint = 'node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.ts';
84
+ };
85
+ if (config?.algolia) {
86
+ siteConfig.search = {
87
+ appID: config.algolia.appId,
88
+ apiKey: config.algolia.apiKey,
89
+ indexName: config.algolia.indexName,
90
+ hits: theme.search.hits
91
+ };
92
+ }
93
+ if (theme?.audio) {
94
+ siteConfig.audio = theme.audio;
95
+ }
96
+ let enterPoint;
97
+ if (import_node_fs.default.existsSync("themes/shokaX/source/js/_app/pjax/siteInit.ts")) {
98
+ enterPoint = "themes/shokaX/source/js/_app/pjax/siteInit.ts";
99
+ } else {
100
+ enterPoint = "node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.ts";
101
+ }
102
+ (0, import_esbuild.buildSync)({
103
+ entryPoints: [enterPoint],
104
+ bundle: true,
105
+ outdir: "shokaxTemp",
106
+ tsconfigRaw: {
107
+ compilerOptions: {
108
+ target: "ES2022",
109
+ esModuleInterop: true,
110
+ module: "ESNext",
111
+ moduleResolution: "Node",
112
+ skipLibCheck: true
113
+ }
114
+ },
115
+ platform: "browser",
116
+ format: "esm",
117
+ target: ["es2022"],
118
+ minify: true,
119
+ legalComments: "linked",
120
+ mainFields: ["module", "browser", "main"],
121
+ splitting: true,
122
+ define: {
123
+ __UNLAZY_LOGGING__: "false",
124
+ __UNLAZY_HASH_DECODING__: theme.modules.unlazyHash ? "true" : "false",
125
+ __shokax_player__: theme.modules.player ? "true" : "false",
126
+ __shokax_VL__: theme.modules.visibilityListener ? "true" : "false",
127
+ __shokax_fireworks__: theme.fireworks && theme.fireworks.enable && theme.fireworks.options && theme.modules.fireworks ? "true" : "false",
128
+ __shokax_search__: config?.algolia ? "true" : "false",
129
+ __shokax_outime__: theme.outime.enable ? "true" : "false",
130
+ __shokax_tabs__: theme.modules.tabs ? "true" : "false",
131
+ __shokax_quiz__: theme.modules.quiz ? "true" : "false",
132
+ __shokax_fancybox__: theme.modules.fancybox ? "true" : "false",
133
+ __shokax_waline__: theme.waline.enable ? "true" : "false",
134
+ __shokax_twikoo__: theme.twikoo.enable ? "true" : "false",
135
+ shokax_CONFIG: JSON.stringify(siteConfig),
136
+ shokax_siteURL: "'" + config.url + "'"
88
137
  }
89
- (0, esbuild_1.buildSync)({
90
- entryPoints: [enterPoint],
91
- bundle: true,
92
- outdir: 'shokaxTemp',
93
- tsconfigRaw: {
94
- compilerOptions: {
95
- target: 'ES2022',
96
- esModuleInterop: true,
97
- module: 'ESNext',
98
- moduleResolution: 'Node',
99
- skipLibCheck: true
100
- }
101
- },
102
- platform: 'browser',
103
- format: 'esm',
104
- target: ['es2022'],
105
- minify: true,
106
- legalComments: 'linked',
107
- mainFields: ['module', 'browser', 'main'],
108
- splitting: true,
109
- define: {
110
- __UNLAZY_LOGGING__: 'false',
111
- __UNLAZY_HASH_DECODING__: theme.modules.unlazyHash ? 'true' : 'false',
112
- __shokax_player__: theme.modules.player ? 'true' : 'false',
113
- __shokax_VL__: theme.modules.visibilityListener ? 'true' : 'false',
114
- __shokax_fireworks__: (theme.fireworks && theme.fireworks.enable && theme.fireworks.options && theme.modules.fireworks) ? 'true' : 'false',
115
- __shokax_search__: config?.algolia ? 'true' : 'false',
116
- __shokax_outime__: theme.outime.enable ? 'true' : 'false',
117
- __shokax_tabs__: theme.modules.tabs ? 'true' : 'false',
118
- __shokax_quiz__: theme.modules.quiz ? 'true' : 'false',
119
- __shokax_fancybox__: theme.modules.fancybox ? 'true' : 'false',
120
- __shokax_waline__: theme.waline.enable ? 'true' : 'false',
121
- __shokax_twikoo__: theme.twikoo.enable ? 'true' : 'false',
122
- shokax_CONFIG: JSON.stringify(siteConfig),
123
- shokax_siteURL: "'" + config.url + "'"
124
- },
125
- alias: {
126
- 'algoliasearch/lite': 'algoliasearch/dist/algoliasearch-lite.esm.browser.js'
127
- }
128
- });
129
- const res = [];
130
- node_fs_1.default.readdirSync('./shokaxTemp').forEach((file) => {
131
- const fileText = node_fs_1.default.readFileSync(`./shokaxTemp/${file}`, { encoding: 'utf-8' });
132
- if (file.endsWith('js')) {
133
- const result = hexo.render.renderSync({ text: fileText, engine: 'js' });
134
- res.push({
135
- path: theme.js + '/' + file,
136
- data: function () {
137
- return result;
138
- }
139
- });
138
+ });
139
+ const res = [];
140
+ import_node_fs.default.readdirSync("./shokaxTemp").forEach((file) => {
141
+ const fileText = import_node_fs.default.readFileSync(`./shokaxTemp/${file}`, { encoding: "utf-8" });
142
+ if (file.endsWith("js")) {
143
+ const result = hexo.render.renderSync({ text: fileText, engine: "js" });
144
+ res.push({
145
+ path: theme.js + "/" + file,
146
+ data: function() {
147
+ return result;
140
148
  }
141
- else if (file.endsWith('css')) {
142
- const result = hexo.render.renderSync({ text: fileText, engine: 'css' });
143
- res.push({
144
- path: theme.css + '/' + file,
145
- data: function () {
146
- return result;
147
- }
148
- });
149
+ });
150
+ } else if (file.endsWith("css")) {
151
+ const result = hexo.render.renderSync({ text: fileText, engine: "css" });
152
+ res.push({
153
+ path: theme.css + "/" + file,
154
+ data: function() {
155
+ return result;
149
156
  }
150
- else {
151
- res.push({
152
- path: theme.js + '/' + file,
153
- data: function () {
154
- return fileText;
155
- }
156
- });
157
+ });
158
+ } else {
159
+ res.push({
160
+ path: theme.js + "/" + file,
161
+ data: function() {
162
+ return fileText;
157
163
  }
158
- });
159
- return res;
164
+ });
165
+ }
166
+ });
167
+ return res;
160
168
  });