hexo-theme-solitude 1.7.14 → 1.8.0
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 +25 -25
- package/{README_zh-cn.md → README_en.md} +25 -25
- package/README_zh-tw.md +3 -3
- package/_config.yml +41 -34
- package/layout/includes/body/mode.pug +6 -3
- package/layout/includes/head/config.pug +0 -33
- package/layout/includes/head/page_config.pug +9 -0
- package/layout/includes/head.pug +4 -1
- package/layout/includes/inject/body.pug +1 -26
- package/layout/includes/inject/head.pug +11 -60
- package/layout/includes/widgets/post/postMeta.pug +24 -24
- package/layout/includes/widgets/third-party/comments/artalk.pug +29 -18
- package/layout/includes/widgets/third-party/comments/comment.pug +48 -12
- package/layout/includes/widgets/third-party/comments/twikoo.pug +61 -39
- package/layout/includes/widgets/third-party/comments/valine.pug +36 -38
- package/layout/includes/widgets/third-party/comments/waline.pug +39 -44
- package/layout/includes/widgets/third-party/news-comment/artalk.pug +57 -67
- package/layout/includes/widgets/third-party/news-comment/newest-comment.pug +6 -6
- package/layout/includes/widgets/third-party/news-comment/twikoo.pug +41 -48
- package/layout/includes/widgets/third-party/news-comment/valine.pug +5 -5
- package/layout/includes/widgets/third-party/news-comment/waline.pug +3 -3
- package/layout/includes/widgets/third-party/pjax.pug +1 -0
- package/package.json +1 -1
- package/plugins.yml +2 -2
- package/scripts/event/merge_config.js +280 -255
- package/scripts/filter/comment.js +13 -0
- package/source/css/_comments/comment.styl +73 -12
- package/source/css/_comments/valine.styl +1 -1
- package/source/css/_highlight/index.styl +1 -0
- package/source/css/_tags/link.styl +7 -2
- package/source/js/main.js +42 -18
- package/source/js/tw_cn.js +3 -3
- package/source/js/utils.js +62 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
#article-container
|
2
|
-
.tag-link
|
2
|
+
a.tag-link
|
3
3
|
background var(--efu-secondbg)
|
4
4
|
border-radius 8px !important
|
5
5
|
display flex
|
@@ -14,10 +14,15 @@
|
|
14
14
|
border var(--style-border-hover) !important
|
15
15
|
|
16
16
|
.tag-link-tips
|
17
|
-
color var(--efu-
|
17
|
+
color var(--efu-white)
|
18
|
+
|
19
|
+
i
|
20
|
+
opacity 1
|
18
21
|
|
19
22
|
i
|
23
|
+
transition .3s
|
20
24
|
margin-left auto
|
25
|
+
opacity .6
|
21
26
|
|
22
27
|
.tag-link-bottom
|
23
28
|
display flex
|
package/source/js/main.js
CHANGED
@@ -71,7 +71,7 @@ const percent = () => {
|
|
71
71
|
let viewportBottom = window.scrollY + document.documentElement.clientHeight
|
72
72
|
let remainingScroll = totalHeight - scrollTop
|
73
73
|
|
74
|
-
if ((document.getElementById("post-comment") || document.getElementById("footer"))
|
74
|
+
if ((document.getElementById("post-comment") || document.getElementById("footer"))?.offsetTop < viewportBottom || scrollPercent > 90) {
|
75
75
|
document.querySelector("#nav-totop").classList.add("long")
|
76
76
|
percentElement.innerHTML = GLOBAL_CONFIG.lang.backtop
|
77
77
|
} else {
|
@@ -281,7 +281,7 @@ let sco = {
|
|
281
281
|
},
|
282
282
|
switchHideAside: function () {
|
283
283
|
const htmlClassList = document.documentElement.classList;
|
284
|
-
htmlClassList.contains("hide-aside") ? saveToLocal.set("aside-status", "show", 1) : saveToLocal.set("aside-status", "hide", 1)
|
284
|
+
htmlClassList.contains("hide-aside") ? utils.saveToLocal.set("aside-status", "show", 1) : saveToLocal.set("aside-status", "hide", 1)
|
285
285
|
htmlClassList.toggle("hide-aside");
|
286
286
|
htmlClassList.contains("hide-aside") ? document.querySelector("#consoleHideAside").classList.add("on") : document.querySelector("#consoleHideAside").classList.remove("on");
|
287
287
|
},
|
@@ -317,12 +317,12 @@ let sco = {
|
|
317
317
|
'light'
|
318
318
|
if (nowMode === 'light') {
|
319
319
|
document.documentElement.setAttribute('data-theme', 'dark')
|
320
|
-
saveToLocal.set('theme', 'dark', 0.02);
|
320
|
+
utils.saveToLocal.set('theme', 'dark', 0.02);
|
321
321
|
utils.snackbarShow(GLOBAL_CONFIG.lang.theme.dark, false, 2000)
|
322
322
|
right_menu && rm.mode(true)
|
323
323
|
} else {
|
324
324
|
document.documentElement.setAttribute('data-theme', 'light')
|
325
|
-
saveToLocal.set('theme', 'light', 0.02);
|
325
|
+
utils.saveToLocal.set('theme', 'light', 0.02);
|
326
326
|
utils.snackbarShow(GLOBAL_CONFIG.lang.theme.light, false, 2000)
|
327
327
|
right_menu && rm.mode(false)
|
328
328
|
}
|
@@ -351,7 +351,7 @@ let sco = {
|
|
351
351
|
el && GLOBAL_CONFIG.runtime && (el.innerText = utils.timeDiff(new Date(GLOBAL_CONFIG.runtime), new Date()) + GLOBAL_CONFIG.lang.time.day)
|
352
352
|
},
|
353
353
|
toTalk: function (txt) {
|
354
|
-
const inputs = ["#wl-edit", ".el-textarea__inner", "#veditor"]
|
354
|
+
const inputs = ["#wl-edit", ".el-textarea__inner", "#veditor",".atk-textarea"]
|
355
355
|
for (let i = 0; i < inputs.length; i++) {
|
356
356
|
let el = document.querySelector(inputs[i])
|
357
357
|
if (el != null) {
|
@@ -617,8 +617,7 @@ let sco = {
|
|
617
617
|
document.getElementById("toPageButton").href = targetPageUrl;
|
618
618
|
}
|
619
619
|
},
|
620
|
-
owoBig() {
|
621
|
-
const owoSelectors = GLOBAL_CONFIG.comment.owo
|
620
|
+
owoBig(owoSelector) {
|
622
621
|
|
623
622
|
let owoBig = document.getElementById('owo-big');
|
624
623
|
if (!owoBig) {
|
@@ -641,8 +640,8 @@ let sco = {
|
|
641
640
|
|
642
641
|
const showOwoBig = (event) => {
|
643
642
|
const target = event.target;
|
644
|
-
const owoItem = target.closest(
|
645
|
-
if (owoItem && target.closest(
|
643
|
+
const owoItem = target.closest(owoSelector.item);
|
644
|
+
if (owoItem && target.closest(owoSelector.body)) {
|
646
645
|
const imgSrc = owoItem.querySelector('img')?.src;
|
647
646
|
if (imgSrc) {
|
648
647
|
owoBig.innerHTML = `<img src="${imgSrc}" style="max-width: 100%; height: auto;">`;
|
@@ -653,7 +652,7 @@ let sco = {
|
|
653
652
|
};
|
654
653
|
|
655
654
|
const hideOwoBig = (event) => {
|
656
|
-
if (event.target.closest(
|
655
|
+
if (event.target.closest(owoSelector.item) && event.target.closest(owoSelector.body)) {
|
657
656
|
owoBig.style.display = 'none';
|
658
657
|
}
|
659
658
|
};
|
@@ -674,6 +673,20 @@ let sco = {
|
|
674
673
|
item.style.display = 'inline'
|
675
674
|
})
|
676
675
|
},
|
676
|
+
switchComments() {
|
677
|
+
const switchBtn = document.getElementById('switch-btn')
|
678
|
+
if (!switchBtn) return
|
679
|
+
let switchDone = false
|
680
|
+
const commentContainer = document.getElementById('post-comment')
|
681
|
+
const handleSwitchBtn = () => {
|
682
|
+
commentContainer.classList.toggle('move')
|
683
|
+
if (!switchDone && typeof loadTwoComment === 'function') {
|
684
|
+
switchDone = true
|
685
|
+
loadTwoComment()
|
686
|
+
}
|
687
|
+
}
|
688
|
+
utils.addEventListenerPjax(switchBtn, 'click', handleSwitchBtn)
|
689
|
+
}
|
677
690
|
}
|
678
691
|
|
679
692
|
const addHighlight = () => {
|
@@ -798,6 +811,17 @@ const addCopyright = () => {
|
|
798
811
|
document.body.addEventListener('copy', handleCopy)
|
799
812
|
}
|
800
813
|
|
814
|
+
const asideStatus = () =>{
|
815
|
+
const asideStatus = utils.saveToLocal.get('aside-status')
|
816
|
+
if (asideStatus !== undefined) {
|
817
|
+
if (asideStatus === 'hide') {
|
818
|
+
document.documentElement.classList.add('hide-aside')
|
819
|
+
} else {
|
820
|
+
document.documentElement.classList.remove('hide-aside')
|
821
|
+
}
|
822
|
+
}
|
823
|
+
}
|
824
|
+
|
801
825
|
class tabs {
|
802
826
|
static init() {
|
803
827
|
this.clickFnOfTabs()
|
@@ -835,12 +859,6 @@ class tabs {
|
|
835
859
|
}
|
836
860
|
}
|
837
861
|
|
838
|
-
sco.initAdjust()
|
839
|
-
percent()
|
840
|
-
initObserver()
|
841
|
-
addCopyright()
|
842
|
-
sco.initConsoleState()
|
843
|
-
|
844
862
|
window.refreshFn = () => {
|
845
863
|
document.body.setAttribute('data-type', PAGE_CONFIG.page)
|
846
864
|
if (PAGE_CONFIG.is_home || PAGE_CONFIG.is_page) {
|
@@ -862,17 +880,23 @@ window.refreshFn = () => {
|
|
862
880
|
GLOBAL_CONFIG.lazyload.enable && utils.lazyloadImg()
|
863
881
|
GLOBAL_CONFIG.lightbox && utils.lightbox(document.querySelectorAll("#article-container img:not(.flink-avatar,.gallery-group img)"))
|
864
882
|
GLOBAL_CONFIG.randomlink && randomLinksList()
|
865
|
-
PAGE_CONFIG.comment && initComment()
|
866
883
|
PAGE_CONFIG.toc && toc.init();
|
867
884
|
(PAGE_CONFIG.is_post || PAGE_CONFIG.is_page) && ((addHighlight()) || tabs.init())
|
868
885
|
PAGE_CONFIG.is_home && showTodayCard()
|
869
886
|
GLOBAL_CONFIG.covercolor.enable && coverColor()
|
870
887
|
PAGE_CONFIG.page === "music" && scoMusic.init()
|
871
|
-
GLOBAL_CONFIG.post_ai && PAGE_CONFIG.
|
888
|
+
GLOBAL_CONFIG.post_ai && PAGE_CONFIG.is_post && efu_ai.init()
|
889
|
+
sco.switchComments()
|
872
890
|
}
|
873
891
|
|
874
892
|
document.addEventListener('DOMContentLoaded', function () {
|
893
|
+
sco.initAdjust()
|
894
|
+
percent()
|
895
|
+
initObserver()
|
896
|
+
addCopyright()
|
897
|
+
sco.initConsoleState()
|
875
898
|
window.refreshFn()
|
899
|
+
asideStatus()
|
876
900
|
})
|
877
901
|
|
878
902
|
window.onkeydown = function (e) {
|
package/source/js/tw_cn.js
CHANGED
@@ -5,9 +5,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
5
5
|
const msgToTraditionalChinese = '轉為繁體';
|
6
6
|
const msgToSimplifiedChinese = '转为简体';
|
7
7
|
let targetEncoding =
|
8
|
-
saveToLocal.get(targetEncodingCookie) === undefined
|
8
|
+
utils.saveToLocal.get(targetEncodingCookie) === undefined
|
9
9
|
? defaultEncoding
|
10
|
-
: Number(saveToLocal.get('translate-chn-cht'))
|
10
|
+
: Number(utils.saveToLocal.get('translate-chn-cht'))
|
11
11
|
let translateButtonObject
|
12
12
|
|
13
13
|
function setLang() {
|
@@ -68,7 +68,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
68
68
|
translateButtonObject.firstChild.className = 'solitude st-jianben-line'
|
69
69
|
utils.snackbarShow('你已切換為繁體')
|
70
70
|
}
|
71
|
-
saveToLocal.set(targetEncodingCookie, targetEncoding, 2)
|
71
|
+
utils.saveToLocal.set(targetEncodingCookie, targetEncoding, 2)
|
72
72
|
setLang()
|
73
73
|
translateBody()
|
74
74
|
rm.hideRightMenu()
|
package/source/js/utils.js
CHANGED
@@ -1,4 +1,33 @@
|
|
1
1
|
const utils = {
|
2
|
+
saveToLocal: {
|
3
|
+
set: function setWithExpiry(key, value, ttl) {
|
4
|
+
if (ttl === 0)
|
5
|
+
return
|
6
|
+
const now = new Date()
|
7
|
+
const expiryDay = ttl * 86400000
|
8
|
+
const item = {
|
9
|
+
value: value,
|
10
|
+
expiry: now.getTime() + expiryDay
|
11
|
+
}
|
12
|
+
localStorage.setItem(key, JSON.stringify(item))
|
13
|
+
},
|
14
|
+
|
15
|
+
get: function getWithExpiry(key) {
|
16
|
+
const itemStr = localStorage.getItem(key)
|
17
|
+
|
18
|
+
if (!itemStr) {
|
19
|
+
return undefined
|
20
|
+
}
|
21
|
+
const item = JSON.parse(itemStr)
|
22
|
+
const now = new Date()
|
23
|
+
|
24
|
+
if (now.getTime() > item.expiry) {
|
25
|
+
localStorage.removeItem(key)
|
26
|
+
return undefined
|
27
|
+
}
|
28
|
+
return item.value
|
29
|
+
}
|
30
|
+
},
|
2
31
|
debounce: function (func, wait, immediate) {
|
3
32
|
let timeout
|
4
33
|
return function () {
|
@@ -278,4 +307,37 @@ const utils = {
|
|
278
307
|
callback()
|
279
308
|
}
|
280
309
|
},
|
310
|
+
getCSS: (url, id = false) => new Promise((resolve, reject) => {
|
311
|
+
const link = document.createElement('link')
|
312
|
+
link.rel = 'stylesheet'
|
313
|
+
link.href = url
|
314
|
+
if (id) link.id = id
|
315
|
+
link.onerror = reject
|
316
|
+
link.onload = link.onreadystatechange = function () {
|
317
|
+
const loadState = this.readyState
|
318
|
+
if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
|
319
|
+
link.onload = link.onreadystatechange = null
|
320
|
+
resolve()
|
321
|
+
}
|
322
|
+
document.head.appendChild(link)
|
323
|
+
}),
|
324
|
+
|
325
|
+
getScript: (url, attr = {}) => new Promise((resolve, reject) => {
|
326
|
+
const script = document.createElement('script')
|
327
|
+
script.src = url
|
328
|
+
script.async = true
|
329
|
+
script.onerror = reject
|
330
|
+
script.onload = script.onreadystatechange = function () {
|
331
|
+
const loadState = this.readyState
|
332
|
+
if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
|
333
|
+
script.onload = script.onreadystatechange = null
|
334
|
+
resolve()
|
335
|
+
}
|
336
|
+
|
337
|
+
Object.keys(attr).forEach(key => {
|
338
|
+
script.setAttribute(key, attr[key])
|
339
|
+
})
|
340
|
+
document.head.appendChild(script)
|
341
|
+
})
|
342
|
+
|
281
343
|
}
|