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.
package/_config.yml CHANGED
@@ -27,6 +27,10 @@ experiments:
27
27
  optimizeLongPosts: false # 优化长文章,这能让长文章的FPS提升70%-150%并解决假死问题,但存在一些副作用
28
28
  # 具体见https://docs.kaitaku.xyz/guide/theme.html#%E9%95%BF%E6%96%87%E7%AB%A0%E4%BC%98%E5%8C%96
29
29
  mobileWidth: 820px # 移动版和桌面版导航栏最短切换长度
30
+ coverConfig:
31
+ enableCover: true # 是否开启头图
32
+ enablePreload: true #是否开启预加载头图
33
+ enableNextGradientCover: true # 使用CSS渐变作为上/下一页封面
30
34
 
31
35
  homeConfig:
32
36
  gradient: false # 使用CSS渐变作为文章封面
@@ -8,16 +8,19 @@ if (theme.quicklink.ignores)
8
8
 
9
9
  - var covers = _cover_index(page, 6)
10
10
  - var enableFixedCover = theme.homeConfig?.fixedCover
11
+ - var enablePreload = theme.experiments?.coverConfig?.enablePreload
12
+ - var enableCover = theme.experiments?.coverConfig?.enableCover
11
13
 
12
14
  doctype html
13
15
  html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'filter: grayscale(1);':'' )
14
16
  head
15
17
  != partial('_partials/head/head.pug', {}, {cache: true})
16
- if enableFixedCover
17
- link(rel="preload" href=theme.homeConfig.fixedCover as="image" fetchpriority="high")
18
- else
19
- each image in covers
20
- link(rel="preload" href=image as="image" fetchpriority="high")
18
+ if enablePreload && enableCover
19
+ if enableFixedCover
20
+ link(rel="preload" href=theme.homeConfig.fixedCover as="image" fetchpriority="high")
21
+ else
22
+ each image in covers
23
+ link(rel="preload" href=image as="image" fetchpriority="high")
21
24
 
22
25
  != partial('_partials/head/head_com.pug')
23
26
  != shokax_inject('head')
@@ -44,17 +47,18 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
44
47
 
45
48
  != partial('_partials/header.pug', {}, {cache: true})
46
49
  div(id="imgs" class="pjax")
47
- if theme.homeConfig.gradient || enableFixedCover
48
- //- cover不可用时用Bing随机图片代替
49
- - var coverImage = theme.homeConfig?.fixedCover || "https://7ed.net/bing/api"
50
- img(src=coverImage loading="eager" decoding="async" fetchpriority="high" alt=title)
51
- else
52
- if covers.length === 6
53
- ul
54
- each image in covers
55
- li(class="item" style=`background-image: url("${image}");`)
50
+ if enableCover
51
+ if theme.homeConfig.gradient || enableFixedCover
52
+ //- cover不可用时用Bing随机图片代替
53
+ - var coverImage = theme.homeConfig?.fixedCover || "https://7ed.net/bing/api"
54
+ img(src=coverImage loading="eager" decoding="async" fetchpriority="high" alt=title)
56
55
  else
57
- img(src=covers loading="eager" decoding="async" fetchpriority="high" alt=title)
56
+ if covers.length === 6
57
+ ul
58
+ each image in covers
59
+ li(class="item" style=`background-image: url("${image}");`)
60
+ else
61
+ img(src=covers loading="eager" decoding="async" fetchpriority="high" alt=title)
58
62
  div(id="waves")
