hexo-theme-shokax 0.0.1-alpha2 → 0.0.1-alpha4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/_config.yml +7 -2
- package/layout/_partials/footer.pug +2 -23
- package/layout/_partials/head/pwa.pug +15 -14
- package/layout/_partials/layout.pug +5 -3
- package/layout/_partials/third-party/baidu-analytics.pug +3 -3
- package/layout/_partials/third-party/qweather.pug +1 -1
- package/package.json +4 -4
- package/scripts/filters/locals.js +7 -5
- package/scripts/plugin/index.js +58 -0
package/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fzkz098%2Fhexo-theme-shokaX.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fzkz098%2Fhexo-theme-shokaX?ref=badge_shield)
|
3
3
|
![LICENSE]( https://img.shields.io/github/license/zkz098/hexo-theme-shokaX)
|
4
4
|
![stars](https://img.shields.io/github/stars/zkz098/hexo-theme-shokaX)
|
5
|
-
|
5
|
+
![version](https://shields.io/npm/v/hexo-theme-shokax)
|
6
6
|
|
7
7
|
此项目是shoka的一个魔改版,致力于提高性能和优化魔改体验 \
|
8
8
|
本项目处于高强度开发期,但github仓库版本已基本可用 \s
|
package/_config.yml
CHANGED
@@ -24,14 +24,13 @@ pwa:
|
|
24
24
|
experiments:
|
25
25
|
noPlayer: false # 禁用音乐播放器
|
26
26
|
gradient: false # 使用CSS渐变作为文章封面
|
27
|
-
gradientCover: "" # 当gradient为true时使用的主页面cover
|
27
|
+
gradientCover: "" # 当gradient为true时使用的主页面cover(为空则使用bing随机图片)
|
28
28
|
debug: false # 使用debug模式启动
|
29
29
|
|
30
30
|
icon:
|
31
31
|
favicon: "/favicon.ico"
|
32
32
|
apple_touch_icon: "/apple-touch-icon.png"
|
33
33
|
|
34
|
-
baidu_analytics: ""
|
35
34
|
seo:
|
36
35
|
bing: "bing-key"
|
37
36
|
google: "google-key"
|
@@ -40,6 +39,7 @@ seo:
|
|
40
39
|
|
41
40
|
visitor:
|
42
41
|
clarity: false
|
42
|
+
baiduAnalytics: false
|
43
43
|
|
44
44
|
darkmode: false
|
45
45
|
auto_dark: # 自动亮/暗模式
|
@@ -47,6 +47,11 @@ auto_dark: # 自动亮/暗模式
|
|
47
47
|
start: 20 #开始时间
|
48
48
|
end: 7 #结束时间
|
49
49
|
|
50
|
+
plugin:
|
51
|
+
enable: false
|
52
|
+
load:
|
53
|
+
# - example
|
54
|
+
|
50
55
|
auto_scroll: true
|
51
56
|
|
52
57
|
loader:
|
@@ -23,7 +23,7 @@ div(class="status")
|
|
23
23
|
//- span(id="times")
|
24
24
|
if theme.footer.powered
|
25
25
|
div(class="powered-by")
|
26
|
-
!= __('footer.powered', _url('https://hexo.io', 'Hexo') + ' & Theme.' + _url('https://github.com/zkz098/hexo-theme-shokaX/
|
26
|
+
!= __('footer.powered', _url('https://hexo.io', 'Hexo') + ' & Theme.' + _url('https://github.com/zkz098/hexo-theme-shokaX/', 'ShokaX'))
|
27
27
|
if theme.footer.icp.enable
|
28
28
|
br
|
29
29
|
span(style="display:inline;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;")
|
@@ -36,26 +36,5 @@ div(class="status")
|
|
36
36
|
img(src=theme.statics + theme.assets + '/' + theme.footer.icp.icon style="max-width: 2em;display:inline;")
|
37
37
|
!= beianN
|
38
38
|
|
39
|
-
|
40
|
-
if theme.footer.lantern.enable
|
41
|
-
div(class="deng-box")
|
42
|
-
div(class="deng")
|
43
|
-
div(class="xian")
|
44
|
-
div(class="deng-a")
|
45
|
-
div(class="deng-b")
|
46
|
-
div(class="deng-t")
|
47
|
-
!= theme.footer.lantern.word2
|
48
|
-
div(class="shui shui-a")
|
49
|
-
div(class="shui-c")
|
50
|
-
div(class="shui-b")
|
51
|
-
div(class="deng-box1")
|
52
|
-
div(class="deng")
|
53
|
-
div(class="xian")
|
54
|
-
div(class="deng-a")
|
55
|
-
div(class="deng-b")
|
56
|
-
div(class="deng-t")
|
57
|
-
!= theme.footer.lantern.word1
|
58
|
-
div(class="shui shui-a")
|
59
|
-
div(class="shui-c")
|
60
|
-
div(class="shui-b")
|
39
|
+
!= insert_footer()
|
61
40
|
|
@@ -1,17 +1,18 @@
|
|
1
1
|
//- https://blog.cyfan.top/p/c0af86bb.html#%E5%AE%89%E8%A3%85-Install
|
2
|
+
- var timeNow = new Date().getTime()
|
2
3
|
if theme.pwa.enable
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
4
|
+
- var sworker = theme.pwa.serviceworker
|
5
|
+
script(data-pjax async).
|
6
|
+
if ('serviceWorker' in navigator) {
|
7
|
+
navigator.serviceWorker.register("/#{sworker}?time=#{timeNow}").then(async (reg) => {
|
8
|
+
if (window.localStorage.getItem('install') !== 'true') {
|
9
|
+
window.localStorage.setItem('install', 'true');
|
10
|
+
setTimeout(() => {
|
11
|
+
window.location.reload()
|
12
|
+
}, 500)
|
13
|
+
}
|
14
|
+
}).catch(err => {
|
15
|
+
console.log(err)
|
16
|
+
});
|
17
|
+
}
|
17
18
|
link(rel="manifest" href=`/${theme.pwa.manifest}`)
|
@@ -31,8 +31,9 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
31
31
|
!= partial('_partials/header.pug', {}, {cache: true})
|
32
32
|
div(id="imgs" class="pjax")
|
33
33
|
if theme.experiments.gradient
|
34
|
-
|
35
|
-
|
34
|
+
//- cover不可用时用Bing随机图片代替
|
35
|
+
- var coverImage = theme?.experiments?.gradientCover || "https://7ed.net/bing/api"
|
36
|
+
img(src=coverImage)
|
36
37
|
else
|
37
38
|
- var covers = _cover(page, 6)
|
38
39
|
if covers.length === 6
|
@@ -101,7 +102,7 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
101
102
|
if page.outime === false
|
102
103
|
| outime: false,
|
103
104
|
else
|
104
|
-
| outime: true,template:
|
105
|
+
| outime: true,template: `!{ __('outime.template') }`,
|
105
106
|
if page.quiz
|
106
107
|
| quiz: {
|
107
108
|
!= `choice: \'${__('quiz.choice')}\',`
|
@@ -133,6 +134,7 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
133
134
|
!= _js('app.js')
|
134
135
|
!= partial('_partials/third-party/baidu-analytics.pug', {}, {cache: true})
|
135
136
|
!= partial('_partials/third-party/qweather.pug', {}, {cache: true})
|
137
|
+
!= partial('_partials/third-party/clarity.pug', {}, {cache: true})
|
136
138
|
!= _new_comments('twikoo')
|
137
139
|
if theme.qweather.enable
|
138
140
|
|
@@ -1,10 +1,10 @@
|
|
1
|
-
- var hmSrc = `https://hm.baidu.com/hm.js?${ theme.
|
2
|
-
if theme.
|
1
|
+
- var hmSrc = `https://hm.baidu.com/hm.js?${ theme.visitor.baiduAnalytics }`
|
2
|
+
if theme.visitor.baiduAnalytics
|
3
3
|
script(data-pjax=true).
|
4
4
|
var _hmt = _hmt || [];
|
5
5
|
(function () {
|
6
6
|
const hm = document.createElement("script");
|
7
|
-
hm.src = #{hmSrc}
|
7
|
+
hm.src = "#{hmSrc}"
|
8
8
|
hm.async = true;
|
9
9
|
const s = document.getElementsByTagName("script")[0];
|
10
10
|
s.parentNode.insertBefore(hm, s);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hexo-theme-shokax",
|
3
|
-
"version": "0.0.1-
|
3
|
+
"version": "0.0.1-alpha4",
|
4
4
|
"description": "a hexo theme based on shoka",
|
5
5
|
"main": "index.js",
|
6
6
|
"repository": "https://github.com/zkz098/hexo-theme-shokaX",
|
@@ -16,10 +16,10 @@
|
|
16
16
|
"@types/jquery": "^3.5.14",
|
17
17
|
"@types/js-yaml": "^4.0.5",
|
18
18
|
"@types/lozad": "^1.16.1",
|
19
|
-
"@types/node": "^18.11.
|
19
|
+
"@types/node": "^18.11.18",
|
20
20
|
"@types/shelljs": "^0.8.11",
|
21
|
-
"@typescript-eslint/eslint-plugin": "^5.47.
|
22
|
-
"@typescript-eslint/parser": "^5.47.
|
21
|
+
"@typescript-eslint/eslint-plugin": "^5.47.1",
|
22
|
+
"@typescript-eslint/parser": "^5.47.1",
|
23
23
|
"eslint": "^8.30.0",
|
24
24
|
"eslint-config-standard": "^17.0.0",
|
25
25
|
"eslint-plugin-import": "^2.26.0",
|
@@ -1,21 +1,19 @@
|
|
1
1
|
'use strict'
|
2
2
|
/* global hexo */
|
3
|
-
const path = require('path')
|
4
|
-
const url = require('url')
|
5
3
|
|
6
4
|
const fmtNum = num => {
|
7
5
|
return num < 10 ? '0' + num : num
|
8
6
|
}
|
9
7
|
|
10
8
|
hexo.extend.filter.register('template_locals', locals => {
|
11
|
-
const {
|
9
|
+
const { config } = hexo
|
12
10
|
const { __, theme } = locals
|
13
11
|
const { i18n } = hexo.theme
|
14
12
|
|
15
13
|
const pangu = theme.pangu
|
16
14
|
? require('pangu')
|
17
15
|
: {
|
18
|
-
spacing: data => {
|
16
|
+
spacing: (data) => {
|
19
17
|
return data
|
20
18
|
}
|
21
19
|
}
|
@@ -32,7 +30,11 @@ hexo.extend.filter.register('template_locals', locals => {
|
|
32
30
|
locals.hostname = new URL(config.url).hostname || config.url
|
33
31
|
|
34
32
|
// Creative Commons
|
35
|
-
|
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
|
+
}
|
36
38
|
|
37
39
|
if (locals.page.title) {
|
38
40
|
locals.page.title = pangu.spacing(locals.page.title)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
/* global hexo */
|
2
|
+
'use strict'
|
3
|
+
|
4
|
+
/** @type {Map<string, string[]>} */
|
5
|
+
const insertions = new Map()
|
6
|
+
class TemplateBlock {
|
7
|
+
constructor (text, type = 'raw') {
|
8
|
+
this.text = text
|
9
|
+
this.type = type
|
10
|
+
this.result = ''
|
11
|
+
}
|
12
|
+
|
13
|
+
render () {
|
14
|
+
if (this.type === 'raw' || this.type === 'html') {
|
15
|
+
this.result = this.text
|
16
|
+
}
|
17
|
+
this.result = hexo.render.renderSync({ text: this.text, engine: this.type })
|
18
|
+
}
|
19
|
+
|
20
|
+
repalceTag (...tag) {
|
21
|
+
tag.forEach((item) => {
|
22
|
+
this.text = this.text.replace(item.tag, item.value)
|
23
|
+
})
|
24
|
+
}
|
25
|
+
|
26
|
+
insert (location) {
|
27
|
+
if (insertions.get(location)) {
|
28
|
+
insertions.get(location).push(this.result)
|
29
|
+
} else {
|
30
|
+
insertions.set(location, [])
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
const toolpack = {
|
36
|
+
TemplateBlock
|
37
|
+
}
|
38
|
+
|
39
|
+
hexo.extend.helper.register('insert_footer', () => {
|
40
|
+
if (hexo.theme.config?.plugin?.enable && insertions.get('footer')) {
|
41
|
+
let res = ''
|
42
|
+
insertions.get('footer').forEach((item) => {
|
43
|
+
res += item
|
44
|
+
})
|
45
|
+
return res
|
46
|
+
}
|
47
|
+
})
|
48
|
+
|
49
|
+
if (hexo.theme.config?.plugin?.enable) {
|
50
|
+
hexo.theme.config.plugin.load.forEach((item) => {
|
51
|
+
const p = require(item)
|
52
|
+
console.log(p)
|
53
|
+
if (p.prepare) {
|
54
|
+
p.prepare(hexo, this)
|
55
|
+
}
|
56
|
+
p.main(hexo, this, toolpack)
|
57
|
+
})
|
58
|
+
}
|