hexo-theme-shokax 0.3.13 → 0.4.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/_config.yml +11 -5
  2. package/layout/_mixin/comment.pug +4 -4
  3. package/package.json +4 -4
  4. package/scripts/filters/locals.d.ts +1 -0
  5. package/scripts/filters/locals.ts +59 -0
  6. package/scripts/filters/post.d.ts +0 -0
  7. package/scripts/filters/post.ts +6 -0
  8. package/scripts/generaters/archive.d.ts +1 -0
  9. package/scripts/generaters/archive.ts +144 -0
  10. package/scripts/generaters/config.d.ts +1 -0
  11. package/scripts/generaters/config.ts +52 -0
  12. package/scripts/generaters/images.d.ts +1 -0
  13. package/scripts/generaters/images.ts +26 -0
  14. package/scripts/generaters/index.d.ts +1 -0
  15. package/scripts/generaters/index.ts +110 -0
  16. package/scripts/generaters/pages.d.ts +0 -0
  17. package/scripts/generaters/pages.ts +16 -0
  18. package/scripts/generaters/script.d.ts +1 -0
  19. package/scripts/generaters/script.js +22 -6
  20. package/scripts/generaters/script.ts +110 -0
  21. package/scripts/helpers/asset.d.ts +1 -0
  22. package/scripts/helpers/asset.ts +158 -0
  23. package/scripts/helpers/engine.d.ts +1 -0
  24. package/scripts/helpers/engine.ts +171 -0
  25. package/scripts/helpers/list_categories.d.ts +1 -0
  26. package/scripts/helpers/list_categories.ts +104 -0
  27. package/scripts/helpers/summary_ai.d.ts +1 -0
  28. package/scripts/helpers/summary_ai.ts +100 -0
  29. package/scripts/helpers/symbols_count_time.d.ts +1 -0
  30. package/scripts/helpers/symbols_count_time.ts +76 -0
  31. package/scripts/plugin/check.d.ts +1 -0
  32. package/scripts/plugin/check.ts +35 -0
  33. package/scripts/plugin/index.d.ts +6 -0
  34. package/scripts/plugin/index.ts +52 -0
  35. package/scripts/plugin/lib/injects-point.d.ts +5 -0
  36. package/scripts/plugin/lib/injects-point.ts +20 -0
  37. package/scripts/plugin/lib/injects.d.ts +2 -0
  38. package/scripts/plugin/lib/injects.ts +101 -0
  39. package/scripts/tags/links.d.ts +1 -0
  40. package/scripts/tags/links.ts +75 -0
  41. package/scripts/tags/media.d.ts +1 -0
  42. package/scripts/tags/media.ts +19 -0
  43. package/source/js/_app/components/sidebar.ts +237 -0
  44. package/source/js/_app/globals/globalVars.ts +98 -0
  45. package/source/js/_app/globals/handles.ts +122 -0
  46. package/source/js/_app/globals/themeColor.ts +64 -0
  47. package/source/js/_app/globals/thirdparty.ts +63 -0
  48. package/source/js/_app/globals/tools.ts +74 -0
  49. package/source/js/_app/library/anime.ts +109 -0
  50. package/source/js/_app/library/declare.d.ts +117 -0
  51. package/source/js/_app/library/dom.ts +26 -0
  52. package/source/js/_app/library/libtype.d.ts +4 -0
  53. package/source/js/_app/library/loadFile.ts +41 -0
  54. package/source/js/_app/library/proto.ts +143 -0
  55. package/source/js/_app/library/scriptPjax.ts +72 -0
  56. package/source/js/_app/library/storage.ts +12 -0
  57. package/source/js/_app/library/vue.ts +60 -0
  58. package/source/js/_app/page/common.ts +42 -0
  59. package/source/js/_app/page/fancybox.ts +70 -0
  60. package/source/js/_app/page/post.ts +265 -0
  61. package/source/js/_app/page/search.ts +129 -0
  62. package/source/js/_app/page/tab.ts +59 -0
  63. package/source/js/_app/pjax/domInit.ts +95 -0
  64. package/source/js/_app/pjax/refresh.ts +75 -0
  65. package/source/js/_app/pjax/siteInit.ts +67 -0
  66. package/source/js/_app/player.ts +798 -0
  67. package/source/js/_app/components/sidebar.js +0 -209
  68. package/source/js/_app/fireworks.js +0 -10
  69. package/source/js/_app/globals/globalVars.js +0 -80
  70. package/source/js/_app/globals/handles.js +0 -98
  71. package/source/js/_app/globals/themeColor.js +0 -62
  72. package/source/js/_app/globals/thirdparty.js +0 -62
  73. package/source/js/_app/globals/tools.js +0 -66
  74. package/source/js/_app/library/anime.js +0 -106
  75. package/source/js/_app/library/dom.js +0 -34
  76. package/source/js/_app/library/loadFile.js +0 -36
  77. package/source/js/_app/library/proto.js +0 -163
  78. package/source/js/_app/library/scriptPjax.js +0 -70
  79. package/source/js/_app/library/storage.js +0 -12
  80. package/source/js/_app/library/vue.js +0 -53
  81. package/source/js/_app/page/comment.js +0 -23
  82. package/source/js/_app/page/common.js +0 -41
  83. package/source/js/_app/page/fancybox.js +0 -65
  84. package/source/js/_app/page/post.js +0 -244
  85. package/source/js/_app/page/search.js +0 -118
  86. package/source/js/_app/page/tab.js +0 -53
  87. package/source/js/_app/pjax/domInit.js +0 -76
  88. package/source/js/_app/pjax/refresh.js +0 -52
  89. package/source/js/_app/pjax/siteInit.js +0 -51
  90. package/source/js/_app/player.js +0 -771