59
63
  svg(class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto")
60
64
  defs
@@ -1,8 +1,12 @@
1
1
  mixin navpost(item, type)
2
+ - var enableNextGradientCover = theme?.experiments?.coverConfig?.enableNextGradientCover
2
3
  - var postText = item.title || item.link || __('post.untitled')
3
4
  - var lastcat = item.categories.last()
4
5
  - var itemlink = `<span class="type">${__('post.' + type)}</span>${lastcat && lastcat.name ? `<span class="category"><i class="ic i-flag"></i>${lastcat.name}</span>` : ''}<h3>${postText}</h3>`
5
- != _url(item.path, itemlink, {itemprop: 'url', rel: type, 'data-background-image': _cover(item), title: postText})
6
+ if enableNextGradientCover
7
+ != _url(item.path, itemlink, {itemprop: 'url', rel: type, title: postText, style: `background-image: linear-gradient(to bottom right, ${random_color()}, ${random_color()});`})
8
+ else
9
+ != _url(item.path, itemlink, {itemprop: 'url', rel: type, 'data-background-image': _cover(item), title: postText})
6
10
 
7
11
  div(class="post-nav")
8
12
  div(class="item left")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.4.12",
3
+ "version": "0.4.14",
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",
@@ -23,13 +23,14 @@
23
23
  "eslint": "^9.11.0",
24
24
  "eslint-config-standard": "~17",
25
25
  "eslint-plugin-vue": "^9.28.0",
26
+ "glob": "^11.0.0",
26
27
  "typescript": "^5.6.2"
27
28
  },
28
29
  "dependencies": {
29
30
  "@algolia/client-search": "^5.5.3",
30
31
  "@waline/client": "^3.3.2",
31
32
  "algoliasearch": "5.5.3",
32
- "esbuild": "^0.23.1",
33
+ "esbuild": "^0.24.0",
33
34
  "hexo": "^7.3.0",
34
35
  "hexo-algoliasearch": "^2.0.1",
35
36
  "hexo-feed": "^1.1.2",
@@ -1,52 +1,45 @@
1
- // @ts-ignore
2
1
  const fmtNum = (num) => {
3
- return num < 10 ? '0' + num : num;
2
+ return num < 10 ? "0" + num : num;
4
3
  };
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);
4
+ hexo.extend.filter.register("template_locals", (locals) => {
5
+ const { config } = hexo;
6
+ const { __, theme } = locals;
7
+ const { i18n } = hexo.theme;
8
+ const pangu = {
9
+ spacing: (data) => {
10
+ return data;
51
11
  }
12
+ };
13
+ locals.alternate = theme.alternate;
14
+ locals.title = pangu.spacing(__("title") !== "title" ? __("title") : config.title);
15
+ locals.subtitle = pangu.spacing(__("subtitle") !== "subtitle" ? __("subtitle") : config.subtitle);
16
+ locals.author = __("author") !== "author" ? __("author") : config.author;
17
+ locals.description = pangu.spacing(__("description") !== "description" ? __("description") : config.description);
18
+ locals.languages = [...i18n.languages];
19
+ locals.languages.splice(locals.languages.indexOf("default"), 1);
20
+ locals.page.lang = locals.page.lang || locals.page.language;
21
+ locals.hostname = new URL(config.url).hostname || config.url;
22
+ if (theme.creative_commons.license === "zero") {
23
+ locals.ccURL = "https://creativecommons.org/publicdomain/zero/1.0/" + (theme.creative_commons.language || "");
24
+ } else {
25
+ locals.ccURL = "https://creativecommons.org/licenses/" + theme.creative_commons.license + "/4.0/" + (theme.creative_commons.language || "");
26
+ }
27
+ if (locals.page.title) {
28
+ locals.page.title = pangu.spacing(locals.page.title);
29
+ }
30
+ locals.page.lastcat = "";
31
+ if (locals.page.categories) {
32
+ locals.page.categories.map((cat) => {
33
+ if (cat.name) {
34
+ cat.name = locals.page.lastcat = pangu.spacing(cat.name);
35
+ }
36
+ return cat;
37
+ });
38
+ }
39
+ if (locals.page.category) {
40
+ locals.page.title = pangu.spacing(locals.page.category);
41
+ }
42
+ if (locals.page.month) {
43
+ locals.page.month = fmtNum(locals.page.month);
44
+ }
52
45
  });
