hexo-theme-shokax 0.2.9 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
package/_config.yml CHANGED
@@ -63,13 +63,13 @@ visitor:
63
63
  baiduAnalytics: false
64
64
  googleAnalytics: false
65
65
 
66
- darkmode: false
66
+ darkmode: true
67
67
  auto_dark: # 自动亮/暗模式
68
68
  enable: true #是否开启
69
69
  start: 20 #开始时间
70
70
  end: 7 #结束时间
71
71
 
72
- auto_scroll: true
72
+ auto_scroll: false
73
73
 
74
74
  loader:
75
75
  start: true # 进入页面时显示加载动画
@@ -253,7 +253,7 @@ widgets:
253
253
  recent_comments: true
254
254
 
255
255
  footer:
256
- # Specify the date when the site was setup. If not defined, current year will be used.
256
+ # Specify the date when the site was set up. If not defined, current year will be used.
257
257
  since: 2022
258
258
  icon:
259
259
  name: sakura rotate
@@ -278,7 +278,7 @@ post:
278
278
 
279
279
  # 文章是否失效
280
280
  outime:
281
- enable: true
281
+ enable: false
282
282
  days: 90 # 超过 90 天文章失效
283
283
 
284
284
  reward:
@@ -34,7 +34,8 @@ mixin CommentRender()
34
34
  wordLimit: #{theme.waline.wordLimit},
35
35
  pageSize: #{theme.waline.pageSize},
36
36
  pageview: #{theme.waline.pageview},
37
- path: path
37
+ path: path,
38
+ dark: 'html[data-theme="dark"]'
38
39
  });
39
40
  }, 1000)
40
41
  else if gt
@@ -83,15 +83,15 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
83
83
  empty: "!{__('search.empty')}",
84
84
  stats: "!{__('search.stats')}"
85
85
  },
86
- valine: `#{page.valine ? _safedump(page.valine) : 'true'}`,
87
- chart: `#{page.chart ? 'true' : 'false'}`,
88
- copy_tex: `#{page.math ? 'true' : 'false'}`,
89
- katex: `#{page.math ? 'true' : 'false'}`,
90
- mermaid: `#{page.mermaid ? 'true' : 'false'}`,
86
+ valine: #{page.valine ? _safedump(page.valine) : true},
87
+ chart: #{!!page.chart},
88
+ copy_tex: #{!!page.math},
89
+ katex: #{!!page.math},
90
+ mermaid: #{!!page.mermaid},
91
91
  audio: `#{_safedump(page.audio)}`,
92
- fancybox: `#{page.fancybox !== false ? 'true' : 'false'}`,
93
- nocopy: `#{page.nocopy ? 'true' : 'false'}`,
94
- outime: `#{page.outime !== false ? 'true' : 'false'}`,
92
+ fancybox: #{page.fancybox !== false},
93
+ nocopy: #{!!page.nocopy},
94
+ outime: #{page.outime !== false},
95
95
  template: `#{__('outime.template')}`,
