hexo-theme-shokax 0.4.0-alpha.1 → 0.4.0-alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- package/_config.yml +5 -4
- package/layout/_partials/footer.pug +1 -1
- package/layout/_partials/head/head.pug +7 -1
- package/layout/_partials/header.pug +1 -1
- package/layout/_partials/layout.pug +0 -10
- package/layout/_partials/post/footer.pug +1 -2
- package/package.json +7 -2
- package/scripts/generaters/archive.js +1 -1
- package/scripts/generaters/script.js +44 -38
- package/scripts/helpers/asset.js +1 -1
- package/scripts/helpers/list_categories.js +0 -4
- package/scripts/plugin/lib/injects.js +1 -1
- package/source/js/_app/components/comments.ts +33 -0
- package/source/js/_app/components/sidebar.ts +7 -5
- package/source/js/_app/globals/globalVars.ts +1 -0
- package/source/js/_app/globals/handles.ts +6 -5
- package/source/js/_app/globals/themeColor.ts +1 -1
- package/source/js/_app/globals/thirdparty.ts +1 -1
- package/source/js/_app/globals/tools.ts +3 -2
- package/source/js/_app/library/anime.ts +6 -5
- package/source/js/_app/library/declare.d.ts +18 -9
- package/source/js/_app/library/loadFile.ts +3 -1
- package/source/js/_app/library/proto.ts +75 -77
- package/source/js/_app/library/vue.ts +38 -48
- package/source/js/_app/page/fancybox.ts +2 -1
- package/source/js/_app/page/post.ts +4 -3
- package/source/js/_app/page/search.ts +17 -11
- package/source/js/_app/page/tab.ts +3 -2
- package/source/js/_app/pjax/domInit.ts +5 -4
- package/source/js/_app/pjax/refresh.ts +5 -2
- package/source/js/_app/pjax/siteInit.ts +12 -7
- package/source/js/_app/player.ts +16 -15
- package/scripts/filters/locals.d.ts +0 -1
- package/scripts/filters/locals.ts +0 -59
- package/scripts/filters/post.d.ts +0 -0
- package/scripts/filters/post.ts +0 -6
- package/scripts/generaters/archive.d.ts +0 -1
- package/scripts/generaters/archive.ts +0 -144
- package/scripts/generaters/config.d.ts +0 -1
- package/scripts/generaters/config.ts +0 -52
- package/scripts/generaters/images.d.ts +0 -1
- package/scripts/generaters/images.ts +0 -26
- package/scripts/generaters/index.d.ts +0 -1
- package/scripts/generaters/index.ts +0 -110
- package/scripts/generaters/pages.d.ts +0 -0
- package/scripts/generaters/pages.ts +0 -16
- package/scripts/generaters/script.d.ts +0 -1
- package/scripts/generaters/script.ts +0 -110
- package/scripts/helpers/asset.d.ts +0 -1
- package/scripts/helpers/asset.ts +0 -158
- package/scripts/helpers/engine.d.ts +0 -1
- package/scripts/helpers/engine.ts +0 -171
- package/scripts/helpers/list_categories.d.ts +0 -1
- package/scripts/helpers/list_categories.ts +0 -104
- package/scripts/helpers/summary_ai.d.ts +0 -1
- package/scripts/helpers/summary_ai.ts +0 -100
- package/scripts/helpers/symbols_count_time.d.ts +0 -1
- package/scripts/helpers/symbols_count_time.ts +0 -76
- package/scripts/plugin/check.d.ts +0 -1
- package/scripts/plugin/check.ts +0 -35
- package/scripts/plugin/index.d.ts +0 -6
- package/scripts/plugin/index.ts +0 -52
- package/scripts/plugin/lib/injects-point.d.ts +0 -5
- package/scripts/plugin/lib/injects-point.ts +0 -20
- package/scripts/plugin/lib/injects.d.ts +0 -2
- package/scripts/plugin/lib/injects.ts +0 -101
- package/scripts/tags/links.d.ts +0 -1
- package/scripts/tags/links.ts +0 -75
- package/scripts/tags/media.d.ts +0 -1
- package/scripts/tags/media.ts +0 -19
- package/source/assets/beian.webp +0 -0
- package/source/js/_app/library/libtype.d.ts +0 -4
@@ -1,59 +0,0 @@
|
|
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
|
package/scripts/filters/post.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,144 +0,0 @@
|
|
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
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,52 +0,0 @@
|
|
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
|
-
})
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,26 +0,0 @@
|
|
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
|
-
})
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,110 +0,0 @@
|
|
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
|
@@ -1,16 +0,0 @@
|
|
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
|
-
})
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,110 +0,0 @@
|
|
1
|
-
/* global hexo */
|
2
|
-
import env from '../../package.json'
|
3
|
-
import * as fs from 'hexo-fs'
|
4
|
-
import { buildSync } from 'esbuild'
|
5
|
-
import { getVendorLink } from '../utils'
|
6
|
-
|
7
|
-
hexo.extend.generator.register('script', function (locals) {
|
8
|
-
const config = hexo.config
|
9
|
-
const theme = hexo.theme.config
|
10
|
-
|
11
|
-
const siteConfig = {
|
12
|
-
version: env.version,
|
13
|
-
hostname: config.url,
|
14
|
-
root: config.root,
|
15
|
-
statics: theme.statics,
|
16
|
-
favicon: {
|
17
|
-
normal: theme.assets + '/favicon.ico',
|
18
|
-
hidden: theme.assets + '/failure.ico'
|
19
|
-
},
|
20
|
-
darkmode: theme.darkmode,
|
21
|
-
auto_dark: theme.auto_dark,
|
22
|
-
auto_scroll: theme.auto_scroll,
|
23
|
-
js: {
|
24
|
-
copy_tex: getVendorLink(hexo, theme.vendors.async_js.copy_tex),
|
25
|
-
fancybox: getVendorLink(hexo, theme.vendors.async_js.fancybox)
|
26
|
-
},
|
27
|
-
css: {
|
28
|
-
katex: getVendorLink(hexo, theme.vendors.css.katex),
|
29
|
-
mermaid: theme.css + '/mermaid.css',
|
30
|
-
fancybox: getVendorLink(hexo, theme.vendors.css.fancybox),
|
31
|
-
justifiedGallery: getVendorLink(hexo, theme.vendors.css.justifiedGallery)
|
32
|
-
},
|
33
|
-
loader: theme.loader,
|
34
|
-
search: null,
|
35
|
-
outime: {
|
36
|
-
enable: theme.outime.enable,
|
37
|
-
days: theme.outime.days
|
38
|
-
},
|
39
|
-
quicklink: {
|
40
|
-
timeout: theme.quicklink.timeout,
|
41
|
-
priority: theme.quicklink.priority
|
42
|
-
},
|
43
|
-
playerAPI: theme.playerAPI,
|
44
|
-
audio: undefined,
|
45
|
-
fireworks: (theme.fireworks && theme.fireworks.enable && theme.fireworks.options)
|
46
|
-
? theme.fireworks.options
|
47
|
-
: undefined
|
48
|
-
}
|
49
|
-
|
50
|
-
if (config?.algolia) {
|
51
|
-
siteConfig.search = {
|
52
|
-
appID: config.algolia.appId,
|
53
|
-
apiKey: config.algolia.apiKey,
|
54
|
-
indexName: config.algolia.indexName,
|
55
|
-
hits: theme.search.hits
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
if (theme?.audio) {
|
60
|
-
siteConfig.audio = theme.audio
|
61
|
-
}
|
62
|
-
|
63
|
-
let text: string
|
64
|
-
let enterPoint: string
|
65
|
-
if (fs.existsSync('themes/shokaX/source/js/_app/pjax/siteInit.ts')) {
|
66
|
-
enterPoint = 'themes/shokaX/source/js/_app/pjax/siteInit.ts'
|
67
|
-
} else {
|
68
|
-
enterPoint = 'node_modules/hexo-theme-shokax/source/js/_app/pjax/siteInit.ts'
|
69
|
-
}
|
70
|
-
text = 'const CONFIG = ' + JSON.stringify(siteConfig) + ';'
|
71
|
-
buildSync({
|
72
|
-
entryPoints: [enterPoint],
|
73
|
-
bundle: true,
|
74
|
-
outfile: 'shokax_temp.js',
|
75
|
-
tsconfigRaw: {
|
76
|
-
compilerOptions: {
|
77
|
-
target: 'ES2022',
|
78
|
-
esModuleInterop: true,
|
79
|
-
module: 'ESNext',
|
80
|
-
moduleResolution: 'Node',
|
81
|
-
skipLibCheck: true
|
82
|
-
}
|
83
|
-
},
|
84
|
-
platform: 'browser',
|
85
|
-
format: 'iife',
|
86
|
-
target: ['es2022'],
|
87
|
-
minify: true,
|
88
|
-
define: {
|
89
|
-
__UNLAZY_LOGGING__: 'false',
|
90
|
-
__UNLAZY_HASH_DECODING__: theme.modules.unlazyHash ? 'true' : 'false',
|
91
|
-
__shokax_player__: theme.modules.player ? 'true' : 'false',
|
92
|
-
__shokax_VL__: theme.modules.visibilityListener ? 'true' : 'false',
|
93
|
-
__shokax_fireworks__: (theme.fireworks && theme.fireworks.enable && theme.fireworks.options && theme.modules.fireworks) ? 'true' : 'false',
|
94
|
-
__shokax_search__: config?.algolia ? 'true' : 'false',
|
95
|
-
__shokax_outime__: theme.outime.enable ? 'true' : 'false',
|
96
|
-
__shokax_tabs__: theme.modules.tabs ? 'true' : 'false',
|
97
|
-
__shokax_quiz__: theme.modules.quiz ? 'true' : 'false',
|
98
|
-
__shokax_fancybox__: theme.modules.fancybox ? 'true' : 'false'
|
99
|
-
}
|
100
|
-
})
|
101
|
-
text += fs.readFileSync('shokax_temp.js')
|
102
|
-
const result = hexo.render.renderSync({ text, engine: 'js' })
|
103
|
-
fs.unlinkSync('shokax_temp.js')
|
104
|
-
return {
|
105
|
-
path: theme.js + '/app.js',
|
106
|
-
data: function () {
|
107
|
-
return result
|
108
|
-
}
|
109
|
-
}
|
110
|
-
})
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|