package/_config.yml CHANGED
@@ -21,7 +21,6 @@ pwa:
21
21
 
22
22
  # 实验性特性
23
23
  experiments:
24
- noPlayer: false # 禁用音乐播放器
25
24
  gradient: false # 使用CSS渐变作为文章封面
26
25
  fixedCover: "" # 主页面cover(为空则使用bing随机图片)
27
26
  debug: false # 使用debug模式启动
@@ -31,6 +30,17 @@ experiments:
31
30
  # 具体见https://docs.kaitaku.xyz/guide/theme.html#%E9%95%BF%E6%96%87%E7%AB%A0%E4%BC%98%E5%8C%96
32
31
  mobileWidth: 820px # 移动版和桌面版导航栏最短切换长度
33
32
 
33
+ # ShokaX 模块化分包引入设置
34
+ # 请关闭所有不使用的模块以优化主题 js 体积和性能
35
+ modules:
36
+ player: true # 启用音乐播放器
37
+ fireworks: true # 启用鼠标点击烟花特效
38
+ unlazyHash: false # 启用unlazy hash预览图支持
39
+ visibilityListener: true # 启用可见度监听器
40
+ tabs: true # 启用选项卡扩展支持,如需开启 summary 功能请一并开启
41
+ quiz: true # 启用文章内问题扩展支持
42
+ fancybox: true # 启用 fancybox 支持(不建议禁用)
43
+
34
44
  # 优化性能区
35
45
  performance:
36
46
  # 使用preconnect预加载的网址(不建议超过三个)
@@ -38,15 +48,11 @@ performance:
38
48
  - "https://lf9-cdn-tos.bytecdntp.com"
39
49
  # 使用dns-prefetch预解析的网址
40
50
  dnsPrefetch:
41
- - "https://cdn.jsdelivr.net"
42
- - "https://unpkg.com"
43
51
 
44
52
  playerAPI: "https://api.injahow.cn" # 结尾不带/,只填写域名
45
53
  # 如果条件允许,请参考 https://github.com/injahow/meting-api 自建API
46
54
  # 使用vercel自行部署,请参考: https://github.com/xizeyoupan/Meting-API
47
55
 
48
- disableVL: false # 禁用可见度监听
49
-
50
56
  icon:
51
57
  favicon: "/favicon.ico"
