hexo-theme-solitude 3.0.20 → 4.0.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 (143) hide show
  1. package/.github/FUNDING.yml +3 -3
  2. package/README.md +11 -1
  3. package/README_en-US.md +11 -1
  4. package/_config.yml +16 -7
  5. package/languages/default.yml +56 -36
  6. package/languages/en.yml +90 -69
  7. package/languages/es.yml +94 -73
  8. package/languages/zh-CN.yml +56 -34
  9. package/languages/zh-TW.yml +80 -57
  10. package/layout/archive.pug +60 -14
  11. package/layout/category.pug +13 -11
  12. package/layout/includes/body/gadsense.pug +2 -2
  13. package/layout/includes/console.pug +71 -72
  14. package/layout/includes/footer.pug +38 -24
  15. package/layout/includes/head/config.pug +83 -39
  16. package/layout/includes/head/mode.pug +7 -7
  17. package/layout/includes/head/page_config.pug +20 -11
  18. package/layout/includes/inject/body.pug +18 -40
  19. package/layout/includes/keyboard.pug +3 -3
  20. package/layout/includes/loading.pug +1 -37
  21. package/layout/includes/mixins/articleSort.pug +3 -3
  22. package/layout/includes/mixins/common.pug +8 -4
  23. package/layout/includes/mixins/pace.pug +1 -1
  24. package/layout/includes/mixins/pagination.pug +3 -3
  25. package/layout/includes/nav.pug +5 -4
  26. package/layout/includes/page/about.pug +9 -8
  27. package/layout/includes/page/brevity.pug +2 -2
  28. package/layout/includes/page/links.pug +23 -11
  29. package/layout/includes/page/music.pug +0 -5
  30. package/layout/includes/rightmenu.pug +20 -20
  31. package/layout/includes/sidebar.pug +2 -2
  32. package/layout/includes/widgets/aside/asideInfoCard.pug +2 -2
  33. package/layout/includes/widgets/aside/asideTag.pug +2 -2
  34. package/layout/includes/widgets/home/bbTimeList.pug +3 -3
  35. package/layout/includes/widgets/home/categoryBar.pug +30 -15
  36. package/layout/includes/widgets/home/hometop.pug +113 -8
  37. package/layout/includes/widgets/home/postList.pug +1 -2
  38. package/layout/includes/widgets/home/topGroup.pug +3 -7
  39. package/layout/includes/widgets/nav/group.pug +4 -2
  40. package/layout/includes/widgets/nav/menu.pug +6 -4
  41. package/layout/includes/widgets/nav/right.pug +7 -6
  42. package/layout/includes/widgets/page/about/award.pug +67 -38
  43. package/layout/includes/widgets/page/about/hobbies.pug +12 -3
  44. package/layout/includes/widgets/page/banner.pug +1 -1
  45. package/layout/includes/widgets/page/kit/content.pug +2 -2
  46. package/layout/includes/widgets/page/links/banner.pug +30 -19
  47. package/layout/includes/widgets/page/message/artalk.pug +3 -3
  48. package/layout/includes/widgets/page/message/content.pug +3 -3
  49. package/layout/includes/widgets/page/message/twikoo.pug +3 -3
  50. package/layout/includes/widgets/page/message/valine.pug +4 -4
  51. package/layout/includes/widgets/page/message/waline.pug +3 -3
  52. package/layout/includes/widgets/page/recentcomment/artalk.pug +5 -9
  53. package/layout/includes/widgets/page/recentcomment/twikoo.pug +5 -9
  54. package/layout/includes/widgets/page/recentcomment/valine.pug +6 -10
  55. package/layout/includes/widgets/page/recentcomment/waline.pug +5 -9
  56. package/layout/includes/widgets/post/award.pug +1 -28
  57. package/layout/includes/widgets/post/copyright.pug +10 -10
  58. package/layout/includes/widgets/post/postInfo.pug +10 -11
  59. package/layout/includes/widgets/post/postMeta.pug +3 -2
  60. package/layout/includes/widgets/rightside/hide.pug +5 -5
  61. package/layout/includes/widgets/rightside/show.pug +7 -7
  62. package/layout/includes/widgets/third-party/comments/artalk.pug +9 -9
  63. package/layout/includes/widgets/third-party/comments/giscus.pug +2 -2
  64. package/layout/includes/widgets/third-party/comments/twikoo.pug +5 -5
  65. package/layout/includes/widgets/third-party/comments/valine.pug +6 -6
  66. package/layout/includes/widgets/third-party/comments/waline.pug +6 -6
  67. package/layout/includes/widgets/third-party/hot/index.pug +1 -1
  68. package/layout/includes/widgets/third-party/hot/twikoo.pug +1 -1
  69. package/layout/includes/widgets/third-party/music.pug +9 -5
  70. package/layout/includes/widgets/third-party/news-comment/artalk.pug +6 -6
  71. package/layout/includes/widgets/third-party/news-comment/twikoo.pug +7 -7
  72. package/layout/includes/widgets/third-party/news-comment/valine.pug +8 -8
  73. package/layout/includes/widgets/third-party/news-comment/waline.pug +7 -7
  74. package/layout/includes/widgets/third-party/pjax.pug +16 -10
  75. package/layout/includes/widgets/third-party/search/algolia-search.pug +2 -2
  76. package/layout/includes/widgets/third-party/search/docsearch.pug +3 -3
  77. package/layout/includes/widgets/third-party/search/index.pug +1 -3
  78. package/layout/includes/widgets/third-party/search/local-search.pug +9 -9
  79. package/layout/index.pug +10 -8
  80. package/package.json +8 -7
  81. package/plugins.yml +22 -21
  82. package/scripts/event/cdn.js +11 -6
  83. package/scripts/event/friend_links.js +30 -0
  84. package/scripts/event/merge_config.js +15 -7
  85. package/scripts/filter/comment.js +2 -2
  86. package/scripts/filter/default.js +1 -1
  87. package/scripts/helper/inject_head_js.js +79 -33
  88. package/scripts/helper/related_post.js +16 -21
  89. package/scripts/tags/chart.js +1 -1
  90. package/scripts/tags/typeit.js +1 -1
  91. package/source/css/_components/capsule.styl +259 -168
  92. package/source/css/_components/rightside.styl +98 -242
  93. package/source/css/_global/animation.styl +1 -10
  94. package/source/css/_global/index.styl +27 -1
  95. package/source/css/_layout/aside.styl +7 -1
  96. package/source/css/_layout/console.styl +144 -163
  97. package/source/css/_layout/header.styl +238 -47
  98. package/source/css/_layout/pagination.styl +176 -132
  99. package/source/css/_layout/rightmenu.styl +11 -2
  100. package/source/css/_layout/sidebar.styl +39 -17
  101. package/source/css/_mode/index.styl +7 -1
  102. package/source/css/_page/_about/about.styl +18 -2
  103. package/source/css/_page/_about/buff.styl +1 -1
  104. package/source/css/_page/_about/contentinfo.styl +2 -1
  105. package/source/css/_page/_about/game.styl +57 -1
  106. package/source/css/_page/_about/like.styl +7 -2
  107. package/source/css/_page/_about/maxim.styl +1 -1
  108. package/source/css/_page/_about/reward.styl +226 -108
  109. package/source/css/_page/_about/skills.styl +5 -3
  110. package/source/css/_page/_home/category-bar.styl +162 -88
  111. package/source/css/_page/_home/home-top.styl +309 -263
  112. package/source/css/_page/_home/home.styl +34 -7
  113. package/source/css/_page/archive.styl +412 -0
  114. package/source/css/_page/category.styl +27 -1
  115. package/source/css/_page/index.styl +2 -0
  116. package/source/css/_page/links.styl +190 -0
  117. package/source/css/_page/other.styl +37 -0
  118. package/source/css/_post/index.styl +2 -1
  119. package/source/css/_post/meta.styl +245 -217
  120. package/source/css/_search/local-search.styl +158 -82
  121. package/source/css/var.styl +2 -2
  122. package/source/js/archive-page.js +191 -0
  123. package/source/js/core/actions.js +48 -0
  124. package/source/js/core/api.js +32 -0
  125. package/source/js/core/config.js +13 -0
  126. package/source/js/core/lifecycle.js +52 -0
  127. package/source/js/core/preloader.js +34 -0
  128. package/source/js/core/resources.js +65 -0
  129. package/source/js/covercolor/api.js +13 -103
  130. package/source/js/covercolor/ave.js +14 -77
  131. package/source/js/covercolor/local.js +22 -116
  132. package/source/js/covercolor/shared.js +102 -0
  133. package/source/js/friend_links.js +502 -0
  134. package/source/js/main.js +793 -177
  135. package/source/js/music.js +24 -14
  136. package/source/js/post_ai.js +13 -2
  137. package/source/js/right_menu.js +44 -24
  138. package/source/js/search/algolia.js +29 -21
  139. package/source/js/search/local.js +231 -266
  140. package/source/js/tw_cn.js +37 -12
  141. package/source/js/utils.js +37 -25
  142. package/layout/includes/widgets/randomlink.pug +0 -43
  143. package/scripts/filter/randomPosts.js +0 -16