96
96
  quiz: {
97
97
  choice: `#{__('quiz.choice')}`,
package/layout/post.pug CHANGED
@@ -11,7 +11,8 @@ block title
11
11
  each cat in page.categories.toArray()
12
12
  - var cat_list = cat.name + comma + cat_list
13
13
  - var comma = ' - '
14
- - var page_title = page.title + ' - ' + cat_list
14
+ if cat_list.length !== 0
15
+ - var page_title = page.title + ' - ' + cat_list
15
16
  != `${page_title}`
16
17
 
17
18
  block header
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "a hexo theme based on shoka",
5
5
  "main": "index.js",
6
6
  "repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX",
@@ -1,4 +1,4 @@
1
- const sideBarToggleHandle = function (event, force) {
1
+ const sideBarToggleHandle = (event, force) => {
2
2
  if (sideBar.hasClass('on')) {
3
3
  sideBar.removeClass('on');
4
4
  menuToggle.removeClass('close');
@@ -14,25 +14,24 @@ const sideBarToggleHandle = function (event, force) {
14
14
  sideBar.style = '';
15
15
  }
16
16
  else {
17
- transition(sideBar, 'slideRightIn', function () {
17
+ transition(sideBar, 'slideRightIn', () => {
18
18
  sideBar.addClass('on');
19
19
  menuToggle.addClass('close');
20
20
  });
21
21
  }
22
22
  }
23
23
  };
24
- const sideBarTab = function () {
24
+ const sideBarTab = () => {
25
25
  const sideBarInner = sideBar.child('.inner');
26
- const panels = sideBar.find('.panel');
27
26
  if (sideBar.child('.tab')) {
28
27
  sideBarInner.removeChild(sideBar.child('.tab'));
29
28
  }
30
29
  const list = document.createElement('ul');
31
30
  let active = 'active';
32
31
  list.className = 'tab';
33
- ['contents', 'related', 'overview'].forEach(function (item) {
32
+ ['contents', 'related', 'overview'].forEach((item) => {
34
33
  const element = sideBar.child('.panel.' + item);
35
- if (element.innerHTML.replace(/(^\s*)|(\s*$)/g, '').length < 1) {
34
+ if (element.innerHTML.trim().length < 1) {
36
35
  if (item === 'contents') {
37
36
  showContents.display('none');
38
37
  }
@@ -54,14 +53,14 @@ const sideBarTab = function () {
54
53
  else {
55
54
  element.removeClass('active');
56
55
  }
57
- tab.addEventListener('click', function (event) {
56
+ tab.addEventListener('click', (event) => {
58
57
  const target = event.currentTarget;
59
58
  if (target.hasClass('active'))
60
59
  return;
61
- sideBar.find('.tab .item').forEach(function (element) {
60
+ sideBar.find('.tab .item').forEach((element) => {
62
61
  element.removeClass('active');
63
62
  });
64
- sideBar.find('.panel').forEach(function (element) {
63
+ sideBar.find('.panel').forEach((element) => {
65
64
  element.removeClass('active');
66
65
  });
67
66
  sideBar.child('.panel.' + target.className.replace(' item', '')).addClass('active');
@@ -78,18 +77,18 @@ const sideBarTab = function () {
78
77
  sideBar.child('.panels').style.paddingTop = '.625rem';
79
78
  }
80
79
  };
81
- const sidebarTOC = function () {
82
- const activateNavByIndex = function (index, lock) {
80
+ const sidebarTOC = () => {
81
+ const activateNavByIndex = (index) => {
83
82
  const target = navItems[index];
84
83
  if (!target)
85
84
  return;
86
85
  if (target.hasClass('current')) {
87
86
  return;
88
87
  }
89
- $dom.each('.toc .active', function (element) {
88
+ $dom.each('.toc .active', (element) => {
90
89
  element && element.removeClass('active current');
91
90
  });
92
- sections.forEach(function (element) {
91
+ sections.forEach((element) => {
93
92
  element && element.removeClass('active');
94
93
  });
95
94
  target.addClass('active current');
@@ -113,32 +112,32 @@ const sidebarTOC = function () {
113
112
  if (navItems.length < 1) {
114
113
  return;
115
114
  }
116
- let sections = Array.prototype.slice.call(navItems) || [];
115
+ let sections = [...navItems];
117
116
  let activeLock = null;
118
- sections = sections.map(function (element, index) {
117
+ sections = sections.map((element, index) => {
119
118
  const link = element.child('a.toc-link');
120
119
  const anchor = $dom(decodeURI(link.attr('href')));
121
120
  if (!anchor)
122
121
  return null;
123
122
  const alink = anchor.child('a.anchor');
124
- const anchorScroll = function (event) {
123
+ const anchorScroll = (event) => {
125
124
  event.preventDefault();
126
125
  const target = $dom(decodeURI(event.currentTarget.attr('href')));
127
126
  activeLock = index;
128
- pageScroll(target, null, function () {
127
+ pageScroll(target, null, () => {
129
128
  activateNavByIndex(index);
130
129
  activeLock = null;
131
130
  });
132
131
  };
133
132
  link.addEventListener('click', anchorScroll);
134
- alink && alink.addEventListener('click', function (event) {
133
+ alink && alink.addEventListener('click', (event) => {
135
134
  anchorScroll(event);
136
135
  clipBoard(CONFIG.hostname + '/' + LOCAL.path + event.currentTarget.attr('href'));
137
136
  });
138
137
  return anchor;
139
138
  });
140
139
  const tocElement = sideBar.child('.contents.panel');
141
- const findIndex = function (entries) {
140
+ const findIndex = (entries) => {
142
141
  let index = 0;
143
142
  let entry = entries[index];
144
143
  if (entry.boundingClientRect.top > 0) {
@@ -155,8 +154,8 @@ const sidebarTOC = function () {
155
154
  }
156
155
  return sections.indexOf(entry.target);
157
156
  };
158
- const createIntersectionObserver = function () {
159
- const observer = new IntersectionObserver(function (entries, observe) {
157
+ const createIntersectionObserver = () => {
158
+ const observer = new IntersectionObserver((entries) => {
160
159
  const index = findIndex(entries) + (diffY < 0 ? 1 : 0);
161
160
  if (activeLock === null) {
162
161
  activateNavByIndex(index);
@@ -164,23 +163,23 @@ const sidebarTOC = function () {
164
163
  }, {
165
164
  rootMargin: '0px 0px -100% 0px', threshold: 0
166
165
  });
167
- sections.forEach(function (element) {
166
+ sections.forEach((element) => {
168
167
  element && observer.observe(element);
169
168
  });
170
169
  };
171
170
  createIntersectionObserver();
172
171
  };
173
- const backToTopHandle = function () {
172
+ const backToTopHandle = () => {
174
173
  pageScroll(0);
175
174
  };
176
- const goToBottomHandle = function () {
175
+ const goToBottomHandle = () => {
177
176
  pageScroll(parseInt(String(Container.changeOrGetHeight())));
178
177
  };
179
- const goToCommentHandle = function () {
178
+ const goToCommentHandle = () => {
180
179
  pageScroll($dom('#comments'));
181
180
  };
182
- const menuActive = function () {
183
- $dom.each('.menu .item:not(.title)', function (element) {
181
+ const menuActive = () => {
182
+ $dom.each('.menu .item:not(.title)', (element) => {
184
183
  const target = element.child('a[href]');
185
184
  const parentItem = element.parentNode.parentNode;
186
185
  if (!target)
@@ -29,51 +29,41 @@ function setParticuleDirection(p) {
29
29
  }
30
30
  function createParticule(x, y) {
31
31
  const p = {
32
- x: undefined,
33
- y: undefined,
32
+ x,
33
+ y,
34
34
  color: undefined,
35
35
  radius: undefined,
36
36
  endPos: undefined,
37
- draw: undefined
37
+ draw() {
38
+ ctx.beginPath();
39
+ ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
40
+ ctx.fillStyle = p.color;
41
+ ctx.fill();
42
+ }
38
43
  };
39
- p.x = x;
40
- p.y = y;
41
44
  p.color = colors[anime.random(0, colors.length - 1)];
42
45
  p.radius = anime.random(16, 32);
43
46
  p.endPos = setParticuleDirection(p);
44
- p.draw = function () {
45
- ctx.beginPath();
46
- ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
47
- ctx.fillStyle = p.color;
48
- ctx.fill();
49
- };
50
47
  return p;
51
48
  }
52
49
  function createCircle(x, y) {
53
50
  const p = {
54
- x: undefined,
55
- y: undefined,
56
- color: undefined,
57
- radius: undefined,
51
+ x,
52
+ y,
53
+ color: '#FFF',
54
+ radius: 0.1,
58
55
  endPos: undefined,
59
- alpha: undefined,
60
- lineWidth: undefined,
61
- draw: undefined
62
- };
63
- p.x = x;
64
- p.y = y;
65
- p.color = '#FFF';
66
- p.radius = 0.1;
67
- p.alpha = 0.5;
68
- p.lineWidth = 6;
69
- p.draw = function () {
70
- ctx.globalAlpha = p.alpha;
71
- ctx.beginPath();
72
- ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
73
- ctx.lineWidth = p.lineWidth;
74
- ctx.strokeStyle = p.color;
75
- ctx.stroke();
76
- ctx.globalAlpha = 1;
56
+ alpha: 0.5,
57
+ lineWidth: 6,
58
+ draw() {
59
+ ctx.globalAlpha = p.alpha;
60
+ ctx.beginPath();
61
+ ctx.arc(p.x, p.y, p.radius, 0, 2 * Math.PI, true);
62
+ ctx.lineWidth = p.lineWidth;
63
+ ctx.strokeStyle = p.color;
64
+ ctx.stroke();
65
+ ctx.globalAlpha = 1;
66
+ }
77
67
  };
78
68
  return p;
79
69
  }
@@ -93,12 +83,8 @@ function animateParticules(x, y) {
93
83
  duration: anime.random(1200, 1800),
94
84
  easing: 'easeOutExpo',
95
85
  update: renderParticule,
96
- x: function (p) {
97
- return p.endPos.x;
98
- },
99
- y: function (p) {
100
- return p.endPos.y;
101
- },
86
+ x: p => p.endPos.x,
87
+ y: p => p.endPos.y,
102
88
  radius: 0.1
103
89
  }).add({
104
90
  targets: circle,
@@ -116,11 +102,11 @@ function animateParticules(x, y) {
116
102
  }
117
103
  const render = anime({
118
104
  duration: Infinity,
119
- update: function () {
105
+ update() {
120
106
  ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);
121
107
  }
122
108
  });
123
- const hasAncestor = function (node, name) {
109
+ const hasAncestor = (node, name) => {
124
110
  name = name.toUpperCase();
125
111
  do {
126
112
  if (node === null || node === undefined)
@@ -130,7 +116,7 @@ const hasAncestor = function (node, name) {
130
116
  } while ((node = node.parentNode) !== null);
131
117
  return false;
132
118
  };
133
- document.addEventListener(tap, function (e) {
119
+ document.addEventListener(tap, (e) => {
134
120
  if (hasAncestor(e.target, 'a')) {
135
121
  return;
136
122
  }
@@ -24,7 +24,7 @@ let oWinWidth = window.innerWidth;
24
24
  let LOCAL_HASH = 0;
25
25
  let LOCAL_URL = window.location.href;
26
26
  let pjax;
27
- const changeTheme = function (type) {
27
+ const changeTheme = (type) => {
28
28
  const btn = $dom('.theme .ic');
29
29
  if (type === 'dark') {
30
30
  HTML.attr('data-theme', type);
@@ -37,7 +37,7 @@ const changeTheme = function (type) {
37
37
  btn.addClass('i-sun');
38
38
  }
39
39
  };
40
- const autoDarkmode = function () {
40
+ const autoDarkmode = () => {
41
41
  if (CONFIG.auto_dark.enable) {
42
42
  if (new Date().getHours() >= CONFIG.auto_dark.start || new Date().getHours() <= CONFIG.auto_dark.end) {
43
43
  changeTheme('dark');
@@ -48,26 +48,26 @@ const autoDarkmode = function () {
48
48
  }
49
49
  };
50
50
  const lazyload = lozad('img, [data-background-image]', {
51
- loaded: function (el) {
51
+ loaded(el) {
52
52
  el.addClass('lozaded');
53
53
  }
54
54
  });
55
55
  const Loader = {
56
56
  timer: undefined,
57
57
  lock: false,
58
- show: function () {
58
+ show() {
59
59
  clearTimeout(this.timer);
60
60
  document.body.removeClass('loaded');
61
61
  loadCat.attr('style', 'display:block');
62
62
  Loader.lock = false;
63
63
  },
64
- hide: function (sec) {
64
+ hide(sec) {
65
65
  if (!CONFIG.loader.start) {
66
66
  sec = -1;
67
67
  }
68
68
  this.timer = setTimeout(this.vanish, sec || 3000);
69
69
  },
70
- vanish: function () {
70
+ vanish() {
71
71
  if (Loader.lock) {
72
72
  return;
73
73
  }
@@ -78,14 +78,14 @@ const Loader = {
78
78
  Loader.lock = true;
79
79
  }
80
80
  };
81
- const changeMetaTheme = function (color) {
81
+ const changeMetaTheme = (color) => {
82
82
  if (HTML.attr('data-theme') === 'dark') {
83
83
  color = '#222';
84
84
  }
85
85
  $dom('meta[name="theme-color"]').attr('content', color);
86
86
  };
87
- const themeColorListener = function () {
88
- window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function (mediaQueryList) {
87
+ const themeColorListener = () => {
88
+ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (mediaQueryList) => {
89
89
  if (mediaQueryList.matches) {
90
90
  changeTheme('dark');
91
91
  }
@@ -103,9 +103,9 @@ const themeColorListener = function () {
103
103
  }
104
104
  }
105
105
  };
106
- const visibilityListener = function () {
106
+ const visibilityListener = () => {
107
107
  const iconNode = $dom('[rel="icon"]');
108
- document.addEventListener('visibilitychange', function () {
108
+ document.addEventListener('visibilitychange', () => {
109
109
  switch (document.visibilityState) {
110
110
  case 'hidden':
111
111
  iconNode.attr('href', statics + CONFIG.favicon.hidden);
@@ -121,14 +121,14 @@ const visibilityListener = function () {
121
121
  if (CONFIG.loader.switch) {
122
122
  Loader.hide(1000);
123
123
  }
124
- titleTime = setTimeout(function () {
124
+ titleTime = setTimeout(() => {
125
125
  document.title = originTitle;
126
126
  }, 2000);
127
127
  break;
128
128
  }
129
129
  });
130
130
  };
131
- const showtip = function (msg) {
131
+ const showtip = (msg) => {
132
132
  if (!msg) {
133
133
  return;
134
134
  }
@@ -136,14 +136,14 @@ const showtip = function (msg) {
136
136
  innerHTML: msg,
137
137
  className: 'tip'
138
138
  });
139
- setTimeout(function () {
139
+ setTimeout(() => {
140
140
  tipbox.addClass('hide');
141
- setTimeout(function () {
141
+ setTimeout(() => {
142
142
  BODY.removeChild(tipbox);
143
143
  }, 300);
144
144
  }, 3000);
145
145
  };
146
- const resizeHandle = function (event) {
146
+ const resizeHandle = (event) => {
147
147
  siteNavHeight = siteNav.changeOrGetHeight();
148
148
  headerHightInner = siteHeader.changeOrGetHeight();
149
149
  headerHight = headerHightInner + $dom('#waves').changeOrGetHeight();
@@ -153,7 +153,7 @@ const resizeHandle = function (event) {
153
153
  oWinHeight = window.innerHeight;
154
154
  oWinWidth = window.innerWidth;
155
155
  };
156
- const scrollHandle = function (event) {
156
+ const scrollHandle = (event) => {
157
157
  const winHeight = window.innerHeight;
158
158
  const docHeight = getDocHeight();
159
159
  const contentVisibilityHeight = docHeight > winHeight ? docHeight - winHeight : document.body.scrollHeight - winHeight;
@@ -191,12 +191,12 @@ const scrollHandle = function (event) {
191
191
  $dom('.percent').changeOrGetWidth(scrollPercent);
192
192
  }
193
193
  };
194
- const pagePosition = function () {
194
+ const pagePosition = () => {
195
195
  if (CONFIG.auto_scroll) {
196
196
  $storage.set(LOCAL_URL, String(scrollAction.y));
197
197
  }
198
198
  };
199
- const positionInit = function (comment) {
199
+ const positionInit = (comment) => {
200
200
  const anchor = window.location.hash;
201
201
  let target = null;
202
202
  if (LOCAL_HASH) {
@@ -218,7 +218,7 @@ const positionInit = function (comment) {
218
218
  LOCAL_HASH = 1;
219
219
  }
220
220
  };
221
- const clipBoard = function (str, callback) {
221
+ const clipBoard = (str, callback) => {
222
222
  if (navigator.clipboard && window.isSecureContext) {
223
223
  navigator.clipboard.writeText(str).then(() => {
224
224
  callback && callback(true);
@@ -251,7 +251,7 @@ const clipBoard = function (str, callback) {
251
251
  BODY.removeChild(ta);
252
252
  }
253
253
  };
254
- const isOutime = function () {
254
+ const isOutime = () => {
255
255
  let updateTime;
256
256
  if (CONFIG.outime.enable && LOCAL.outime) {
257
257
  const times = document.getElementsByTagName('time');
@@ -280,7 +280,7 @@ const isOutime = function () {
280
280
  }
281
281
  }
282
282
  };
283
- const clickMenu = function () {
283
+ const clickMenu = () => {
284
284
  const menuElement = $dom('#clickMenu');
285
285
  window.oncontextmenu = function (event) {
286
286
  if (event.ctrlKey) {
@@ -308,7 +308,7 @@ const clickMenu = function () {
308
308
  }
309
309
  });
310
310
  };
311
- window.addEventListener('click', function () {
311
+ window.addEventListener('click', () => {
312
312
  menuElement.classList.remove('active');
313
313
  });
314
314
  };