hexo-theme-stellar 1.35.0 → 1.36.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 (46) hide show
  1. package/_config.yml +25 -10
  2. package/layout/_partial/comments/artalk/layout.ejs +2 -2
  3. package/layout/_partial/comments/artalk/script.ejs +3 -9
  4. package/layout/_partial/comments/beaudar/script.ejs +2 -8
  5. package/layout/_partial/comments/giscus/script.ejs +2 -8
  6. package/layout/_partial/comments/twikoo/layout.ejs +2 -2
  7. package/layout/_partial/comments/twikoo/script.ejs +3 -9
  8. package/layout/_partial/comments/utterances/script.ejs +2 -8
  9. package/layout/_partial/comments/waline/layout.ejs +1 -1
  10. package/layout/_partial/comments/waline/script.ejs +1 -7
  11. package/layout/_partial/scripts/defines.ejs +118 -1
  12. package/layout/_partial/scripts/lazyload.ejs +7 -6
  13. package/layout/_partial/scripts/services.ejs +11 -13
  14. package/layout/_partial/scripts/utils.ejs +359 -24
  15. package/layout/_partial/widgets/tagtree.ejs +1 -1
  16. package/layout/_partial/widgets/toc.ejs +1 -4
  17. package/layout/_partial/widgets/tree.ejs +1 -1
  18. package/layout/_plugins/fancybox.ejs +23 -8
  19. package/layout/_plugins/scrollreveal.ejs +77 -13
  20. package/package.json +1 -1
  21. package/scripts/filters/lib/img_lazyload.js +9 -9
  22. package/scripts/tags/lib/emoji.js +17 -2
  23. package/scripts/tags/lib/image.js +13 -18
  24. package/source/css/_common/html.styl +0 -2
  25. package/source/css/_components/widgets/toc.styl +2 -2
  26. package/source/css/_plugins/lazyload.styl +40 -26
  27. package/source/css/_plugins/scrollreveal.styl +5 -1
  28. package/source/js/main.js +157 -69
  29. package/source/js/search/algolia-search.js +62 -62
  30. package/source/js/search/local-search.js +37 -36
  31. package/source/js/services/artalk_latest_comment.js +5 -7
  32. package/source/js/services/contributors.js +4 -6
  33. package/source/js/services/fcircle.js +4 -6
  34. package/source/js/services/friends.js +4 -6
  35. package/source/js/services/friends_and_posts.js +4 -6
  36. package/source/js/services/ghinfo.js +6 -8
  37. package/source/js/services/giscus_latest_comment.js +4 -6
  38. package/source/js/services/mdrender.js +2 -2
  39. package/source/js/services/memos.js +3 -4
  40. package/source/js/services/rss.js +10 -12
  41. package/source/js/services/siteinfo.js +24 -26
  42. package/source/js/services/sites.js +4 -6
  43. package/source/js/services/timeline.js +4 -6
  44. package/source/js/services/twikoo_latest_comment.js +5 -7
  45. package/source/js/services/waline_latest_comment.js +4 -6
  46. package/source/js/services/weibo.js +4 -6
@@ -130,58 +130,59 @@ var searchFunc = function(path, filter, wrapperId, searchId, contentId) {
130
130
  }
131
131
  };
132
132
 