@@ -1,5 +1,3 @@
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=');
1
+ hexo.extend.filter.register("after_post_render", (data) => {
2
+ data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 loading="lazy" data-src=');
5
3
  }, 0);
@@ -1,133 +1,129 @@
1
- /* global hexo */
2
- 'use strict';
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- 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;
5
15
  };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- // @ts-ignore
8
- const hexo_pagination_1 = __importDefault(require("hexo-pagination"));
9
- // @ts-ignore
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"));
10
25
  const fmtNum = (num) => {
11
- return num < 10 ? '0' + num : num;
26
+ return num < 10 ? "0" + num : num;
12
27
  };
13
28
  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;
29
+ let per_page;
30
+ if (hexo.config.archive === 1) {
31
+ per_page = 0;
32
+ } else if (typeof hexo.config.per_page === "undefined") {
33
+ per_page = 10;
34
+ } else {
35
+ per_page = hexo.config.per_page;
36
+ }
37
+ hexo.config.archive_generator = Object.assign({
38
+ per_page,
39
+ yearly: true,
40
+ monthly: true,
41
+ daily: false
42
+ }, hexo.config.archive_generator);
43
+ hexo.extend.generator.register("archive", function(locals) {
44
+ const config = hexo.config;
45
+ let archiveDir = config.archive_dir;
46
+ const paginationDir = config.pagination_dir || "page";
47
+ const allPosts = locals.posts.sort(config.archive_generator.order_by || "-date");
48
+ const perPage = config.archive_generator.per_page;
49
+ let result = [];
50
+ if (!allPosts.length) return;
51
+ if (archiveDir[archiveDir.length - 1] !== "/") archiveDir += "/";
52
+ function generate(path, posts2, options) {
53
+ options = options || {};
54
+ options.archive = true;
55
+ result = result.concat((0, import_hexo_pagination.default)(path, posts2, {
56
+ perPage: path === archiveDir ? 0 : perPage,
57
+ layout: ["archive", "index"],
58
+ format: paginationDir + "/%d/",
59
+ data: options
60
+ }));
18
61
  }
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
- }
62
+ generate(archiveDir, allPosts);
63
+ if (!config.archive_generator.yearly) return result;
64
+ const posts = {};
65
+ allPosts.forEach((post) => {
66
+ const date = post.date;
67
+ const year2 = date.year();
68
+ const month2 = date.month() + 1;
69
+ if (!Object.prototype.hasOwnProperty.call(posts, year2)) {
70
+ posts[year2] = [
71
+ [],
72
+ [],
73
+ [],
74
+ [],
75
+ [],
76
+ [],
77
+ [],
78
+ [],
79
+ [],
80
+ [],
81
+ [],
82
+ [],
83
+ []
84
+ ];
85
+ }
86
+ posts[year2][0].push(post);
87
+ posts[year2][month2].push(post);
88
+ if (config.archive_generator.daily) {
89
+ const day = date.date();
90
+ if (!Object.prototype.hasOwnProperty.call(posts[year2][month2], "day")) {
91
+ posts[year2][month2].day = {};
130
92
  }
131
- return result;
93
+ (posts[year2][month2].day[day] || (posts[year2][month2].day[day] = [])).push(post);
94
+ }
132
95
  });
96
+ const Query = this.model("Post").Query;
97
+ const years = Object.keys(posts);
98
+ let year, data, month, monthData, url;
99
+ for (let i = 0, len = years.length; i < len; i++) {
100
+ year = +years[i];
101
+ data = posts[year];
102
+ url = archiveDir + year + "/";
103
+ if (!data[0].length) continue;
104
+ generate(url, new Query(data[0]), { year });
105
+ if (!config.archive_generator.monthly && !config.archive_generator.daily) continue;
106
+ for (month = 1; month <= 12; month++) {
107
+ monthData = data[month];
108
+ if (!monthData.length) continue;
109
+ if (config.archive_generator.monthly) {
110
+ generate(url + fmtNum(month) + "/", new Query(monthData), {
111
+ year,
112
+ month
113
+ });
114
+ }
115
+ if (!config.archive_generator.daily) continue;
116
+ for (let day = 1; day <= 31; day++) {
117
+ const dayData = monthData.day[day];
118
+ if (!dayData || !dayData.length) continue;
119
+ generate(url + fmtNum(month) + "/" + fmtNum(day) + "/", new Query(dayData), {
120
+ year,
121
+ month,
122
+ day
123
+ });
124
+ }
125
+ }
126
+ }
127
+ return result;
128
+ });
133
129
  }
