hexo-theme-stellar 1.33.1 → 1.34.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 (81) hide show
  1. package/CLAUDE.md +217 -0
  2. package/README.md +2 -0
  3. package/_config.yml +28 -14
  4. package/docs/audits/2026-08-08-stellar-analysis.md +267 -0
  5. package/docs/release-process.md +59 -0
  6. package/layout/_partial/comments/artalk/script.ejs +56 -41
  7. package/layout/_partial/comments/beaudar/script.ejs +35 -20
  8. package/layout/_partial/comments/giscus/script.ejs +34 -19
  9. package/layout/_partial/comments/twikoo/script.ejs +29 -14
  10. package/layout/_partial/comments/utterances/script.ejs +35 -20
  11. package/layout/_partial/comments/waline/script.ejs +40 -28
  12. package/layout/_partial/cover/wiki_cover.ejs +1 -1
  13. package/layout/_partial/head.ejs +53 -4
  14. package/layout/_partial/scripts/defines.ejs +21 -3
  15. package/layout/_partial/scripts/lazyload.ejs +2 -2
  16. package/layout/_partial/scripts/services.ejs +101 -41
  17. package/layout/_partial/scripts/utils.ejs +144 -5
  18. package/layout/_partial/sidebar/index_leftbar.ejs +3 -0
  19. package/layout/_partial/sidebar/search.ejs +3 -0
  20. package/layout/_partial/widgets/ghuser.ejs +18 -4
  21. package/layout/_partial/widgets/linklist.ejs +1 -1
  22. package/layout/_partial/widgets/timeline.ejs +36 -33
  23. package/layout/_plugins/copycode.ejs +9 -5
  24. package/layout/_plugins/mermaid.ejs +28 -24
  25. package/layout/_plugins/pjax.ejs +8 -0
  26. package/layout/_plugins/scrollreveal.ejs +14 -13
  27. package/layout/_plugins/swiper.ejs +2 -2
  28. package/layout/index.ejs +4 -2
  29. package/layout/index_topic.ejs +4 -2
  30. package/layout/index_wiki.ejs +6 -4
  31. package/layout/layout.ejs +3 -2
  32. package/package.json +2 -1
  33. package/scripts/commands/new-note.js +49 -0
  34. package/scripts/filters/lib/img_onerror.js +0 -2
  35. package/scripts/helpers/json_ld.js +11 -8
  36. package/scripts/helpers/pretty_url.js +5 -0
  37. package/scripts/tags/lib/chat.js +16 -9
  38. package/scripts/tags/lib/frame.js +2 -1
  39. package/scripts/tags/lib/image.js +6 -5
  40. package/scripts/tags/lib/link.js +6 -4
  41. package/scripts/tags/lib/timeline.js +101 -79
  42. package/source/css/_common/canonical.styl +11 -6
  43. package/source/css/_common/highlight.styl +4 -1
  44. package/source/css/_common/html.styl +4 -0
  45. package/source/css/_common/loading.styl +5 -1
  46. package/source/css/_components/md.styl +1 -0
  47. package/source/css/_components/pages/article-story.styl +2 -0
  48. package/source/css/_components/partial/article-footer.styl +1 -0
  49. package/source/css/_components/partial/navbar.styl +2 -0
  50. package/source/css/_components/sidebar/menu.styl +1 -0
  51. package/source/css/_components/sidebar/search.styl +4 -0
  52. package/source/css/_components/sidebar/sidebar.styl +12 -5
  53. package/source/css/_components/tag-plugins/chat.styl +6 -8
  54. package/source/css/_components/tag-plugins/folding.styl +1 -0
  55. package/source/css/_components/tag-plugins/gallery.styl +2 -0
  56. package/source/css/_components/tag-plugins/grid.styl +1 -0
  57. package/source/css/_components/tag-plugins/image.styl +3 -0
  58. package/source/css/_components/tag-plugins/link.styl +1 -0
  59. package/source/css/_components/tag-plugins/navbar.styl +15 -13
  60. package/source/css/_components/tag-plugins/note.styl +1 -0
  61. package/source/css/_components/tag-plugins/okr.styl +1 -0
  62. package/source/css/_components/tag-plugins/sites.styl +2 -0
  63. package/source/css/_components/tag-plugins/timeline.styl +9 -0
  64. package/source/css/_components/tag-plugins/vote.styl +2 -0
  65. package/source/css/_components/widgets/components.styl +1 -0
  66. package/source/css/_components/widgets/ghuser.styl +19 -3
  67. package/source/css/_components/widgets/list.styl +1 -0
  68. package/source/css/_components/widgets/toc.styl +3 -0
  69. package/source/css/_components/widgets/widgets.styl +4 -0
  70. package/source/css/_custom.styl +2 -1
  71. package/source/css/_defines/func.styl +8 -0
  72. package/source/css/_plugins/comments/artalk.styl +6 -2
  73. package/source/css/_plugins/comments/twikoo.styl +2 -0
  74. package/source/css/_plugins/index.styl +2 -0
  75. package/source/css/_plugins/pjax.styl +61 -0
  76. package/source/js/main.js +80 -26
  77. package/source/js/plugins/copycode.js +34 -27
  78. package/source/js/plugins/pjax.js +646 -0
  79. package/source/js/search/local-search.js +5 -2
  80. package/source/js/services/memos.js +42 -4
  81. package/source/js/services/rss.js +200 -0
