hexo-theme-shokax 0.0.1-alpha3 → 0.0.1-alpha5
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +16 -10
- package/_config.yml +5 -0
- package/layout/_partials/footer.pug +2 -23
- package/layout/_partials/layout.pug +1 -0
- package/layout/archive.pug +87 -0
- package/layout/category.pug +4 -7
- package/package.json +1 -1
- package/scripts/filters/locals.js +7 -5
- package/scripts/generaters/config.js +1 -1
- package/scripts/generaters/script.js +10 -2
- package/scripts/plugin/index.js +58 -0
package/README.md
CHANGED
@@ -4,8 +4,9 @@
|
|
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
|
-
此项目是shoka
|
8
|
-
|
7
|
+
此项目是shoka的一个二次开发版(算精神续作),致力于提高性能和优化魔改体验 \
|
8
|
+
诞生原因是目前shoka已经两年没有更新了,积压了大量BUG和功能请求。\
|
9
|
+
本项目处于高强度开发期,但github仓库版本已基本可用 \
|
9
10
|
二次开发与常见问题请看wiki
|
10
11
|
|
11
12
|
## 待办名单
|
@@ -19,14 +20,19 @@
|
|
19
20
|
- [ ] 重构lib方法(长期计划)
|
20
21
|
- [ ] 异步化js
|
21
22
|
|
22
|
-
##
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
## 和shoka的区别
|
24
|
+
原先shoka使用了javascript+Native+nunjucks的技术 \
|
25
|
+
而shokaX则使用了typescript+Vue 3+Pug的技术搭配 \
|
26
|
+
图标库可能会更换为Font Awesome 6 \
|
27
|
+
更改了大量难以访问的CDN链接
|
28
|
+
|
29
|
+
## 如何安装?
|
30
|
+
建议使用[ShokaX-CLI](https://github.com/zkz098/shokaX-CLI) ,执行下列命令即可:
|
31
|
+
```bash
|
32
|
+
npm i shokax-cli --location=global
|
33
|
+
# hexo init 初始化环境
|
34
|
+
SXC install shokaX
|
35
|
+
```
|
30
36
|
|
31
37
|
# 许可证
|
32
38
|
许可证: MIT \
|
package/_config.yml
CHANGED
@@ -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
|
|
@@ -134,6 +134,7 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
134
134
|
!= _js('app.js')
|
135
135
|
!= partial('_partials/third-party/baidu-analytics.pug', {}, {cache: true})
|
136
136
|
!= partial('_partials/third-party/qweather.pug', {}, {cache: true})
|
137
|
+
!= partial('_partials/third-party/clarity.pug', {}, {cache: true})
|
137
138
|
!= _new_comments('twikoo')
|
138
139
|
if theme.qweather.enable
|
139
140
|
|
package/layout/archive.pug
CHANGED
@@ -29,3 +29,90 @@ block content
|
|
29
29
|
!= `${page.month}${__('symbol.month')}`
|
30
30
|
small
|
31
31
|
!= __('title.archive')
|
32
|
+
else if is_year()
|
33
|
+
a(href=url_for(config.archive_dir))
|
34
|
+
!= __('title.all')
|
35
|
+
small /
|
36
|
+
!= page.year + __('symbol.year')
|
37
|
+
small
|
38
|
+
!= __('title.archive')
|
39
|
+
else
|
40
|
+
a(href=url_for(site.path))
|
41
|
+
!= __('menu.home')
|
42
|
+
small /
|
43
|
+
- var posts_length = site.posts.length,cheers
|
44
|
+
if posts_length > 210
|
45
|
+
- cheers = 'excellent'
|
46
|
+
else if posts_length > 130
|
47
|
+
- cheers = 'great'
|
48
|
+
else if posts_length > 80
|
49
|
+
- cheers = 'good'
|
50
|
+
else if posts_length > 50
|
51
|
+
- cheers = 'nice'
|
52
|
+
else if posts_length > 30
|
53
|
+
- cheers = 'ok'
|
54
|
+
else
|
55
|
+
- cheers = 'um'
|
56
|
+
!= _p('counter.archive_posts', site.posts.length)
|
57
|
+
small(class="cheers")
|
58
|
+
!= __('cheers.' + cheers)
|
59
|
+
!= ' '
|
60
|
+
!= __('keep_on')
|
61
|
+
|
62
|
+
- var current_year = '1970'
|
63
|
+
- var current_month = '01'
|
64
|
+
- var count_post = 1
|
65
|
+
each post in page.posts.toArray()
|
66
|
+
- var year = date(post.date, 'YYYY')
|
67
|
+
- var month = date(post.date, 'MM')
|
68
|
+
if !is_year()
|
69
|
+
if year !== current_year || month !== current_month
|
70
|
+
if current_year !== '1970'
|
71
|
+
small (#{count_post})
|
72
|
+
</h3>
|
73
|
+
<h3 class="item section">
|
74
|
+
a(href=url_for(config.archive_dir + '/' + year )) #{year} #{__('symbol.year')}
|
75
|
+
small /
|
76
|
+
a(href=url_for(config.archive_dir + '/' + year + '/' + month)) #{ month } #{__('symbol.month')}
|
77
|
+
- current_year = year
|
78
|
+
- current_month = month
|
79
|
+
- count_post = 1
|
80
|
+
else
|
81
|
+
- count_post = count_post + 1
|
82
|
+
else
|
83
|
+
if year !== current_year && !is_year()
|
84
|
+
- current_year = year
|
85
|
+
h3(class="item section")
|
86
|
+
a(href=url_for(config.archive_dir + '/' + year )) #{ year } #{__('symbol.year')}
|
87
|
+
if month !== current_month && is_year() && !is_month()
|
88
|
+
- current_month = month
|
89
|
+
h3(class="item section")
|
90
|
+
a(href=url_for(config.archive_dir + '/' + year + '/' + month)) #{ month } #{__('symbol.month')}
|
91
|
+
article(class="item normal" itemscope itemtype="http://schema.org/Article")
|
92
|
+
div(class="meta")
|
93
|
+
time(
|
94
|
+
itemprop="dateCreated"
|
95
|
+
datetime=moment(post.date).format()
|
96
|
+
content=date(post.date, config.date_format)
|
97
|
+
) #{date(post.date, 'MM-DD')}
|
98
|
+
if post.categories && post.categories.length
|
99
|
+
- var cat_length = post.categories.length
|
100
|
+
each cat,index in post.categories.toArray()
|
101
|
+
if index == cat_length && cat.name !== page.category
|
102
|
+
span
|
103
|
+
a(href=url_for(cat.path)) #{cat.name}
|
104
|
+
div(class="title")
|
105
|
+
if post.link
|
106
|
+
- var postTitleIcon = '<i class="ic i-link-alt"></i>'
|
107
|
+
- var postText = post.title || post.link
|
108
|
+
!= _url(post.link, postText + postTitleIcon, {class: 'external', itemprop: 'url'})
|
109
|
+
else
|
110
|
+
- var postTitle = post.title || __('post.untitled')
|
111
|
+
a(href=url_for(post.path) itemprop="url")
|
112
|
+
span(itemprop="name") #{postTitle}
|
113
|
+
if !is_year()
|
114
|
+
small (#{count_post})
|
115
|
+
</h3>
|
116
|
+
|
117
|
+
include _partials/pagination.pug
|
118
|
+
|
package/layout/category.pug
CHANGED
@@ -11,15 +11,13 @@ block content
|
|
11
11
|
div(class="collapse wrap")
|
12
12
|
- var prev = _category_prev(page.category)
|
13
13
|
h2(class="item header")
|
14
|
-
a(href=url_for(config.category_dir))
|
15
|
-
!= __('title.all')
|
14
|
+
a(href=url_for(config.category_dir)) #{__('title.all')}
|
16
15
|
if prev
|
17
16
|
small /
|
18
17
|
!= prev
|
19
18
|
small /
|
20
19
|
!= page.title
|
21
|
-
small
|
22
|
-
!= __('title.category')
|
20
|
+
small #{__('title.category')}
|
23
21
|
- var posts = page.posts
|
24
22
|
- var current = "c"
|
25
23
|
- var lastcat = ""
|
@@ -40,7 +38,7 @@ block content
|
|
40
38
|
if index >= post.categories.toArray().length
|
41
39
|
!= cat.length
|
42
40
|
else
|
43
|
-
|
41
|
+
#{'/'}
|
44
42
|
- var lastcatslug = lastcatslug + cat.slug
|
45
43
|
if lastcat && lastcatslug && lastcatslug !== current
|
46
44
|
h3(class="item section")
|
@@ -52,8 +50,7 @@ block content
|
|
52
50
|
itemprop="dateCreated"
|
53
51
|
datetime=moment(post.date).format()
|
54
52
|
content=date(post.date, config.date_format)
|
55
|
-
)
|
56
|
-
!= date(post.date, 'MM-DD')
|
53
|
+
) #{date(post.date, 'MM-DD')}
|
57
54
|
div(class="title")
|
58
55
|
if post.link
|
59
56
|
- var postTitleIcon = '<i class="ic i-link-alt"></i>'
|
package/package.json
CHANGED
@@ -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)
|
@@ -35,7 +35,7 @@ hexo.extend.filter.register('before_generate', () => {
|
|
35
35
|
}
|
36
36
|
}
|
37
37
|
|
38
|
-
if (data.images && data.images.length
|
38
|
+
if (data.images && data.images.length >= 6) {
|
39
39
|
hexo.theme.config.image_list = data.images
|
40
40
|
} else {
|
41
41
|
hexo.theme.config.image_list = yaml.load(fs.readFileSync(path.join(__dirname, '../../_images.yml')))
|
@@ -61,10 +61,18 @@ hexo.extend.generator.register('script', function (locals) {
|
|
61
61
|
let text = '';
|
62
62
|
|
63
63
|
['library', 'global', 'page', 'vue', 'components'].forEach(function (item) {
|
64
|
-
|
64
|
+
if (fs.existsSync(`themes/shokaX/source/js/_app/${item}.js`)) {
|
65
|
+
text += fs.readFileSync(`themes/shokaX/source/js/_app/${item}.js`).toString()
|
66
|
+
} else {
|
67
|
+
text += fs.readFileSync(`node_modules/hexo-theme-shokax/source/js/_app/${item}.js`).toString()
|
68
|
+
}
|
65
69
|
})
|
66
70
|
if (!theme.experiments?.noPlayer) {
|
67
|
-
|
71
|
+
if (fs.existsSync('themes/shokaX/source/js/_app/player.js')) {
|
72
|
+
text += fs.readFileSync('themes/shokaX/source/js/_app/player.js').toString()
|
73
|
+
} else {
|
74
|
+
text += fs.readFileSync('node_modules/hexo-theme-shokax/source/js/_app/player.js').toString()
|
75
|
+
}
|
68
76
|
}
|
69
77
|
if (theme.fireworks && theme.fireworks.enable) {
|
70
78
|
siteConfig.fireworks = theme.fireworks.color || ['rgba(255,182,185,.9)', 'rgba(250,227,217,.9)', 'rgba(187,222,214,.9)', 'rgba(138,198,209,.9)']
|
@@ -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
|
+
}
|