@@ -1,9 +1,18 @@
1
- document.addEventListener('DOMContentLoaded', function () {
2
- const { defaultEncoding, translateDelay } = GLOBAL_CONFIG.translate;
1
+ import { Solitude } from "./core/api.js";
2
+
3
+ const initializeTranslation = () => {
4
+ const {
5
+ defaultEncoding,
6
+ translateDelay,
7
+ toSimplified,
8
+ toTraditional,
9
+ switchedToSimplified,
10
+ switchedToTraditional,
11
+ } = Solitude.config.translate;
3
12
  const targetEncodingCookie = 'translate-chn-cht';
4
13
 
5
14
  let currentEncoding = defaultEncoding;
6
- let targetEncoding = Number(utils.saveToLocal.get(targetEncodingCookie)) || defaultEncoding;
15
+ let targetEncoding = Number(Solitude.saveToLocal.get(targetEncodingCookie)) || defaultEncoding;
7
16
 
8
17
  function setLang() {
9
18
  document.documentElement.lang = targetEncoding === 1 ? 'zh-TW' : 'zh-CN';
@@ -23,6 +32,9 @@ document.addEventListener('DOMContentLoaded', function () {
23
32
  if (obj.title) obj.title = translateText(obj.title);
24
33
  if (obj.alt) obj.alt = translateText(obj.alt);
25
34
  if (obj.placeholder) obj.placeholder = translateText(obj.placeholder);
35
+ if (obj.getAttribute?.('heotip')) {
36
+ obj.setAttribute('heotip', translateText(obj.getAttribute('heotip')));
37
+ }
26
38
  if (obj.tagName === 'INPUT' && obj.value && !['text', 'hidden'].includes(obj.type)) {
27
39
  obj.value = translateText(obj.value);
28
40
  }
@@ -34,16 +46,23 @@ document.addEventListener('DOMContentLoaded', function () {
34
46
  });
35
47
  }
36
48
 
37
- function translatePage(simplified, traditional, button) {
49
+ function updateButtonLabel(button, label) {
50
+ const textNode = button.lastElementChild || button.lastChild;
51
+ if (textNode) textNode.textContent = label;
52
+ button.setAttribute('title', label);
53
+ button.setAttribute('heotip', label);
54
+ }
55
+
56
+ function translatePage(button, simplified = toSimplified, traditional = toTraditional) {
38
57
  currentEncoding = targetEncoding;
39
58
  targetEncoding = targetEncoding === 1 ? 2 : 1;
40
- button.lastChild.textContent = targetEncoding === 1 ? simplified : traditional;
59
+ updateButtonLabel(button, targetEncoding === 1 ? simplified : traditional);
41
60
 
42
- utils.snackbarShow(targetEncoding === 1 ? '你已切換為繁體' : '你已切换为简体');
43
- utils.saveToLocal.set(targetEncodingCookie, targetEncoding, 2);
61
+ Solitude.snackbarShow(targetEncoding === 1 ? switchedToTraditional : switchedToSimplified);
62
+ Solitude.saveToLocal.set(targetEncodingCookie, targetEncoding, 2);
44
63
  setLang();
45
64
  translateBody();
46
- rm.hideRightMenu();
65
+ Solitude.hideRightMenu?.();
47
66
  }
48
67
 
49
68
  function JTPYStr() {
@@ -75,12 +94,12 @@ document.addEventListener('DOMContentLoaded', function () {
75
94
  function translateInitialization() {
76
95
  const btn_1 = document.getElementById('menu-translate');
77
96
  if (btn_1) {
78
- btn_1.lastChild.textContent = targetEncoding === 1 ? '转为简体' : '转为繁体';
97
+ updateButtonLabel(btn_1, targetEncoding === 1 ? toSimplified : toTraditional);
79
98
  if (currentEncoding !== targetEncoding) {
80
99
  setLang();
81
100
  setTimeout(translateBody, translateDelay);
82
101
  }
83
- btn_1.addEventListener('click', () => translatePage('转为简体', '转为繁体', btn_1), false);
102
+ btn_1.addEventListener('click', () => translatePage(btn_1), false);
84
103
  }
85
104
 
86
105
  const btn_2 = document.querySelector('.rs_hide .translate');
@@ -90,10 +109,16 @@ document.addEventListener('DOMContentLoaded', function () {
90
109
  setLang();
91
110
  setTimeout(translateBody, translateDelay);
92
111
  }
93
- btn_2.addEventListener('click', () => translatePage('简', '繁', btn_2), false);
112
+ btn_2.addEventListener('click', () => translatePage(btn_2, '简', '繁'), false);
94
113
  }
95
114
  }
96
115
 
97
116
  translateInitialization();
98
117
  document.addEventListener('pjax:complete', translateInitialization);
99
- });
118
+ };
119
+
120
+ if (document.readyState === 'loading') {
121
+ document.addEventListener('DOMContentLoaded', initializeTranslation, { once: true });
122
+ } else {
123
+ initializeTranslation();
124
+ }
@@ -38,9 +38,9 @@
38
38
  copy: async (text) => {
39
39
  const message = await navigator.clipboard
40
40
  .writeText(text)
41
- .then(() => GLOBAL_CONFIG.lang.copy.success)
42
- .catch(() => GLOBAL_CONFIG.lang.copy.error);
43
- utils.snackbarShow(message, false, 2000);
41
+ .then(() => Solitude.config.lang.copy.success)
42
+ .catch(() => Solitude.config.lang.copy.error);
43
+ Solitude.snackbarShow(message, false, 2000);
44
44
  },
45
45
  getEleTop: (ele) => {
46
46
  let actualTop = ele.offsetTop;
@@ -113,11 +113,11 @@
113
113
  elements_selector: "img",
114
114
  threshold: 0,
115
115
  data_src: "lazy-src",
116
- callback_error: (img) => (img.src = GLOBAL_CONFIG.lazyload.error),
116
+ callback_error: (img) => (img.src = Solitude.config.lazyload.error),
117
117
  });
118
118
  },
119
119
  lightbox: function (selector) {
120
- const lightboxType = GLOBAL_CONFIG.lightbox;
120
+ const lightboxType = Solitude.config.lightbox;
121
121
  const options = {
122
122
  class: "fancybox",
123
123
  "data-fancybox": "gallery",
@@ -131,30 +131,42 @@
131
131
  if (i.parentNode.tagName !== "A") {
132
132
  options.href = options["data-thumb"] = i.dataset.lazySrc || i.src;
133
133
  options["data-caption"] = i.title || i.alt || "";
134
- utils.wrap(i, "a", options);
134
+ Solitude.wrap(i, "a", options);
135
135
  }
136
136
  });
137
137
 
138
138
  if (!window.fancyboxRun) {
139
139
  Fancybox.bind("[data-fancybox]", {
140
140
  Hash: false,
141
- animated: true,
142
- Thumbs: { showOnStart: false },
143
- Images: { Panzoom: { maxScale: 4 } },
144
- Carousel: { transition: "slide" },
145
- Toolbar: {
146
- display: {
147
- left: ["infobar"],
148
- middle: [
149
- "zoomIn",
150
- "zoomOut",
151
- "toggle1to1",
152
- "rotateCCW",
153
- "rotateCW",
154
- "flipX",
155
- "flipY",
156
- ],
157
- right: ["slideshow", "thumbs", "close"],
141
+ Carousel: {
142
+ transition: "slide",
143
+ Thumbs: { showOnStart: false },
144
+ Zoomable: { Panzoom: { maxScale: 4 } },
145
+ Toolbar: {
146
+ display: {
147
+ left: ["counter"],
148
+ middle: [],
149
+ right: ["thumbs", "close"],
150
+ },
151
+ },
152
+ breakpoints: {
153
+ "(min-width: 768px)": {
154
+ Toolbar: {
155
+ display: {
156
+ left: ["counter"],
157
+ middle: [
158
+ "zoomIn",
159
+ "zoomOut",
160
+ "toggle1to1",
161
+ "rotateCCW",
162
+ "rotateCW",
163
+ "flipX",
164
+ "flipY",
165
+ ],
166
+ right: ["autoplay", "thumbs", "close"],
167
+ },
168
+ },
169
+ },
158
170
  },
159
171
  },
160
172
  });
@@ -170,7 +182,7 @@
170
182
  const hour = 3600000;
171
183
  const day = 86400000;
172
184
  const month = 2592000000;
173
- const { time } = GLOBAL_CONFIG.lang;
185
+ const { time } = Solitude.config.lang;
174
186
 
175
187
  const dayCount = Math.floor(dateDiff / day);
176
188
  if (!more) return dayCount;
@@ -214,5 +226,5 @@
214
226
  }[m])
215
227
  ),
216
228
  };
217
- window.utils = { ...window.utils, ...utilsFn };
229
+ Object.assign(window.Solitude, utilsFn);
218
230
  })();
@@ -1,43 +0,0 @@
1
- - var datalinks = []
2
- - var data = site.data.links.links
3
- if(data)
4
- each item in data
5
- each y in item.link_list
6
- - datalinks.push({ name: y.name,link: y.link})
7
-
8
- script.
9
- const links = !{JSON.stringify(datalinks)}
10
- const randomText = '!{_p('link.random')}'
11
- function travelling() {
12
- const link = links[utils.randomNum(links.length)];
13
- Snackbar.show({
14
- text: randomText.replace(/\$\{name}/,link.name),
15
- duration: 8000,
16
- pos: 'top-center',
17
- actionText: '!{_p('link.to')}',
18
- onActionClick: function(element) {
19
- element.style.opacity = 0;
20
- window.open(link.link, '_blank');
21
- }
22
- });
23
- }
24
-
25
- if theme.footer.randomlink
26
- script.
27
- function randomLinksList() {
28
- const linkcard = document.getElementById('friend-links-in-footer');
29
- if (linkcard == null) return;
30
-
31
- let data = '';
32
- let linksCopy = [...links];
33
- let count = Math.min(3, linksCopy.length);
34
-
35
- for (let i = 0; i < count; i++) {
36
- let index = utils.randomNum(linksCopy.length);
37
- const {link, name} = linksCopy[index];
38
- data += `<a class="footer-item" href="${link}" target="_blank" rel="noopener noreferrer nofollow">${name}</a>`;
39
- linksCopy.splice(index, 1);
40
- }
41
-
42
- linkcard.innerHTML = data + '<a class="footer-item" href="#{url_for(/links/)}">#{_p('more')}</a>';
43
- }
@@ -1,16 +0,0 @@
1
- hexo.extend.filter.register('after_render:html', function (data) {
2
- const posts = hexo.locals.get('posts')
3
- .filter(post => post.random !== false)
4
- .map(post => post.path);
5
-
6
- const scriptContent = `
7
- <script>
8
- const posts = ${JSON.stringify(posts)};
9
- function toRandomPost() {
10
- const randomPost = posts[Math.floor(Math.random() * posts.length)];
11
- pjax.loadUrl(GLOBAL_CONFIG.root + randomPost);
12
- }
13
- </script>`;
14
-
15
- return data + scriptContent;
16
- });