hexo-theme-shokax 0.0.1-alpha3 → 0.0.1-alpha4

Sign up to get free protection for your applications and to get access to all the features.
package/_config.yml CHANGED
@@ -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/tree/vue', 'ShokaX with Vue'))
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.0.1-alpha3",
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",
@@ -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 { env, config } = hexo
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
- locals.ccURL = 'https://creativecommons.org/' + (theme.creative_commons.license === 'zero' ? 'publicdomain/zero/1.0/' : 'licenses/' + theme.creative_commons.license + '/4.0/') + (theme.creative_commons.language || '')
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
+ }