hexo-theme-stellar 1.34.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.
- package/_config.yml +25 -19
- package/layout/_partial/comments/artalk/layout.ejs +2 -2
- package/layout/_partial/comments/artalk/script.ejs +3 -9
- package/layout/_partial/comments/beaudar/script.ejs +2 -8
- package/layout/_partial/comments/giscus/script.ejs +2 -8
- package/layout/_partial/comments/twikoo/layout.ejs +2 -2
- package/layout/_partial/comments/twikoo/script.ejs +3 -9
- package/layout/_partial/comments/utterances/script.ejs +2 -8
- package/layout/_partial/comments/waline/layout.ejs +1 -1
- package/layout/_partial/comments/waline/script.ejs +1 -7
- package/layout/_partial/head.ejs +0 -3
- package/layout/_partial/scripts/defines.ejs +118 -1
- package/layout/_partial/scripts/lazyload.ejs +7 -6
- package/layout/_partial/scripts/services.ejs +11 -13
- package/layout/_partial/scripts/utils.ejs +358 -66
- package/layout/_partial/widgets/tagtree.ejs +1 -1
- package/layout/_partial/widgets/toc.ejs +1 -4
- package/layout/_partial/widgets/tree.ejs +1 -1
- package/layout/_plugins/fancybox.ejs +23 -8
- package/layout/_plugins/scrollreveal.ejs +77 -13
- package/layout/layout.ejs +0 -1
- package/package.json +4 -2
- package/scripts/events/index.js +2 -1
- package/scripts/events/lib/doc_tree.js +7 -4
- package/scripts/events/lib/merge_posts.js +3 -1
- package/scripts/events/lib/notebooks.js +5 -3
- package/scripts/events/lib/path_normalize.js +22 -0
- package/scripts/filters/lib/img_lazyload.js +9 -9
- package/scripts/generators/search.js +3 -1
- package/scripts/helpers/json_ld.js +3 -2
- package/scripts/helpers/pretty_url.js +9 -10
- package/scripts/lib/path_utils.js +24 -0
- package/scripts/tags/lib/emoji.js +17 -2
- package/scripts/tags/lib/image.js +13 -18
- package/source/css/_common/html.styl +0 -2
- package/source/css/_components/widgets/toc.styl +2 -2
- package/source/css/_plugins/index.styl +0 -3
- package/source/css/_plugins/lazyload.styl +40 -26
- package/source/css/_plugins/scrollreveal.styl +5 -1
- package/source/js/main.js +157 -73
- package/source/js/search/algolia-search.js +62 -62
- package/source/js/search/local-search.js +37 -36
- package/source/js/services/artalk_latest_comment.js +5 -7
- package/source/js/services/contributors.js +4 -6
- package/source/js/services/fcircle.js +4 -6
- package/source/js/services/friends.js +4 -6
- package/source/js/services/friends_and_posts.js +4 -6
- package/source/js/services/ghinfo.js +6 -8
- package/source/js/services/giscus_latest_comment.js +4 -6
- package/source/js/services/mdrender.js +2 -2
- package/source/js/services/memos.js +3 -4
- package/source/js/services/rss.js +10 -12
- package/source/js/services/siteinfo.js +24 -26
- package/source/js/services/sites.js +4 -6
- package/source/js/services/timeline.js +4 -6
- package/source/js/services/twikoo_latest_comment.js +5 -7
- package/source/js/services/waline_latest_comment.js +4 -6
- package/source/js/services/weibo.js +4 -6
- package/CLAUDE.md +0 -217
- package/docs/audits/2026-08-08-stellar-analysis.md +0 -267
- package/docs/release-process.md +0 -59
- package/layout/_plugins/pjax.ejs +0 -8
- package/source/css/_plugins/pjax.styl +0 -61
- package/source/js/plugins/pjax.js +0 -646
package/source/js/main.js
CHANGED
|
@@ -53,11 +53,14 @@ const util = {
|
|
|
53
53
|
},
|
|
54
54
|
|
|
55
55
|
scrollTop: () => {
|
|
56
|
-
|
|
56
|
+
smoothScrollTo(0);
|
|
57
57
|
},
|
|
58
58
|
|
|
59
59
|
scrollComment: () => {
|
|
60
|
-
document.getElementById('comments')
|
|
60
|
+
const el = document.getElementById('comments');
|
|
61
|
+
if (el) {
|
|
62
|
+
smoothScrollTo(el.getBoundingClientRect().top + window.scrollY - 32);
|
|
63
|
+
}
|
|
61
64
|
},
|
|
62
65
|
|
|
63
66
|
viewportLazyload: (target, func, enabled = true) => {
|
|
@@ -94,73 +97,168 @@ const hud = {
|
|
|
94
97
|
|
|
95
98
|
const l_body = document.querySelector('.l_body');
|
|
96
99
|
|
|
100
|
+
// 通用平滑滚动(自定义动画,TOC / 回到顶部 / 参与讨论共用)
|
|
101
|
+
let scrollAnim = null;
|
|
102
|
+
function cancelSmoothScroll() {
|
|
103
|
+
if (scrollAnim !== null) {
|
|
104
|
+
cancelAnimationFrame(scrollAnim);
|
|
105
|
+
scrollAnim = null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function smoothScrollTo(targetY) {
|
|
109
|
+
cancelSmoothScroll();
|
|
110
|
+
targetY = Math.max(0, targetY);
|
|
111
|
+
const startY = window.scrollY;
|
|
112
|
+
const diff = targetY - startY;
|
|
113
|
+
if (Math.abs(diff) < 2) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
// 短距离 300ms,长距离最多 600ms
|
|
117
|
+
const duration = Math.min(600, Math.max(300, Math.abs(diff) * 0.15));
|
|
118
|
+
const startTime = performance.now();
|
|
119
|
+
function step(now) {
|
|
120
|
+
const t = Math.min(1, (now - startTime) / duration);
|
|
121
|
+
const eased = 1 - Math.pow(1 - t, 3); // easeOutCubic
|
|
122
|
+
// 显式指定 instant,避免全局 scroll-behavior: smooth 与自定义动画叠加导致滚动变慢
|
|
123
|
+
window.scrollTo({ top: startY + diff * eased, behavior: 'instant' });
|
|
124
|
+
if (t < 1) {
|
|
125
|
+
scrollAnim = requestAnimationFrame(step);
|
|
126
|
+
} else {
|
|
127
|
+
scrollAnim = null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
scrollAnim = requestAnimationFrame(step);
|
|
131
|
+
}
|
|
132
|
+
window.addEventListener('wheel', cancelSmoothScroll, { passive: true });
|
|
133
|
+
window.addEventListener('touchstart', cancelSmoothScroll, { passive: true });
|
|
134
|
+
|
|
97
135
|
|
|
98
136
|
const init = {
|
|
99
137
|
toc: () => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (seg.offset().top > scrollTop + scrollOffset) {
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
if (!topSeg) {
|
|
115
|
-
topSeg = seg;
|
|
116
|
-
} else if (seg.offset().top >= topSeg.offset().top) {
|
|
117
|
-
topSeg = seg;
|
|
118
|
-
}
|
|
138
|
+
const scrollOffset = 32;
|
|
139
|
+
// 滚动位置取整后标题顶可能落在偏移线下方 1~2px,加容差避免高亮回跳到上一条
|
|
140
|
+
const scrollTolerance = 4;
|
|
141
|
+
var segs = utils.qsa("article.md-text h1, article.md-text h2, article.md-text h3, article.md-text h4, article.md-text h5, article.md-text h6");
|
|
142
|
+
function activeTOC() {
|
|
143
|
+
var scrollTop = window.scrollY;
|
|
144
|
+
var topSeg = null;
|
|
145
|
+
for (var i = 0; i < segs.length; i++) {
|
|
146
|
+
var segTop = segs[i].getBoundingClientRect().top + window.scrollY;
|
|
147
|
+
if (segTop > scrollTop + scrollOffset + scrollTolerance) {
|
|
148
|
+
continue;
|
|
119
149
|
}
|
|
120
|
-
if (topSeg) {
|
|
121
|
-
|
|
122
|
-
var link = "#" + topSeg.attr("id");
|
|
123
|
-
if (link != '#undefined') {
|
|
124
|
-
const highlightItem = $('#data-toc a.toc-link[href="' + encodeURI(link) + '"]');
|
|
125
|
-
if (highlightItem.length > 0) {
|
|
126
|
-
highlightItem.addClass("active");
|
|
127
|
-
}
|
|
128
|
-
} else {
|
|
129
|
-
$('#data-toc a.toc-link:first').addClass("active");
|
|
130
|
-
}
|
|
150
|
+
if (!topSeg || segTop >= topSeg.getBoundingClientRect().top + window.scrollY) {
|
|
151
|
+
topSeg = segs[i];
|
|
131
152
|
}
|
|
132
153
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
154
|
+
if (topSeg) {
|
|
155
|
+
utils.dom("#data-toc a.toc-link").removeClass("active");
|
|
156
|
+
var id = topSeg.getAttribute("id");
|
|
157
|
+
var link = id ? "#" + id : "#undefined";
|
|
158
|
+
if (link != '#undefined') {
|
|
159
|
+
const highlightItem = utils.dom('#data-toc a.toc-link[href="' + encodeURI(link) + '"]');
|
|
160
|
+
if (highlightItem.length > 0) {
|
|
161
|
+
highlightItem.addClass("active");
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
const first = utils.qs('#data-toc a.toc-link');
|
|
165
|
+
if (first) first.classList.add("active");
|
|
145
166
|
}
|
|
146
167
|
}
|
|
168
|
+
}
|
|
169
|
+
function scrollTOC() {
|
|
170
|
+
const e0 = document.querySelector('#data-toc .toc');
|
|
171
|
+
const e1 = document.querySelector('#data-toc .toc a.toc-link.active');
|
|
172
|
+
if (e0 == null || e1 == null) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const offsetBottom = e1.getBoundingClientRect().bottom - e0.getBoundingClientRect().bottom + 100;
|
|
176
|
+
const offsetTop = e1.getBoundingClientRect().top - e0.getBoundingClientRect().top - 64;
|
|
177
|
+
if (offsetTop < 0) {
|
|
178
|
+
e0.scrollBy({ top: offsetTop, behavior: "smooth" });
|
|
179
|
+
} else if (offsetBottom > 0) {
|
|
180
|
+
e0.scrollBy({ top: offsetBottom, behavior: "smooth" });
|
|
181
|
+
}
|
|
182
|
+
}
|
|
147
183
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
})
|
|
184
|
+
var timeout = null;
|
|
185
|
+
window.addEventListener('scroll', function () {
|
|
186
|
+
activeTOC();
|
|
187
|
+
if (timeout !== null) clearTimeout(timeout);
|
|
188
|
+
timeout = setTimeout(function () {
|
|
189
|
+
scrollTOC();
|
|
190
|
+
}, 50);
|
|
191
|
+
});
|
|
157
192
|
},
|
|
158
193
|
sidebar: () => {
|
|
159
|
-
utils.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
194
|
+
utils.dom("#data-toc a.toc-link").click(function (e) {
|
|
195
|
+
const href = this.getAttribute("href");
|
|
196
|
+
const id = href && href.indexOf("#") === 0 ? decodeURIComponent(href.slice(1)) : null;
|
|
197
|
+
const target = id && document.getElementById(id);
|
|
198
|
+
if (target) {
|
|
199
|
+
e.preventDefault();
|
|
200
|
+
const offset = 32; // 与 activeTOC 的 scrollOffset 保持一致
|
|
201
|
+
const targetY = target.getBoundingClientRect().top + window.scrollY - offset;
|
|
202
|
+
smoothScrollTo(targetY);
|
|
203
|
+
if (window.history && window.history.pushState) {
|
|
204
|
+
window.history.pushState(null, "", href);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
sidebar.dismiss();
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
leftbarScroll: () => {
|
|
211
|
+
const container = document.querySelector('.l_left .widgets');
|
|
212
|
+
if (container == null) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const PREFIX = 'Stellar.leftbarScroll.';
|
|
216
|
+
const encode = (s) => encodeURIComponent(String(s || ''));
|
|
217
|
+
function scope() {
|
|
218
|
+
const wikiEl = document.querySelector('.doc-tree[data-wiki]');
|
|
219
|
+
if (wikiEl != null) {
|
|
220
|
+
return 'wiki:' + encode(wikiEl.getAttribute('data-wiki'));
|
|
221
|
+
}
|
|
222
|
+
const notebookEl = document.querySelector('widget[data-notebook]');
|
|
223
|
+
if (notebookEl != null) {
|
|
224
|
+
return 'notebook:' + encode(notebookEl.getAttribute('data-notebook'));
|
|
225
|
+
}
|
|
226
|
+
const body = document.querySelector('.l_body');
|
|
227
|
+
return 'layout:' + encode((body && body.getAttribute('layout')) || 'default');
|
|
228
|
+
}
|
|
229
|
+
window.addEventListener('pagehide', function () {
|
|
230
|
+
try {
|
|
231
|
+
const s = scope();
|
|
232
|
+
sessionStorage.setItem(PREFIX + s, String(container.scrollTop));
|
|
233
|
+
sessionStorage.setItem(PREFIX + 'last', s);
|
|
234
|
+
} catch (e) {}
|
|
235
|
+
});
|
|
236
|
+
try {
|
|
237
|
+
const s = scope();
|
|
238
|
+
// 仅当上一页与当前页属于同一分区时才恢复,离开分区后再回来不跳回旧位置
|
|
239
|
+
if (sessionStorage.getItem(PREFIX + 'last') !== s) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const value = sessionStorage.getItem(PREFIX + s);
|
|
243
|
+
if (value == null) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
container.scrollTop = parseInt(value, 10) || 0;
|
|
247
|
+
const link = container.querySelector('a.link.active');
|
|
248
|
+
if (link == null) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const padding = 16;
|
|
252
|
+
const containerRect = container.getBoundingClientRect();
|
|
253
|
+
const linkRect = link.getBoundingClientRect();
|
|
254
|
+
const top = linkRect.top - containerRect.top;
|
|
255
|
+
const bottom = linkRect.bottom - containerRect.top;
|
|
256
|
+
if (top < 0) {
|
|
257
|
+
container.scrollTop += top - padding;
|
|
258
|
+
} else if (bottom > container.clientHeight) {
|
|
259
|
+
container.scrollTop += bottom - container.clientHeight + padding;
|
|
260
|
+
}
|
|
261
|
+
} catch (e) {}
|
|
164
262
|
},
|
|
165
263
|
relativeDate: (selector) => {
|
|
166
264
|
selector.forEach(item => {
|
|
@@ -293,29 +391,15 @@ window.stellar = window.stellar || {};
|
|
|
293
391
|
|
|
294
392
|
/**
|
|
295
393
|
* Initialize page components
|
|
296
|
-
* Called on initial load and after PJAX navigation
|
|
297
394
|
*/
|
|
298
395
|
stellar.initPage = function () {
|
|
299
396
|
init.toc();
|
|
300
397
|
init.sidebar();
|
|
398
|
+
init.leftbarScroll();
|
|
301
399
|
init.relativeDate(document.querySelectorAll('#post-meta time'));
|
|
302
400
|
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
401
|
};
|
|
313
402
|
|
|
314
403
|
// Initial page load
|
|
315
404
|
stellar.initPage();
|
|
316
405
|
init.canonicalCheck();
|
|
317
|
-
|
|
318
|
-
// Listen for PJAX navigation complete
|
|
319
|
-
document.addEventListener('pjax:complete', function () {
|
|
320
|
-
stellar.initPage();
|
|
321
|
-
});
|
|
@@ -1,77 +1,77 @@
|
|
|
1
1
|
utils.js(window.searchConfig.js).then(() => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
2
|
+
var inputArea = document.querySelector("input#search-input");
|
|
3
|
+
if (!inputArea) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
var resultArea = document.querySelector("#search-result");
|
|
8
|
+
var searchWrapper = document.querySelector("#search-wrapper");
|
|
9
|
+
var client = algoliasearch(window.searchConfig.appId, window.searchConfig.apiKey);
|
|
10
|
+
var index = client.initIndex(window.searchConfig.indexName);
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
function filterResults(hits, filterPath) {
|
|
13
|
+
if (!filterPath || filterPath === '/') return hits;
|
|
14
|
+
var regex = new RegExp(filterPath);
|
|
15
|
+
return hits.filter(hit => regex.test(hit.url));
|
|
16
|
+
}
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
function displayResults(hits) {
|
|
19
|
+
var resultList = document.createElement("ul");
|
|
20
|
+
resultList.classList.add("search-result-list");
|
|
21
|
+
if (hits.length === 0) {
|
|
22
|
+
searchWrapper.classList.add('noresult');
|
|
23
|
+
} else {
|
|
24
|
+
searchWrapper.classList.remove('noresult');
|
|
25
|
+
hits.forEach(function(hit) {
|
|
26
|
+
var contentSnippet = hit._snippetResult.content.value;
|
|
27
|
+
var title = hit.hierarchy.lvl1 || 'Untitled';
|
|
28
|
+
var item = document.createElement("li");
|
|
29
|
+
item.innerHTML = `<a href="${hit.url}"><span class='search-result-title'>${title}</span><p class="search-result-content">${contentSnippet}</p></a>`;
|
|
30
|
+
resultList.appendChild(item);
|
|
31
|
+
});
|
|
33
32
|
}
|
|
33
|
+
resultArea.replaceChildren(resultList);
|
|
34
|
+
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
inputArea.addEventListener("input", function() {
|
|
37
|
+
var query = inputArea.value.trim();
|
|
38
|
+
var filterPath = inputArea.getAttribute('data-filter');
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
if (query.length <= 0) {
|
|
41
|
+
searchWrapper.setAttribute('searching', 'false');
|
|
42
|
+
resultArea.replaceChildren();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
searchWrapper.setAttribute('searching', 'true');
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
});
|
|
48
|
+
index.search(query, {
|
|
49
|
+
hitsPerPage: window.searchConfig.hitsPerPage,
|
|
50
|
+
attributesToHighlight: ['content'],
|
|
51
|
+
attributesToSnippet: ['content:30'],
|
|
52
|
+
highlightPreTag: '<span class="search-keyword">',
|
|
53
|
+
highlightPostTag: '</span>',
|
|
54
|
+
restrictSearchableAttributes: ['content']
|
|
55
|
+
}).then(function(responses) {
|
|
56
|
+
displayResults(filterResults(responses.hits, filterPath));
|
|
57
57
|
});
|
|
58
|
+
});
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
inputArea.addEventListener("keydown", function(e) {
|
|
61
|
+
if (e.key == 'Enter') {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
66
|
+
var observer = new MutationObserver(function(mutationsList) {
|
|
67
|
+
if (mutationsList.length === 1) {
|
|
68
|
+
if (mutationsList[0].addedNodes.length) {
|
|
69
|
+
searchWrapper.classList.remove('noresult');
|
|
70
|
+
} else if (mutationsList[0].removedNodes.length) {
|
|
71
|
+
searchWrapper.classList.add('noresult');
|
|
72
72
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
observer.observe($resultArea[0], { childList: true });
|
|
73
|
+
}
|
|
76
74
|
});
|
|
75
|
+
|
|
76
|
+
observer.observe(resultArea, { childList: true });
|
|
77
77
|
});
|
|
@@ -130,58 +130,59 @@ var searchFunc = function(path, filter, wrapperId, searchId, contentId) {
|
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
|
|
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 =
|
|
172
|
+
const filter = inputArea.getAttribute('data-filter') || '';
|
|
173
173
|
searchFunc(path, filter, 'search-wrapper', 'search-input', 'search-result');
|
|
174
174
|
});
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
if (e.
|
|
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 =
|
|
184
|
-
|
|
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(
|
|
187
|
-
});
|
|
187
|
+
observer.observe(resultArea, { childList: true, subtree: true });
|
|
188
|
+
})();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
27
|
+
utils.dom(el).append(cell);
|
|
29
28
|
});
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
})();
|
|
32
|
+
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
31
|
+
utils.dom(el).append(cell);
|
|
33
32
|
});
|
|
34
33
|
});
|
|
35
34
|
}
|
|
36
|
-
|
|
37
|
-
});
|
|
35
|
+
})();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
})();
|