hexo-theme-shokax 0.4.0-alpha.1 → 0.4.0-alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- package/_config.yml +5 -4
- package/languages/README.md +22 -0
- package/languages/ar.yml +153 -0
- package/languages/de.yml +153 -0
- package/languages/es.yml +153 -0
- package/languages/fr.yml +153 -0
- package/languages/hi.yml +153 -0
- package/languages/id.yml +153 -0
- package/languages/it.yml +153 -0
- package/languages/ko.yml +153 -0
- package/languages/nl.yml +153 -0
- package/languages/pl.yml +153 -0
- package/languages/pt.yml +153 -0
- package/languages/ru.yml +153 -0
- package/languages/tr.yml +153 -0
- package/languages/vi.yml +153 -0
- package/layout/_mixin/comment.pug +2 -37
- package/layout/_partials/footer.pug +1 -1
- package/layout/_partials/head/head.pug +7 -3
- package/layout/_partials/header.pug +1 -1
- package/layout/_partials/layout.pug +1 -10
- package/layout/_partials/post/footer.pug +0 -9
- package/package.json +8 -2
- package/scripts/generaters/archive.js +1 -1
- package/scripts/generaters/script.js +63 -39
- package/scripts/helpers/asset.js +3 -72
- package/scripts/helpers/list_categories.js +0 -4
- package/scripts/plugin/lib/injects.js +1 -1
- package/source/js/_app/components/comments.ts +60 -0
- package/source/js/_app/components/sidebar.ts +7 -5
- package/source/js/_app/components/tcomments.ts +41 -0
- 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 +25 -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 +20 -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,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 {};
|
package/scripts/helpers/asset.ts
DELETED
@@ -1,158 +0,0 @@
|
|
1
|
-
/* global hexo */
|
2
|
-
|
3
|
-
import type { VendorsConfig } from '../utils'
|
4
|
-
import theme_env from '../../package.json'
|
5
|
-
import { htmlTag, url_for, stripHTML } from 'hexo-util'
|
6
|
-
import { getVendorLink } from '../utils'
|
7
|
-
|
8
|
-
hexo.extend.helper.register('_new_comments', function (mode) {
|
9
|
-
const root = this.config.url.replace(/^(https?:\/\/)?[^\/]*/, '')
|
10
|
-
if (mode === 'twikoo') {
|
11
|
-
return `<script data-pjax type="module">
|
12
|
-
let comments = []
|
13
|
-
twikoo.getRecentComments({
|
14
|
-
envId: "${hexo.theme.config?.twikoo?.envId}",
|
15
|
-
pageSize: 10
|
16
|
-
}).then(function (res) {
|
17
|
-
res.forEach(function (item) {
|
18
|
-
let cText = item.commentText
|
19
|
-
if (item.commentText.length > 50) {
|
20
|
-
cText = item.commentText.substring(0,50)+'...'
|
21
|
-
}
|
22
|
-
const siteLink = item.url + "#" + item.id
|
23
|
-
comments.push({
|
24
|
-
href: siteLink,
|
25
|
-
nick: item.nick,
|
26
|
-
time: item.relativeTime,
|
27
|
-
text: cText
|
28
|
-
})
|
29
|
-
});
|
30
|
-
Vue.createApp({
|
31
|
-
data() {
|
32
|
-
return {
|
33
|
-
coms: comments,
|
34
|
-
root: '${root}'
|
35
|
-
}
|
36
|
-
}
|
37
|
-
}).mount('#new-comment')
|
38
|
-
}).catch(function (err) {
|
39
|
-
console.error(err)
|
40
|
-
})
|
41
|
-
</script>`
|
42
|
-
} else if (mode === 'waline') {
|
43
|
-
return `
|
44
|
-
<script type="module" data-pjax>
|
45
|
-
let items = []
|
46
|
-
import { RecentComments } from 'https://npm.webcache.cn/@waline/client@v2/dist/waline.mjs'
|
47
|
-
RecentComments({
|
48
|
-
serverURL: '${hexo.theme.config.waline.serverURL.replace(/\/+$/, '')}',
|
49
|
-
count: 10,
|
50
|
-
}).then(({ comments }) => {
|
51
|
-
comments.forEach(function (item) {
|
52
|
-
let cText = (item.orig.length > 50) ? item.orig.substring(0,50)+'...' : item.orig
|
53
|
-
item.url = item.url.startsWith('/') ? item.url : '/' + item.url;
|
54
|
-
const siteLink = item.url + "#" + item.objectId
|
55
|
-
items.push({
|
56
|
-
href: siteLink,
|
57
|
-
nick: item.nick,
|
58
|
-
time: item.insertedAt.split('T').shift(),
|
59
|
-
text: cText
|
60
|
-
})
|
61
|
-
})
|
62
|
-
Vue.createApp({
|
63
|
-
data() {
|
64
|
-
return {
|
65
|
-
coms: items,
|
66
|
-
root: '${root}'
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}).mount('#new-comment')
|
70
|
-
}).catch(function (err) {
|
71
|
-
console.error(err)
|
72
|
-
})
|
73
|
-
</script>
|
74
|
-
`
|
75
|
-
} else {
|
76
|
-
console.log(`${mode} is not supported recent comment`)
|
77
|
-
}
|
78
|
-
})
|
79
|
-
|
80
|
-
hexo.extend.helper.register('_safedump', (source) => {
|
81
|
-
return JSON.stringify(source)
|
82
|
-
})
|
83
|
-
|
84
|
-
hexo.extend.helper.register('hexo_env', function (type) {
|
85
|
-
return this.env[type]
|
86
|
-
})
|
87
|
-
|
88
|
-
hexo.extend.helper.register('theme_env', function (type) {
|
89
|
-
return theme_env[type]
|
90
|
-
})
|
91
|
-
|
92
|
-
hexo.extend.helper.register('_vendor_font', () => {
|
93
|
-
const config = hexo.theme.config.font
|
94
|
-
|
95
|
-
if (!config || !config.enable) return ''
|
96
|
-
|
97
|
-
const fontDisplay = '&display=swap'
|
98
|
-
const fontSubset = '&subset=latin,latin-ext'
|
99
|
-
const fontStyles = ':300,300italic,400,400italic,700,700italic'
|
100
|
-
const fontHost = 'https://fonts.googleapis.com'
|
101
|
-
|
102
|
-
// Get a font list from config
|
103
|
-
let fontFamilies = ['global', 'logo', 'title', 'headings', 'posts', 'codes'].map(item => {
|
104
|
-
if (config[item] && config[item].family && config[item].external) {
|
105
|
-
return config[item].family + fontStyles
|
106
|
-
}
|
107
|
-
return ''
|
108
|
-
})
|
109
|
-
|
110
|
-
fontFamilies = fontFamilies.filter(item => item !== '')
|
111
|
-
// @ts-ignore
|
112
|
-
fontFamilies = [...new Set(fontFamilies)]
|
113
|
-
// @ts-ignore
|
114
|
-
fontFamilies = fontFamilies.join('|')
|
115
|
-
|
116
|
-
// Merge extra parameters to the final processed font string
|
117
|
-
return fontFamilies
|
118
|
-
? htmlTag('link', {
|
119
|
-
rel: 'stylesheet',
|
120
|
-
href: `${fontHost}/css?family=${fontFamilies.concat(fontDisplay, fontSubset)}`
|
121
|
-
})
|
122
|
-
: ''
|
123
|
-
})
|
124
|
-
|
125
|
-
hexo.extend.helper.register('_css', function (...urls) {
|
126
|
-
const { statics, css } = hexo.theme.config
|
127
|
-
|
128
|
-
return urls.map(url => htmlTag('link', {
|
129
|
-
rel: 'stylesheet',
|
130
|
-
href: url_for.call(this, `${statics}${css}/${url}?v=${theme_env.version}`)
|
131
|
-
})).join('')
|
132
|
-
})
|
133
|
-
|
134
|
-
hexo.extend.helper.register('_js', function (...urls) {
|
135
|
-
const { statics, js } = hexo.theme.config
|
136
|
-
|
137
|
-
return urls.map(url => htmlTag('script', { src: url_for.call(this, `${statics}${js}/${url}?v=${theme_env.version}`) }, '')).join('')
|
138
|
-
})
|
139
|
-
|
140
|
-
hexo.extend.helper.register('vendor_js', function () {
|
141
|
-
const vendors = hexo.theme.config.vendors as VendorsConfig
|
142
|
-
let res = ''
|
143
|
-
for (const jsSync in vendors.js) {
|
144
|
-
res += htmlTag('script', { src: getVendorLink(hexo, vendors.js[jsSync]) }, '')
|
145
|
-
}
|
146
|
-
// for (const jsAsync in vendors.async_js) {
|
147
|
-
// res += htmlTag('script', { src: getVendorLink(hexo, vendors.async_js[jsAsync]), async: true }, '')
|
148
|
-
// }
|
149
|
-
return res
|
150
|
-
})
|
151
|
-
|
152
|
-
hexo.extend.helper.register('_striptags', function (data) {
|
153
|
-
return stripHTML(data)
|
154
|
-
})
|
155
|
-
|
156
|
-
hexo.extend.helper.register('_truncate', function (data, end) {
|
157
|
-
return data.substring(0, end)
|
158
|
-
})
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|