52
58
  apple_touch_icon: "/apple-touch-icon.png"
@@ -3,17 +3,17 @@ mixin CommentRender()
3
3
  - var tk = theme?.twikoo?.enable,wl = theme?.waline?.enable
4
4
  if page.comment !== false && !theme.experiments.disableThemeComment
5
5
  if tk
6
- div(class="wrap" id="tcomments")
6
+ div(class="wrap" id="comments")
7
7
  script(type="text/javascript" data-pjax).
8
8
  setTimeout(function () {
9
9
  twikoo.init({
10
10
  envId: '#{ theme.twikoo.envId }',
11
- el: '#tcomments',
11
+ el: '#comments',
12
12
  region: '#{theme.twikoo.region}'
13
13
  })
14
14
  }, 1000)
15
15
  else if wl
16
- div(class="wrap" id="wcomments")
16
+ div(class="wrap" id="comments")
17
17
  - var locale = JSON.stringify(theme.waline.locale)
18
18
  - var emoji = JSON.stringify(theme.waline.emoji)
19
19
  - var meta = JSON.stringify(theme.waline.meta)
@@ -23,7 +23,7 @@ mixin CommentRender()
23
23
 
24
24
  setTimeout(function () {
25
25
  init({
26
- el: '#wcomments',
26
+ el: '#comments',
27
27
  serverURL: '#{theme.waline.serverURL.replace(/\/+$/, '')}',
28
28
  lang: '#{theme.waline.lang}',
29
29
  locale: !{locale},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.3.13",
3
+ "version": "0.4.0-alpha.1",
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",
@@ -9,15 +9,15 @@
9
9
  "packageManager": "pnpm@8.14.1",
10
10
  "scripts": {
11
11
  "test": "tsc --build --verbose",
12
- "build": "cd ./source && tsc --build --verbose && cd ../scripts && tsc --build --verbose"
12
+ "build": "cd ./scripts && tsc --build --verbose"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/fancybox": "^3.5.6",
16
16
  "@types/jquery": "^3.5.29",
17
17
  "@types/js-yaml": "^4.0.9",
18
18
  "@types/node": "^20.11.10",
19
- "@typescript-eslint/eslint-plugin": "^6.19.1",
20
- "@typescript-eslint/parser": "^6.19.1",
19
+ "@typescript-eslint/eslint-plugin": "^6.20.0",
20
+ "@typescript-eslint/parser": "^6.20.0",
21
21
  "eslint": "^8.56.0",
22
22
  "eslint-config-standard": "~17",
23
23
  "eslint-plugin-import": "^2.29.1",
@@ -0,0 +1 @@
1
+ declare const fmtNum: (num: any) => any;
@@ -0,0 +1,59 @@
1
+
2
+ // @ts-ignore
3
+ const fmtNum = (num) => {
4
+ return num < 10 ? '0' + num : num
5
+ }
6
+
7
+ hexo.extend.filter.register('template_locals', (locals:localsPlus) => {
8
+ const { config } = hexo
9
+ const { __, theme } = locals
10
+ // @ts-ignore
11
+ const { i18n } = hexo.theme
12
+
13
+ const pangu = {
14
+ spacing: (data) => {
15
+ return data
16
+ }
17
+ }
18
+
19
+ // Language & Config
20
+ // 根据主题配置的 Creative Commons 许可证生成链接
21
+ locals.alternate = theme.alternate
22
+ locals.title = pangu.spacing(__('title') !== 'title' ? __('title') : config.title)
23
+ locals.subtitle = pangu.spacing(__('subtitle') !== 'subtitle' ? __('subtitle') : config.subtitle)
24
+ locals.author = __('author') !== 'author' ? __('author') : config.author
25
+ locals.description = pangu.spacing(__('description') !== 'description' ? __('description') : config.description)
26
+ locals.languages = [...i18n.languages]
27
+ locals.languages.splice(locals.languages.indexOf('default'), 1)
28
+ locals.page.lang = locals.page.lang || locals.page.language
29
+ locals.hostname = new URL(config.url).hostname || config.url
30
+
31
+ // Creative Commons
32
+ // 根据主题配置的 Creative Commons 许可证生成链接
33
+ if (theme.creative_commons.license === 'zero') {
34
+ locals.ccURL = 'https://creativecommons.org/' + 'publicdomain/zero/1.0/' + (theme.creative_commons.language || '')
35
+ } else {
36
+ locals.ccURL = 'https://creativecommons.org/' + 'licenses/' + theme.creative_commons.license + '/4.0/' + (theme.creative_commons.language || '')
37
+ }
38
+
39
+ if (locals.page.title) {
40
+ locals.page.title = pangu.spacing(locals.page.title)
41
+ }
42
+ locals.page.lastcat = ''
43
+ if (locals.page.categories) {
44
+ locals.page.categories.map((cat) => {
45
+ if (cat.name) {
46
+ cat.name = locals.page.lastcat = pangu.spacing(cat.name)
47
+ }
48
+ return cat
49
+ })
50
+ }
51
+
52
+ if (locals.page.category) {
53
+ locals.page.title = pangu.spacing(locals.page.category)
54
+ }
55
+
56
+ if (locals.page.month) {
57
+ locals.page.month = fmtNum(locals.page.month)
58
+ }
59
+ })
File without changes
@@ -0,0 +1,6 @@
1
+ /* global hexo */
2
+
3
+ hexo.extend.filter.register('after_post_render', (data) => {
4
+ // 使用正则表达式将<img>标签的src属性替换为data-src属性
5
+ data.content = data.content.replace(/(<img[^>]*) src=/img, '$1 loading="lazy" data-src=')
6
+ }, 0)
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,144 @@
1
+ /* global hexo */
2
+ 'use strict'
3
+
4
+ // @ts-ignore
5
+ import pagination from 'hexo-pagination'
6
+
7
+ // @ts-ignore
8
+ const fmtNum = num => {
9
+ return num < 10 ? '0' + num : num
10
+ }
11
+
12
+ if (!(hexo.config.archive && hexo.config.archive.enabled === false)) {
13
+ // when archive disabled pagination, per_page should be 0.
14
+ let per_page
15
+
16
+ if (hexo.config.archive === 1) {
17
+ per_page = 0
18
+ } else if (typeof hexo.config.per_page === 'undefined') {
19
+ per_page = 10
20
+ } else {
21
+ per_page = hexo.config.per_page
22
+ }
23
+
24
+ hexo.config.archive_generator = Object.assign({
25
+ per_page,
26
+ yearly: true,
27
+ monthly: true,
28
+ daily: false
29
+ }, hexo.config.archive_generator)
30
+
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
+
40
+ if (!allPosts.length) return
41
+
42
+ if (archiveDir[archiveDir.length - 1] !== '/') archiveDir += '/'
43
+
44
+ function generate (path, posts, options?) {
45
+ options = options || {}
46
+ options.archive = true
47
+
48
+ result = result.concat(pagination(path, posts, {
49
+ perPage: path === archiveDir ? 0 : perPage,
50
+ layout: ['archive', 'index'],
51
+ format: paginationDir + '/%d/',
52
+ data: options
53
+ }))
54
+ }
55
+
56
+ generate(archiveDir, allPosts)
57
+
58
+ if (!config.archive_generator.yearly) return result
59
+
60
+ const posts = {}
61
+
62
+ // 按日期对文章进行分类
63
+ allPosts.forEach(post => {
64
+ const date = post.date
65
+ const year = date.year()
66
+ const month = date.month() + 1 // month is started from 0
67
+
68
+ if (!Object.prototype.hasOwnProperty.call(posts, year)) {
69
+ // 13个数组. 第一个数组是给这一年的文章准备的
70
+ // 其他则是各个月份的文章
71
+ posts[year] = [
72
+ [],
73
+ [],
74
+ [],
75
+ [],
76
+ [],
77
+ [],
78
+ [],
79
+ [],
80
+ [],
81
+ [],
82
+ [],
83
+ [],
84
+ []
85
+ ]
86
+ }
87
+
88
+ posts[year][0].push(post)
89
+ posts[year][month].push(post)
90
+ // Daily
91
+ if (config.archive_generator.daily) {
92
+ const day = date.date()
93
+ if (!Object.prototype.hasOwnProperty.call(posts[year][month], 'day')) {
94
+ posts[year][month].day = {}
95
+ }
96
+
97
+ (posts[year][month].day[day] || (posts[year][month].day[day] = [])).push(post)
98
+ }
99
+ })
100
+
101
+ const Query = this.model('Post').Query
102
+ const years = Object.keys(posts)
103
+ let year, data, month, monthData, url
104
+
105
+ // Yearly
106
+ for (let i = 0, len = years.length; i < len; i++) {
107
+ year = +years[i]
108
+ data = posts[year]
109
+ url = archiveDir + year + '/'
110
+ if (!data[0].length) continue
111
+
112
+ generate(url, new Query(data[0]), { year })
113
+
114
+ if (!config.archive_generator.monthly && !config.archive_generator.daily) continue
115
+
116
+ // Monthly
117
+ for (month = 1; month <= 12; month++) {
118
+ monthData = data[month]
119
+ if (!monthData.length) continue
120
+ if (config.archive_generator.monthly) {
121
+ generate(url + fmtNum(month) + '/', new Query(monthData), {
122
+ year,
123
+ month
124
+ })
125
+ }
126
+
127
+ if (!config.archive_generator.daily) continue
128
+
129
+ // Daily
130
+ for (let day = 1; day <= 31; day++) {
131
+ const dayData = monthData.day[day]
132
+ if (!dayData || !dayData.length) continue
133
+ generate(url + fmtNum(month) + '/' + fmtNum(day) + '/', new Query(dayData), {
134
+ year,
135
+ month,
136
+ day
137
+ })
138
+ }
139
+ }
140
+ }
141
+
142
+ return result
143
+ })
144
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ 'use strict'
2
+ /* global hexo */
3
+
4
+ import { deepMerge } from 'hexo-util'
5
+ import fs from 'node:fs'
6
+ import path from 'path'
7
+ import yaml from 'js-yaml'
8
+
9
+ hexo.extend.filter.register('before_generate', () => {
10
+ if (hexo.config.theme_config) {
11
+ // @ts-ignore
12
+ hexo.theme.config = deepMerge(hexo.theme.config, hexo.config.theme_config) as any
13
+ }
14
+
15
+ const data = hexo.locals.get('data')
16
+
17
+ if (data.languages) {
18
+ // @ts-ignore
19
+ const { i18n } = hexo.theme
20
+
21
+ const mergeLang = lang => {
22
+ if (data.languages[lang]) { // @ts-ignore
23
+ i18n.set(lang, deepMerge(i18n.get([lang]), data.languages[lang]))
24
+ }
25
+ }
26
+
27
+ for (const lang of ['en', 'ja', 'zh-CN', 'zh-HK', 'zh-TW']) {
28
+ mergeLang(lang)
29
+ }
30
+ }
31
+
32
+ (hexo.theme.config as any).style = {}
33
+
34
+ for (const style of ['iconfont', 'colors', 'custom']) {
35
+ const custom_file = 'source/_data/' + style + '.styl'
36
+ if (fs.existsSync(custom_file)) {
37
+ hexo.theme.config.style[style] = path.resolve(hexo.base_dir, custom_file)
38
+ }
39
+ }
40
+
41
+ if (data.images && data.images.length > 0) {
42
+ hexo.theme.config.image_list = data.images
43
+ } else {
44
+ hexo.theme.config.image_list = yaml.load(fs.readFileSync(path.join(__dirname, '../../_images.yml'), { encoding: 'utf-8' }))
45
+ }
46
+
47
+ if (fs.existsSync(path.join(__dirname, '../../_images_index.yml'))) {
48
+ hexo.theme.config.index_images = yaml.load(fs.readFileSync(path.join(__dirname, '../../_images_index.yml'), { encoding: 'utf-8' }))
49
+ } else {
50
+ hexo.theme.config.index_images = data.index_images || []
51
+ }
52
+ })
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ /* global hexo */
2
+ 'use strict'
3
+
4
+ // @ts-ignore
5
+ import fs = require('hexo-fs')
6
+
7
+ hexo.extend.generator.register('images', function (locals) {
8
+ const theme = hexo.theme.config
9
+ const dir = 'source/_data/' + theme.assets + '/'
10
+
11
+ if (!fs.existsSync(dir)) { return }
12
+
13
+ const result = []
14
+ const files = fs.listDirSync(dir) as string[]
15
+
16
+ files.forEach((file) => {
17
+ result.push({
18
+ path: theme.assets + '/' + file,
19
+ data: function () {
20
+ return fs.createReadStream(dir + file)
21
+ }
22
+ })
23
+ })
24
+
25
+ return result
26
+ })
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,110 @@
1
+ // @ts-nocheck
2
+ /* global hexo */
3
+ 'use strict'
4
+
5
+ import fs = require('hexo-fs')
6
+ import pagination from 'hexo-pagination'
7
+
8
+ hexo.config.index_generator = Object.assign({
9
+ per_page: typeof hexo.config.per_page === 'undefined' ? 10 : hexo.config.per_page,
10
+ order_by: '-date'
11
+ }, hexo.config.index_generator)
12
+
13
+ hexo.extend.generator.register('index', function (locals) {
14
+ const covers = []
15
+ const catlist = []
16
+ let pages
17
+ const config = hexo.config
18
+ const sticky = locals.posts.find({ sticky: true }).sort(config.index_generator.order_by)
19
+ const posts = locals.posts.find({ sticky: {$in: [false, undefined]} }).sort(config.index_generator.order_by)
20
+ const paginationDir = config.pagination_dir || 'page'
21
+ const path = config.index_generator.path || ''
22
+ const categories = locals.categories
23
+
24
+ const getTopcat = function (cat) {
25
+ if (cat.parent) {
26
+ const pCat = categories.findOne({ _id: cat.parent })
27
+ return getTopcat(pCat)
28
+ } else {
29
+ return cat
30
+ }
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
+ } else if (fs.existsSync(cover + '/cover.webp')) {
44
+ covers.push({
45
+ path: cat.slug + '/cover.webp',
46
+ data: function () {
47
+ return fs.createReadStream(cover + '/cover.webp')
48
+ }
49
+ })
50
+ } else if (fs.existsSync(cover + '/cover.jpg')) {
51
+ covers.push({
52
+ path: cat.slug + '/cover.jpg',
53
+ data: function () {
54
+ return fs.createReadStream(cover + '/cover.jpg')
55
+ }
56
+ })
57
+
58
+ const topcat = getTopcat(cat)
59
+
60
+ if (topcat._id !== cat._id) {
61
+ cat.top = topcat
62
+ }
63
+
64
+ const child = categories.find({ parent: cat._id })
65
+ let pl = 6
66
+
67
+ if (child.length !== 0) {
68
+ cat.child = child.length
69
+ cat.subs = child.sort({ name: 1 }).limit(6).toArray()
70
+ pl = Math.max(0, pl - child.length)
71
+ if (pl > 0) {
72
+ cat.subs.push(...cat.posts.sort({ title: 1 })
73
+ .filter(function (item, i) { return item.categories.last()._id === cat._id })
74
+ .limit(pl).toArray())
75
+ }
76
+ } else {
77
+ cat.subs = cat.posts.sort({ title: 1 }).limit(6).toArray()
78
+ }
79
+
80
+ catlist.push(cat)
81
+ }
82
+ })
83
+ }
84
+
85
+ if (posts.length > 0) {
86
+ pages = pagination(path, posts, {
87
+ perPage: config.index_generator.per_page,
88
+ layout: ['index', 'archive'],
89
+ format: paginationDir + '/%d/',
90
+ data: {
91
+ __index: true,
92
+ catlist,
93
+ sticky
94
+ }
95
+ })
96
+ } else {
97
+ pages = [{
98
+ path,
99
+ layout: ['index', 'archive'],
100
+ data: {
101
+ __index: true,
102
+ catlist,
103
+ sticky,
104
+ current: 1,
105
+ }
106
+ }]
107
+ }
108
+
109
+ return [...covers, ...pages]
110
+ })
File without changes
@@ -0,0 +1,16 @@
1
+ hexo.extend.generator.register('pages', function () {
2
+ const config = hexo.config
3
+
4
+ return [
5
+ {
6
+ path: config.category_dir + '/index.html',
7
+ data: { type: 'categories' },
8
+ layout: 'page'
9
+ },
10
+ {
11
+ path: config.tag_dir + '/index.html',
12
+ data: { type: 'tags' },
13
+ layout: 'page'
14
+ }
15
+ ]
16
+ })
@@ -0,0 +1 @@
1
+ export {};
@@ -67,8 +67,6 @@ hexo.extend.generator.register('script', function (locals) {
67
67
  priority: theme.quicklink.priority
68
68
  },
69
69
  playerAPI: theme.playerAPI,
70
- disableVL: theme.disableVL,
71
- noPlayer: theme.experiments?.noPlayer,
72
70
  audio: undefined,
73
71
  fireworks: (theme.fireworks && theme.fireworks.enable && theme.fireworks.options)
74
72
  ? theme.fireworks.options
@@ -87,23 +85,41 @@ hexo.extend.generator.register('script', function (locals) {
87
85
  }
88
86
  let text;
89
87
  let enterPoint;
90
- if (fs.existsSync('themes/shokaX/source/js/_app/pjax/siteInit.js')) {
91
- enterPoint = 'themes/shokaX/source/js/_app/pjax/siteInit.js';
88
+ if (fs.existsSync('themes/shokaX/source/js/_app/pjax/siteInit.ts')) {
89
+ enterPoint = 'themes/shokaX/source/js/_app/pjax/siteInit.ts';
92
90
  }
93
91
  else {
94
- enterPoint = 'node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.js';
92
+ enterPoint = 'node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.ts';
95
93
  }
96
94
  text = 'const CONFIG = ' + JSON.stringify(siteConfig) + ';';
97
95
  (0, esbuild_1.buildSync)({
98
96
  entryPoints: [enterPoint],
99
97
  bundle: true,
100
98
  outfile: 'shokax_temp.js',
99
+ tsconfigRaw: {
100
+ compilerOptions: {
101
+ target: 'ES2022',
102
+ esModuleInterop: true,
103
+ module: 'ESNext',
104
+ moduleResolution: 'Node',
105
+ skipLibCheck: true
106
+ }
107
+ },
101
108
  platform: 'browser',
102
109
  format: 'iife',
103
110
  target: ['es2022'],
104
111
  minify: true,
105
112
  define: {
106
- __UNLAZY_LOGGING__: 'false'
113
+ __UNLAZY_LOGGING__: 'false',
114
+ __UNLAZY_HASH_DECODING__: theme.modules.unlazyHash ? 'true' : 'false',
115
+ __shokax_player__: theme.modules.player ? 'true' : 'false',
116
+ __shokax_VL__: theme.modules.visibilityListener ? 'true' : 'false',
117
+ __shokax_fireworks__: (theme.fireworks && theme.fireworks.enable && theme.fireworks.options && theme.modules.fireworks) ? 'true' : 'false',
118
+ __shokax_search__: config?.algolia ? 'true' : 'false',
119
+ __shokax_outime__: theme.outime.enable ? 'true' : 'false',
120
+ __shokax_tabs__: theme.modules.tabs ? 'true' : 'false',
121
+ __shokax_quiz__: theme.modules.quiz ? 'true' : 'false',
122
+ __shokax_fancybox__: theme.modules.fancybox ? 'true' : 'false'
107
123
  }
108
124
  });
109
125
  text += fs.readFileSync('shokax_temp.js');