hexo-theme-gnix 13.0.0 → 14.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.
- package/include/hexo/generator/archive.js +14 -1
- package/include/hexo/generator/index.js +0 -5
- package/include/hexo/generator/page.js +18 -4
- package/include/hexo/generator/tag.js +1 -1
- package/include/hexo/helper.js +0 -4
- package/include/hexo/i18n.js +21 -136
- package/include/util/i18n.js +92 -106
- package/layout/archive.jsx +155 -78
- package/layout/common/article.jsx +82 -121
- package/layout/common/article_cover.jsx +3 -3
- package/layout/common/article_media.jsx +9 -2
- package/layout/common/footer.jsx +4 -1
- package/layout/common/navbar.jsx +15 -12
- package/layout/common/scripts.jsx +1 -1
- package/layout/layout.jsx +12 -11
- package/layout/tag.jsx +3 -70
- package/layout/tags.jsx +26 -23
- package/package.json +4 -4
- package/source/css/archive.css +287 -166
- package/source/css/default.css +102 -80
- package/source/css/responsive.css +1 -45
- package/source/css/tags.css +53 -59
- package/source/js/components/archive-popup.js +313 -0
- package/source/js/components/friends-list.js +0 -1
- package/source/js/main.js +14 -13
- package/include/hexo/generator/home.js +0 -64
- package/layout/index.jsx +0 -19
- package/layout/misc/paginator.jsx +0 -69
- package/source/js/host/iconify-icon/3.0.2/iconify-icon.min.js +0 -12
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
const HOVER_DELAY = 180;
|
|
2
|
+
const CLOSE_DELAY = 140;
|
|
3
|
+
|
|
4
|
+
const coarsePointerQuery = typeof window.matchMedia === "function" ? window.matchMedia("(hover: none)") : null;
|
|
5
|
+
let coarsePointer = coarsePointerQuery?.matches ?? false;
|
|
6
|
+
coarsePointerQuery?.addEventListener?.("change", (event) => {
|
|
7
|
+
coarsePointer = event.matches;
|
|
8
|
+
if (coarsePointer) close();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
let popupEl = null;
|
|
12
|
+
let excerptEl = null;
|
|
13
|
+
let indexEl = null;
|
|
14
|
+
let sepEl = null;
|
|
15
|
+
let readEl = null;
|
|
16
|
+
let openTimer = null;
|
|
17
|
+
let closeTimer = null;
|
|
18
|
+
let activeItem = null;
|
|
19
|
+
let populatedItem = null;
|
|
20
|
+
let popupSize = null;
|
|
21
|
+
let scrollFrame = 0;
|
|
22
|
+
|
|
23
|
+
const accentCache = new WeakMap();
|
|
24
|
+
const indexCache = new WeakMap();
|
|
25
|
+
let indexCacheBuilt = false;
|
|
26
|
+
|
|
27
|
+
function ensurePopup() {
|
|
28
|
+
if (popupEl) return popupEl;
|
|
29
|
+
|
|
30
|
+
popupEl = document.createElement("div");
|
|
31
|
+
popupEl.className = "archive-popup";
|
|
32
|
+
popupEl.setAttribute("aria-hidden", "true");
|
|
33
|
+
popupEl.innerHTML = `
|
|
34
|
+
<p class="archive-popup__eyebrow">
|
|
35
|
+
<span class="archive-popup__index"></span>
|
|
36
|
+
<span class="archive-popup__sep" hidden> · </span>
|
|
37
|
+
<span class="archive-popup__read" hidden></span>
|
|
38
|
+
</p>
|
|
39
|
+
<div class="archive-popup__excerpt"></div>
|
|
40
|
+
`;
|
|
41
|
+
document.body.appendChild(popupEl);
|
|
42
|
+
|
|
43
|
+
excerptEl = popupEl.querySelector(".archive-popup__excerpt");
|
|
44
|
+
indexEl = popupEl.querySelector(".archive-popup__index");
|
|
45
|
+
sepEl = popupEl.querySelector(".archive-popup__sep");
|
|
46
|
+
readEl = popupEl.querySelector(".archive-popup__read");
|
|
47
|
+
|
|
48
|
+
popupEl.addEventListener("pointerenter", clearCloseTimer);
|
|
49
|
+
popupEl.addEventListener("pointerleave", scheduleClose);
|
|
50
|
+
|
|
51
|
+
return popupEl;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function clearOpenTimer() {
|
|
55
|
+
if (openTimer) {
|
|
56
|
+
clearTimeout(openTimer);
|
|
57
|
+
openTimer = null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function clearCloseTimer() {
|
|
62
|
+
if (closeTimer) {
|
|
63
|
+
clearTimeout(closeTimer);
|
|
64
|
+
closeTimer = null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function clearTimers() {
|
|
69
|
+
clearOpenTimer();
|
|
70
|
+
clearCloseTimer();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function getItemIndex(item) {
|
|
74
|
+
const cached = indexCache.get(item);
|
|
75
|
+
if (cached !== undefined) return cached;
|
|
76
|
+
if (!indexCacheBuilt) {
|
|
77
|
+
const items = document.querySelectorAll(".archive-item");
|
|
78
|
+
items.forEach((el, i) => {
|
|
79
|
+
indexCache.set(el, String(i + 1).padStart(3, "0"));
|
|
80
|
+
});
|
|
81
|
+
indexCacheBuilt = true;
|
|
82
|
+
}
|
|
83
|
+
return indexCache.get(item) ?? null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getGroupAccent(group) {
|
|
87
|
+
if (!group) return null;
|
|
88
|
+
const cached = accentCache.get(group);
|
|
89
|
+
if (cached !== undefined) return cached;
|
|
90
|
+
const accent = getComputedStyle(group).getPropertyValue("--archive-accent").trim();
|
|
91
|
+
accentCache.set(group, accent);
|
|
92
|
+
return accent;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function populate(item) {
|
|
96
|
+
ensurePopup();
|
|
97
|
+
if (populatedItem === item) return;
|
|
98
|
+
|
|
99
|
+
const readTime = item.dataset.readTime || "";
|
|
100
|
+
const excerptTemplate = item.querySelector(".archive-item__excerpt");
|
|
101
|
+
|
|
102
|
+
const accent = getGroupAccent(item.closest(".archive-group"));
|
|
103
|
+
if (accent) popupEl.style.setProperty("--popup-accent", accent);
|
|
104
|
+
|
|
105
|
+
const idx = getItemIndex(item);
|
|
106
|
+
indexEl.textContent = idx ? `N° ${idx}` : "";
|
|
107
|
+
if (readTime) {
|
|
108
|
+
readEl.textContent = readTime.replace(/min$/i, "min read").toUpperCase();
|
|
109
|
+
readEl.hidden = false;
|
|
110
|
+
sepEl.hidden = !idx;
|
|
111
|
+
} else {
|
|
112
|
+
readEl.textContent = "";
|
|
113
|
+
readEl.hidden = true;
|
|
114
|
+
sepEl.hidden = true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
excerptEl.innerHTML = excerptTemplate ? excerptTemplate.innerHTML : "";
|
|
118
|
+
populatedItem = item;
|
|
119
|
+
popupSize = null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function position(item) {
|
|
123
|
+
const margin = 12;
|
|
124
|
+
const viewportW = window.innerWidth;
|
|
125
|
+
const viewportH = window.innerHeight;
|
|
126
|
+
|
|
127
|
+
const RIGHT_VIEWPORT_MIN = 1280;
|
|
128
|
+
const RIGHT_POPUP_WIDTH = 208;
|
|
129
|
+
|
|
130
|
+
const rect = item.getBoundingClientRect();
|
|
131
|
+
const availableRight = viewportW - rect.right - margin;
|
|
132
|
+
const canPlaceRight = viewportW >= RIGHT_VIEWPORT_MIN && availableRight >= RIGHT_POPUP_WIDTH + margin;
|
|
133
|
+
|
|
134
|
+
// Only mutate dataset (and invalidate size cache) when the width-affecting
|
|
135
|
+
// placement actually changes — "below" and "above" share dimensions.
|
|
136
|
+
const wasRight = popupEl.dataset.placement === "right";
|
|
137
|
+
if (wasRight !== canPlaceRight) {
|
|
138
|
+
popupEl.dataset.placement = canPlaceRight ? "right" : "below";
|
|
139
|
+
popupSize = null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (!popupSize) {
|
|
143
|
+
const popupRect = popupEl.getBoundingClientRect();
|
|
144
|
+
popupSize = { width: popupRect.width, height: popupRect.height };
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (canPlaceRight) {
|
|
148
|
+
const left = rect.right + margin + window.scrollX;
|
|
149
|
+
let top = rect.top + window.scrollY - 4;
|
|
150
|
+
const minTop = window.scrollY + margin;
|
|
151
|
+
const maxTop = window.scrollY + viewportH - popupSize.height - margin;
|
|
152
|
+
if (top > maxTop) top = maxTop;
|
|
153
|
+
if (top < minTop) top = minTop;
|
|
154
|
+
popupEl.style.top = `${top}px`;
|
|
155
|
+
popupEl.style.left = `${left}px`;
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const spaceBelow = viewportH - rect.bottom;
|
|
160
|
+
const spaceAbove = rect.top;
|
|
161
|
+
const placeBelow = spaceBelow >= popupSize.height + margin || spaceBelow >= spaceAbove;
|
|
162
|
+
|
|
163
|
+
const top = placeBelow
|
|
164
|
+
? rect.bottom + margin + window.scrollY
|
|
165
|
+
: rect.top - popupSize.height - margin + window.scrollY;
|
|
166
|
+
|
|
167
|
+
let left = rect.left + window.scrollX;
|
|
168
|
+
const maxLeft = window.scrollX + viewportW - popupSize.width - margin;
|
|
169
|
+
if (left > maxLeft) left = maxLeft;
|
|
170
|
+
if (left < window.scrollX + margin) left = window.scrollX + margin;
|
|
171
|
+
|
|
172
|
+
popupEl.style.top = `${top}px`;
|
|
173
|
+
popupEl.style.left = `${left}px`;
|
|
174
|
+
const finalPlacement = placeBelow ? "below" : "above";
|
|
175
|
+
if (popupEl.dataset.placement !== finalPlacement) {
|
|
176
|
+
popupEl.dataset.placement = finalPlacement;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function open(item) {
|
|
181
|
+
ensurePopup();
|
|
182
|
+
if (activeItem === item && popupEl.classList.contains("is-open")) return;
|
|
183
|
+
activeItem = item;
|
|
184
|
+
populate(item);
|
|
185
|
+
position(item);
|
|
186
|
+
popupEl.classList.add("is-open");
|
|
187
|
+
popupEl.setAttribute("aria-hidden", "false");
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function close() {
|
|
191
|
+
if (!popupEl) return;
|
|
192
|
+
popupEl.classList.remove("is-open");
|
|
193
|
+
popupEl.setAttribute("aria-hidden", "true");
|
|
194
|
+
activeItem = null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function scheduleOpen(item) {
|
|
198
|
+
clearTimers();
|
|
199
|
+
openTimer = window.setTimeout(() => open(item), HOVER_DELAY);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function scheduleClose() {
|
|
203
|
+
clearTimers();
|
|
204
|
+
closeTimer = window.setTimeout(() => {
|
|
205
|
+
if (!popupEl) return;
|
|
206
|
+
if (popupEl.matches(":hover")) return;
|
|
207
|
+
if (popupEl.contains(document.activeElement)) return;
|
|
208
|
+
if (document.querySelector(".archive-item.has-preview:hover")) return;
|
|
209
|
+
const focused = document.activeElement;
|
|
210
|
+
if (focused?.closest?.(".archive-item.has-preview")) return;
|
|
211
|
+
close();
|
|
212
|
+
}, CLOSE_DELAY);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function handlePointerOver(event) {
|
|
216
|
+
if (coarsePointer) return;
|
|
217
|
+
const item = event.target.closest(".archive-item.has-preview");
|
|
218
|
+
if (!item) return;
|
|
219
|
+
const from = event.relatedTarget;
|
|
220
|
+
if (from && item.contains(from)) return;
|
|
221
|
+
scheduleOpen(item);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function handlePointerOut(event) {
|
|
225
|
+
if (coarsePointer) return;
|
|
226
|
+
const item = event.target.closest(".archive-item.has-preview");
|
|
227
|
+
if (!item) return;
|
|
228
|
+
const to = event.relatedTarget;
|
|
229
|
+
if (to && item.contains(to)) return;
|
|
230
|
+
clearOpenTimer();
|
|
231
|
+
scheduleClose();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function handleFocusIn(event) {
|
|
235
|
+
if (coarsePointer) return;
|
|
236
|
+
const item = event.target.closest(".archive-item.has-preview");
|
|
237
|
+
if (!item) return;
|
|
238
|
+
clearTimers();
|
|
239
|
+
open(item);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function handleFocusOut(event) {
|
|
243
|
+
const item = event.target.closest(".archive-item.has-preview");
|
|
244
|
+
if (!item && !event.target.closest?.(".archive-popup")) return;
|
|
245
|
+
scheduleClose();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function handleScroll() {
|
|
249
|
+
if (!activeItem || !popupEl?.classList.contains("is-open")) return;
|
|
250
|
+
if (scrollFrame) return;
|
|
251
|
+
scrollFrame = requestAnimationFrame(() => {
|
|
252
|
+
scrollFrame = 0;
|
|
253
|
+
if (activeItem && popupEl?.classList.contains("is-open")) {
|
|
254
|
+
position(activeItem);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function handleResize() {
|
|
260
|
+
popupSize = null;
|
|
261
|
+
handleScroll();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
let boundArchivePage = null;
|
|
265
|
+
let globalListenersBound = false;
|
|
266
|
+
|
|
267
|
+
function unbindArchivePage() {
|
|
268
|
+
if (!boundArchivePage) return;
|
|
269
|
+
boundArchivePage.removeEventListener("pointerover", handlePointerOver);
|
|
270
|
+
boundArchivePage.removeEventListener("pointerout", handlePointerOut);
|
|
271
|
+
boundArchivePage = null;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function resetPerPageState() {
|
|
275
|
+
populatedItem = null;
|
|
276
|
+
popupSize = null;
|
|
277
|
+
indexCacheBuilt = false;
|
|
278
|
+
clearTimers();
|
|
279
|
+
close();
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function initArchivePopup() {
|
|
283
|
+
const archivePage = document.querySelector(".archive-page");
|
|
284
|
+
|
|
285
|
+
// Left the archive page (or navigated to a page without one): tear down.
|
|
286
|
+
if (!archivePage) {
|
|
287
|
+
unbindArchivePage();
|
|
288
|
+
resetPerPageState();
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (coarsePointer) return;
|
|
293
|
+
|
|
294
|
+
// Same element we already bound to (re-init on same page): nothing to do.
|
|
295
|
+
if (boundArchivePage === archivePage) return;
|
|
296
|
+
|
|
297
|
+
// New archive-page element (Swup swap): rebind to it and drop stale state.
|
|
298
|
+
unbindArchivePage();
|
|
299
|
+
resetPerPageState();
|
|
300
|
+
|
|
301
|
+
boundArchivePage = archivePage;
|
|
302
|
+
archivePage.addEventListener("pointerover", handlePointerOver);
|
|
303
|
+
archivePage.addEventListener("pointerout", handlePointerOut);
|
|
304
|
+
|
|
305
|
+
if (globalListenersBound) return;
|
|
306
|
+
globalListenersBound = true;
|
|
307
|
+
document.addEventListener("focusin", handleFocusIn);
|
|
308
|
+
document.addEventListener("focusout", handleFocusOut);
|
|
309
|
+
window.addEventListener("scroll", handleScroll, { passive: true });
|
|
310
|
+
window.addEventListener("resize", handleResize, { passive: true });
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
window.__gnixInitArchivePopup = initArchivePopup;
|
package/source/js/main.js
CHANGED
|
@@ -597,18 +597,6 @@ function initArticleCommentPopover() {
|
|
|
597
597
|
});
|
|
598
598
|
}
|
|
599
599
|
|
|
600
|
-
function refreshNavbarIcons() {
|
|
601
|
-
document.querySelectorAll(".navbar-end iconify-icon").forEach((el) => {
|
|
602
|
-
if (!el.getAttribute("icon")) return;
|
|
603
|
-
if (el.shadowRoot?.querySelector("svg")) return;
|
|
604
|
-
const parent = el.parentNode;
|
|
605
|
-
if (!parent) return;
|
|
606
|
-
const next = el.nextSibling;
|
|
607
|
-
parent.removeChild(el);
|
|
608
|
-
parent.insertBefore(el, next);
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
|
|
612
600
|
function initPage() {
|
|
613
601
|
handleMermaid();
|
|
614
602
|
addHighlightTool();
|
|
@@ -618,7 +606,7 @@ function initPage() {
|
|
|
618
606
|
document.querySelectorAll(".content img").forEach((img) => zoomImgs.add(img));
|
|
619
607
|
mediumZoom([...zoomImgs], zoomOpts);
|
|
620
608
|
initArticleCommentPopover();
|
|
621
|
-
|
|
609
|
+
window.__gnixInitArchivePopup?.();
|
|
622
610
|
}
|
|
623
611
|
|
|
624
612
|
document.addEventListener("DOMContentLoaded", initPage, { once: true });
|
|
@@ -637,6 +625,19 @@ document.addEventListener("keydown", handleKeyDown, {
|
|
|
637
625
|
passive: false, // 允许调用 preventDefault
|
|
638
626
|
});
|
|
639
627
|
|
|
628
|
+
document.addEventListener(
|
|
629
|
+
"click",
|
|
630
|
+
(e) => {
|
|
631
|
+
const el = e.target.closest("#language-switch");
|
|
632
|
+
if (el && el.dataset.mode === "missing") {
|
|
633
|
+
e.preventDefault();
|
|
634
|
+
e.stopPropagation();
|
|
635
|
+
window.showSiteToast?.(el.dataset.toastMessage);
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
{ capture: true },
|
|
639
|
+
);
|
|
640
|
+
|
|
640
641
|
function toggleNav(event) {
|
|
641
642
|
const container = event.currentTarget;
|
|
642
643
|
const burger = container.querySelector(".navbar-burger");
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
const pagination = require("hexo-pagination");
|
|
2
|
-
const { filterByLanguage, getDefaultLanguageKey, getLanguage, getLanguageBasePath, getLanguageKeys, isI18nEnabled } = require("../../util/i18n");
|
|
3
|
-
|
|
4
|
-
function redirectTo(path) {
|
|
5
|
-
const target = path.startsWith("/") ? path : `/${path}`;
|
|
6
|
-
return `<!doctype html><html><head><meta charset="utf-8"><meta name="robots" content="noindex"><meta http-equiv="refresh" content="0;url=${target}"><link rel="canonical" href="${target}"></head><body><a href="${target}">Continue</a></body></html>`;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
module.exports = (hexo) => {
|
|
10
|
-
hexo.extend.generator.register("index", function (locals) {
|
|
11
|
-
const config = this.config;
|
|
12
|
-
const fullConfig = Object.assign({}, config, config.theme_config, hexo.theme.config);
|
|
13
|
-
const themeConfig = hexo.theme.config.index_generator || {};
|
|
14
|
-
const orderBy = themeConfig.order_by ?? "-date";
|
|
15
|
-
const perPage = themeConfig.per_page ?? config.per_page ?? 16;
|
|
16
|
-
const layout = themeConfig.layout ?? ["index", "archive"];
|
|
17
|
-
const paginationDir = themeConfig.pagination_dir ?? config.pagination_dir ?? "page";
|
|
18
|
-
const path = themeConfig.path ?? "";
|
|
19
|
-
|
|
20
|
-
if (!isI18nEnabled(fullConfig)) {
|
|
21
|
-
const posts = locals.posts.sort(orderBy);
|
|
22
|
-
posts.data.sort((a, b) => (b.sticky || 0) - (a.sticky || 0));
|
|
23
|
-
|
|
24
|
-
return pagination(path, posts, {
|
|
25
|
-
perPage,
|
|
26
|
-
layout,
|
|
27
|
-
format: `${paginationDir}/%d/`,
|
|
28
|
-
data: {
|
|
29
|
-
__index: true,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const result = [];
|
|
35
|
-
const defaultLanguageBase = getLanguageBasePath(fullConfig, getDefaultLanguageKey(fullConfig));
|
|
36
|
-
|
|
37
|
-
if (defaultLanguageBase) {
|
|
38
|
-
result.push({
|
|
39
|
-
path: "index.html",
|
|
40
|
-
data: redirectTo(defaultLanguageBase),
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
getLanguageKeys(fullConfig).forEach((langKey) => {
|
|
45
|
-
const posts = filterByLanguage(locals.posts.sort(orderBy), langKey, fullConfig);
|
|
46
|
-
posts.data.sort((a, b) => (b.sticky || 0) - (a.sticky || 0));
|
|
47
|
-
|
|
48
|
-
result.push(
|
|
49
|
-
...pagination(getLanguageBasePath(fullConfig, langKey) + path, posts, {
|
|
50
|
-
perPage,
|
|
51
|
-
layout,
|
|
52
|
-
format: `${paginationDir}/%d/`,
|
|
53
|
-
data: {
|
|
54
|
-
__index: true,
|
|
55
|
-
i18n_lang: langKey,
|
|
56
|
-
lang: getLanguage(fullConfig, langKey).locale,
|
|
57
|
-
},
|
|
58
|
-
}),
|
|
59
|
-
);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return result;
|
|
63
|
-
});
|
|
64
|
-
};
|
package/layout/index.jsx
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const { Component, Fragment } = require("../include/util/common");
|
|
2
|
-
const Paginator = require("./misc/paginator");
|
|
3
|
-
const Article = require("./common/article");
|
|
4
|
-
|
|
5
|
-
module.exports = class extends Component {
|
|
6
|
-
render() {
|
|
7
|
-
const { config, page, helper } = this.props;
|
|
8
|
-
const { url_for } = helper;
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<Fragment>
|
|
12
|
-
{page.posts.map((post) => (
|
|
13
|
-
<Article config={config} page={post} helper={helper} index={true} />
|
|
14
|
-
))}
|
|
15
|
-
{page.total > 1 ? <Paginator current={page.current} total={page.total} baseUrl={page.base} path={config.pagination_dir} urlFor={url_for} /> : null}
|
|
16
|
-
</Fragment>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const { Component } = require("inferno");
|
|
2
|
-
|
|
3
|
-
module.exports = class extends Component {
|
|
4
|
-
render() {
|
|
5
|
-
const { current, total, baseUrl, path, urlFor } = this.props;
|
|
6
|
-
|
|
7
|
-
function getPageUrl(i) {
|
|
8
|
-
return urlFor(i === 1 ? baseUrl : `${baseUrl + path}/${i}/`);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function pagination(c, m) {
|
|
12
|
-
const current = c;
|
|
13
|
-
const last = m;
|
|
14
|
-
const delta = 2;
|
|
15
|
-
const left = current - delta;
|
|
16
|
-
const right = current + delta + 1;
|
|
17
|
-
const range = [];
|
|
18
|
-
const elements = [];
|
|
19
|
-
let l;
|
|
20
|
-
|
|
21
|
-
for (let i = 1; i <= last; i++) {
|
|
22
|
-
if (i === 1 || i === last || (i >= left && i < right)) {
|
|
23
|
-
range.push(i);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
for (const i of range) {
|
|
28
|
-
if (l) {
|
|
29
|
-
if (i - l === 2) {
|
|
30
|
-
elements.push(
|
|
31
|
-
<li>
|
|
32
|
-
<a class="pagination-link" href={getPageUrl(l + 1)}>
|
|
33
|
-
{l + 1}
|
|
34
|
-
</a>
|
|
35
|
-
</li>,
|
|
36
|
-
);
|
|
37
|
-
} else if (i - l !== 1) {
|
|
38
|
-
elements.push(
|
|
39
|
-
<li>
|
|
40
|
-
<span class="pagination-ellipsis" style="pointer-events: none;" dangerouslySetInnerHTML={{ __html: "…" }}></span>
|
|
41
|
-
</li>,
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
elements.push(
|
|
46
|
-
<li>
|
|
47
|
-
<a class={`pagination-link${c === i ? " is-current" : ""}`} href={getPageUrl(i)}>
|
|
48
|
-
{i}
|
|
49
|
-
</a>
|
|
50
|
-
</li>,
|
|
51
|
-
);
|
|
52
|
-
l = i;
|
|
53
|
-
}
|
|
54
|
-
return elements;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<nav class="pagination card" aria-label="pagination">
|
|
59
|
-
<a href={getPageUrl(current - 1)} class={`pagination-previous`} style={current > 1 ? {} : { visibility: "hidden" }}>
|
|
60
|
-
Prev
|
|
61
|
-
</a>
|
|
62
|
-
<a href={getPageUrl(current + 1)} class={`pagination-next`} style={current < total ? {} : { visibility: "hidden" }}>
|
|
63
|
-
Next
|
|
64
|
-
</a>
|
|
65
|
-
<ul class="pagination-list is-hidden-mobile">{pagination(current, total)}</ul>
|
|
66
|
-
</nav>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* (c) Iconify
|
|
3
|
-
*
|
|
4
|
-
* For the full copyright and license information, please view the license.txt
|
|
5
|
-
* files at https://github.com/iconify/iconify
|
|
6
|
-
*
|
|
7
|
-
* Licensed under MIT.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
* @version 3.0.2
|
|
11
|
-
*/
|
|
12
|
-
!function(){"use strict";const t=Object.freeze({left:0,top:0,width:16,height:16}),e=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),n=Object.freeze({...t,...e}),i=Object.freeze({...n,body:"",hidden:!1}),r=Object.freeze({width:null,height:null}),o=Object.freeze({...r,...e});const s=/[\s,]+/;const c={...o,preserveAspectRatio:""};function a(t){const e={...c},n=(e,n)=>t.getAttribute(e)||n;var i;return e.width=n("width",null),e.height=n("height",null),e.rotate=function(t,e=0){const n=t.replace(/^-?[0-9.]*/,"");function i(t){for(;t<0;)t+=4;return t%4}if(""===n){const e=parseInt(t);return isNaN(e)?0:i(e)}if(n!==t){let e=0;switch(n){case"%":e=25;break;case"deg":e=90}if(e){let r=parseFloat(t.slice(0,t.length-n.length));return isNaN(r)?0:(r/=e,r%1==0?i(r):0)}}return e}(n("rotate","")),i=e,n("flip","").split(s).forEach(t=>{switch(t.trim()){case"horizontal":i.hFlip=!0;break;case"vertical":i.vFlip=!0}}),e.preserveAspectRatio=n("preserveAspectRatio",n("preserveaspectratio","")),e}const u=/^[a-z0-9]+(-[a-z0-9]+)*$/,l=(t,e,n,i="")=>{const r=t.split(":");if("@"===t.slice(0,1)){if(r.length<2||r.length>3)return null;i=r.shift().slice(1)}if(r.length>3||!r.length)return null;if(r.length>1){const t=r.pop(),n=r.pop(),o={provider:r.length>0?r[0]:i,prefix:n,name:t};return e&&!f(o)?null:o}const o=r[0],s=o.split("-");if(s.length>1){const t={provider:i,prefix:s.shift(),name:s.join("-")};return e&&!f(t)?null:t}if(n&&""===i){const t={provider:i,prefix:"",name:o};return e&&!f(t,n)?null:t}return null},f=(t,e)=>!!t&&!(!(e&&""===t.prefix||t.prefix)||!t.name);function d(t,n){const r=function(t,e){const n={};!t.hFlip!=!e.hFlip&&(n.hFlip=!0),!t.vFlip!=!e.vFlip&&(n.vFlip=!0);const i=((t.rotate||0)+(e.rotate||0))%4;return i&&(n.rotate=i),n}(t,n);for(const o in i)o in e?o in t&&!(o in r)&&(r[o]=e[o]):o in n?r[o]=n[o]:o in t&&(r[o]=t[o]);return r}function h(t,e,n){const i=t.icons,r=t.aliases||Object.create(null);let o={};function s(t){o=d(i[t]||r[t],o)}return s(e),n.forEach(s),d(t,o)}function p(t,e){const n=[];if("object"!=typeof t||"object"!=typeof t.icons)return n;t.not_found instanceof Array&&t.not_found.forEach(t=>{e(t,null),n.push(t)});const i=function(t){const e=t.icons,n=t.aliases||Object.create(null),i=Object.create(null);return Object.keys(e).concat(Object.keys(n)).forEach(function t(r){if(e[r])return i[r]=[];if(!(r in i)){i[r]=null;const e=n[r]&&n[r].parent,o=e&&t(e);o&&(i[r]=[e].concat(o))}return i[r]}),i}(t);for(const r in i){const o=i[r];o&&(e(r,h(t,r,o)),n.push(r))}return n}const g={provider:"",aliases:{},not_found:{},...t};function b(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function v(t){if("object"!=typeof t||null===t)return null;const e=t;if("string"!=typeof e.prefix||!t.icons||"object"!=typeof t.icons)return null;if(!b(t,g))return null;const n=e.icons;for(const t in n){const e=n[t];if(!t||"string"!=typeof e.body||!b(e,i))return null}const r=e.aliases||Object.create(null);for(const t in r){const e=r[t],o=e.parent;if(!t||"string"!=typeof o||!n[o]&&!r[o]||!b(e,i))return null}return e}const m=Object.create(null);function y(t,e){const n=m[t]||(m[t]=Object.create(null));return n[e]||(n[e]=function(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}(t,e))}function x(t,e){return v(e)?p(e,(e,n)=>{n?t.icons[e]=n:t.missing.add(e)}):[]}function _(t,e){let n=[];return("string"==typeof t?[t]:Object.keys(m)).forEach(t=>{("string"==typeof t&&"string"==typeof e?[e]:Object.keys(m[t]||{})).forEach(e=>{const i=y(t,e);n=n.concat(Object.keys(i.icons).map(n=>(""!==t?"@"+t+":":"")+e+":"+n))})}),n}let w=!1;function k(t){return"boolean"==typeof t&&(w=t),w}function A(t){const e="string"==typeof t?l(t,!0,w):t;if(e){const t=y(e.provider,e.prefix),n=e.name;return t.icons[n]||(t.missing.has(n)?null:void 0)}}function j(t,e){const n=l(t,!0,w);if(!n)return!1;const i=y(n.provider,n.prefix);return e?function(t,e,n){try{if("string"==typeof n.body)return t.icons[e]={...n},!0}catch(t){}return!1}(i,n.name,e):(i.missing.add(n.name),!0)}function O(t,e){if("object"!=typeof t)return!1;if("string"!=typeof e&&(e=t.provider||""),w&&!e&&!t.prefix){let e=!1;return v(t)&&(t.prefix="",p(t,(t,n)=>{j(t,n)&&(e=!0)})),e}const n=t.prefix;return!!f({prefix:n,name:"a"})&&!!x(y(e,n),t)}function C(t){return!!A(t)}function I(t){const e=A(t);return e?{...n,...e}:e}function E(t,e){t.forEach(t=>{const n=t.loaderCallbacks;n&&(t.loaderCallbacks=n.filter(t=>t.id!==e))})}let T=0;const F=Object.create(null);function R(t,e){F[t]=e}function S(t){return F[t]||F[""]}function L(t){let e;if("string"==typeof t.resources)e=[t.resources];else if(e=t.resources,!(e instanceof Array&&e.length))return null;return{resources:e,path:t.path||"/",maxURL:t.maxURL||500,rotate:t.rotate||750,timeout:t.timeout||5e3,random:!0===t.random,index:t.index||0,dataAfterTimeout:!1!==t.dataAfterTimeout}}const P=Object.create(null),M=["https://api.simplesvg.com","https://api.unisvg.com"],N=[];for(;M.length>0;)1===M.length||Math.random()>.5?N.push(M.shift()):N.push(M.pop());function z(t,e){const n=L(e);return null!==n&&(P[t]=n,!0)}function Q(t){return P[t]}function q(){return Object.keys(P)}P[""]=L({resources:["https://api.iconify.design"].concat(N)});const U={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function D(t,e,n,i){const r=t.resources.length,o=t.random?Math.floor(Math.random()*r):t.index;let s;if(t.random){let e=t.resources.slice(0);for(s=[];e.length>1;){const t=Math.floor(Math.random()*e.length);s.push(e[t]),e=e.slice(0,t).concat(e.slice(t+1))}s=s.concat(e)}else s=t.resources.slice(o).concat(t.resources.slice(0,o));const c=Date.now();let a,u="pending",l=0,f=null,d=[],h=[];function p(){f&&(clearTimeout(f),f=null)}function g(){"pending"===u&&(u="aborted"),p(),d.forEach(t=>{"pending"===t.status&&(t.status="aborted")}),d=[]}function b(t,e){e&&(h=[]),"function"==typeof t&&h.push(t)}function v(){u="failed",h.forEach(t=>{t(void 0,a)})}function m(){d.forEach(t=>{"pending"===t.status&&(t.status="aborted")}),d=[]}function y(){if("pending"!==u)return;p();const i=s.shift();if(void 0===i)return d.length?void(f=setTimeout(()=>{p(),"pending"===u&&(m(),v())},t.timeout)):void v();const r={status:"pending",resource:i,callback:(e,n)=>{!function(e,n,i){const r="success"!==n;switch(d=d.filter(t=>t!==e),u){case"pending":break;case"failed":if(r||!t.dataAfterTimeout)return;break;default:return}if("abort"===n)return a=i,void v();if(r)return a=i,void(d.length||(s.length?y():v()));if(p(),m(),!t.random){const n=t.resources.indexOf(e.resource);-1!==n&&n!==t.index&&(t.index=n)}u="completed",h.forEach(t=>{t(i)})}(r,e,n)}};d.push(r),l++,f=setTimeout(y,t.rotate),n(i,e,r.callback)}return"function"==typeof i&&h.push(i),setTimeout(y),function(){return{startTime:c,payload:e,status:u,queriesSent:l,queriesPending:d.length,subscribe:b,abort:g}}}function H(t){const e={...U,...t};let n=[];function i(){n=n.filter(t=>"pending"===t().status)}return{query:function(t,r,o){const s=D(e,t,r,(t,e)=>{i(),o&&o(t,e)});return n.push(s),s},find:function(t){return n.find(e=>t(e))||null},setIndex:t=>{e.index=t},getIndex:()=>e.index,cleanup:i}}function J(){}const $=Object.create(null);function B(t,e,n){let i,r;if("string"==typeof t){const e=S(t);if(!e)return n(void 0,424),J;r=e.send;const o=function(t){if(!$[t]){const e=Q(t);if(!e)return;$[t]={config:e,redundancy:H(e)}}return $[t]}(t);o&&(i=o.redundancy)}else{const e=L(t);if(e){i=H(e);const n=S(t.resources?t.resources[0]:"");n&&(r=n.send)}}return i&&r?i.query(e,r,n)().abort:(n(void 0,424),J)}function G(){}function V(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout(()=>{t.iconsLoaderFlag=!1,function(t){t.pendingCallbacksFlag||(t.pendingCallbacksFlag=!0,setTimeout(()=>{t.pendingCallbacksFlag=!1;const e=t.loaderCallbacks?t.loaderCallbacks.slice(0):[];if(!e.length)return;let n=!1;const i=t.provider,r=t.prefix;e.forEach(e=>{const o=e.icons,s=o.pending.length;o.pending=o.pending.filter(e=>{if(e.prefix!==r)return!0;const s=e.name;if(t.icons[s])o.loaded.push({provider:i,prefix:r,name:s});else{if(!t.missing.has(s))return n=!0,!0;o.missing.push({provider:i,prefix:r,name:s})}return!1}),o.pending.length!==s&&(n||E([t],e.id),e.callback(o.loaded.slice(0),o.missing.slice(0),o.pending.slice(0),e.abort))})}))}(t)}))}function K(t,e,n){function i(){const n=t.pendingIcons;e.forEach(e=>{n&&n.delete(e),t.icons[e]||t.missing.add(e)})}if(n&&"object"==typeof n)try{if(!x(t,n).length)return void i()}catch(t){console.error(t)}i(),V(t)}function W(t,e){t instanceof Promise?t.then(t=>{e(t)}).catch(()=>{e(null)}):e(t)}function X(t,e){t.iconsToLoad?t.iconsToLoad=t.iconsToLoad.concat(e).sort():t.iconsToLoad=e,t.iconsQueueFlag||(t.iconsQueueFlag=!0,setTimeout(()=>{t.iconsQueueFlag=!1;const{provider:e,prefix:n}=t,i=t.iconsToLoad;if(delete t.iconsToLoad,!i||!i.length)return;const r=t.loadIcon;if(t.loadIcons&&(i.length>1||!r))return void W(t.loadIcons(i,n,e),e=>{K(t,i,e)});if(r)return void i.forEach(i=>{W(r(i,n,e),e=>{K(t,[i],e?{prefix:n,icons:{[i]:e}}:null)})});const{valid:o,invalid:s}=function(t){const e=[],n=[];return t.forEach(t=>{(t.match(u)?e:n).push(t)}),{valid:e,invalid:n}}(i);if(s.length&&K(t,s,null),!o.length)return;const c=n.match(u)?S(e):null;c?c.prepare(e,n,o).forEach(n=>{B(e,n,e=>{K(t,n.icons,e)})}):K(t,o,null)}))}const Y=(t,e)=>{const n=function(t){const e={loaded:[],missing:[],pending:[]},n=Object.create(null);t.sort((t,e)=>t.provider!==e.provider?t.provider.localeCompare(e.provider):t.prefix!==e.prefix?t.prefix.localeCompare(e.prefix):t.name.localeCompare(e.name));let i={provider:"",prefix:"",name:""};return t.forEach(t=>{if(i.name===t.name&&i.prefix===t.prefix&&i.provider===t.provider)return;i=t;const r=t.provider,o=t.prefix,s=t.name,c=n[r]||(n[r]=Object.create(null)),a=c[o]||(c[o]=y(r,o));let u;u=s in a.icons?e.loaded:""===o||a.missing.has(s)?e.missing:e.pending;const l={provider:r,prefix:o,name:s};u.push(l)}),e}(function(t,e=!0,n=!1){const i=[];return t.forEach(t=>{const r="string"==typeof t?l(t,e,n):t;r&&i.push(r)}),i}(t,!0,k()));if(!n.pending.length){let t=!0;return e&&setTimeout(()=>{t&&e(n.loaded,n.missing,n.pending,G)}),()=>{t=!1}}const i=Object.create(null),r=[];let o,s;return n.pending.forEach(t=>{const{provider:e,prefix:n}=t;if(n===s&&e===o)return;o=e,s=n,r.push(y(e,n));const c=i[e]||(i[e]=Object.create(null));c[n]||(c[n]=[])}),n.pending.forEach(t=>{const{provider:e,prefix:n,name:r}=t,o=y(e,n),s=o.pendingIcons||(o.pendingIcons=new Set);s.has(r)||(s.add(r),i[e][n].push(r))}),r.forEach(t=>{const e=i[t.provider][t.prefix];e.length&&X(t,e)}),e?function(t,e,n){const i=T++,r=E.bind(null,n,i);if(!e.pending.length)return r;const o={id:i,icons:e,callback:t,abort:r};return n.forEach(t=>{(t.loaderCallbacks||(t.loaderCallbacks=[])).push(o)}),r}(e,n,r):G},Z=t=>new Promise((e,i)=>{const r="string"==typeof t?l(t,!0):t;r?Y([r||t],o=>{if(o.length&&r){const t=A(r);if(t)return void e({...n,...t})}i(t)}):i(t)});function tt(t){try{const e="string"==typeof t?JSON.parse(t):t;if("string"==typeof e.body)return{...e}}catch(t){}}let et=!1;try{et=0===navigator.vendor.indexOf("Apple")}catch(t){}const nt=/(-?[0-9.]*[0-9]+[0-9.]*)/g,it=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function rt(t,e,n){if(1===e)return t;if(n=n||100,"number"==typeof t)return Math.ceil(t*e*n)/n;if("string"!=typeof t)return t;const i=t.split(nt);if(null===i||!i.length)return t;const r=[];let o=i.shift(),s=it.test(o);for(;;){if(s){const t=parseFloat(o);isNaN(t)?r.push(o):r.push(Math.ceil(t*e*n)/n)}else r.push(o);if(o=i.shift(),void 0===o)return r.join("");s=!s}}function ot(t,e){const i={...n,...t},r={...o,...e},s={left:i.left,top:i.top,width:i.width,height:i.height};let c=i.body;[i,r].forEach(t=>{const e=[],n=t.hFlip,i=t.vFlip;let r,o=t.rotate;switch(n?i?o+=2:(e.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),e.push("scale(-1 1)"),s.top=s.left=0):i&&(e.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),e.push("scale(1 -1)"),s.top=s.left=0),o<0&&(o-=4*Math.floor(o/4)),o%=4,o){case 1:r=s.height/2+s.top,e.unshift("rotate(90 "+r.toString()+" "+r.toString()+")");break;case 2:e.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:r=s.width/2+s.left,e.unshift("rotate(-90 "+r.toString()+" "+r.toString()+")")}o%2==1&&(s.left!==s.top&&(r=s.left,s.left=s.top,s.top=r),s.width!==s.height&&(r=s.width,s.width=s.height,s.height=r)),e.length&&(c=function(t,e,n){const i=function(t,e="defs"){let n="";const i=t.indexOf("<"+e);for(;i>=0;){const r=t.indexOf(">",i),o=t.indexOf("</"+e);if(-1===r||-1===o)break;const s=t.indexOf(">",o);if(-1===s)break;n+=t.slice(r+1,o).trim(),t=t.slice(0,i).trim()+t.slice(s+1)}return{defs:n,content:t}}(t);return r=i.defs,o=e+i.content+n,r?"<defs>"+r+"</defs>"+o:o;var r,o}(c,'<g transform="'+e.join(" ")+'">',"</g>"))});const a=r.width,u=r.height,l=s.width,f=s.height;let d,h;null===a?(h=null===u?"1em":"auto"===u?f:u,d=rt(h,l/f)):(d="auto"===a?l:a,h=null===u?rt(d,f/l):"auto"===u?f:u);const p={},g=(t,e)=>{(t=>"unset"===t||"undefined"===t||"none"===t)(e)||(p[t]=e.toString())};g("width",d),g("height",h);const b=[s.left,s.top,l,f];return p.viewBox=b.join(" "),{attributes:p,viewBox:b,body:c}}function st(t,e){let n=-1===t.indexOf("xlink:")?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const t in e)n+=" "+t+'="'+e[t]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+t+"</svg>"}function ct(t){return'url("'+function(t){return"data:image/svg+xml,"+function(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}(t)}(t)+'")'}let at=(()=>{let t;try{if(t=fetch,"function"==typeof t)return t}catch(t){}})();function ut(t){at=t}function lt(){return at}const ft={prepare:(t,e,n)=>{const i=[],r=function(t,e){const n=Q(t);if(!n)return 0;let i;if(n.maxURL){let t=0;n.resources.forEach(e=>{const n=e;t=Math.max(t,n.length)});const r=e+".json?icons=";i=n.maxURL-t-n.path.length-r.length}else i=0;return i}(t,e),o="icons";let s={type:o,provider:t,prefix:e,icons:[]},c=0;return n.forEach((n,a)=>{c+=n.length+1,c>=r&&a>0&&(i.push(s),s={type:o,provider:t,prefix:e,icons:[]},c=n.length),s.icons.push(n)}),i.push(s),i},send:(t,e,n)=>{if(!at)return void n("abort",424);let i=function(t){if("string"==typeof t){const e=Q(t);if(e)return e.path}return"/"}(e.provider);switch(e.type){case"icons":{const t=e.prefix,n=e.icons.join(",");i+=t+".json?"+new URLSearchParams({icons:n}).toString();break}case"custom":{const t=e.uri;i+="/"===t.slice(0,1)?t.slice(1):t;break}default:return void n("abort",400)}let r=503;at(t+i).then(t=>{const e=t.status;if(200===e)return r=501,t.json();setTimeout(()=>{n(function(t){return 404===t}(e)?"abort":"next",e)})}).then(t=>{"object"==typeof t&&null!==t?setTimeout(()=>{n("success",t)}):setTimeout(()=>{404===t?n("abort",t):n("next",r)})}).catch(()=>{n("next",r)})}};function dt(t,e,n){y(n||"",e).loadIcons=t}function ht(t,e,n){y(n||"",e).loadIcon=t}const pt="data-style";let gt="";function bt(t){gt=t}function vt(t,e){let n=Array.from(t.childNodes).find(t=>t.hasAttribute&&t.hasAttribute(pt));n||(n=document.createElement("style"),n.setAttribute(pt,pt),t.appendChild(n)),n.textContent=":host{display:inline-block;vertical-align:"+(e?"-0.125em":"0")+"}span,svg{display:block;margin:auto}"+gt}const mt={"background-color":"currentColor"},yt={"background-color":"transparent"},xt={image:"var(--svg)",repeat:"no-repeat",size:"100% 100%"},_t={"-webkit-mask":mt,mask:mt,background:yt};for(const t in _t){const e=_t[t];for(const n in xt)e[t+"-"+n]=xt[n]}function wt(t){return t?t+(t.match(/^[-0-9.]+$/)?"px":""):"inherit"}let kt;function At(t){return void 0===kt&&function(){try{kt=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch(t){kt=null}}(),kt?kt.createHTML(t):t}function jt(t){return Array.from(t.childNodes).find(t=>{const e=t.tagName&&t.tagName.toUpperCase();return"SPAN"===e||"SVG"===e})}function Ot(t,e){const i=e.icon.data,r=e.customisations,o=ot(i,r);r.preserveAspectRatio&&(o.attributes.preserveAspectRatio=r.preserveAspectRatio);const s=e.renderedMode;let c;if("svg"===s)c=function(t){const e=document.createElement("span"),n=t.attributes;let i="";n.width||(i="width: inherit;"),n.height||(i+="height: inherit;"),i&&(n.style=i);const r=st(t.body,n);return e.innerHTML=At(r),e.firstChild}(o);else c=function(t,e,n){const i=document.createElement("span");let r=t.body;-1!==r.indexOf("<a")&&(r+="\x3c!-- "+Date.now()+" --\x3e");const o=t.attributes,s=ct(st(r,{...o,width:e.width+"",height:e.height+""})),c=i.style,a={"--svg":s,width:wt(o.width),height:wt(o.height),...n?mt:yt};for(const t in a)c.setProperty(t,a[t]);return i}(o,{...n,...i},"mask"===s);const a=jt(t);a?"SPAN"===c.tagName&&a.tagName===c.tagName?a.setAttribute("style",c.getAttribute("style")):t.replaceChild(c,a):t.appendChild(c)}function Ct(t,e,n){return{rendered:!1,inline:e,icon:t,lastRender:n&&(n.rendered?n:n.lastRender)}}!function(t="iconify-icon"){let e,n;try{e=window.customElements,n=window.HTMLElement}catch(t){return}if(!e||!n)return;const i=e.get(t);if(i)return i;const r=["icon","mode","inline","noobserver","width","height","rotate","flip"],o=class extends n{_shadowRoot;_initialised=!1;_state;_checkQueued=!1;_connected=!1;_observer=null;_visible=!0;constructor(){super();const t=this._shadowRoot=this.attachShadow({mode:"open"}),e=this.hasAttribute("inline");vt(t,e),this._state=Ct({value:""},e),this._queueCheck()}connectedCallback(){this._connected=!0,this.startObserver()}disconnectedCallback(){this._connected=!1,this.stopObserver()}static get observedAttributes(){return r.slice(0)}attributeChangedCallback(t){switch(t){case"inline":{const t=this.hasAttribute("inline"),e=this._state;t!==e.inline&&(e.inline=t,vt(this._shadowRoot,t));break}case"noobserver":this.hasAttribute("noobserver")?this.startObserver():this.stopObserver();break;default:this._queueCheck()}}get icon(){const t=this.getAttribute("icon");if(t&&"{"===t.slice(0,1))try{return JSON.parse(t)}catch(t){}return t}set icon(t){"object"==typeof t&&(t=JSON.stringify(t)),this.setAttribute("icon",t)}get inline(){return this.hasAttribute("inline")}set inline(t){t?this.setAttribute("inline","true"):this.removeAttribute("inline")}get observer(){return this.hasAttribute("observer")}set observer(t){t?this.setAttribute("observer","true"):this.removeAttribute("observer")}restartAnimation(){const t=this._state;if(t.rendered){const e=this._shadowRoot;if("svg"===t.renderedMode)try{return void e.lastChild.setCurrentTime(0)}catch(t){}Ot(e,t)}}get status(){const t=this._state;return t.rendered?"rendered":null===t.icon.data?"failed":"loading"}_queueCheck(){this._checkQueued||(this._checkQueued=!0,setTimeout(()=>{this._check()}))}_check(){if(!this._checkQueued)return;this._checkQueued=!1;const t=this._state,e=this.getAttribute("icon");if(e!==t.icon.value)return void this._iconChanged(e);if(!t.rendered||!this._visible)return;const n=this.getAttribute("mode"),i=a(this);t.attrMode===n&&!function(t,e){for(const n in c)if(t[n]!==e[n])return!0;return!1}(t.customisations,i)&&jt(this._shadowRoot)||this._renderIcon(t.icon,i,n)}_iconChanged(t){const e=function(t,e){if("object"==typeof t)return{data:tt(t),value:t};if("string"!=typeof t)return{value:t};if(t.includes("{")){const e=tt(t);if(e)return{data:e,value:t}}const n=l(t,!0,!0);if(!n)return{value:t};const i=A(n);if(void 0!==i||!n.prefix)return{value:t,name:n,data:i};const r=Y([n],()=>e(t,n,A(n)));return{value:t,name:n,loading:r}}(t,(t,e,n)=>{const i=this._state;if(i.rendered||this.getAttribute("icon")!==t)return;const r={value:t,name:e,data:n};r.data?this._gotIconData(r):i.icon=r});e.data?this._gotIconData(e):this._state=Ct(e,this._state.inline,this._state)}_forceRender(){if(!this._visible){const t=jt(this._shadowRoot);return void(t&&this._shadowRoot.removeChild(t))}this._queueCheck()}_gotIconData(t){this._checkQueued=!1,this._renderIcon(t,a(this),this.getAttribute("mode"))}_renderIcon(t,e,n){const i=function(t,e){switch(e){case"svg":case"bg":case"mask":return e}return"style"===e||!et&&-1!==t.indexOf("<a")?-1===t.indexOf("currentColor")?"bg":"mask":"svg"}(t.data.body,n),r=this._state.inline;Ot(this._shadowRoot,this._state={rendered:!0,icon:t,inline:r,customisations:e,attrMode:n,renderedMode:i})}startObserver(){if(!this._observer&&!this.hasAttribute("noobserver"))try{this._observer=new IntersectionObserver(t=>{const e=t.some(t=>t.isIntersecting);e!==this._visible&&(this._visible=e,this._forceRender())}),this._observer.observe(this)}catch(t){if(this._observer){try{this._observer.disconnect()}catch(t){}this._observer=null}}}stopObserver(){this._observer&&(this._observer.disconnect(),this._observer=null,this._visible=!0,this._connected&&this._forceRender())}};r.forEach(t=>{t in o.prototype||Object.defineProperty(o.prototype,t,{get:function(){return this.getAttribute(t)},set:function(e){null!==e?this.setAttribute(t,e):this.removeAttribute(t)}})});const s=function(){let t;R("",ft),k(!0);try{t=window}catch(t){}if(t){if(void 0!==t.IconifyPreload){const e=t.IconifyPreload,n="Invalid IconifyPreload syntax.";"object"==typeof e&&null!==e&&(e instanceof Array?e:[e]).forEach(t=>{try{("object"!=typeof t||null===t||t instanceof Array||"object"!=typeof t.icons||"string"!=typeof t.prefix||!O(t))&&console.error(n)}catch(t){console.error(n)}})}if(void 0!==t.IconifyProviders){const e=t.IconifyProviders;if("object"==typeof e&&null!==e)for(const t in e){const n="IconifyProviders["+t+"] is invalid.";try{const i=e[t];if("object"!=typeof i||!i||void 0===i.resources)continue;z(t,i)||console.error(n)}catch(t){console.error(n)}}}}return{iconLoaded:C,getIcon:I,listIcons:_,addIcon:j,addCollection:O,calculateSize:rt,buildIcon:ot,iconToHTML:st,svgToURL:ct,loadIcons:Y,loadIcon:Z,addAPIProvider:z,setCustomIconLoader:ht,setCustomIconsLoader:dt,appendCustomStyle:bt,_api:{getAPIConfig:Q,setAPIModule:R,sendAPIQuery:B,setFetch:ut,getFetch:lt,listAPIProviders:q}}}();for(const t in s)o[t]=o.prototype[t]=s[t];e.define(t,o)}()}();
|