package/source/js/main.js CHANGED
@@ -37,10 +37,11 @@ const util = {
37
37
  const el = document.getElementById(id);
38
38
  if (el) {
39
39
  el.select();
40
- document.execCommand("Copy");
41
- if (msg && msg.length > 0) {
42
- hud.toast(msg, 2500);
43
- }
40
+ navigator.clipboard.writeText(el.value).then(() => {
41
+ if (msg && msg.length > 0) {
42
+ hud.toast(msg, 2500);
43
+ }
44
+ }).catch(() => {});
44
45
  }
45
46
  },
46
47
 
@@ -52,11 +53,11 @@ const util = {
52
53
  },
53
54
 
54
55
  scrollTop: () => {
55
- window.scrollTo({top: 0, behavior: "smooth"});
56
+ window.scrollTo({ top: 0, behavior: "smooth" });
56
57
  },
57
58
 
58
59
  scrollComment: () => {
59
- document.getElementById('comments').scrollIntoView({behavior: "smooth"});
60
+ document.getElementById('comments').scrollIntoView({ behavior: "smooth" });
60
61
  },
61
62
 
62
63
  viewportLazyload: (target, func, enabled = true) => {
@@ -83,8 +84,8 @@ const hud = {
83
84
  el.innerHTML = msg;
84
85
  document.body.appendChild(el);
85
86
 
86
- setTimeout(function(){ document.body.removeChild(el) }, d);
87
-
87
+ setTimeout(function () { document.body.removeChild(el) }, d);
88
+
88
89
  },
89
90
 
90
91
  }
@@ -138,20 +139,20 @@ const init = {
138
139
  const offsetBottom = e1.getBoundingClientRect().bottom - e0.getBoundingClientRect().bottom + 100;
139
140
  const offsetTop = e1.getBoundingClientRect().top - e0.getBoundingClientRect().top - 64;
140
141
  if (offsetTop < 0) {
141
- e0.scrollBy({top: offsetTop, behavior: "smooth"});
142
+ e0.scrollBy({ top: offsetTop, behavior: "smooth" });
142
143
  } else if (offsetBottom > 0) {
143
- e0.scrollBy({top: offsetBottom, behavior: "smooth"});
144
+ e0.scrollBy({ top: offsetBottom, behavior: "smooth" });
144
145
  }
145
146
  }
146
-
147
+
147
148
  var timeout = null;
148
- window.addEventListener('scroll', function() {
149
+ window.addEventListener('scroll', function () {
149
150
  activeTOC();
150
- if(timeout !== null) clearTimeout(timeout);
151
- timeout = setTimeout(function() {
151
+ if (timeout !== null) clearTimeout(timeout);
152
+ timeout = setTimeout(function () {
152
153
  scrollTOC();
153
154
  }.bind(this), 50);
154
- });
155
+ });
155
156
  })