133
- utils.jq(() => {
134
- (function preloadSearchData() {
135
- var path = ctx.search.path;
136
- if (path.startsWith('/')) {
137
- path = path.substring(1);
138
- }
139
- path = ctx.root + path;
133
+ (function preloadSearchData() {
134
+ var path = ctx.search.path;
135
+ if (path.startsWith('/')) {
136
+ path = path.substring(1);
137
+ }
138
+ path = ctx.root + path;
140
139
 
141
- try {
142
- var cached = localStorage.getItem(searchCacheKey);
143
- if (cached) {
144
- searchCache = JSON.parse(cached);
145
- }
146
- } catch (e) {
147
- console.warn('搜索缓存解析失败', e);
140
+ try {
141
+ var cached = localStorage.getItem(searchCacheKey);
142
+ if (cached) {
143
+ searchCache = JSON.parse(cached);
148
144
  }
145
+ } catch (e) {
146
+ console.warn('搜索缓存解析失败', e);
147
+ }
149
148
 
150
- fetch(path)
151
- .then(res => res.json())
152
- .then(json => {
153
- searchCache = json;
154
- try {
155
- localStorage.setItem(searchCacheKey, JSON.stringify(json));
156
- } catch (e) {
157
- console.warn('搜索缓存写入失败', e);
158
- }
159
- });
160
- })();
149
+ fetch(path)
150
+ .then(res => res.json())
151
+ .then(json => {
152
+ searchCache = json;
153
+ try {
154
+ localStorage.setItem(searchCacheKey, JSON.stringify(json));
155
+ } catch (e) {
156
+ console.warn('搜索缓存写入失败', e);
157
+ }
158
+ });
159
+ })();
161
160
 
162
- var $inputArea = $("input#search-input");
163
- if ($inputArea.length == 0) return;
164
- var $resultArea = document.querySelector("div#search-result");
161
+ (function () {
162
+ var inputArea = document.querySelector("input#search-input");
163
+ if (!inputArea) return;
164
+ var resultArea = document.querySelector("div#search-result");
165
165
 
166
- $inputArea.focus(function() {
166
+ inputArea.addEventListener("focus", function() {
167
167
  var path = ctx.search.path;
168
168
  if (path.startsWith('/')) {
169
169
  path = path.substring(1);
170
170
  }
171
171
  path = ctx.root + path;
172
- const filter = $inputArea.attr('data-filter') || '';
172
+ const filter = inputArea.getAttribute('data-filter') || '';
173
173
  searchFunc(path, filter, 'search-wrapper', 'search-input', 'search-result');
174
174
  });
175
175
 
176
- $inputArea.keydown(function(e) {
177
- if (e.which == 13) {
176
+ inputArea.addEventListener("keydown", function(e) {
177
+ if (e.key == 'Enter') {
178
178
  e.preventDefault();
179
179
  }
180
180
  });
181
181
 
182
182
  const observer = new MutationObserver(function(mutationsList) {
183
- const hasResults = $resultArea.querySelector(".search-result-list li");
184
- $('.search-wrapper').toggleClass('noresult', !hasResults);
183
+ const hasResults = resultArea.querySelector(".search-result-list li");
184
+ const wrapper = document.querySelector('.search-wrapper');
185
+ if (wrapper) wrapper.classList.toggle('noresult', !hasResults);
185
186
  });
186
- observer.observe($resultArea, { childList: true, subtree: true });
187
- });
187
+ observer.observe(resultArea, { childList: true, subtree: true });
188
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-artalk');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-artalk');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const limit = parseInt(el.getAttribute('limit')) || 10;
@@ -25,10 +24,9 @@ utils.jq(() => {
25
24
  cell += item.content_marked;
26
25
  cell += '</a>';
27
26
  cell += '</div>';
28
- $(el).append(cell);
27
+ utils.dom(el).append(cell);
29
28
  });
30
29
  });
31
30
  }
32
- });
33
- });
34
-
31
+ })();
32
+
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- function parseGithubFileContributors(data) {
1
+ (function () {
2
+ function parseGithubFileContributors(data) {
4
3
  // 去重贡献者(按 login)
5
4
  const contributorsMap = new Map();
6
5
 
@@ -47,10 +46,9 @@ utils.jq(() => {
47
46
  cell += `</div>`;
48
47
  cell += `</a>`;
49
48
  cell += `</div>`;
50
- $(el).find('.grid-box').append(cell);
49
+ utils.dom(el).find('.grid-box').append(cell);
51
50
  }
52
51
  window.wrapLazyloadImages(el);
53
52
  });
54
53
  }
55
- });
56
- });
54
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-fcircle');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-fcircle');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const api = el.dataset.api;
@@ -29,9 +28,8 @@ utils.jq(() => {
29
28
  cell += item.title;
30
29
  cell += '</a>';
31
30
  cell += '</div>';
32
- $(el).append(cell);
31
+ utils.dom(el).append(cell);
33
32
  });
