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.
Files changed (33) hide show
  1. package/README.md +25 -25
  2. package/{README_zh-cn.md → README_en.md} +25 -25
  3. package/README_zh-tw.md +3 -3
  4. package/_config.yml +41 -34
  5. package/layout/includes/body/mode.pug +6 -3
  6. package/layout/includes/head/config.pug +0 -33
  7. package/layout/includes/head/page_config.pug +9 -0
  8. package/layout/includes/head.pug +4 -1
  9. package/layout/includes/inject/body.pug +1 -26
  10. package/layout/includes/inject/head.pug +11 -60
  11. package/layout/includes/widgets/post/postMeta.pug +24 -24
  12. package/layout/includes/widgets/third-party/comments/artalk.pug +29 -18
  13. package/layout/includes/widgets/third-party/comments/comment.pug +48 -12
  14. package/layout/includes/widgets/third-party/comments/twikoo.pug +61 -39
  15. package/layout/includes/widgets/third-party/comments/valine.pug +36 -38
  16. package/layout/includes/widgets/third-party/comments/waline.pug +39 -44
  17. package/layout/includes/widgets/third-party/news-comment/artalk.pug +57 -67
  18. package/layout/includes/widgets/third-party/news-comment/newest-comment.pug +6 -6
  19. package/layout/includes/widgets/third-party/news-comment/twikoo.pug +41 -48
  20. package/layout/includes/widgets/third-party/news-comment/valine.pug +5 -5
  21. package/layout/includes/widgets/third-party/news-comment/waline.pug +3 -3
  22. package/layout/includes/widgets/third-party/pjax.pug +1 -0
  23. package/package.json +1 -1
  24. package/plugins.yml +2 -2
  25. package/scripts/event/merge_config.js +280 -255
  26. package/scripts/filter/comment.js +13 -0
  27. package/source/css/_comments/comment.styl +73 -12
  28. package/source/css/_comments/valine.styl +1 -1
  29. package/source/css/_highlight/index.styl +1 -0
  30. package/source/css/_tags/link.styl +7 -2
  31. package/source/js/main.js +42 -18
  32. package/source/js/tw_cn.js +3 -3
  33. package/source/js/utils.js +62 -0
@@ -42,6 +42,7 @@ figure
42
42
  align-items center
43
43
  overflow hidden
44
44
  min-height 1.2rem
45
+ border-radius 8px 8px 0 0
45
46
  height 2.15em
46
47
  font-size 16px
47
48
  background var(--efu-hltools-bg)
@@ -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-card-bg)
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")).offsetTop < viewportBottom || scrollPercent > 90) {
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(owoSelectors.item);
645
- if (owoItem && target.closest(owoSelectors.body)) {
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(owoSelectors.item) && event.target.closest(owoSelectors.body)) {
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.page === "post" && efu_ai.init()
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) {
@@ -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()
@@ -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
  }