@@ -1,51 +1,63 @@
1
- 'use strict';
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- 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;
4
15
  };
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
- }
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_util = require("hexo-util");
25
+ var import_node_fs = __toESM(require("node:fs"));
26
+ var import_path = __toESM(require("path"));
27
+ var import_js_yaml = __toESM(require("js-yaml"));
28
+ hexo.extend.filter.register("before_generate", () => {
29
+ if (hexo.config.theme_config) {
30
+ hexo.theme.config = (0, import_hexo_util.deepMerge)(hexo.theme.config, hexo.config.theme_config);
31
+ }
32
+ const data = hexo.locals.get("data");
33
+ if (data.languages) {
34
+ const { i18n } = hexo.theme;
35
+ const mergeLang = (lang) => {
36
+ if (data.languages[lang]) {
37
+ i18n.set(lang, (0, import_hexo_util.deepMerge)(i18n.get([lang]), data.languages[lang]));
38
+ }
39
+ };
40
+ for (const lang of ["en", "ja", "zh-CN", "zh-HK", "zh-TW"]) {
41
+ mergeLang(lang);
42
+ }
43
+ }
44
+ hexo.theme.config.style = {};
45
+ for (const style of ["iconfont", "colors", "custom"]) {
46
+ const custom_file = "source/_data/" + style + ".styl";
47
+ if (import_node_fs.default.existsSync(custom_file)) {
48
+ hexo.theme.config.style[style] = import_path.default.resolve(hexo.base_dir, custom_file);
49
+ }
50
+ }
51
+ if (data.images && data.images.length > 0) {
52
+ hexo.theme.config.image_list = data.images;
53
+ } else {
54
+ hexo.theme.config.image_list = import_js_yaml.default.load(import_node_fs.default.readFileSync(import_path.default.join(__dirname, "../../_images.yml"), { encoding: "utf-8" }));
55
+ }
56
+ if (data.images_index && data.images_index.length > 0) {
57
+ hexo.theme.config.index_images = data.images_index;
58
+ } else if (import_node_fs.default.existsSync(import_path.default.join(__dirname, "../../_images_index.yml"))) {
59
+ hexo.theme.config.index_images = import_js_yaml.default.load(import_node_fs.default.readFileSync(import_path.default.join(__dirname, "../../_images_index.yml"), { encoding: "utf-8" }));
60
+ } else {
61
+ hexo.theme.config.index_images = data.index_images || [];
62
+ }
51
63
  });
@@ -1,23 +1,20 @@
1
- /* global hexo */
2
- 'use strict';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- // @ts-ignore
1
+ "use strict";
5
2
  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
- });
3
+ hexo.extend.generator.register("images", function(locals) {
4
+ const theme = hexo.theme.config;
5
+ const dir = "source/_data/" + theme.assets + "/";
6
+ if (!fs.existsSync(dir)) {
7
+ return;
8
+ }
9
+ const result = [];
10
+ const files = fs.listDirSync(dir);
11
+ files.forEach((file) => {
12
+ result.push({
13
+ path: theme.assets + "/" + file,
14
+ data: function() {
15
+ return fs.createReadStream(dir + file);
16
+ }
21
17
  });
22
- return result;
18
+ });
19
+ return result;
23
20
  });