34
33
  });
35
34
  }
36
- });
37
- });
35
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-friends');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-friends');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const api = el.dataset.api;
@@ -24,10 +23,9 @@ utils.jq(() => {
24
23
  }
25
24
  cell += `</a>`;
26
25
  cell += `</div>`;
27
- $(el).find('.grid-box').append(cell);
26
+ utils.dom(el).find('.grid-box').append(cell);
28
27
  }
29
28
  window.wrapLazyloadImages(el);
30
29
  });
31
30
  }
32
- });
33
- });
31
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-friends_and_posts');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-friends_and_posts');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const api = el.dataset.api;
@@ -50,10 +49,9 @@ utils.jq(() => {
50
49
  cell += `</div>`;
51
50
  cell += `</div>`;
52
51
  cell += `</div>`;
53
- $(el).find('.grid-box').append(cell);
52
+ utils.dom(el).find('.grid-box').append(cell);
54
53
  }
55
54
  window.wrapLazyloadImages(el);
56
55
  });
57
56
  }
58
- });
59
- });
57
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-ghinfo');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-ghinfo');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const api = el.dataset.api;
@@ -12,9 +11,9 @@ utils.jq(() => {
12
11
  const data = await resp.json();
13
12
  function fill(data) {
14
13
  for (let key of Object.keys(data)) {
15
- $(el).find("[type=text]#" + key).text(data[key]);
16
- $(el).find("[type=link]#" + key).attr("href", data[key]);
17
- $(el).find("[type=img]#" + key).attr("src", data[key]);
14
+ utils.dom(el).find("[type=text]#" + key).text(data[key]);
15
+ utils.dom(el).find("[type=link]#" + key).attr("href", data[key]);
16
+ utils.dom(el).find("[type=img]#" + key).attr("src", data[key]);
18
17
  }
19
18
  }
20
19
  const idx = el.getAttribute('index');
@@ -30,5 +29,4 @@ utils.jq(() => {
30
29
  }
31
30
  });
32
31
  }
33
- });
34
- });
32
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-giscus');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-giscus');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const api = el.dataset.api;
@@ -29,9 +28,8 @@ utils.jq(() => {
29
28
  cell += comment;
30
29
  cell += '</a>';
31
30
  cell += '</div>';
32
- $(el).append(cell);
31
+ utils.dom(el).append(cell);
33
32
  });
34
33
  });
35
34
  }
36
- });
37
- });
35
+ })();
@@ -1,4 +1,4 @@
1
- utils.jq(() => {
1
+ (function () {
2
2
  const els = document.getElementsByClassName('ds-mdrender');
3
3
  for (var i = 0; i < els.length; i++) {
4
4
  const el = els[i];
@@ -9,4 +9,4 @@ utils.jq(() => {
9
9
  el.innerHTML = marked.parse(data);
10
10
  });
11
11
  }
12
- });
12
+ })();
@@ -1,4 +1,4 @@
1
- utils.jq(() => {
1
+ (function () {
2
2
  const els = Array.from(document.getElementsByClassName('ds-memos'));
3
3
 
4
4
  els.forEach(el => {
@@ -18,7 +18,7 @@ utils.jq(() => {
18
18
  const hide = el.getAttribute('hide')?.split(",") || [];
19
19
 
20
20
  await Promise.all(memos.data.slice(0, limit || memos.data.length).map(item =>
21
- createMemoCell(item, memos, users, hide, default_avatar, host).then(cell => $(el).append(cell))
21
+ createMemoCell(item, memos, users, hide, default_avatar, host).then(cell => utils.dom(el).append(cell))
22
22
  ));
23
23
  });
24
24
 
@@ -130,5 +130,4 @@ utils.jq(() => {
130
130
  }
131
131
  };
132
132
  });
133
- });
134
-
133
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-rss');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-rss');
4
3
 
5
4
  for (let i = 0; i < els.length; i++) {
6
5
  const el = els[i];
@@ -44,10 +43,9 @@ utils.jq(() => {
44
43
  handleRSS1(el, doc, content_type, show_title, show_content, limit);
45
44
  return;
46
45
  }
47
- });
48
- }
49
- });
50
- });
46
+ });
47
+ }
48
+ })();
51
49
 
