hexo-theme-linen 1.0.21 → 1.0.23
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/languages/en.yml +3 -0
- package/languages/zh-CN.yml +4 -1
- package/layout/footer.ejs +62 -0
- package/layout/layout.ejs +22 -9
- package/layout/partials/header.ejs +1 -1
- package/layout/partials/post-item.ejs +5 -5
- package/layout/partials/related-posts.ejs +1 -1
- package/layout/post.ejs +362 -24
- package/layout/series.ejs +277 -4
- package/package.json +1 -1
- package/scripts/font-version.js +5 -3
- package/scripts/helpers/tools.js +187 -191
- package/scripts/lazyload/client.js +11 -2
- package/scripts/lazyload/index.js +7 -5
- package/scripts/lazyload/inject.js +8 -0
- package/scripts/lazyload/process.js +202 -163
- package/scripts/markdown-it-image-grid.js +74 -10
- package/source/linen-theme/css/{mediaquery.scss → _mediaquery.scss} +183 -12
- package/source/linen-theme/css/atom.xsl +37 -0
- package/source/linen-theme/css/font-version.scss +1 -1
- package/source/linen-theme/css/images/layers-2x.png +0 -0
- package/source/linen-theme/css/images/layers.png +0 -0
- package/source/linen-theme/css/images/marker-icon-2x.png +0 -0
- package/source/linen-theme/css/images/marker-icon.png +0 -0
- package/source/linen-theme/css/images/marker-shadow.png +0 -0
- package/source/linen-theme/css/leaflet.css +661 -0
- package/source/linen-theme/css/linen.scss +1198 -114
- package/source/linen-theme/css/linkcard.scss +53 -11
- package/source/linen-theme/css/noscript.css +70 -0
- package/source/linen-theme/css/photoswipe-dynamic-caption-plugin.css +1 -1
- package/source/linen-theme/css/photoswipe.css +166 -1
- package/source/linen-theme/css/rss-en.xsl +1 -1
- package/source/linen-theme/css/rss-zh.xsl +1 -1
- package/source/linen-theme/css/vars.scss +1 -1
- package/source/linen-theme/img/pattern-randomized.svg +1 -0
- package/source/linen-theme/img/travel-map-fallback.svg +30 -0
- package/source/linen-theme/js/hdr.js +42 -12
- package/source/linen-theme/js/lazyload.js +11 -2
- package/source/linen-theme/js/leaflet.js +6 -0
- package/source/linen-theme/js/linen.js +114 -83
- package/source/linen-theme/js/photoswipe/photoswipe.esm.min.js +13 -0
- package/source/linen-theme/js/replace-emoji.js +2 -4
- package/source/linen-theme/js/toc.js +71 -121
- package/layout/partials/footer.ejs +0 -12
- package/source/linen-theme/img/icons/backref.svg +0 -1
- package/source/linen-theme/img/icons/more.svg +0 -4
|
@@ -3,6 +3,18 @@ var isResizing = false;
|
|
|
3
3
|
var viewportWidth = window.innerWidth;
|
|
4
4
|
var isAnchoring = false;
|
|
5
5
|
var anchoringId = null;
|
|
6
|
+
var anchoringTimer = null;
|
|
7
|
+
function triggerAnchoring() {
|
|
8
|
+
isAnchoring = true;
|
|
9
|
+
var header = document.querySelector(".nav-header");
|
|
10
|
+
if (header) {
|
|
11
|
+
header.classList.add("hide");
|
|
12
|
+
}
|
|
13
|
+
clearTimeout(anchoringTimer);
|
|
14
|
+
anchoringTimer = setTimeout(function () {
|
|
15
|
+
isAnchoring = false;
|
|
16
|
+
}, 800);
|
|
17
|
+
}
|
|
6
18
|
|
|
7
19
|
(function addUAClass() {
|
|
8
20
|
const isIOS = /iPhone/.test(window.navigator.userAgent);
|
|
@@ -161,30 +173,14 @@ function copyToClipboard(text) {
|
|
|
161
173
|
copyToClipboard(text);
|
|
162
174
|
}
|
|
163
175
|
|
|
164
|
-
function highlightAnchor(
|
|
165
|
-
hash
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
element.classList.add(highlightClass);
|
|
173
|
-
setTimeout(() => {
|
|
174
|
-
element.classList.remove(highlightClass);
|
|
175
|
-
}, 4000);
|
|
176
|
-
} else {
|
|
177
|
-
if (!hash) return;
|
|
178
|
-
const id = hash.replace(/^#/, "");
|
|
179
|
-
const el = document.getElementById(id);
|
|
180
|
-
if (el) {
|
|
181
|
-
el.classList.remove(highlightClass);
|
|
182
|
-
void el.offsetWidth;
|
|
183
|
-
el.classList.add(highlightClass);
|
|
184
|
-
setTimeout(() => {
|
|
185
|
-
el.classList.remove(highlightClass);
|
|
186
|
-
}, 4000);
|
|
187
|
-
}
|
|
176
|
+
function highlightAnchor(hash, highlightClass = "anchor-highlight") {
|
|
177
|
+
if (!hash) return;
|
|
178
|
+
const id = hash.replace(/^#/, "");
|
|
179
|
+
const el = document.getElementById(id);
|
|
180
|
+
if (el) {
|
|
181
|
+
el.classList.remove(highlightClass);
|
|
182
|
+
void el.offsetWidth;
|
|
183
|
+
el.classList.add(highlightClass);
|
|
188
184
|
}
|
|
189
185
|
}
|
|
190
186
|
|
|
@@ -192,6 +188,7 @@ function initAnchorHighlighter({
|
|
|
192
188
|
highlightClass = "anchor-highlight",
|
|
193
189
|
duration = 2000,
|
|
194
190
|
} = {}) {
|
|
191
|
+
// 动态注入高亮样式
|
|
195
192
|
if (!document.getElementById("anchor-highlight-style")) {
|
|
196
193
|
const style = document.createElement("style");
|
|
197
194
|
style.id = "anchor-highlight-style";
|
|
@@ -218,55 +215,117 @@ initAnchorHighlighter({
|
|
|
218
215
|
duration: 4000,
|
|
219
216
|
});
|
|
220
217
|
|
|
218
|
+
function initImageGridSwitchers() {
|
|
219
|
+
var switchers = document.querySelectorAll(".image-grid.switcher");
|
|
220
|
+
for (var i = 0; i < switchers.length; i++) {
|
|
221
|
+
(function (switcher) {
|
|
222
|
+
var items = switcher.querySelectorAll(".grid-item");
|
|
223
|
+
var buttons = switcher.querySelectorAll(".image-grid-switcher-button");
|
|
224
|
+
var controls = switcher.querySelector(".image-grid-switcher-controls");
|
|
225
|
+
|
|
226
|
+
if (controls) {
|
|
227
|
+
if (!controls.style.getPropertyValue("--switcher-item-count")) {
|
|
228
|
+
controls.style.setProperty("--switcher-item-count", buttons.length);
|
|
229
|
+
}
|
|
230
|
+
controls.style.setProperty("--switcher-active-index", 0);
|
|
231
|
+
controls.classList.add("is-ready");
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
var setActiveItem = function (activeIndex) {
|
|
235
|
+
if (controls) {
|
|
236
|
+
controls.style.setProperty("--switcher-active-index", activeIndex);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
for (var index = 0; index < items.length; index++) {
|
|
240
|
+
var isActive = index === activeIndex;
|
|
241
|
+
items[index].classList.toggle("active", isActive);
|
|
242
|
+
items[index].setAttribute("aria-hidden", isActive ? "false" : "true");
|
|
243
|
+
|
|
244
|
+
if (buttons[index]) {
|
|
245
|
+
buttons[index].classList.toggle("active", isActive);
|
|
246
|
+
buttons[index].setAttribute("aria-selected", isActive ? "true" : "false");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
for (var index = 0; index < buttons.length; index++) {
|
|
252
|
+
(function (buttonIndex) {
|
|
253
|
+
buttons[buttonIndex].addEventListener("click", function () {
|
|
254
|
+
setActiveItem(buttonIndex);
|
|
255
|
+
});
|
|
256
|
+
})(index);
|
|
257
|
+
}
|
|
258
|
+
})(switchers[i]);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (document.readyState === "loading") {
|
|
263
|
+
document.addEventListener("DOMContentLoaded", initImageGridSwitchers);
|
|
264
|
+
} else {
|
|
265
|
+
initImageGridSwitchers();
|
|
266
|
+
}
|
|
267
|
+
|
|
221
268
|
function onScroll() {
|
|
222
269
|
var backToTop = document.querySelector("#back-to-top");
|
|
223
270
|
var header = document.querySelector(".nav-header");
|
|
271
|
+
if (!header) return;
|
|
272
|
+
|
|
273
|
+
var currentScrollY = window.scrollY;
|
|
224
274
|
var triggerHeight = window.innerHeight * 1.5;
|
|
225
|
-
|
|
275
|
+
|
|
276
|
+
if (!window.$gitalkInitiated && currentScrollY > window.innerHeight) {
|
|
226
277
|
typeof loadGitalk !== "undefined" && loadGitalk();
|
|
227
278
|
}
|
|
228
|
-
|
|
279
|
+
|
|
280
|
+
if (isAnchoring) {
|
|
281
|
+
header.classList.add("hide");
|
|
282
|
+
previousScrollY = currentScrollY;
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (currentScrollY <= 10) {
|
|
287
|
+
header.classList.remove("hide");
|
|
288
|
+
previousScrollY = currentScrollY;
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
var scrollDelta = currentScrollY - previousScrollY;
|
|
293
|
+
if (Math.abs(scrollDelta) < 5) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (scrollDelta < 0) {
|
|
229
298
|
if (!document.querySelector(".pswp--open")) {
|
|
230
299
|
header.classList.remove("hide");
|
|
231
300
|
}
|
|
232
|
-
if (
|
|
301
|
+
if (currentScrollY >= triggerHeight) {
|
|
233
302
|
backToTop.classList.add("visible");
|
|
234
303
|
}
|
|
235
|
-
} else
|
|
304
|
+
} else {
|
|
236
305
|
backToTop.classList.remove("visible");
|
|
237
|
-
if (
|
|
306
|
+
if (currentScrollY > window.innerHeight * 0.75) {
|
|
238
307
|
header.classList.add("hide");
|
|
239
308
|
}
|
|
240
309
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
window.scrollY < previousScrollY
|
|
244
|
-
) {
|
|
245
|
-
header.classList.remove("hide");
|
|
246
|
-
}
|
|
247
|
-
previousScrollY = window.scrollY;
|
|
248
|
-
if (isAnchoring) {
|
|
249
|
-
header.classList.add("hide");
|
|
250
|
-
isAnchoring = false;
|
|
251
|
-
}
|
|
310
|
+
|
|
311
|
+
previousScrollY = currentScrollY;
|
|
252
312
|
}
|
|
253
313
|
|
|
254
314
|
window.addEventListener("scroll", throttle(onScroll, 300));
|
|
255
315
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
isResizing = false;
|
|
316
|
+
var resizeTimer = null;
|
|
317
|
+
window.addEventListener("resize", function () {
|
|
318
|
+
if (window.innerWidth === viewportWidth) return;
|
|
319
|
+
|
|
320
|
+
const body = document.body;
|
|
321
|
+
body.classList.add("resizing");
|
|
322
|
+
viewportWidth = window.innerWidth;
|
|
323
|
+
|
|
324
|
+
clearTimeout(resizeTimer);
|
|
325
|
+
resizeTimer = setTimeout(function () {
|
|
267
326
|
body.classList.remove("resizing");
|
|
268
|
-
},
|
|
269
|
-
);
|
|
327
|
+
}, 200);
|
|
328
|
+
});
|
|
270
329
|
|
|
271
330
|
function onclickPostItem(element) {
|
|
272
331
|
const selection = window.getSelection();
|
|
@@ -288,34 +347,6 @@ function handleClick(e) {
|
|
|
288
347
|
var maskElement = document.getElementById("mask");
|
|
289
348
|
var bodyElement = document.body;
|
|
290
349
|
var donateModal = document.getElementById("donate-modal");
|
|
291
|
-
if(target?.className === 'footnote-href') {
|
|
292
|
-
const footNoteDefinitionId = target.getAttribute("href").substring(1);
|
|
293
|
-
const footNoteDefinitionElement = document.getElementById(footNoteDefinitionId);
|
|
294
|
-
if (footNoteDefinitionElement) {
|
|
295
|
-
footNoteDefinitionElement.scrollIntoView({
|
|
296
|
-
behavior: "smooth",
|
|
297
|
-
block: "start",
|
|
298
|
-
});
|
|
299
|
-
e.preventDefault();
|
|
300
|
-
highlightAnchor(undefined, undefined, footNoteDefinitionElement);
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
if (target?.className === "footnote-backref") {
|
|
305
|
-
const footNoteId = target.getAttribute("href").substring(1);
|
|
306
|
-
const footNoteTextElements = document.querySelectorAll('.footnote-anchor-wrap');
|
|
307
|
-
if (footNoteTextElements.length) {
|
|
308
|
-
footNoteTextElements[0].scrollIntoView({
|
|
309
|
-
behavior: "smooth",
|
|
310
|
-
block: "start",
|
|
311
|
-
});
|
|
312
|
-
e.preventDefault();
|
|
313
|
-
Array.prototype.forEach.call(footNoteTextElements, (el) => {
|
|
314
|
-
highlightAnchor(undefined, undefined, el);
|
|
315
|
-
})
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
350
|
if (/content-switch/.test(target.id)) {
|
|
320
351
|
if (document.body.classList.contains("render-raw")) {
|
|
321
352
|
target.innerText = target.dataset.rawcontentlabel;
|
|
@@ -390,7 +421,7 @@ function handleClick(e) {
|
|
|
390
421
|
window.scrollTo({
|
|
391
422
|
top: 0,
|
|
392
423
|
left: 0,
|
|
393
|
-
behavior: "
|
|
424
|
+
behavior: "instant",
|
|
394
425
|
});
|
|
395
426
|
} else {
|
|
396
427
|
anchor &&
|
|
@@ -398,7 +429,7 @@ function handleClick(e) {
|
|
|
398
429
|
behavior: "instant",
|
|
399
430
|
block: "start",
|
|
400
431
|
});
|
|
401
|
-
|
|
432
|
+
triggerAnchoring();
|
|
402
433
|
}
|
|
403
434
|
highlightAnchor(targetId);
|
|
404
435
|
if (
|
|
@@ -148,6 +148,19 @@ function removeTransitionStyle(el) {
|
|
|
148
148
|
* @returns {Promise<HTMLImageElement | void>}
|
|
149
149
|
*/
|
|
150
150
|
function decodeImage(img) {
|
|
151
|
+
// Skip decode for HDR images to prevent crashes
|
|
152
|
+
if (img.src && img.src.includes("/hdr/")) {
|
|
153
|
+
if (img.complete) {
|
|
154
|
+
return Promise.resolve(img);
|
|
155
|
+
}
|
|
156
|
+
return new Promise((resolve, reject) => {
|
|
157
|
+
img.onload = () => resolve(img);
|
|
158
|
+
img.onerror = reject;
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if ("decode" in img) {
|
|
162
|
+
return img.decode().catch(() => {});
|
|
163
|
+
}
|
|
151
164
|
if (img.complete) {
|
|
152
165
|
return Promise.resolve(img);
|
|
153
166
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
function replaceEmojis() {
|
|
2
|
-
const replacements = [
|
|
3
|
-
{ emoji: "✅", className: "custom-checked-checkbox" },
|
|
4
|
-
];
|
|
2
|
+
const replacements = [{ emoji: "✅", className: "custom-checked-checkbox" }];
|
|
5
3
|
|
|
6
4
|
replacements.forEach(({ emoji, className }) => {
|
|
7
5
|
const walker = document.createTreeWalker(
|
|
@@ -13,7 +11,7 @@ function replaceEmojis() {
|
|
|
13
11
|
? NodeFilter.FILTER_ACCEPT
|
|
14
12
|
: NodeFilter.FILTER_REJECT;
|
|
15
13
|
},
|
|
16
|
-
}
|
|
14
|
+
},
|
|
17
15
|
);
|
|
18
16
|
|
|
19
17
|
const nodesToReplace = [];
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
document.addEventListener("DOMContentLoaded", () => {
|
|
2
|
+
const tocContainer = document.getElementById("toc");
|
|
3
|
+
if (!tocContainer) return;
|
|
4
|
+
|
|
2
5
|
const headers = [...document.querySelectorAll("h2, h3")];
|
|
6
|
+
if (headers.length === 0) return;
|
|
7
|
+
|
|
3
8
|
const toc = [];
|
|
4
9
|
let lastH2 = null;
|
|
5
|
-
let previousToc = [];
|
|
6
10
|
let previousH2Id = null;
|
|
7
11
|
let previousH3Id = null;
|
|
12
|
+
let lastActiveH2Id = null;
|
|
13
|
+
let lastActiveH3Id = null;
|
|
8
14
|
|
|
9
15
|
headers.forEach((header) => {
|
|
10
16
|
const title = header.textContent.trim();
|
|
@@ -30,12 +36,13 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
30
36
|
}
|
|
31
37
|
});
|
|
32
38
|
|
|
39
|
+
const tocItems = (tocContainer.children[1] && tocContainer.children[1].children) || [];
|
|
40
|
+
|
|
33
41
|
const observer = new IntersectionObserver(
|
|
34
42
|
(entries) => {
|
|
35
43
|
entries.forEach((entry) => {
|
|
36
44
|
const id = entry.target.id;
|
|
37
45
|
const isVisible = !!entry.intersectionRatio;
|
|
38
|
-
const isH2 = toc.findIndex((h2) => h2.id === id) !== -1;
|
|
39
46
|
toc.forEach((h2) => {
|
|
40
47
|
if (h2.id === id) {
|
|
41
48
|
h2.visible = isVisible;
|
|
@@ -60,6 +67,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
60
67
|
}
|
|
61
68
|
});
|
|
62
69
|
});
|
|
70
|
+
|
|
63
71
|
const activeH2Index = toc.findIndex(
|
|
64
72
|
(tocItem) => tocItem.passiveVisible || tocItem.visible,
|
|
65
73
|
);
|
|
@@ -80,147 +88,89 @@ document.addEventListener("DOMContentLoaded", () => {
|
|
|
80
88
|
});
|
|
81
89
|
|
|
82
90
|
const activeH2 = toc.find((item) =>
|
|
83
|
-
typeof anchoringId !== undefined && anchoringId
|
|
91
|
+
typeof anchoringId !== "undefined" && anchoringId
|
|
84
92
|
? item.id === anchoringId
|
|
85
93
|
: item.active,
|
|
86
94
|
);
|
|
95
|
+
|
|
96
|
+
let targetH2Id = null;
|
|
97
|
+
let targetH3Id = null;
|
|
98
|
+
|
|
87
99
|
if (activeH2) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
previousToc = cloneDeep(toc);
|
|
92
|
-
}
|
|
93
|
-
if (activeH2?.children?.every((h3) => !h3?.active)) {
|
|
94
|
-
previousH3Id = null;
|
|
95
|
-
}
|
|
96
|
-
const tocItems =
|
|
97
|
-
document.getElementById("toc")?.children[1]?.children || [];
|
|
98
|
-
Array.prototype.forEach.call(tocItems, (tocItem) => {
|
|
99
|
-
if (tocItem.children[0].dataset.id === activeH2.id) {
|
|
100
|
-
tocItem.className = "toc-item-wrap active";
|
|
101
|
-
tocItem.scrollIntoView({
|
|
102
|
-
block: "nearest",
|
|
103
|
-
inline: "nearest",
|
|
104
|
-
});
|
|
105
|
-
} else {
|
|
106
|
-
tocItem.className = "toc-item-wrap";
|
|
107
|
-
}
|
|
108
|
-
const subItems = tocItem.children[1];
|
|
109
|
-
const activeH3 = (activeH2.children || []).find(
|
|
110
|
-
(item) => item.active,
|
|
111
|
-
);
|
|
112
|
-
if (subItems) {
|
|
113
|
-
Array.prototype.forEach.call(
|
|
114
|
-
subItems?.children || [],
|
|
115
|
-
(subItem) => {
|
|
116
|
-
if (subItem.children[0].dataset.id === activeH3?.id) {
|
|
117
|
-
subItem.children[0].className = "toc-sub-item-link active";
|
|
118
|
-
subItem.children[0].scrollIntoView({
|
|
119
|
-
block: "nearest",
|
|
120
|
-
inline: "nearest",
|
|
121
|
-
});
|
|
122
|
-
} else {
|
|
123
|
-
subItem.children[0].className = "toc-sub-item-link";
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
if (anchoringId) {
|
|
130
|
-
anchoringId = null;
|
|
131
|
-
}
|
|
100
|
+
targetH2Id = activeH2.id;
|
|
101
|
+
const activeH3 = (activeH2.children || []).find((item) => item.active);
|
|
102
|
+
targetH3Id = activeH3 ? activeH3.id : null;
|
|
132
103
|
} else {
|
|
133
104
|
const isScrollingUp = window.scrollY < previousScrollY;
|
|
134
105
|
if (isScrollingUp) {
|
|
135
|
-
const previousH2 = toc.find((h2) => h2.id === previousH2Id);
|
|
136
106
|
const previousH2Index = toc.findIndex((h2) => h2.id === previousH2Id);
|
|
137
107
|
const previousH3ParentIndex = toc.findIndex((h2) =>
|
|
138
|
-
h2
|
|
108
|
+
h2 && h2.children && h2.children.find((h3) => h3.id === previousH3Id),
|
|
139
109
|
);
|
|
140
|
-
const newToc = cloneDeep(toc);
|
|
141
110
|
let targetH2Index = 0;
|
|
142
111
|
if (!previousH3Id || previousH3ParentIndex > previousH2Index) {
|
|
143
112
|
targetH2Index = previousH2Index - 1;
|
|
144
113
|
} else {
|
|
145
114
|
targetH2Index = previousH3ParentIndex;
|
|
146
115
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
const tocItems =
|
|
155
|
-
document.getElementById("toc")?.children[1]?.children || [];
|
|
156
|
-
Array.prototype.forEach.call(tocItems, (tocItem) => {
|
|
157
|
-
if (tocItem.children[0].dataset.id === newActiveH2.id) {
|
|
158
|
-
tocItem.className = "toc-item-wrap active";
|
|
159
|
-
tocItem.scrollIntoView({
|
|
160
|
-
block: "nearest",
|
|
161
|
-
inline: "nearest",
|
|
162
|
-
});
|
|
163
|
-
} else {
|
|
164
|
-
tocItem.className = "toc-item-wrap";
|
|
165
|
-
}
|
|
166
|
-
const subItems = tocItem.children[1];
|
|
167
|
-
let activeH3Index = newActiveH2?.children?.length - 1;
|
|
168
|
-
if (newActiveH2?.children?.find((h3) => h3.id === previousH3Id)) {
|
|
169
|
-
const previousH3Index = newActiveH2?.children?.findIndex(
|
|
116
|
+
const newActiveH2 = toc[targetH2Index];
|
|
117
|
+
if (newActiveH2) {
|
|
118
|
+
targetH2Id = newActiveH2.id;
|
|
119
|
+
let activeH3Index = (newActiveH2.children ? newActiveH2.children.length : 0) - 1;
|
|
120
|
+
if (newActiveH2.children && newActiveH2.children.find((h3) => h3.id === previousH3Id)) {
|
|
121
|
+
const previousH3Index = newActiveH2.children.findIndex(
|
|
170
122
|
(h3) => h3.id === previousH3Id,
|
|
171
123
|
);
|
|
172
124
|
activeH3Index =
|
|
173
125
|
previousH3Index - 1 > -1 ? previousH3Index - 1 : 0;
|
|
174
126
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
Array.prototype.forEach.call(
|
|
178
|
-
subItems?.children || [],
|
|
179
|
-
(subItem) => {
|
|
180
|
-
if (subItem.children[0].dataset.id === activeH3Id) {
|
|
181
|
-
subItem.children[0].className = "toc-sub-item-link active";
|
|
182
|
-
subItem.children[0].scrollIntoView({
|
|
183
|
-
block: "nearest",
|
|
184
|
-
inline: "nearest",
|
|
185
|
-
});
|
|
186
|
-
} else {
|
|
187
|
-
subItem.children[0].className = "toc-sub-item-link";
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
});
|
|
127
|
+
targetH3Id = (newActiveH2.children && newActiveH2.children[activeH3Index] && newActiveH2.children[activeH3Index].id) || null;
|
|
128
|
+
}
|
|
193
129
|
} else {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
130
|
+
targetH2Id = previousH2Id;
|
|
131
|
+
targetH3Id = previousH3Id;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (targetH2Id) {
|
|
136
|
+
if (lastActiveH2Id === targetH2Id && lastActiveH3Id === targetH3Id && !anchoringId) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
lastActiveH2Id = targetH2Id;
|
|
140
|
+
lastActiveH3Id = targetH3Id;
|
|
141
|
+
|
|
142
|
+
if (activeH2 && activeH2.children && activeH2.children.every((h3) => !h3.active)) {
|
|
143
|
+
previousH3Id = null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
Array.from(tocItems).forEach((tocItem) => {
|
|
147
|
+
if (tocItem.children[0].dataset.id === targetH2Id) {
|
|
148
|
+
tocItem.className = "toc-item-wrap active";
|
|
149
|
+
tocItem.scrollIntoView({
|
|
150
|
+
block: "nearest",
|
|
151
|
+
inline: "nearest",
|
|
152
|
+
});
|
|
153
|
+
} else {
|
|
154
|
+
tocItem.className = "toc-item-wrap";
|
|
155
|
+
}
|
|
156
|
+
const subItems = tocItem.children[1];
|
|
157
|
+
if (subItems) {
|
|
158
|
+
Array.from(subItems.children || []).forEach((subItem) => {
|
|
159
|
+
if (subItem.children[0].dataset.id === targetH3Id) {
|
|
160
|
+
subItem.children[0].className = "toc-sub-item-link active";
|
|
161
|
+
subItem.children[0].scrollIntoView({
|
|
162
|
+
block: "nearest",
|
|
163
|
+
inline: "nearest",
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
subItem.children[0].className = "toc-sub-item-link";
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
if (anchoringId) {
|
|
173
|
+
anchoringId = null;
|
|
224
174
|
}
|
|
225
175
|
}
|
|
226
176
|
},
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<footer id="footer">
|
|
2
|
-
<div class="footerInner">
|
|
3
|
-
<div class="footerItems">
|
|
4
|
-
<!-- <a class="footerItem" href="">About This Blog</a> -->
|
|
5
|
-
<span class="footerItem"><abbr title="<%=__('common.copyright')%>" style="cursor: help;">©</abbr> <%=date(Date.now(), 'YYYY')+' '+config.author%></span>
|
|
6
|
-
<span class="footerItem">Powered by <a href="https://hexo.io/" target="_blank">Hexo</a></span>
|
|
7
|
-
<% if (theme?.info?.registration) { %>
|
|
8
|
-
<span class="footerItem"><%=theme.info.registration%></span>
|
|
9
|
-
<% } %>
|
|
10
|
-
</div>
|
|
11
|
-
</div>
|
|
12
|
-
</footer>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg t="1776504285799" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4049" width="200" height="200"><path d="M853.312 170.688v384a170.688 170.688 0 0 1-170.624 170.624H294.976L401.664 832l-60.352 60.352-209.664-209.664L341.312 472.96l60.352 60.288L295.04 640h387.712C729.792 640 768 601.792 768 554.688v-384h85.312z" p-id="4050" fill="#0f730c"></path></svg>
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
<svg t="1770982352451" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4586" width="200" height="200">
|
|
2
|
-
<path d="M0 161.422222C7.395556 115.2 50.915556 79.928889 97.991111 85.333333h828.017778c46.364444-5.262222 87.608889 28.444444 97.991111 72.675556v704.426667c-7.395556 46.364444-50.915556 81.635556-98.133333 76.231111H97.991111C51.626667 944.071111 10.24 910.222222 0 865.848889V161.422222m202.524444 296.106667c-41.102222 21.617778-41.102222 87.466667 0.142223 109.084444 39.253333 26.026667 97.848889-7.822222 95.146666-54.613333 2.702222-46.933333-56.035556-80.64-95.288889-54.471111m272.924445 2.844444c-28.16 18.631111-35.697778 61.44-14.933333 88.32 18.915556 28.302222 61.866667 35.555556 88.746666 14.364445 27.875556-18.915556 34.702222-61.582222 13.937778-88.177778-18.773333-27.733333-61.013333-34.844444-87.751111-14.506667m281.6-2.844444c-40.533333 21.475556-40.96 86.471111-0.711111 108.373333 39.111111 27.306667 98.986667-6.684444 96.142222-53.902222 2.702222-46.933333-56.177778-80.924444-95.431111-54.471111z" fill="#F5F5F5" p-id="4587"></path>
|
|
3
|
-
<path d="M202.524444 457.528889c39.253333-26.168889 97.991111 7.537778 95.288889 54.471111 2.702222 46.791111-55.893333 80.64-95.146666 54.613333-41.244444-21.617778-41.244444-87.466667-0.142223-109.084444zM475.448889 460.373333c26.737778-20.337778 68.977778-13.226667 87.751111 14.506667 20.764444 26.595556 13.937778 69.262222-13.937778 88.177778-26.88 21.191111-69.831111 13.937778-88.746666-14.364445-20.764444-26.88-13.226667-69.688889 14.933333-88.32zM757.048889 457.528889c39.253333-26.453333 98.133333 7.537778 95.431111 54.471111 2.844444 47.217778-57.031111 81.208889-96.142222 53.902222-40.248889-21.902222-39.822222-86.897778 0.711111-108.373333z" fill="#494949" p-id="4588"></path>
|
|
4
|
-
</svg>
|