hexo-theme-shokax 0.5.0-dev-58aa58e → 0.5.0-dev-31f9f21
Sign up to get free protection for your applications and to get access to all the features.
- package/_config.yml +1 -1
- package/layout/_partials/head/head.pug +5 -0
- package/layout/_partials/head/pwa.pug +1 -1
- package/layout/_partials/layout.pug +2 -0
- package/layout/_partials/third-party/baidu-analytics.pug +1 -1
- package/layout/_partials/third-party/google-analytics.pug +1 -1
- package/package.json +12 -13
- package/source/js/_app/components/comments.ts +2 -0
- package/source/js/_app/page/fancybox.ts +51 -61
- package/source/js/_app/pjax/refresh.ts +3 -26
- package/source/js/_app/library/loadFile.ts +0 -44
package/_config.yml
CHANGED
@@ -374,7 +374,6 @@ vendors:
|
|
374
374
|
source: cdnjs
|
375
375
|
url: jquery/3.5.1/jquery.min.js
|
376
376
|
sri: "sha384-ZvpUoO/+PpLXR1lu4jmpXWu80pZlYUAfxl5NsBMWOEPSjUn/6Z/hRTt8+pR6L4N2"
|
377
|
-
async_js:
|
378
377
|
fancybox:
|
379
378
|
source: cdnjs
|
380
379
|
url: fancybox/3.5.7/jquery.fancybox.min.js
|
@@ -383,6 +382,7 @@ vendors:
|
|
383
382
|
source: cdnjs
|
384
383
|
url: justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js
|
385
384
|
sri: "sha384-TOxsBplaL96/QDWPIUg+ye3v89qSE3s22XNtJMmCeZEep3cVDmXy1zEfZvVv+y2m"
|
385
|
+
async_js:
|
386
386
|
copy_tex:
|
387
387
|
source: cdnjs
|
388
388
|
url: KaTeX/0.16.9/contrib/copy-tex.min.js
|
@@ -45,6 +45,11 @@ if fontConfig
|
|
45
45
|
!= preloadjs()
|
46
46
|
!= load_async_css()
|
47
47
|
|
48
|
+
// 临时处理
|
49
|
+
link(rel="stylesheet" media="none" onload="this.media='all'" href="https://s4.zstatic.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css")
|
50
|
+
link(rel="stylesheet" media="none" onload="this.media='all'" href="https://s4.zstatic.net/ajax/libs/justifiedGallery/3.8.1/css/justifiedGallery.min.css")
|
51
|
+
//link(rel="stylesheet" media="none" onload="this.media='all'" href="https://s4.zstatic.net/ajax/libs/KaTeX/0.16.9/katex.min.css")
|
52
|
+
!= _css('mermaid.css')
|
48
53
|
if theme.experiments.cloudflarePatch
|
49
54
|
!= _js('cf-patch.js')
|
50
55
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
- var timeNow = new Date().getTime()
|
3
3
|
if theme.pwa.enable
|
4
4
|
- var sworker = theme.pwa.serviceworker
|
5
|
-
script(
|
5
|
+
script(async).
|
6
6
|
if ('serviceWorker' in navigator) {
|
7
7
|
navigator.serviceWorker.register("/#{sworker}?time=#{timeNow}").then(async (reg) => {
|
8
8
|
if (window.localStorage.getItem('install') !== 'true') {
|
@@ -134,6 +134,8 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f
|
|
134
134
|
|
135
135
|
!= vendor_js('pace')
|
136
136
|
!= vendor_js('jquery')
|
137
|
+
!= vendor_js('justifiedGallery')
|
138
|
+
!= vendor_js('fancybox')
|
137
139
|
|
138
140
|
if theme.polyfill.enable
|
139
141
|
script(src=`https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?version=4.8.0&features=${theme.polyfill.features}` defer)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
- var googleId = theme.visitor.googleAnalytics
|
2
2
|
if googleId
|
3
3
|
script(async, src=`https://www.googletagmanager.com/gtag/js?id=${ googleId }`)
|
4
|
-
script
|
4
|
+
script.
|
5
5
|
window.dataLayer = window.dataLayer || [];
|
6
6
|
function gtag() {
|
7
7
|
dataLayer.push(arguments);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hexo-theme-shokax",
|
3
|
-
"version": "0.5.0-dev-
|
3
|
+
"version": "0.5.0-dev-31f9f21",
|
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",
|
@@ -13,23 +13,23 @@
|
|
13
13
|
},
|
14
14
|
"devDependencies": {
|
15
15
|
"@types/fancybox": "^3.5.7",
|
16
|
-
"@types/jquery": "^3.5.
|
16
|
+
"@types/jquery": "^3.5.32",
|
17
17
|
"@types/js-yaml": "^4.0.9",
|
18
18
|
"@types/katex": "^0.16.7",
|
19
|
-
"@types/node": "^22.
|
19
|
+
"@types/node": "^22.8.6",
|
20
20
|
"@types/quicklink": "^2.3.4",
|
21
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
22
|
-
"@typescript-eslint/parser": "^8.
|
23
|
-
"eslint": "^9.
|
21
|
+
"@typescript-eslint/eslint-plugin": "^8.12.2",
|
22
|
+
"@typescript-eslint/parser": "^8.12.2",
|
23
|
+
"eslint": "^9.13.0",
|
24
24
|
"eslint-config-standard": "~17",
|
25
|
-
"eslint-plugin-vue": "^9.
|
25
|
+
"eslint-plugin-vue": "^9.30.0",
|
26
26
|
"glob": "^11.0.0",
|
27
|
-
"typescript": "^5.6.
|
27
|
+
"typescript": "^5.6.3"
|
28
28
|
},
|
29
29
|
"dependencies": {
|
30
|
-
"@algolia/client-search": "^5.
|
30
|
+
"@algolia/client-search": "^5.12.0",
|
31
31
|
"@waline/client": "^3.3.2",
|
32
|
-
"algoliasearch": "5.
|
32
|
+
"algoliasearch": "5.12.0",
|
33
33
|
"esbuild": "^0.24.0",
|
34
34
|
"hexo": "^7.3.0",
|
35
35
|
"hexo-algoliasearch": "^2.0.1",
|
@@ -38,18 +38,17 @@
|
|
38
38
|
"hexo-pagination": "^4.0.0",
|
39
39
|
"hexo-renderer-pug": "^3.0.0",
|
40
40
|
"hexo-util": "^3.3.0",
|
41
|
-
"instantsearch.js": "^4.
|
41
|
+
"instantsearch.js": "^4.75.3",
|
42
42
|
"js-yaml": "^4.1.0",
|
43
43
|
"katex": "^0.16.11",
|
44
44
|
"mouse-firework": "^0.0.6",
|
45
45
|
"quicklink": "^2.3.0",
|
46
46
|
"theme-shokax-anime": "^0.0.7",
|
47
|
-
"theme-shokax-pjax": "^0.0.3",
|
48
47
|
"twikoo": "^1.6.39",
|
49
48
|
"unlazy": "^0.11.3"
|
50
49
|
},
|
51
50
|
"engines": {
|
52
|
-
"node": ">=
|
51
|
+
"node": ">=20.0.0"
|
53
52
|
},
|
54
53
|
"engineStrict": true,
|
55
54
|
"pnpm": {
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { CONFIG } from '../globals/globalVars'
|
2
2
|
import { init, RecentComments } from '@waline/client'
|
3
|
+
// @ts-ignore
|
3
4
|
import { pageviewCount } from '@waline/client/pageview'
|
5
|
+
// @ts-ignore
|
4
6
|
await import('@waline/client/style')
|
5
7
|
|
6
8
|
export const walineComment = function () {
|
@@ -1,76 +1,66 @@
|
|
1
1
|
import { $dom } from '../library/dom'
|
2
|
-
import { vendorCss, vendorJs } from '../library/loadFile'
|
3
2
|
import { insertAfter } from '../library/proto'
|
4
3
|
|
5
4
|
// TODO 使用PhotoSwipe替换Fancybox
|
6
5
|
export const postFancybox = (p:string) => {
|
7
6
|
if (document.querySelector(p + ' .md img')) {
|
8
|
-
|
9
|
-
vendorCss('justifiedGallery')
|
10
|
-
vendorJs('jquery', ()=>{
|
11
|
-
vendorJs('justifiedGallery',()=>{
|
12
|
-
vendorJs('fancybox', () => {
|
13
|
-
const q = jQuery.noConflict()
|
7
|
+
const q = jQuery.noConflict()
|
14
8
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
$dom.each(p + ' p.gallery', (element) => {
|
10
|
+
const box = document.createElement('div')
|
11
|
+
box.className = 'gallery'
|
12
|
+
box.setAttribute('data-height', String(element.getAttribute('data-height') || 220))
|
19
13
|
|
20
|
-
|
14
|
+
box.innerHTML = element.innerHTML.replace(/<br>/g, '')
|
21
15
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
$dom.each(p + ' .md img:not(.emoji):not(.vemoji)', (element) => {
|
27
|
-
const $image = q(element)
|
28
|
-
const imageLink = $image.attr('data-src') || $image.attr('src') // 替换
|
29
|
-
const $imageWrapLink = $image.wrap('<a class="fancybox" href="' + imageLink + '" itemscope itemtype="https://schema.org/ImageObject" itemprop="url"></a>').parent('a')
|
30
|
-
let info; let captionClass = 'image-info'
|
31
|
-
if (!$image.is('a img')) {
|
32
|
-
$image.data('safe-src', imageLink)
|
33
|
-
if (!$image.is('.gallery img')) {
|
34
|
-
$imageWrapLink.attr('data-fancybox', 'default').attr('rel', 'default')
|
35
|
-
} else {
|
36
|
-
captionClass = 'jg-caption'
|
37
|
-
}
|
38
|
-
}
|
39
|
-
if ((info = element.getAttribute('title'))) {
|
40
|
-
$imageWrapLink.attr('data-caption', info)
|
41
|
-
const para = document.createElement('span')
|
42
|
-
const txt = document.createTextNode(info)
|
43
|
-
para.appendChild(txt)
|
44
|
-
para.addClass(captionClass)
|
45
|
-
insertAfter(element, para)
|
46
|
-
}
|
47
|
-
})
|
16
|
+
element.parentNode.insertBefore(box, element)
|
17
|
+
element.remove()
|
18
|
+
})
|
48
19
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
20
|
+
$dom.each(p + ' .md img:not(.emoji):not(.vemoji)', (element) => {
|
21
|
+
const $image = q(element)
|
22
|
+
const imageLink = $image.attr('data-src') || $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
|
+
})
|
60
42
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
})
|
71
|
-
// @ts-ignore
|
72
|
-
}, window.jQuery)
|
43
|
+
$dom.each(p + ' div.gallery', (el, i) => {
|
44
|
+
// @ts-ignore
|
45
|
+
q(el).justifiedGallery({
|
46
|
+
rowHeight: q(el).data('height') || 120,
|
47
|
+
rel: 'gallery-' + i
|
48
|
+
}).on('jg.complete', function () {
|
49
|
+
q(this).find('a').each((k, ele) => {
|
50
|
+
ele.setAttribute('data-fancybox', 'gallery-' + i)
|
51
|
+
})
|
73
52
|
})
|
74
53
|
})
|
54
|
+
|
55
|
+
q.fancybox.defaults.hash = false
|
56
|
+
q(p + ' .fancybox').fancybox({
|
57
|
+
loop: true,
|
58
|
+
// @ts-ignore
|
59
|
+
helpers: {
|
60
|
+
overlay: {
|
61
|
+
locked: false
|
62
|
+
}
|
63
|
+
}
|
64
|
+
})
|
75
65
|
}
|
76
66
|
}
|
@@ -1,46 +1,23 @@
|
|
1
|
-
import { $dom } from '../library/dom'
|
2
1
|
import { cardActive } from '../page/common'
|
3
|
-
import { pageScroll, transition } from '../library/anime'
|
4
|
-
import { vendorCss, vendorJs } from '../library/loadFile'
|
5
2
|
import { resizeHandle } from '../globals/handles'
|
6
3
|
import {
|
7
4
|
CONFIG,
|
8
|
-
loadCat,
|
9
|
-
menuToggle,
|
10
5
|
setLocalHash, setLocalUrl, setOriginTitle,
|
11
|
-
sideBar,
|
12
6
|
toolPlayer
|
13
7
|
} from '../globals/globalVars'
|
14
|
-
import {
|
8
|
+
import { positionInit } from '../globals/tools'
|
15
9
|
import { menuActive, sideBarTab, sidebarTOC } from '../components/sidebar'
|
16
10
|
import { Loader, isOutime } from '../globals/thirdparty'
|
17
11
|
import { tabFormat } from '../page/tab'
|
18
12
|
import { lazyLoad } from 'unlazy'
|
19
13
|
|
20
|
-
export const pjaxReload = () => {
|
21
|
-
pagePosition()
|
22
|
-
|
23
|
-
if (sideBar.hasClass('on')) {
|
24
|
-
transition(sideBar, 0, () => {
|
25
|
-
sideBar.removeClass('on')
|
26
|
-
menuToggle.removeClass('close')
|
27
|
-
}) // 'transition.slideRightOut'
|
28
|
-
}
|
29
|
-
const mainNode = document.getElementById('main')
|
30
|
-
mainNode.innerHTML = ''
|
31
|
-
mainNode.appendChild(loadCat.lastChild.cloneNode(true))
|
32
|
-
pageScroll(0)
|
33
|
-
}
|
34
|
-
|
35
14
|
export const siteRefresh = async (reload) => {
|
36
15
|
setLocalHash(0)
|
37
16
|
setLocalUrl(window.location.href)
|
38
17
|
|
39
|
-
|
40
|
-
|
41
|
-
// vendorJs('copy_tex')
|
18
|
+
// @ts-ignore
|
19
|
+
await import('katex/dist/katex.min.css')
|
42
20
|
await import('katex/dist/contrib/copy-tex.mjs')
|
43
|
-
vendorCss('mermaid')
|
44
21
|
|
45
22
|
// 懒加载背景图
|
46
23
|
const lazyBg = new IntersectionObserver(function (entries, observer) {
|
@@ -1,44 +0,0 @@
|
|
1
|
-
import { CONFIG } from '../globals/globalVars'
|
2
|
-
import { createChild } from './proto'
|
3
|
-
|
4
|
-
/**
|
5
|
-
* 用途是根据不同的资源名称和类型生成相应的资源 URL。
|
6
|
-
*/
|
7
|
-
const assetUrl = (asset: string, type: string): string => {
|
8
|
-
const str = CONFIG[asset][type].url as string
|
9
|
-
if (str.startsWith('https')) {
|
10
|
-
return str
|
11
|
-
}
|
12
|
-
if (str.startsWith('http')) {
|
13
|
-
console.warn(`Upgrade vendor ${asset}/${type} to HTTPS, Please use HTTPS url instead of HTTP url.`)
|
14
|
-
return str.replace('http', 'https')
|
15
|
-
}
|
16
|
-
return `/${str}`
|
17
|
-
}
|
18
|
-
|
19
|
-
export const vendorJs = (type: string, callback?: Function, condition?: string) => {
|
20
|
-
if (LOCAL[type]) {
|
21
|
-
assetUrl('js', type)
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
export const vendorCss = (type: string, condition?: string): void => {
|
26
|
-
if (window['css' + type]) {
|
27
|
-
return
|
28
|
-
}
|
29
|
-
|
30
|
-
if (LOCAL[type]) {
|
31
|
-
const attr:any = {
|
32
|
-
rel: 'stylesheet',
|
33
|
-
href: assetUrl('css', type),
|
34
|
-
}
|
35
|
-
const vendor = CONFIG['css'][type] as vendorUrl
|
36
|
-
if (!vendor.local) {
|
37
|
-
attr.integrity = vendor.sri
|
38
|
-
attr.crossOrigin = 'anonymous'
|
39
|
-
}
|
40
|
-
createChild(document.head, 'link', attr)
|
41
|
-
|
42
|
-
window['css' + type] = true
|
43
|
-
}
|
44
|
-
}
|