156
157
  },
157
158
  sidebar: () => {
@@ -202,24 +203,44 @@ const init = {
202
203
 
203
204
  canonicalCheck: () => {
204
205
  const canonical = window.canonical;
205
- function showTip(isOfficial = false) {
206
+ function originStatusCheck() {
207
+ return new Promise((resolve) => {
208
+ if (window.canonical.originalHost === window.location.hostname) {
209
+ resolve(true);
210
+ return;
211
+ }
212
+ const scriptUrl = `https://${window.canonical.originalHost}${window.canonical.param.checklink}`;
213
+ const script = document.createElement('script');
214
+ script.src = scriptUrl;
215
+ script.type = 'text/javascript';
216
+ script.onload = function () { resolve(true); };
217
+ script.onerror = function () { resolve(false); };
218
+ document.head.appendChild(script);
219
+ });
220
+ }
221
+ async function showTip(isOfficial = false) {
206
222
  const meta = document.createElement('meta');
207
223
  meta.name = 'robots';
208
224
  meta.content = 'noindex, nofollow';
209
225
  document.head.appendChild(meta);
210
226
  const notice = document.createElement('div');
211
227
  const originalURL = `https://${canonical.originalHost}`;
228
+ const currentURL = canonical.param.permalink.startsWith("http") ? canonical.param.permalink : originalURL;
212
229
  if (isOfficial) {
230
+ const closeEnable = window.localStorage.getItem('Stellar.canonical.closeEnable') === 'true'
231
+ const closedToday = window.localStorage.getItem('Stellar.canonical.closeTime') === new Date().toDateString()
232
+ if ((closeEnable && closedToday) || !(await originStatusCheck())) return;
213
233
  notice.className = 'canonical-tip official';
214
234
  notice.innerHTML = `
215
- <a href="${originalURL}" target="_self" rel="noopener noreferrer">
216
- 本站为官方备用站,仅供应急。主站:${originalURL}
217
- </a>
235
+ <a href="${currentURL}" target="_self" rel="noopener noreferrer">
236
+ 本站为官方备用站,仅供应急。点击移步主站<br>${originalURL}
237
+ </a>
238
+ ${canonical.closeEnable ? '<button id="canonical-close">' + canonical.closeText || '关闭提示' + '</button>' : ''}
218
239
  `;
219
240
  } else {
220
241
  notice.className = 'canonical-tip unofficial';
221
242
  notice.innerHTML = `
222
- <a href="${originalURL}" target="_self" rel="noopener noreferrer">
243
+ <a href="${currentURL}" target="_self" rel="noopener noreferrer">
223
244
  <div class="headline icon">☠️</div>
224
245
  本站为非法克隆站,请前往官方源站访问。<br>
225
246
  源站:${originalURL}
@@ -227,6 +248,14 @@ const init = {
227
248
  `;
228
249
  }
229
250
  document.body.appendChild(notice);
251
+ const closeBtn = notice.querySelector('#canonical-close');
252
+ if (closeBtn) {
253
+ closeBtn.addEventListener('click', function () {
254
+ window.localStorage.setItem('Stellar.canonical.closeEnable', "true")
255
+ window.localStorage.setItem('Stellar.canonical.closeTime', new Date().toDateString())
256
+ notice.style.display = 'none';
257
+ });
258
+ }
230
259
  }
231
260
  if (!canonical.originalHost) return;
232
261
  const currentURL = new URL(window.location.href);
@@ -259,9 +288,34 @@ const init = {
259
288
  }
260
289
 
261
290
 
262
- // init
263
- init.toc()
264
- init.sidebar()
265
- init.relativeDate(document.querySelectorAll('#post-meta time'))
266
- init.registerTabsTag()
267
- init.canonicalCheck()
291
+ // Stellar namespace
292
+ window.stellar = window.stellar || {};
293
+
294
+ /**
295
+ * Initialize page components
296
+ * Called on initial load and after PJAX navigation
297
+ */
298
+ stellar.initPage = function () {
299
+ init.toc();
300
+ init.sidebar();
301
+ init.relativeDate(document.querySelectorAll('#post-meta time'));
302
+ init.registerTabsTag();
303
+
304
+ // Reinitialize comments after PJAX navigation
305
+ if (stellar.initComments) {
306
+ for (const commentSystem in stellar.initComments) {
307
+ if (typeof stellar.initComments[commentSystem] === 'function') {
308
+ stellar.initComments[commentSystem]();
309
+ }
310
+ }
311
+ }
312
+ };
313
+
314
+ // Initial page load
315
+ stellar.initPage();
316
+ init.canonicalCheck();
317
+
318
+ // Listen for PJAX navigation complete
319
+ document.addEventListener('pjax:complete', function () {
320
+ stellar.initPage();
321
+ });
@@ -1,32 +1,39 @@
1
- window.codeElements.forEach((codeElement) => {
2
- // 创建复制按钮
3
- const codeCopyBtn = document.createElement('div');
4
- codeCopyBtn.className = 'copy-btn';
5
- codeCopyBtn.textContent = ctx.copycode.default_text;
6
- codeElement.appendChild(codeCopyBtn);
1
+ function createCopyButtons(codeElements) {
2
+ codeElements.forEach((codeElement) => {
3
+ if (codeElement.querySelector('.copy-btn')) return;
4
+ // 创建复制按钮
5
+ const codeCopyBtn = document.createElement('div');
6
+ codeCopyBtn.className = 'copy-btn';
7
+ codeCopyBtn.textContent = ctx.copycode.default_text;
8
+ codeElement.appendChild(codeCopyBtn);
7
9
 
8
- // 添加点击事件监听
9
- codeCopyBtn.addEventListener('click', async () => {
10
- const codeToCopy = codeElement.querySelector('pre')?.innerText || '';
11
- if (navigator.clipboard) {
12
- try {
13
- await navigator.clipboard.writeText(codeToCopy);
14
- codeCopyBtn.textContent = ctx.copycode.success_text;
15
- codeCopyBtn.classList.add('success');
16
- hud.toast(ctx.copycode.toast, 2500);
17
- } catch (error) {
18
- codeCopyBtn.textContent = '未获得用户许可';
10
+ // 添加点击事件监听
11
+ codeCopyBtn.addEventListener('click', async () => {
12
+ const codeToCopy = codeElement.querySelector('pre')?.innerText || '';
13
+ if (navigator.clipboard) {
14
+ try {
15
+ await navigator.clipboard.writeText(codeToCopy);
16
+ codeCopyBtn.textContent = ctx.copycode.success_text;
17
+ codeCopyBtn.classList.add('success');
18
+ hud.toast(ctx.copycode.toast, 2500);
19
+ } catch (error) {
20
+ codeCopyBtn.textContent = '未获得用户许可';
21
+ codeCopyBtn.classList.add('warning');
22
+ }
23
+ } else {
24
+ codeCopyBtn.textContent = '浏览器不支持/非HTTPS';
19
25
  codeCopyBtn.classList.add('warning');
20
26
  }
21
- } else {
22
- codeCopyBtn.textContent = '浏览器不支持/非HTTPS';
23
- codeCopyBtn.classList.add('warning');
24
- }
25
27
 
26
- // 3秒后恢复默认文本
27
- setTimeout(() => {
28
- codeCopyBtn.textContent = ctx.copycode.default_text;
29
- codeCopyBtn.classList.remove('success', 'warning');
30
- }, 3000);
28
+ // 3秒后恢复默认文本
29
+ setTimeout(() => {
30
+ codeCopyBtn.textContent = ctx.copycode.default_text;
31
+ codeCopyBtn.classList.remove('success', 'warning');
32
+ }, 3000);
33
+ });
31
34
  });
32
- });
35
+ }
36
+
37
+ if (typeof window.codeElements !== 'undefined') {
38
+ createCopyButtons(window.codeElements);
39
+ }