hexo-theme-shokax 0.3.5 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,6 +1,3 @@
1
- # 📣 公告
2
- * [ShokaX 正在寻找社区维护者](https://github.com/theme-shoka-x/hexo-theme-shokaX/discussions/137)
3
-
4
1
  # hexo-theme-shokaX
5
2
  ![LICENSE]( https://img.shields.io/github/license/theme-shoka-x/hexo-theme-shokaX)
6
3
  ![stars](https://img.shields.io/github/stars/theme-shoka-x/hexo-theme-shokaX)
@@ -44,11 +41,6 @@ SXC install shokaX
44
41
  ```
45
42
  [点此](https://docs.kaitaku.xyz/guide/#%E9%85%8D%E7%BD%AE%E4%B8%BB%E9%A2%98)以进行下一步配置
46
43
 
47
- github仓库建议通过右边的 releases 下载,步骤为:
48
- - 点击 Releases 的 Latest 版本
49
- - 下载 Assets 中的 `Source code(zip)`
50
- - 解压即可作为主题使用
51
-
52
44
  ## 📚子项目
53
45
  - [ShokaX docs](https://github.com/theme-shoka-x/shokaX-docs) ShokaX 主题文档 (正在编写中,欢迎加入!)
54
46
  - [HRMNMI](https://github.com/theme-shoka-x/hexo-renderer-multi-next-markdown-it) ShokaX 正在使用的 markdown 渲染器 (等待重构)
package/README_en.MD CHANGED
@@ -37,11 +37,6 @@ Note: This project requires node.js 18.x or higher to run. \
37
37
  It is recommended to use [ShokaX-CLI](https://github.com/zkz098/shokaX-CLI) \
38
38
  [Click here](https://docs.kaitaku.xyz/guide/#%E9%85%8D%E7%BD%AE%E4%B8%BB%E9%A2%98) for the next configuration steps.
39
39
 
40
- For the GitHub repository, it is recommended to download from the releases on the right side, with the following steps:
41
- - Click on the Latest version in Releases
42
- - Download `Source code(zip)` from Assets
43
- - Unzip to use as a theme
44
-
45
40
  ## 📚 Sub-projects
46
41
  - [ShokaX docs](https://github.com/theme-shoka-x/shokaX-docs) ShokaX Theme Documentation (work in progress, contributions welcome!)
47
42
  - [HRMNMI](https://github.com/theme-shoka-x/hexo-renderer-multi-next-markdown-it) The markdown renderer used by ShokaX (awaiting refactoring)
@@ -20,4 +20,7 @@
20
20
  - 取消您获取 ShokaX 社区支持和进行协作的权利;(社区管理)
21
21
  - 追究法律责任,包括要求赔偿因违规行为给 ShokaX 项目组造成的损失。(依照相关法律而定)
22
22
 
23
- 当发生纠纷时,全部由甲方(即zkz098)所在地负责,适用中华人民共和国法律。
23
+ 当发生纠纷时,全部由甲方(即zkz098)所在地负责,适用中华人民共和国法律。
24
+
25
+ 此文件及其后续更新适用于所有版本的 ShokaX,无论其发行版内携带哪种版本的此文件或不携带此文件,均以 Github main分支储存的最新版为准。
26
+ 如果本文件内容与 Github main 分支最新版有冲突的,本文件冲突部分无效,按照 Github main 分支最新版执行
package/_config.yml CHANGED
@@ -358,18 +358,12 @@ advVendors:
358
358
  js:
359
359
  pace:
360
360
  src: bytedance:pace/1.0.2/pace.min.js
361
- # pjax:
362
- # src: npm:theme-shokax-pjax@latest/pjax.shokax.min.js
363
361
  fetch:
364
362
  src: npm:whatwg-fetch@3.4.0/dist/fetch.umd.js
365
- # anime:
366
- # src: npm:theme-shokax-anime@latest/anime.shokax.min.js
367
363
  algolia:
368
364
  src: bytedance:algoliasearch/4.12.1/algoliasearch-lite.umd.min.js
369
365
  instantsearch:
370
366
  src: bytedance:instantsearch.js/4.39.0/instantsearch.production.min.js
371
- # lazyload:
372
- # src: bytedance:lozad.js/1.16.0/lozad.min.js
373
367
  quicklink:
374
368
  src: bytedance:quicklink/2.2.0/quicklink.umd.min.js
375
369
  fancybox:
@@ -388,11 +382,8 @@ advVendors:
388
382
  vendorsList:
389
383
  js:
390
384
  - pace
391
- # - pjax
392
- # - anime
393
385
  - algolia
394
386
  - instantsearch
395
- # - lazyload
396
387
  - quicklink
397
388
  - fancybox
398
389
  - copy_tex
@@ -405,15 +396,12 @@ vendors:
405
396
 
406
397
  js:
407
398
  pace: npm/pace-js@1.0.2/pace.min.js # ok
408
- # pjax: npm/theme-shokax-pjax@latest/pjax.shokax.min.js # ok
409
399
  fetch: npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js # ok
410
- # anime: npm/theme-shokax-anime@latest/anime.shokax.min.js
411
400
  algolia: npm/algoliasearch@4/dist/algoliasearch-lite.umd.js # ok
412
401
  instantsearch: npm/instantsearch.js@4/dist/instantsearch.production.min.js # ok
413
- # lazyload: npm/lozad@1/dist/lozad.min.js # ok
414
402
  quicklink: npm/quicklink@2/dist/quicklink.umd.js # ok
415
403
  fancybox: combine/npm/jquery@3.5.1/dist/jquery.min.js,npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js,npm/justifiedGallery@3.8.1/dist/js/jquery.justifiedGallery.min.js # notok
416
- valine: gh/amehime/MiniValine@4.2.2-beta10/dist/MiniValine.min.js # TODO 弃用
404
+ # valine: gh/amehime/MiniValine@4.2.2-beta10/dist/MiniValine.min.js # TODO 弃用
417
405
  copy_tex: npm/katex@0.16.7/dist/contrib/copy-tex.min.js # ok
418
406
  chart: npm/frappe-charts@1.5.0/dist/frappe-charts.min.iife.min.js # ok
419
407
 
@@ -11,7 +11,7 @@ mixin SMRender(item)
11
11
  div(class="cover" style=`background: linear-gradient(to bottom right, ${random_color()}, ${random_color()});`)
12
12
  else
13
13
  div(class="cover")
14
- != _url(link1, '<img data-src="'+ _cover(item) +'" alt="article cover">', {itemprop: 'url', title: postText})
14
+ != _url(link1, '<img data-src="'+ _cover_index(item) +'" alt="article cover">', {itemprop: 'url', title: postText})
15
15
  div(class="info")
16
16
  +PMRender(item)
17
17
  h3
@@ -1,7 +1,7 @@
1
1
  div(class="status")
2
2
  div(class="copyright")
3
3
  - var copyright_year = date(null, 'YYYY')
4
- if theme.footer.since && theme.footer.since != copyright_year
4
+ if theme.footer.since && theme.footer.since !== copyright_year
5
5
  != `&copy; ${theme.footer.since} -`
6
6
  span(itemprop="copyrightYear")
7
7
  != copyright_year
@@ -92,7 +92,6 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
92
92
  empty: "!{__('search.empty')}",
93
93
  stats: "!{__('search.stats')}"
94
94
  },
95
- valine: #{page.valine ? _safedump(page.valine) : true},
96
95
  chart: #{!!page.chart},
97
96
  copy_tex: #{!!page.math},
98
97
  katex: #{!!page.math},
@@ -1,5 +1,5 @@
1
1
  div(class="meta")
2
- if date(post.date) != date(post.updated) || time(post.date) != time(post.updated)
2
+ if date(post.date) !== date(post.updated) || time(post.date) !== time(post.updated)
3
3
  if theme.twikoo.enable || theme.waline.pageview
4
4
  span(class="icon")
5
5
  i(class="ic i-eye")
@@ -14,7 +14,7 @@ div(class="meta")
14
14
  != date(post.updated)
15
15
  if theme.waline.pageview && !theme.waline.enable && !theme.twikoo.enable
16
16
  script(type = "module" data-pjax).
17
- import { pageviewCount } from 'https://unpkg.com/@waline/client/dist/pageview.mjs';
17
+ import { pageviewCount } from 'https://unpkg.com/@waline/client@2/dist/pageview.mjs';
18
18
 
19
19
  const path = document.getElementById("twikoo_visitors").getAttribute("data-path");
20
20
  pageviewCount({
@@ -7,7 +7,7 @@ mixin item(name, path, parent, sublist)
7
7
  - var menuText = __('menu.' + name).replace('menu.', '')
8
8
  if parent
9
9
  li(class="item dropdown")
10
- if itemURL == '/'
10
+ if itemURL === '/'
11
11
  a(href="javascript:void(0);")
12
12
  != menuIcon + menuText
13
13
  else
@@ -18,7 +18,7 @@ mixin item(name, path, parent, sublist)
18
18
  - var itemURL = path[0].trim()
19
19
  - if (itemURL==='/') itemURL='javascript:void(0)'
20
20
  - var menuText = __('menu.' + subname).replace('menu.', '')
21
- if subname == 'default'
21
+ if subname === 'default'
22
22
  - var menuText = __('menu.' + name).replace('menu.', '')
23
23
  else
24
24
  - var menuIcon = '<i class="ic i-' + trimn(path[1]) + '"></i>'
@@ -29,9 +29,9 @@ mixin item(name, path, parent, sublist)
29
29
  != _url(itemURL, menuIcon + menuText, {rel: 'section'})
30
30
 
31
31
  each value, name in theme.menu
32
- if value == '[object Object]'
32
+ if value.toString() === '[object Object]'
33
33
  each subvalue, subname in value
34
- if subname == 'default'
34
+ if subname === 'default'
35
35
  +item(name, subvalue, true, value)
36
36
  else
37
37
  +item(name, value)
@@ -3,6 +3,6 @@ if code
3
3
  script.
4
4
  (function(c,l,a,r,i,t,y){
5
5
  c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
6
- t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
6
+ t=l.createElement(r);t.async=true;t.src="https://www.clarity.ms/tag/"+i;
7
7
  y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
8
8
  })(window, document, "clarity", "script", "#{code}");
@@ -98,7 +98,7 @@ block content
98
98
  if post.categories && post.categories.length
99
99
  - var cat_length = post.categories.length
100
100
  each cat,index in post.categories.toArray()
101
- if index == cat_length && cat.name !== page.category
101
+ if index === cat_length && cat.name !== page.category
102
102
  span
103
103
  a(href=url_for(cat.path)) #{cat.name}
104
104
  div(class="title")
@@ -26,25 +26,20 @@ block content
26
26
  if post.categories && post.categories.length
27
27
  - var cat_length = post.categories.length
28
28
  each cat,index in post.categories.toArray()
29
- if cat.name == page.title
30
- - var lastcat = ""
31
- - var lastcatslug = ""
29
+ if cat.name === page.title
30
+ - lastcat = ""
31
+ - lastcatslug = ""
32
32
  else
33
- - var lastcat = true
34
- mixin lastcat
35
- != lastcat
36
- a(href=url_for(cat.path))
37
- != cat.name
38
- small
39
- if index >= post.categories.toArray().length
40
- != cat.length
41
- else
42
- #{'/'}
43
- - var lastcatslug = lastcatslug + cat.slug
33
+ - lastcat += `<a href=${url_for(cat.path)}>${cat.name}</a><small>`
34
+ if index >= post.categories.toArray().length - 1
35
+ - lastcat = lastcat+' ( '+cat.length+' ) '+`</small>`
36
+ else
37
+ - lastcat = lastcat+'/'+`</small>`
38
+ - lastcatslug = lastcatslug + cat.slug
44
39
  if lastcat && lastcatslug && lastcatslug !== current
45
40
  h3(class="item section")
46
- +lastcat
47
- - var current = lastcatslug
41
+ !=lastcat
42
+ - current = lastcatslug
48
43
  article(class="item normal" itemscope itemtype="http://schema.org/Article")
49
44
  div(class="meta")
50
45
  time(
package/layout/index.pug CHANGED
@@ -5,7 +5,7 @@ include _mixin/segment.pug
5
5
 
6
6
  block content
7
7
  div(class="index wrap")
8
- if page.current == 1
8
+ if page.current === 1
9
9
  if page.sticky.length > 0
10
10
  h2(class="divider")
11
11
  != __('index.sticky')
@@ -22,7 +22,7 @@ block content
22
22
  - var pagePosts = page?.posts?.length
23
23
  if pagePosts > 0
24
24
  - var posts = page.posts.toArray()
25
- if page.current == 1
25
+ if page.current === 1
26
26
  h2(class="divider")
27
27
  != __('index.posts')
28
28
  div(class="segments posts")
package/layout/tag.pug CHANGED
@@ -27,7 +27,7 @@ block content
27
27
  if post.categories && post.categories.length
28
28
  - var cat_length = post.categories.length
29
29
  each cat,index in post.categories.toArray()
30
- if index == cat_length && cat.name !== page.category
30
+ if index === cat_length && cat.name !== page.category
31
31
  span
32
32
  a(href=url_for(cat.path))
33
33
  != cat.name
package/package.json CHANGED
@@ -1,44 +1,44 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
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",
7
7
  "author": "zkz098",
8
8
  "license": "AGPL-3.0-or-later",
9
9
  "scripts": {
10
- "test": "mocha test --coverage",
10
+ "test": "mocha test",
11
11
  "build": "pnpm install && tsc"
12
12
  },
13
13
  "devDependencies": {
14
- "@types/chai": "^4.3.5",
15
- "@types/fancybox": "^3.5.3",
16
- "@types/hexo": "^3.8.8",
17
- "@types/jquery": "^3.5.16",
18
- "@types/js-yaml": "^4.0.5",
19
- "@types/lozad": "^1.16.1",
20
- "@types/mocha": "^10.0.1",
21
- "@types/node": "^20.4.4",
22
- "@typescript-eslint/eslint-plugin": "^6.2.0",
23
- "@typescript-eslint/parser": "^6.2.0",
24
- "chai": "^4.3.7",
25
- "eslint": "^8.45.0",
26
- "eslint-config-standard": "*",
14
+ "@types/chai": "^4.3.11",
15
+ "@types/fancybox": "^3.5.6",
16
+ "@types/hexo": "^3.8.12",
17
+ "@types/jquery": "^3.5.29",
18
+ "@types/js-yaml": "^4.0.9",
19
+ "@types/lozad": "^1.16.4",
20
+ "@types/mocha": "^10.0.6",
21
+ "@types/node": "^20.10.0",
22
+ "@typescript-eslint/eslint-plugin": "^6.12.0",
23
+ "@typescript-eslint/parser": "^6.12.0",
24
+ "chai": "^4.3.10",
25
+ "eslint": "^8.54.0",
26
+ "eslint-config-standard": "~17",
27
27
  "eslint-plugin-chai-friendly": "^0.7.2",
28
- "eslint-plugin-import": "^2.27.5",
29
- "eslint-plugin-n": "^16.0.1",
28
+ "eslint-plugin-import": "^2.29.0",
29
+ "eslint-plugin-n": "^16.3.1",
30
30
  "eslint-plugin-promise": "^6.1.1",
31
- "eslint-plugin-vue": "^9.15.1",
31
+ "eslint-plugin-vue": "^9.18.1",
32
32
  "hexo-fs": "^4.1.1",
33
33
  "hexo-util": "^3.1.0",
34
- "instantsearch.js": "^4.56.7",
34
+ "instantsearch.js": "^4.60.0",
35
35
  "mocha": "^10.2.0",
36
- "typescript": "^5.1.6",
37
- "vue": "^3.3.4",
36
+ "typescript": "^5.3.2",
37
+ "vue": "^3.3.9",
38
38
  "jsdom": "^22.1.0"
39
39
  },
40
40
  "dependencies": {
41
- "esbuild": "^0.19.2",
41
+ "esbuild": "^0.19.7",
42
42
  "js-yaml": "^4.1.0",
43
43
  "lozad": "^1.16.0",
44
44
  "theme-shokax-anime": "^0.0.4",
@@ -34,6 +34,12 @@ hexo.extend.filter.register('before_generate', () => {
34
34
  hexo.theme.config.image_list = data.images;
35
35
  }
36
36
  else {
37
- hexo.theme.config.image_list = js_yaml_1.default.load(node_fs_1.default.readFileSync(path_1.default.join(__dirname, '../../_images.yml')));
37
+ hexo.theme.config.image_list = js_yaml_1.default.load(node_fs_1.default.readFileSync(path_1.default.join(__dirname, '../../_images.yml'), { encoding: 'utf-8' }));
38
+ }
39
+ if (node_fs_1.default.existsSync(path_1.default.join(__dirname, '../../_images_index.yml'))) {
40
+ hexo.theme.config.index_images = js_yaml_1.default.load(node_fs_1.default.readFileSync(path_1.default.join(__dirname, '../../_images_index.yml'), { encoding: 'utf-8' }));
41
+ }
42
+ else {
43
+ hexo.theme.config.index_images = [];
38
44
  }
39
45
  });
@@ -27,7 +27,6 @@ hexo.extend.generator.register('script', function (locals) {
27
27
  fancybox: theme.vendors.js.fancybox
28
28
  },
29
29
  css: {
30
- valine: theme.css + '/comment.css',
31
30
  katex: theme.vendors.css.katex,
32
31
  mermaid: theme.css + '/mermaid.css',
33
32
  fancybox: theme.vendors.css.fancybox
@@ -46,7 +45,9 @@ hexo.extend.generator.register('script', function (locals) {
46
45
  disableVL: theme.disableVL,
47
46
  noPlayer: theme.experiments?.noPlayer,
48
47
  audio: undefined,
49
- fireworks: undefined
48
+ fireworks: (theme.fireworks && theme.fireworks.enable)
49
+ ? (theme.fireworks.color || ['rgba(255,182,185,.9)', 'rgba(250,227,217,.9)', 'rgba(187,222,214,.9)', 'rgba(138,198,209,.9)'])
50
+ : undefined
50
51
  };
51
52
  if (config?.algolia) {
52
53
  siteConfig.search = {
@@ -109,6 +109,18 @@ hexo.extend.helper.register('_cover', function (item, num) {
109
109
  return randomBG(num || 1, image_server, image_list);
110
110
  }
111
111
  });
112
+ hexo.extend.helper.register('_cover_index', function (item) {
113
+ const { index_images, image_list, image_server } = hexo.theme.config;
114
+ if (item.cover) {
115
+ return this._image_url(item.cover, item.path);
116
+ }
117
+ else if (item.photos && item.photos.length > 0) {
118
+ return this._image_url(item.photos[0], item.path);
119
+ }
120
+ else {
121
+ return randomBG(1, image_server, index_images.length === 0 ? image_list : index_images);
122
+ }
123
+ });
112
124
  hexo.extend.helper.register('_permapath', function (str) {
113
125
  const { permalink } = hexo.config;
114
126
  let url = str.replace(/index\.html$/, '');
@@ -82,7 +82,7 @@ const transition = (target, type, complete, begin) => {
82
82
  exports.transition = transition;
83
83
  const pageScroll = (target, offset, complete) => {
84
84
  const opt = {
85
- targets: typeof offset === 'number' ? target.parentNode : document.scrollingElement,
85
+ targets: typeof offset === 'number' && typeof target !== 'number' ? target.parentNode : document.scrollingElement,
86
86
  duration: 500,
87
87
  easing: 'easeInOutQuad',
88
88
  scrollTop: offset || (typeof target === 'number' ? target : (target ? target.getTop() + document.documentElement.scrollTop - globalVars_1.siteNavHeight : 0)),
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const dom_1 = require("../library/dom");
4
4
  const anime_1 = require("../library/anime");
5
5
  const globalVars_1 = require("../globals/globalVars");
6
- const loadFile_1 = require("../library/loadFile");
7
6
  function loadComments() {
8
7
  const element = (0, dom_1.$dom)('#comments');
9
8
  if (!element) {
@@ -15,7 +14,6 @@ function loadComments() {
15
14
  }
16
15
  const io = new IntersectionObserver((entries, observer) => {
17
16
  const entry = entries[0];
18
- (0, loadFile_1.vendorCss)('valine');
19
17
  if (entry.isIntersecting || entry.intersectionRatio > 0) {
20
18
  (0, anime_1.transition)((0, dom_1.$dom)('#comments'), 'bounceUpIn');
21
19
  observer.disconnect();
@@ -15,7 +15,6 @@ const fireworks_1 = require("../fireworks");
15
15
  const theme_shokax_pjax_1 = __importDefault(require("theme-shokax-pjax"));
16
16
  const vue_1 = require("../library/vue");
17
17
  const siteInit = () => {
18
- (0, scriptPjax_1.cloudflareInit)();
19
18
  (0, domInit_1.default)();
20
19
  (0, vue_1.initVue)();
21
20
  (0, globalVars_1.setPjax)(new theme_shokax_pjax_1.default({
@@ -47,6 +46,7 @@ const siteInit = () => {
47
46
  });
48
47
  (0, refresh_1.siteRefresh)(1);
49
48
  };
49
+ (0, scriptPjax_1.cloudflareInit)();
50
50
  window.addEventListener('DOMContentLoaded', siteInit, {
51
51
  passive: true
52
52
  });
@@ -369,11 +369,11 @@ const mediaPlayer = (t, config) => {
369
369
  ['music.163.com.*artist.*id=(\\d+)', 'netease', 'artist'],
370
370
  ['music.163.com.*playlist.*id=(\\d+)', 'netease', 'playlist'],
371
371
  ['music.163.com.*discover/toplist.*id=(\\d+)', 'netease', 'playlist'],
372
- ['y.qq.com.*song/(\\w+).html', 'tencent', 'song'],
373
- ['y.qq.com.*album/(\\w+).html', 'tencent', 'album'],
374
- ['y.qq.com.*singer/(\\w+).html', 'tencent', 'artist'],
375
- ['y.qq.com.*playsquare/(\\w+).html', 'tencent', 'playlist'],
376
- ['y.qq.com.*playlist/(\\w+).html', 'tencent', 'playlist'],
372
+ ['y.qq.com.*song/(\\w+)(.html)?', 'tencent', 'song'],
373
+ ['y.qq.com.*album/(\\w+)(.html)?', 'tencent', 'album'],
374
+ ['y.qq.com.*singer/(\\w+)(.html)?', 'tencent', 'artist'],
375
+ ['y.qq.com.*playsquare/(\\w+)(.html)?', 'tencent', 'playlist'],
376
+ ['y.qq.com.*playlist/(\\w+)(.html)?', 'tencent', 'playlist'],
377
377
  ['xiami.com.*song/(\\w+)', 'xiami', 'song'],
378
378
  ['xiami.com.*album/(\\w+)', 'xiami', 'album'],
379
379
  ['xiami.com.*artist/(\\w+)', 'xiami', 'artist'],
package/.eslintrc.cjs DELETED
@@ -1,32 +0,0 @@
1
- module.exports = {
2
- parser: '@typescript-eslint/parser',
3
- env: {
4
- browser: true,
5
- commonjs: true,
6
- es6: true,
7
- node: true
8
- },
9
- extends: [
10
- 'standard',
11
- 'plugin:@typescript-eslint/recommended',
12
- 'plugin:vue/vue3-recommended',
13
- 'plugin:chai-friendly/recommended'
14
- ],
15
- plugins: [
16
- '@typescript-eslint',
17
- 'vue',
18
- 'chai-friendly'
19
- ],
20
- parserOptions: {
21
- ecmaVersion: 12
22
- },
23
- rules: {
24
- camelcase: 'off',
25
- 'n/no-callback-literal': 'off',
26
- '@typescript-eslint/ban-types': 'off',
27
- '@typescript-eslint/ban-ts-comment': 'off',
28
- '@typescript-eslint/no-var-requires': 'off',
29
- '@typescript-eslint/no-unused-vars': 'off',
30
- 'prefer-const': 'off'
31
- }
32
- }