52
50
 
53
51
  function handleAtom(el, doc, content_type, show_title, show_content, limit) {
@@ -88,7 +86,7 @@ function handleAtom(el, doc, content_type, show_title, show_content, limit) {
88
86
  return cell;
89
87
  }).join('');
90
88
 
91
- $(el).append(htmlBuffer);
89
+ utils.dom(el).append(htmlBuffer);
92
90
  }
93
91
 
94
92
  function handleRSS2(el, doc, content_type, show_title, show_content, limit) {
@@ -124,7 +122,7 @@ function handleRSS2(el, doc, content_type, show_title, show_content, limit) {
124
122
  return cell;
125
123
  }).join('');
126
124
 
127
- $(el).append(htmlBuffer);
125
+ utils.dom(el).append(htmlBuffer);
128
126
  }
129
127
  function handleRSS1(el, doc, content_type, show_title, show_content, limit) {
130
128
  const items = Array.from(doc.querySelectorAll('item')).slice(0, limit);
@@ -159,7 +157,7 @@ function handleRSS1(el, doc, content_type, show_title, show_content, limit) {
159
157
  return cell;
160
158
  }).join('');
161
159
 
162
- $(el).append(htmlBuffer);
160
+ utils.dom(el).append(htmlBuffer);
163
161
  }
164
162
  function handleJsonFeed(el, data, content_type, show_title, show_content, limit) {
165
163
  const items = (data.items || []).slice(0, limit);
@@ -196,5 +194,5 @@ function handleJsonFeed(el, data, content_type, show_title, show_content, limit)
196
194
  return cell;
197
195
  }).join('');
198
196
 
199
- $(el).append(htmlBuffer);
200
- }
197
+ utils.dom(el).append(htmlBuffer);
198
+ }
@@ -8,31 +8,29 @@ function setCardLink(nodes) {
8
8
  el.removeAttribute('cardlink');
9
9
  const api = el.dataset.api;
10
10
  if (api == null) return;
11
- fetch(api).then(function(response) {
12
- if (response.ok) {
13
- return response.json();
14
- }
15
- throw new Error('Network response was not ok.');
16
- }).then(function(data) {
17
- var autofill = [];
18
- const autofillStr = el.getAttribute('autofill');
19
- if (autofillStr) {
20
- autofill = autofillStr.split(',');
21
- }
22
- if (data.title && data.title.length > 0 && autofill.includes('title')) {
23
- el.querySelector('.title').innerHTML = data.title;
24
- el.title = data.title;
25
- }
26
- if (data.icon && data.icon.length > 0 && autofill.includes('icon')) {
27
- el.querySelector('.img').style = 'background-image: url("' + data.icon + '");';
28
- el.querySelector('.img').setAttribute('data-bg', data.icon);
29
- }
30
- let desc = el.querySelector('.desc');
31
- if (desc && data.desc && data.desc.length > 0 && autofill.includes('desc')) {
32
- desc.innerHTML = data.desc;
33
- }
34
- }).catch(function(error) {
35
- console.error(error);
36
- });
11
+ // 走统一请求入口,动态数据缓存对 siteinfo 同样生效
12
+ utils.request(null, api, function(response) {
13
+ return response.json().then(function(data) {
14
+ var autofill = [];
15
+ const autofillStr = el.getAttribute('autofill');
16
+ if (autofillStr) {
17
+ autofill = autofillStr.split(',');
18
+ }
19
+ if (data.title && data.title.length > 0 && autofill.includes('title')) {
20
+ el.querySelector('.title').innerHTML = data.title;
21
+ el.title = data.title;
22
+ }
23
+ if (data.icon && data.icon.length > 0 && autofill.includes('icon')) {
24
+ el.querySelector('.img').style = 'background-image: url("' + data.icon + '");';
25
+ el.querySelector('.img').setAttribute('data-bg', data.icon);
26
+ }
27
+ let desc = el.querySelector('.desc');
28
+ if (desc && data.desc && data.desc.length > 0 && autofill.includes('desc')) {
29
+ desc.innerHTML = data.desc;
30
+ }
31
+ }).catch(function(error) {
32
+ console.error(error);
33
+ });
34
+ }, undefined, { service: 'siteinfo' });
37
35
  })
