hexo-theme-shokax 0.5.0-beta2-dev-86064c8 → 0.5.0-beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,6 @@
20
20
  ## 📚子项目
21
21
  - [ShokaX docs](https://github.com/theme-shoka-x/shokaX-docs) ShokaX 主题文档 (正在编写中,欢迎加入!)
22
22
  - [HRMNMI](https://github.com/theme-shoka-x/hexo-renderer-multi-next-markdown-it) ShokaX 正在使用的 markdown 渲染器 (等待重构)
23
- - [ShokaX Pjax](https://github.com/theme-shoka-x/theme-shokax-pjax) ShokaX 提供的高效 Pjax 实现
24
23
  - [ShokaX Anime](https://github.com/theme-shoka-x/theme-shokax-anime) ShokaX 提供的精简版 Anime.js 实现
25
24
 
26
25
  # [许可证](https://github.com/theme-shoka-x/hexo-theme-shokaX/blob/main/LICENSE)
package/_config.yml CHANGED
@@ -52,7 +52,6 @@ modules:
52
52
  visibilityListener: true # 启用可见度监听器
53
53
  tabs: true # 启用选项卡扩展支持,如需开启 summary 功能请一并开启
54
54
  quiz: true # 启用文章内问题扩展支持
55
- fancybox: true # 启用 fancybox 支持(不建议禁用)
56
55
 
57
56
  # 优化性能区
58
57
  performance:
@@ -354,41 +353,13 @@ vendors:
354
353
  cdns:
355
354
  cdnjs: https://s4.zstatic.net/ajax/libs
356
355
  js:
357
- jquery:
358
- source: cdnjs
359
- url: jquery/3.5.1/jquery.min.js
360
- sri: "sha384-ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn/6Z/hRTt8+pR6L4N2"
361
- fancybox:
362
- source: cdnjs
363
- url: fancybox/3.5.7/jquery.fancybox.min.js
364
- sri: "sha384-Zm+UU4tdcfAm29vg+MTbfu//q5B/lInMbMCr4T8c9rQFyOv6PlfQYpB5wItcXWe7"
365
- justifiedGallery:
366
- source: cdnjs
367
- url: justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js
368
- sri: "sha384-TOxsBplaL96/QDWPIUg+ye3v89qSE3s22XNtJMmCeZEep3cVDmXy1zEfZvVv+y2m"
369
356
  async_js:
370
357
  copy_tex:
371
358
  source: cdnjs
372
359
  url: KaTeX/0.16.9/contrib/copy-tex.min.js
373
360
  sri: "sha384-ww/583aHhxWkz5DEVn6OKtNiIaLi2iBRNZXfJRiY1Ai7tnJ9UXpEsyvOITVpTl4A"
374
- fancybox:
375
- source: cdnjs
376
- url: fancybox/3.5.7/jquery.fancybox.min.js
377
- sri: "sha384-Zm+UU4tdcfAm29vg+MTbfu//q5B/lInMbMCr4T8c9rQFyOv6PlfQYpB5wItcXWe7"
378
- justifiedGallery:
379
- source: cdnjs
380
- url: justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js
381
- sri: "sha384-TOxsBplaL96/QDWPIUg+ye3v89qSE3s22XNtJMmCeZEep3cVDmXy1zEfZvVv+y2m"
382
361
  css:
383
362
  katex:
384
363
  source: cdnjs
385
364
  url: KaTeX/0.16.9/katex.min.css
386
365
  sri: "sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV"
387
- fancybox:
388
- source: cdnjs
389
- url: fancybox/3.5.7/jquery.fancybox.min.css
390
- sri: "sha384-Q8BgkilbsFGYNNiDqJm69hvDS7NCJWOodvfK/cwTyQD4VQA0qKzuPpvqNER1UC0F"
391
- justifiedGallery:
392
- source: cdnjs
393
- url: justifiedGallery/3.8.1/css/justifiedGallery.min.css
394
- sri: "sha384-V/1Ew9pYm8xpy/L9i078ZXT6HSEOrGC6KNFYLbXOdtqb3+c6brpGqVzZtEPSQOiz"
@@ -113,7 +113,6 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
113
113
  katex: #{!!page.math},
114
114
  mermaid: #{!!page.mermaid},
115
115
  audio: !{audioValue},
116
- fancybox: #{page.fancybox !== false},
117
116
  nocopy: #{!!page.nocopy},
118
117
  outime: #{page.outime !== false},
119
118
  template: `!{__('outime.template')}`,
@@ -131,10 +130,6 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
131
130
  != partial('_partials/third-party/clarity.pug', {}, {cache: true})
132
131
  != partial('_partials/third-party/google-analytics.pug', {}, {cache: true})
133
132
 
134
- != vendor_js('jquery')
135
- != vendor_js('justifiedGallery')
136
- != vendor_js('fancybox')
137
-
138
133
  if theme.polyfill.enable
139
134
  script(src=`https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?version=4.8.0&features=${theme.polyfill.features}` defer)
140
135
 
package/layout/page.pug CHANGED
@@ -5,8 +5,6 @@ include _mixin/comment.pug
5
5
  block head
6
6
  != _css('post.css')
7
7
  // 临时处理
8
- link(rel="stylesheet" media="none" onload="this.media='all'" href="https://s4.zstatic.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css")
9
- link(rel="stylesheet" media="none" onload="this.media='all'" href="https://s4.zstatic.net/ajax/libs/justifiedGallery/3.8.1/css/justifiedGallery.min.css")
10
8
  link(rel="stylesheet" media="none" onload="this.media='all'" href="https://s4.zstatic.net/ajax/libs/KaTeX/0.16.9/katex.min.css")
11
9
 
12
10
  block title
package/layout/post.pug CHANGED
@@ -7,8 +7,6 @@ block head
7
7
  != _css('post.css')
8
8
  != _css('mermaid.css')
9
9
  // 临时处理
10
- link(rel="stylesheet" media="none" onload="this.media='all'" href="https://s4.zstatic.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css")
11
- link(rel="stylesheet" media="none" onload="this.media='all'" href="https://s4.zstatic.net/ajax/libs/justifiedGallery/3.8.1/css/justifiedGallery.min.css")
12
10
  link(rel="stylesheet" media="none" onload="this.media='all'" href="https://s4.zstatic.net/ajax/libs/KaTeX/0.16.9/katex.min.css")
13
11
 
14
12
  block title
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hexo-theme-shokax",
3
- "version": "0.5.0-beta2-dev-86064c8",
3
+ "version": "0.5.0-beta2",
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",
@@ -12,12 +12,9 @@
12
12
  "build": "node ./toolbox/compiler.mjs"
13
13
  },
14
14
  "devDependencies": {
15
- "@types/fancybox": "^3.5.7",
16
- "@types/jquery": "^3.5.32",
17
15
  "@types/js-yaml": "^4.0.9",
18
16
  "@types/katex": "^0.16.7",
19
17
  "@types/node": "^22.14.0",
20
- "@types/quicklink": "^2.3.4",
21
18
  "@typescript-eslint/eslint-plugin": "^8.29.1",
22
19
  "@typescript-eslint/parser": "^8.29.1",
23
20
  "eslint": "^9.24.0",
@@ -34,6 +31,7 @@
34
31
  "dompurify": "^3.2.5",
35
32
  "es-toolkit": "^1.34.1",
36
33
  "esbuild": "^0.25.2",
34
+ "hana-img-viewer": "^1.2.1",
37
35
  "hexo": "^7.3.0",
38
36
  "hexo-algoliasearch": "^2.0.1",
39
37
  "hexo-feed": "^1.1.2",
@@ -48,7 +46,8 @@
48
46
  "nyx-player": "^0.0.2",
49
47
  "quicklink": "^2.3.0",
50
48
  "theme-shokax-anime": "^0.0.8",
51
- "twikoo": "^1.6.42"
49
+ "twikoo": "^1.6.42",
50
+ "vue": "^3.5.13"
52
51
  },
53
52
  "engines": {
54
53
  "node": ">=20.0.0"
@@ -46,9 +46,7 @@ hexo.extend.generator.register("script", async function(locals) {
46
46
  url: theme.css + "/mermaid.css",
47
47
  local: true,
48
48
  sri: ""
49
- },
50
- fancybox: (0, import_utils.getVendorLink)(hexo, theme.vendors.css.fancybox),
51
- justifiedGallery: (0, import_utils.getVendorLink)(hexo, theme.vendors.css.justifiedGallery)
49
+ }
52
50
  },
53
51
  loader: theme.loader,
54
52
  search: null,
@@ -127,7 +125,6 @@ hexo.extend.generator.register("script", async function(locals) {
127
125
  __shokax_outime__: theme.outime.enable ? "true" : "false",
128
126
  __shokax_tabs__: theme.modules.tabs ? "true" : "false",
129
127
  __shokax_quiz__: theme.modules.quiz ? "true" : "false",
130
- __shokax_fancybox__: theme.modules.fancybox ? "true" : "false",
131
128
  __shokax_waline__: theme.waline.enable ? "true" : "false",
132
129
  __shokax_twikoo__: theme.twikoo.enable ? "true" : "false",
133
130
  __shokax_antiFakeWebsite__: theme.experiments.antiFakeWebsite ? "true" : "false",
@@ -108,14 +108,16 @@ export const sidebarTOC = () => {
108
108
  }
109
109
 
110
110
  document.querySelectorAll('.toc .active').forEach((element) => {
111
- element && element.classList.remove('active current')
111
+ element && element.classList.remove('active')
112
+ element && element.classList.remove('current')
112
113
  })
113
114
 
114
115
  sections.forEach((element) => {
115
116
  element && element.classList.remove('active')
116
117
  })
117
118
 
118
- target.classList.add('active current')
119
+ target.classList.add('active')
120
+ target.classList.add('current')
119
121
  sections[index] && sections[index].classList.add('active')
120
122
 
121
123
  let parent = <Element> target.parentNode
@@ -16,7 +16,7 @@ export const siteBrand = document.getElementById('brand')
16
16
  export let toolBtn = document.getElementById('tool')
17
17
  export let backToTop: HTMLElement
18
18
  export let goToComment
19
- export let showContents
19
+ export let showContents: HTMLElement
20
20
  export let siteSearch = document.getElementById('search')
21
21
  export let siteNavHeight: number, headerHightInner: number, headerHight: number
22
22
  export let oWinHeight = window.innerHeight
@@ -0,0 +1,20 @@
1
+ import DOMPurify from 'dompurify';
2
+ import { HanaImgViewer } from 'hana-img-viewer'
3
+ import { createApp } from 'vue';
4
+
5
+ export const postImageViewer = (p: string) => {
6
+ document.querySelectorAll(`${p} .md img:not(.emoji):not(.vemoji)`).forEach((element) => {
7
+ const img = element as HTMLImageElement;
8
+ const imgSrc = DOMPurify.sanitize(img.dataset.src);
9
+
10
+ const wrapper = document.createElement('div');
11
+ console.log(wrapper)
12
+ img.replaceWith(wrapper);
13
+
14
+ console.log(imgSrc)
15
+ const app = createApp(HanaImgViewer, { src: imgSrc, maskOpacity: 0.8 });
16
+ console.log(app)
17
+ app.mount(wrapper);
18
+ console.log(app)
19
+ });
20
+ };
@@ -1,4 +1,4 @@
1
- import { postFancybox } from './fancybox'
1
+ import { postImageViewer } from './imageviewer'
2
2
  import { clipBoard, showtip } from '../globals/tools'
3
3
  import { CONFIG, BODY } from '../globals/globalVars'
4
4
  import { pageScroll, transition } from '../library/anime'
@@ -7,9 +7,7 @@ import { getDisplay, setDisplay, wrapObject } from '../library/proto'
7
7
  export const postBeauty = () => {
8
8
  if (!document.querySelector('.md')) { return }
9
9
 
10
- if (__shokax_fancybox__) {
11
- postFancybox('.post.block')
12
- }
10
+ postImageViewer('.post.block');
13
11
 
14
12
  (document.querySelector('.post.block') as HTMLTextAreaElement).oncopy = (event) => {
15
13
  showtip(LOCAL.copyright)
@@ -1,66 +0,0 @@
1
- import { insertAfter } from '../library/proto'
2
- import DOMPurify from 'dompurify';
3
-
4
- // TODO 使用PhotoSwipe替换Fancybox
5
- export const postFancybox = (p:string) => {
6
- if (document.querySelector(p + ' .md img')) {
7
- // vendorCss('fancybox')
8
- // vendorCss('justifiedGallery')
9
- document.querySelectorAll(p + ' p.gallery').forEach((element) => {
10
- const box = document.createElement('div')
11
- box.className = 'gallery'
12
- box.setAttribute('data-height', String(element.getAttribute('data-height') || 220))
13
-
14
- box.innerHTML = element.innerHTML.replace(/<br>/g, '')
15
-
16
- element.parentNode.insertBefore(box, element)
17
- element.remove()
18
- })
19
-
20
- document.querySelectorAll(p + ' .md img:not(.emoji):not(.vemoji)').forEach((element) => {
21
- const $image = $(element)
22
- const imageLink = DOMPurify.sanitize($image.attr('src')) // 替换
23
- const $imageWrapLink = $image.wrap('<a class="fancybox" href="' + imageLink + '" itemscope itemtype="https://schema.org/ImageObject" itemprop="url"></a>').parent('a')
24
- let info; let captionClass = 'image-info'
25
- if (!$image.is('a img')) {
26
- $image.data('safe-src', imageLink)
27
- if (!$image.is('.gallery img')) {
28
- $imageWrapLink.attr('data-fancybox', 'default').attr('rel', 'default')
29
- } else {
30
- captionClass = 'jg-caption'
31
- }
32
- }
33
- if ((info = element.getAttribute('title'))) {
34
- $imageWrapLink.attr('data-caption', info)
35
- const para = document.createElement('span')
36
- const txt = document.createTextNode(info)
37
- para.appendChild(txt)
38
- para.addClass(captionClass)
39
- insertAfter(element, para)
40
- }
41
- })
42
-
43
- document.querySelectorAll(p + ' div.gallery').forEach((el, i) => {
44
- // @ts-ignore
45
- $(el).justifiedGallery({
46
- rowHeight: $(el).data('height') || 120,
47
- rel: 'gallery-' + i
48
- }).on('jg.complete', function () {
49
- $(this).find('a').each((k, ele) => {
50
- ele.setAttribute('data-fancybox', 'gallery-' + i)
51
- })
52
- })
53
- })
54
-
55
- $.fancybox.defaults.hash = false
56
- $(p + ' .fancybox').fancybox({
57
- loop: true,
58
- // @ts-ignore
59
- helpers: {
60
- overlay: {
61
- locked: false
62
- }
63
- }
64
- })
65
- }
66
- }