38
36
  }
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-sites');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-sites');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const api = el.dataset.api;
@@ -34,10 +33,9 @@ utils.jq(() => {
34
33
  cell += `</div>`;
35
34
  cell += `</a>`;
36
35
  cell += `</div>`;
37
- $(el).find('.grid-box').append(cell);
36
+ utils.dom(el).find('.grid-box').append(cell);
38
37
  }
39
38
  window.wrapLazyloadImages(el);
40
39
  });
41
40
  }
42
- });
43
- });
41
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const reactions = {
1
+ (function () {
2
+ const reactions = {
4
3
  '+1': '👍',
5
4
  '-1': '👎',
6
5
  'laugh': '😀',
@@ -99,10 +98,9 @@ utils.jq(() => {
99
98
 
100
99
  cell += '</div>';
101
100
  cell += '</div>';
102
- $(el).append(cell);
101
+ utils.dom(el).append(cell);
103
102
  });
104
103
  window.wrapLazyloadImages(el);
105
104
  });
106
105
  }
107
- });
108
- });
106
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const el = document.querySelector('.ds-twikoo');
1
+ (function () {
2
+ const el = document.querySelector('.ds-twikoo');
4
3
  utils.onLoading(el); // 加载动画
5
4
 
6
5
  const api = el.dataset.api;
@@ -38,10 +37,9 @@ utils.jq(() => {
38
37
  cell += commentText;
39
38
  cell += '</a>';
40
39
  cell += '</div>';
41
- $(el).append(cell);
40
+ utils.dom(el).append(cell);
42
41
  });
43
42
  })
44
43
  .catch(() => utils.onLoadFailure(el));
45
- });
46
- });
47
-
44
+ })();
45
+
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-waline');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-waline');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const limit = parseInt(el.getAttribute('limit')) || 10;
@@ -25,9 +24,8 @@ utils.jq(() => {
25
24
  cell += item.comment.replace(/<a\b[^>]*>(.*?)<\/a>/g, '$1');
26
25
  cell += '</a>';
27
26
  cell += '</div>';
28
- $(el).append(cell);
27
+ utils.dom(el).append(cell);
29
28
  });
30
29
  });
31
30
  }
32
- });
33
- });
31
+ })();
@@ -1,6 +1,5 @@
1
- utils.jq(() => {
2
- $(function () {
3
- const els = document.getElementsByClassName('ds-weibo');
1
+ (function () {
2
+ const els = document.getElementsByClassName('ds-weibo');
4
3
  for (var i = 0; i < els.length; i++) {
5
4
  const el = els[i];
6
5
  const api = el.dataset.api;
@@ -53,9 +52,8 @@ utils.jq(() => {
53
52
  cell += '</div>';
54
53
  cell += '</div>';
55
54
  // 右下角结束
56
- $(el).append(cell);
55
+ utils.dom(el).append(cell);
57
56
  });
58
57
  });
59
58
  }
60
- });
61
- });
59
+ })();