@tdacorp/hyle-sdk 0.21.0 → 0.23.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/README.md +141 -18
- package/dist/check-routes-bin.js +174 -42
- package/dist/{chunk-56Y24XBV.js → chunk-JHZJOJDC.js} +4 -3
- package/dist/{chunk-K5VDLROQ.js → chunk-SFFBZFEN.js} +34 -1
- package/dist/{chunk-HJX57NLI.js → chunk-UFMKLCXS.js} +246 -225
- package/dist/{chunk-X2TLYM7Y.js → chunk-VUML2UPD.js} +1 -1
- package/dist/chunk-VXARM37R.js +68 -0
- package/dist/{chunk-75JFLML4.js → chunk-YHXE3TGS.js} +94 -12
- package/dist/{client-41fU6OY2.d.cts → client--ighAWaj.d.ts} +13 -1
- package/dist/{client-LwzHwqpM.d.ts → client-DK-S2580.d.cts} +13 -1
- package/dist/code-copy.cjs +4 -2
- package/dist/code-copy.d.cts +5 -2
- package/dist/code-copy.d.ts +5 -2
- package/dist/code-copy.js +5 -3
- package/dist/comments.cjs +14 -6
- package/dist/comments.js +14 -6
- package/dist/docs-enhance.cjs +7 -4
- package/dist/docs-enhance.d.cts +5 -3
- package/dist/docs-enhance.d.ts +5 -3
- package/dist/docs-enhance.js +8 -5
- package/dist/{embed-BUFRQboD.d.ts → embed-XT0x_Jaa.d.cts} +4 -2
- package/dist/{embed-CYt-q13P.d.cts → embed-g7NT1CyB.d.ts} +4 -2
- package/dist/html.cjs +14 -6
- package/dist/html.d.cts +1 -1
- package/dist/html.d.ts +1 -1
- package/dist/html.js +2 -2
- package/dist/index.cjs +85 -12
- package/dist/index.d.cts +13 -11
- package/dist/index.d.ts +13 -11
- package/dist/index.js +2 -2
- package/dist/mermaid-diagram.cjs +46 -6
- package/dist/mermaid-diagram.js +15 -6
- package/dist/mermaid-image.cjs +4 -1
- package/dist/mermaid-image.js +1 -1
- package/dist/next.cjs +521 -242
- package/dist/next.d.cts +74 -17
- package/dist/next.d.ts +74 -17
- package/dist/next.js +207 -33
- package/dist/print-coordinator.js +1 -1
- package/dist/react.cjs +233 -197
- package/dist/react.d.cts +17 -6
- package/dist/react.d.ts +17 -6
- package/dist/react.js +5 -3
- package/dist/{resolve-BjAK0k_Y.d.ts → resolve-BqC9l5RH.d.ts} +1 -1
- package/dist/{resolve-eI1muCKL.d.cts → resolve-CiZCPysX.d.cts} +1 -1
- package/dist/{sanitize-ijiWjEm9.d.cts → sanitize-BpY_AdZh.d.cts} +1 -1
- package/dist/{sanitize-ijiWjEm9.d.ts → sanitize-BpY_AdZh.d.ts} +1 -1
- package/dist/styles.css +4 -4
- package/dist/toc-spy.cjs +2 -1
- package/dist/toc-spy.js +2 -1
- package/dist/{types-3F0wqD-o.d.cts → types-b9QbmEDd.d.cts} +44 -1
- package/dist/{types-3F0wqD-o.d.ts → types-b9QbmEDd.d.ts} +44 -1
- package/dist/use-cache.cjs +73 -3
- package/dist/use-cache.d.cts +3 -3
- package/dist/use-cache.d.ts +3 -3
- package/dist/use-cache.js +3 -3
- package/package.json +3 -3
- package/dist/chunk-67IOIAVW.js +0 -35
package/dist/next.cjs
CHANGED
|
@@ -31,12 +31,17 @@ __export(next_exports, {
|
|
|
31
31
|
createLlmsTxtRoute: () => createLlmsTxtRoute,
|
|
32
32
|
createMarkdownRoute: () => createMarkdownRoute,
|
|
33
33
|
createOgImageRoute: () => createOgImageRoute,
|
|
34
|
+
createProtectedUnlockRoute: () => createProtectedUnlockRoute,
|
|
34
35
|
createRevalidateRoute: () => createRevalidateRoute,
|
|
35
36
|
fetchResolver: () => fetchResolver,
|
|
36
37
|
hyleFeed: () => hyleFeed,
|
|
37
38
|
hyleFeedLink: () => hyleFeedLink,
|
|
38
39
|
hyleMetadata: () => hyleMetadata,
|
|
39
40
|
hylePage: () => hylePage,
|
|
41
|
+
hylePreviewMetadata: () => hylePreviewMetadata,
|
|
42
|
+
hylePreviewPage: () => hylePreviewPage,
|
|
43
|
+
hyleProtectedMetadata: () => hyleProtectedMetadata,
|
|
44
|
+
hyleProtectedPage: () => hyleProtectedPage,
|
|
40
45
|
hyleRootMetadata: () => hyleRootMetadata,
|
|
41
46
|
hyleRootPage: () => hyleRootPage,
|
|
42
47
|
hyleRootSitemap: () => hyleRootSitemap,
|
|
@@ -52,12 +57,32 @@ var import_navigation3 = require("next/navigation");
|
|
|
52
57
|
// src/asset-path.ts
|
|
53
58
|
var ASSET_ROUTE_PREFIX = "/api/hyle/assets";
|
|
54
59
|
var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
|
55
|
-
var EXTENSIONS = "png|jpg|gif|webp|svg|pdf|mp4|webm|mp3|ogg";
|
|
60
|
+
var EXTENSIONS = "png|jpg|gif|webp|svg|pdf|mp4|webm|mp3|ogg|woff2";
|
|
56
61
|
var ASSET_FILE = new RegExp(`^${UUID}(?:\\.(?:${EXTENSIONS}))?$`);
|
|
57
|
-
var
|
|
62
|
+
var THEME_FILE = /^theme-([0-9a-f]{16})-([0-9a-f]{64})\.css$/;
|
|
63
|
+
var THEME_FONT = new RegExp(`^/assets/${UUID}\\.woff2$`);
|
|
64
|
+
function themeStylesheetHref({ scope, hash }) {
|
|
65
|
+
const file = `theme-${scope}-${hash}.css`;
|
|
66
|
+
return THEME_FILE.test(file) ? `${ASSET_ROUTE_PREFIX}/${file}` : void 0;
|
|
67
|
+
}
|
|
68
|
+
function themeFontHrefs(preload) {
|
|
69
|
+
return preload.flatMap((src) => typeof src === "string" && THEME_FONT.test(src) ? [hostAssetSrc(src)] : []);
|
|
70
|
+
}
|
|
71
|
+
var PREVIEW_TOKEN_SOURCE = "hyle_pv_[A-Za-z0-9_-]{43}";
|
|
72
|
+
var PREVIEW_TOKEN = new RegExp(`^${PREVIEW_TOKEN_SOURCE}$`);
|
|
73
|
+
var PREVIEW_HEADER = "cp-preview";
|
|
74
|
+
var PREVIEW_PARAM = "hyle_preview";
|
|
75
|
+
var PREVIEW_QUERY_SOURCE = `\\?${PREVIEW_PARAM}=${PREVIEW_TOKEN_SOURCE}`;
|
|
76
|
+
var PROTECTED_PARAM = "hyle_protected";
|
|
77
|
+
var PROTECTED_HEADER = "cp-protected";
|
|
78
|
+
var PROTECTED_ID = new RegExp(`^${UUID}$`);
|
|
79
|
+
var PROTECTED_PASSWORD = /^[A-Za-z0-9]{16}$/;
|
|
80
|
+
var protectedCookieName = (pageId) => `hyle_p_${pageId}`;
|
|
81
|
+
var PROTECTED_QUERY_SOURCE = `\\?${PROTECTED_PARAM}=${UUID}`;
|
|
82
|
+
var HYLE_ASSET_URL = new RegExp(`^/assets/(${UUID}(?:\\.(?:${EXTENSIONS}))?)(${PREVIEW_QUERY_SOURCE}|${PROTECTED_QUERY_SOURCE})?$`, "i");
|
|
58
83
|
function hostAssetSrc(src) {
|
|
59
|
-
const file = HYLE_ASSET_URL.exec(src)
|
|
60
|
-
return file ? `${ASSET_ROUTE_PREFIX}/${file.toLowerCase()}` : src;
|
|
84
|
+
const [, file, query = ""] = HYLE_ASSET_URL.exec(src) ?? [];
|
|
85
|
+
return file ? `${ASSET_ROUTE_PREFIX}/${file.toLowerCase()}${query}` : src;
|
|
61
86
|
}
|
|
62
87
|
function hostAssetHtml(html) {
|
|
63
88
|
return html.replace(new RegExp(`(\\ssrc=")(/assets/${UUID}(?:\\.(?:${EXTENSIONS}))?)(")`, "gi"), (_m, open, url, close) => `${open}${hostAssetSrc(url)}${close}`);
|
|
@@ -72,7 +97,8 @@ var ASSET_CONTENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
72
97
|
"video/mp4",
|
|
73
98
|
"video/webm",
|
|
74
99
|
"audio/mpeg",
|
|
75
|
-
"audio/ogg"
|
|
100
|
+
"audio/ogg",
|
|
101
|
+
"font/woff2"
|
|
76
102
|
]);
|
|
77
103
|
|
|
78
104
|
// src/errors.ts
|
|
@@ -91,6 +117,30 @@ var Cp1ClientError = class extends Error {
|
|
|
91
117
|
}
|
|
92
118
|
};
|
|
93
119
|
|
|
120
|
+
// src/preview.ts
|
|
121
|
+
var ASSET_PATH = /^\/assets\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?:\.[a-z0-9]+)?(?= |$)/i;
|
|
122
|
+
var ASSET_PROPERTIES = ["src", "dataLight", "dataDark"];
|
|
123
|
+
var MAX_DEPTH = 200;
|
|
124
|
+
function mapNode(node, mark, depth) {
|
|
125
|
+
if (typeof node !== "object" || node === null || depth > MAX_DEPTH) return node;
|
|
126
|
+
const { properties, children } = node;
|
|
127
|
+
const marked = properties && Object.fromEntries(ASSET_PROPERTIES.filter((name) => name in properties).map((name) => [name, mark(properties[name])]));
|
|
128
|
+
return {
|
|
129
|
+
...node,
|
|
130
|
+
...properties ? { properties: { ...properties, ...marked } } : {},
|
|
131
|
+
...Array.isArray(children) ? { children: children.map((child) => mapNode(child, mark, depth + 1)) } : {}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function withAssetQuery(article, query) {
|
|
135
|
+
const mark = (value) => typeof value === "string" ? value.replace(ASSET_PATH, (path) => `${path}?${query}`) : value;
|
|
136
|
+
const { publication, content } = article;
|
|
137
|
+
return {
|
|
138
|
+
...article,
|
|
139
|
+
publication: publication.cover ? { ...publication, cover: { path: String(mark(publication.cover.path)) } } : publication,
|
|
140
|
+
content: content.format === "hast" ? { ...content, tree: mapNode(content.tree, mark, 0) } : content
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
94
144
|
// src/client.ts
|
|
95
145
|
var RENDERER_VERSION = "4";
|
|
96
146
|
function applyCredential(headers, credential, method, url) {
|
|
@@ -126,6 +176,17 @@ async function readCapped(res, max) {
|
|
|
126
176
|
}
|
|
127
177
|
return Buffer.concat(chunks).toString("utf8");
|
|
128
178
|
}
|
|
179
|
+
function isNotFoundBody(status, body) {
|
|
180
|
+
if (status !== 404) return false;
|
|
181
|
+
try {
|
|
182
|
+
return JSON.parse(body)?.error?.code === "NOT_FOUND";
|
|
183
|
+
} catch {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
async function isNotFoundResponse(res) {
|
|
188
|
+
return isNotFoundBody(res.status, await readCapped(res, 64 * 1024).catch(() => ""));
|
|
189
|
+
}
|
|
129
190
|
var KINDS = /* @__PURE__ */ new Set(["article", "list", "redirect", "notfound", "disabled"]);
|
|
130
191
|
var isStrings = (value) => Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
131
192
|
function isMounts(data) {
|
|
@@ -203,8 +264,31 @@ function createHyleClient(options) {
|
|
|
203
264
|
if (data?.cp === 1 && data.kind === "push_posts" && Array.isArray(data.posts) && typeof data.complete === "boolean") return data;
|
|
204
265
|
throw failure(reply2);
|
|
205
266
|
}
|
|
267
|
+
async function preview(token) {
|
|
268
|
+
if (typeof token !== "string" || !PREVIEW_TOKEN.test(token)) return { kind: "notfound" };
|
|
269
|
+
const reply2 = await get("/cp1/read/_preview", new URLSearchParams(), { headers: { [PREVIEW_HEADER]: token }, cache: "no-store" });
|
|
270
|
+
if (reply2.status === 404 && reply2.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
|
|
271
|
+
const data = reply2.parsed?.data;
|
|
272
|
+
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
273
|
+
const article = data?.article;
|
|
274
|
+
if (data?.cp !== 1 || data.kind !== "preview" || typeof data.expires_at !== "string" || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply2);
|
|
275
|
+
return { kind: "preview", expires_at: data.expires_at, article: withAssetQuery(article, `${PREVIEW_PARAM}=${token}`) };
|
|
276
|
+
}
|
|
277
|
+
async function protectedPage(pageId, password) {
|
|
278
|
+
if (!PROTECTED_ID.test(pageId) || !PROTECTED_PASSWORD.test(password)) return { kind: "notfound" };
|
|
279
|
+
const reply2 = await get("/cp1/read/_protected", new URLSearchParams(), { headers: { [PROTECTED_HEADER]: `${pageId}.${password}` }, cache: "no-store" });
|
|
280
|
+
if (reply2.status === 404 && reply2.parsed?.error?.code === "NOT_FOUND") return { kind: "notfound" };
|
|
281
|
+
const data = reply2.parsed?.data;
|
|
282
|
+
if (data?.cp === 1 && data.kind === "disabled") return { kind: "disabled" };
|
|
283
|
+
const article = data?.article;
|
|
284
|
+
const expires = data?.expires_at;
|
|
285
|
+
if (data?.cp !== 1 || data.kind !== "protected" || typeof expires !== "string" && expires !== null || article?.kind !== "article" || article.content?.format !== "hast" || !article.publication) throw failure(reply2);
|
|
286
|
+
return { kind: "protected", expires_at: expires, article: withAssetQuery(article, `${PROTECTED_PARAM}=${pageId}`) };
|
|
287
|
+
}
|
|
206
288
|
async function asset(file, opts = {}) {
|
|
207
289
|
if (!ASSET_FILE.test(file)) throw new TypeError("asset file must be <uuid>[.<ext>]");
|
|
290
|
+
const { previewToken } = opts;
|
|
291
|
+
if (previewToken !== void 0 && !PREVIEW_TOKEN.test(previewToken)) throw new TypeError("previewToken is not a preview token");
|
|
208
292
|
const url = `${base}/cp1/read/assets/${file}`;
|
|
209
293
|
const headers = new Headers();
|
|
210
294
|
const applied = applyCredential(headers, options, "GET", url);
|
|
@@ -213,9 +297,21 @@ function createHyleClient(options) {
|
|
|
213
297
|
const value = opts.headers?.[name];
|
|
214
298
|
if (value) headers.set(name, value);
|
|
215
299
|
}
|
|
300
|
+
const { protectedAccess } = opts;
|
|
301
|
+
if (protectedAccess !== void 0 && !(PROTECTED_ID.test(protectedAccess.pageId) && PROTECTED_PASSWORD.test(protectedAccess.password))) throw new TypeError("protectedAccess is not a page id and password");
|
|
302
|
+
if (previewToken !== void 0) headers.set(PREVIEW_HEADER, previewToken);
|
|
303
|
+
if (protectedAccess !== void 0) headers.set(PROTECTED_HEADER, `${protectedAccess.pageId}.${protectedAccess.password}`);
|
|
304
|
+
const uncached = previewToken !== void 0 || protectedAccess !== void 0;
|
|
305
|
+
return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS), ...uncached ? { cache: "no-store" } : {} });
|
|
306
|
+
}
|
|
307
|
+
async function theme(opts = {}) {
|
|
308
|
+
const url = `${base}/cp1/read/theme.css`;
|
|
309
|
+
const headers = new Headers();
|
|
310
|
+
const applied = applyCredential(headers, options, "GET", url);
|
|
311
|
+
if (applied) await applied;
|
|
216
312
|
return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
|
|
217
313
|
}
|
|
218
|
-
return { resolve, mounts, pushPosts, asset };
|
|
314
|
+
return { resolve, mounts, pushPosts, preview, protected: protectedPage, asset, theme };
|
|
219
315
|
}
|
|
220
316
|
|
|
221
317
|
// src/delivery-dedupe.ts
|
|
@@ -553,7 +649,7 @@ var HastLimitError = class extends Error {
|
|
|
553
649
|
};
|
|
554
650
|
var MAX_NODES = 2e4;
|
|
555
651
|
var MAX_TEXT = 512 * 1024;
|
|
556
|
-
var
|
|
652
|
+
var MAX_DEPTH2 = 128;
|
|
557
653
|
var MAX_SRCDOC = 1024 * 1024;
|
|
558
654
|
var DROP = /* @__PURE__ */ new Set(["script", "style", "template", "noscript"]);
|
|
559
655
|
var VOID = /* @__PURE__ */ new Set(["br", "hr", "img", "input", "path"]);
|
|
@@ -619,7 +715,7 @@ var ENTITIES = { "<": "<", "&": "&", "<": "<", ">": ">", "&"
|
|
|
619
715
|
function mermaidSource(srcDoc) {
|
|
620
716
|
return MERMAID_SRCDOC.exec(srcDoc)?.[1]?.replace(/&(?:#x3c|#x26|#x27|lt|gt|amp|quot);/gi, (e) => ENTITIES[e.toLowerCase()]);
|
|
621
717
|
}
|
|
622
|
-
var RENDER_REF =
|
|
718
|
+
var RENDER_REF = new RegExp(`^(/assets/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\.svg(?:${PREVIEW_QUERY_SOURCE})?) ([1-9]\\d{0,5}) ([1-9]\\d{0,5})$`);
|
|
623
719
|
var isRenderRef = matches(RENDER_REF);
|
|
624
720
|
function diagramRender(value) {
|
|
625
721
|
const m = typeof value === "string" ? RENDER_REF.exec(value) : null;
|
|
@@ -671,11 +767,11 @@ var ATTRS = new Map(
|
|
|
671
767
|
);
|
|
672
768
|
var isObject = (v) => typeof v === "object" && v !== null;
|
|
673
769
|
function textOf(node, depth = 0) {
|
|
674
|
-
if (!isObject(node) || depth >
|
|
770
|
+
if (!isObject(node) || depth > MAX_DEPTH2) return "";
|
|
675
771
|
if (node.type === "text") return typeof node.value === "string" ? node.value : "";
|
|
676
772
|
return Array.isArray(node.children) ? node.children.map((c) => textOf(c, depth + 1)).join("") : "";
|
|
677
773
|
}
|
|
678
|
-
var holdsEmbed = (node, depth = 0) => isObject(node) && depth <=
|
|
774
|
+
var holdsEmbed = (node, depth = 0) => isObject(node) && depth <= MAX_DEPTH2 && (isObject(node.properties) && "dataEmbed" in node.properties || Array.isArray(node.children) && node.children.some((c) => holdsEmbed(c, depth + 1)));
|
|
679
775
|
var collapse = (text) => text.replace(/\s+/g, " ").trim();
|
|
680
776
|
var CALLOUT_MARKER = /^\s*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*/i;
|
|
681
777
|
var CALLOUT_KIND = { note: "note", tip: "tip", important: "important", warning: "warning", caution: "caution" };
|
|
@@ -706,7 +802,7 @@ function toFigure(children) {
|
|
|
706
802
|
return { type: "element", tagName: "figure", properties: { dataSlotComponent: "Image" }, children: [media, ...caption] };
|
|
707
803
|
}
|
|
708
804
|
function clean(node, depth, ctx2, budget) {
|
|
709
|
-
if (!isObject(node) || depth >
|
|
805
|
+
if (!isObject(node) || depth > MAX_DEPTH2) return [];
|
|
710
806
|
if (++budget.nodes > MAX_NODES) throw new HastLimitError("content has too many nodes");
|
|
711
807
|
if (node.type === "text") {
|
|
712
808
|
if (typeof node.value !== "string") return [];
|
|
@@ -756,7 +852,7 @@ function sanitizeHast(tree, title, description) {
|
|
|
756
852
|
const [first] = elements;
|
|
757
853
|
const skip = title !== void 0 && isObject(first) && first.tagName === "h1" && collapse(textOf(first)) === collapse(title) ? first : void 0;
|
|
758
854
|
const lead = elements[skip ? 1 : 0];
|
|
759
|
-
const repeat = description && isObject(lead) && lead.tagName === "p" && collapse(textOf(lead))
|
|
855
|
+
const repeat = description && isObject(lead) && lead.tagName === "p" && collapse(textOf(lead)) === collapse(description) && !holdsEmbed(lead) ? lead : void 0;
|
|
760
856
|
const budget = { nodes: 0, text: 0 };
|
|
761
857
|
return { type: "root", children: raw.filter((n) => n !== skip && n !== repeat).flatMap((n) => clean(n, 0, { katex: false }, budget)) };
|
|
762
858
|
}
|
|
@@ -1688,79 +1784,94 @@ function CommentBody({ tree }) {
|
|
|
1688
1784
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle-cm-body", children: (0, import_hast_util_to_jsx_runtime2.toJsxRuntime)({ type: "root", children }, { Fragment: import_react3.Fragment, jsx: import_jsx_runtime5.jsx, jsxs: import_jsx_runtime5.jsxs, elementAttributeNameCase: "react", stylePropertyNameCase: "dom" }) });
|
|
1689
1785
|
}
|
|
1690
1786
|
|
|
1691
|
-
// src/react/
|
|
1787
|
+
// src/react/theme.tsx
|
|
1692
1788
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1693
|
-
function
|
|
1789
|
+
function HyleTheme({ theme }) {
|
|
1790
|
+
const href = theme ? themeStylesheetHref(theme) : void 0;
|
|
1791
|
+
if (!href) return null;
|
|
1792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1793
|
+
themeFontHrefs(Array.isArray(theme?.preload) ? theme.preload : []).map((font) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("link", { rel: "preload", as: "font", type: "font/woff2", href: font, crossOrigin: "anonymous" }, font)),
|
|
1794
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("link", { rel: "stylesheet", href, precedence: "hyle-theme" })
|
|
1795
|
+
] });
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
// src/react/embed.tsx
|
|
1799
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1800
|
+
function HyleListView({ items, layout = "list", title, headingLevel = 2, moreHref, olderHref, theme, ...base }) {
|
|
1694
1801
|
const c = ctx(base, "en");
|
|
1695
1802
|
const { s, Link } = c;
|
|
1696
1803
|
const Row = base.slots?.["list.item"];
|
|
1697
1804
|
const Heading = `h${headingLevel}`;
|
|
1698
1805
|
const safe = items.filter((item) => item.canonical_path.startsWith("/"));
|
|
1699
|
-
if (safe.length === 0) return base.slots?.["list.empty"] ? /* @__PURE__ */ (0,
|
|
1700
|
-
return /* @__PURE__ */ (0,
|
|
1701
|
-
|
|
1702
|
-
/* @__PURE__ */ (0,
|
|
1703
|
-
|
|
1704
|
-
/* @__PURE__ */ (0,
|
|
1705
|
-
|
|
1706
|
-
|
|
1806
|
+
if (safe.length === 0) return base.slots?.["list.empty"] ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle hyle-embed", "data-layout": layout, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "list.empty", slots: base.slots }) }) : null;
|
|
1807
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle hyle-embed", "data-layout": layout, lang: c.locale, children: [
|
|
1808
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HyleTheme, { theme }),
|
|
1809
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Heading, { className: "hyle-title", children: title }) : null,
|
|
1810
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: "hyle-items", children: safe.map((item) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: Row ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
|
|
1811
|
+
item.published_at ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }) : null,
|
|
1812
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
|
|
1813
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "t", children: item.title }),
|
|
1814
|
+
item.description ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: item.description }) : null
|
|
1707
1815
|
] })
|
|
1708
1816
|
] }) }, item.canonical_path)) }),
|
|
1709
|
-
olderHref ? /* @__PURE__ */ (0,
|
|
1710
|
-
moreHref ? /* @__PURE__ */ (0,
|
|
1817
|
+
olderHref ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OlderNav, { href: olderHref, c }) : null,
|
|
1818
|
+
moreHref ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", { className: "hyle-more", href: moreHref, children: s.viewAll }) : null
|
|
1711
1819
|
] });
|
|
1712
1820
|
}
|
|
1713
1821
|
function HyleArticleView({ article, headingLevel = 2, ...base }) {
|
|
1714
1822
|
const { publication: pub } = article;
|
|
1715
1823
|
const c = ctx(base, pub.locale);
|
|
1716
1824
|
const Heading = `h${headingLevel}`;
|
|
1717
|
-
return /* @__PURE__ */ (0,
|
|
1718
|
-
/* @__PURE__ */ (0,
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
/* @__PURE__ */ (0,
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle hyle-embed", children: [
|
|
1826
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HyleTheme, { theme: article.theme }),
|
|
1827
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("article", { lang: c.locale, children: [
|
|
1828
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("header", { className: "hyle-head", children: [
|
|
1829
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Heading, { className: "hyle-title", children: pub.title }),
|
|
1830
|
+
pub.description ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
|
|
1831
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-meta", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) }) }) })
|
|
1832
|
+
] }),
|
|
1833
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Body, { article, components: base.components, locale: c.locale }),
|
|
1834
|
+
pub.canonical_path.startsWith("/") ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("a", { className: "hyle-more", href: c.href(pub.canonical_path, pub.locale), rel: "bookmark", children: [
|
|
1835
|
+
c.s.readAtSource,
|
|
1836
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "hyle-sr", children: [
|
|
1837
|
+
": ",
|
|
1838
|
+
pub.title
|
|
1839
|
+
] })
|
|
1840
|
+
] }) : null
|
|
1841
|
+
] })
|
|
1842
|
+
] });
|
|
1732
1843
|
}
|
|
1733
1844
|
var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((w) => [...w][0] ?? "").join("").toUpperCase() || "?";
|
|
1734
1845
|
function StaticThread({ nodes, locale, s, level = 1 }) {
|
|
1735
|
-
return /* @__PURE__ */ (0,
|
|
1736
|
-
const kids = node.kids.length > 0 && level < 32 ? /* @__PURE__ */ (0,
|
|
1846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ol", { className: "hyle-cm-list", role: "list", children: nodes.map((node) => {
|
|
1847
|
+
const kids = node.kids.length > 0 && level < 32 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StaticThread, { nodes: node.kids, locale, s, level: level + 1 }) : null;
|
|
1737
1848
|
if (node.status === "removed") {
|
|
1738
1849
|
const why = node.removedBy === "moderator" ? s.removedByModerator : node.removedBy === "author" ? s.removedByAuthor : s.removed;
|
|
1739
|
-
return /* @__PURE__ */ (0,
|
|
1740
|
-
/* @__PURE__ */ (0,
|
|
1741
|
-
/* @__PURE__ */ (0,
|
|
1742
|
-
/* @__PURE__ */ (0,
|
|
1850
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "removed", "data-removed-by": node.removedBy, children: [
|
|
1851
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("article", { "aria-label": why, children: [
|
|
1852
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "ban" }) }),
|
|
1853
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-cm-main", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-cm-body", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: why }) }) })
|
|
1743
1854
|
] }),
|
|
1744
1855
|
kids
|
|
1745
1856
|
] }, node.id);
|
|
1746
1857
|
}
|
|
1747
|
-
return /* @__PURE__ */ (0,
|
|
1748
|
-
/* @__PURE__ */ (0,
|
|
1749
|
-
/* @__PURE__ */ (0,
|
|
1750
|
-
/* @__PURE__ */ (0,
|
|
1751
|
-
/* @__PURE__ */ (0,
|
|
1752
|
-
/* @__PURE__ */ (0,
|
|
1753
|
-
/* @__PURE__ */ (0,
|
|
1754
|
-
/* @__PURE__ */ (0,
|
|
1755
|
-
node.editedAt ? /* @__PURE__ */ (0,
|
|
1858
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "visible", children: [
|
|
1859
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("article", { children: [
|
|
1860
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: initials(node.name ?? "") }),
|
|
1861
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-cm-main", children: [
|
|
1862
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-cm-by", children: [
|
|
1863
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("b", { children: node.name }),
|
|
1864
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
|
|
1865
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: node.createdAt, title: node.createdAt, children: formatDate(node.createdAt, locale) }),
|
|
1866
|
+
node.editedAt ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
1756
1867
|
" ",
|
|
1757
|
-
/* @__PURE__ */ (0,
|
|
1868
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { "aria-hidden": "true", children: "\xB7" }),
|
|
1758
1869
|
" ",
|
|
1759
|
-
/* @__PURE__ */ (0,
|
|
1870
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: s.edited })
|
|
1760
1871
|
] }) : null
|
|
1761
1872
|
] })
|
|
1762
1873
|
] }),
|
|
1763
|
-
node.unrenderable ? /* @__PURE__ */ (0,
|
|
1874
|
+
node.unrenderable ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-cm-body", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: s.unrenderable }) }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CommentBody, { tree: node.tree })
|
|
1764
1875
|
] })
|
|
1765
1876
|
] }),
|
|
1766
1877
|
kids
|
|
@@ -1771,26 +1882,26 @@ function HyleCommentsView({ listing, locale }) {
|
|
|
1771
1882
|
const thread = buildThread(listing, []);
|
|
1772
1883
|
if (thread.length === 0) return null;
|
|
1773
1884
|
const s = stringsFor(locale).comments;
|
|
1774
|
-
return /* @__PURE__ */ (0,
|
|
1775
|
-
/* @__PURE__ */ (0,
|
|
1885
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", lang: locale, children: [
|
|
1886
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-cm-head", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("h2", { children: [
|
|
1776
1887
|
s.heading,
|
|
1777
1888
|
" ",
|
|
1778
|
-
/* @__PURE__ */ (0,
|
|
1889
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-cm-count", "aria-label": s.countLabel.replace("{n}", String(listing.comment_count)), children: listing.comment_count })
|
|
1779
1890
|
] }) }),
|
|
1780
|
-
/* @__PURE__ */ (0,
|
|
1781
|
-
listing.truncated ? /* @__PURE__ */ (0,
|
|
1891
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(StaticThread, { nodes: thread, locale, s }),
|
|
1892
|
+
listing.truncated ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "hyle-cm-note", children: s.truncated }) : null
|
|
1782
1893
|
] }) });
|
|
1783
1894
|
}
|
|
1784
1895
|
function HyleCommentsFallback({ locale }) {
|
|
1785
1896
|
const s = stringsFor(locale).comments;
|
|
1786
|
-
return /* @__PURE__ */ (0,
|
|
1787
|
-
/* @__PURE__ */ (0,
|
|
1788
|
-
/* @__PURE__ */ (0,
|
|
1789
|
-
/* @__PURE__ */ (0,
|
|
1790
|
-
/* @__PURE__ */ (0,
|
|
1791
|
-
/* @__PURE__ */ (0,
|
|
1792
|
-
/* @__PURE__ */ (0,
|
|
1793
|
-
/* @__PURE__ */ (0,
|
|
1897
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { role: "status", "aria-live": "polite", "aria-busy": "true", children: [
|
|
1898
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-sr", children: s.loading }),
|
|
1899
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "aria-hidden": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-cm-sk", children: [
|
|
1900
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-sk c" }),
|
|
1901
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
|
|
1902
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-sk l", style: { width: 120 } }),
|
|
1903
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-sk l", style: { width: "100%" } }),
|
|
1904
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-sk l", style: { width: "72%" } })
|
|
1794
1905
|
] })
|
|
1795
1906
|
] }, i)) })
|
|
1796
1907
|
] }) }) });
|
|
@@ -1921,13 +2032,16 @@ function listJsonLd({ list, origin, href, path, locale, description, jsonLd, cur
|
|
|
1921
2032
|
|
|
1922
2033
|
// src/react/pages.tsx
|
|
1923
2034
|
var import_toc_spy = require("./toc-spy.cjs");
|
|
1924
|
-
var
|
|
2035
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1925
2036
|
function Slot({ name, slots, tag: Tag = "div", className }) {
|
|
1926
2037
|
const fill = slots?.[name];
|
|
1927
|
-
return fill ? /* @__PURE__ */ (0,
|
|
2038
|
+
return fill ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Tag, { "data-slot": name, className, children: fill }) : null;
|
|
1928
2039
|
}
|
|
1929
|
-
function Shell({ children }) {
|
|
1930
|
-
return /* @__PURE__ */ (0,
|
|
2040
|
+
function Shell({ children, theme }) {
|
|
2041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
2042
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HyleTheme, { theme }),
|
|
2043
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "hyle", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "hyle-page", children }) })
|
|
2044
|
+
] });
|
|
1931
2045
|
}
|
|
1932
2046
|
function ctx(p, fallbackLocale) {
|
|
1933
2047
|
const locale = p.locale ?? fallbackLocale;
|
|
@@ -1936,29 +2050,29 @@ function ctx(p, fallbackLocale) {
|
|
|
1936
2050
|
function Pager({ prev, next, c }) {
|
|
1937
2051
|
if (!prev && !next) return null;
|
|
1938
2052
|
const { Link, s } = c;
|
|
1939
|
-
return /* @__PURE__ */ (0,
|
|
1940
|
-
prev ? /* @__PURE__ */ (0,
|
|
1941
|
-
/* @__PURE__ */ (0,
|
|
1942
|
-
/* @__PURE__ */ (0,
|
|
2053
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("nav", { className: "hyle-pager", "aria-label": s.pager, children: [
|
|
2054
|
+
prev ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Link, { href: c.href(prev.canonical_path), rel: "prev", children: [
|
|
2055
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "dir", children: [
|
|
2056
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev-left" }),
|
|
1943
2057
|
s.prev
|
|
1944
2058
|
] }),
|
|
1945
|
-
/* @__PURE__ */ (0,
|
|
1946
|
-
] }) : /* @__PURE__ */ (0,
|
|
1947
|
-
next ? /* @__PURE__ */ (0,
|
|
1948
|
-
/* @__PURE__ */ (0,
|
|
2059
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ttl", children: prev.title })
|
|
2060
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "none", "aria-hidden": "true" }),
|
|
2061
|
+
next ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Link, { href: c.href(next.canonical_path), rel: "next", className: "next", children: [
|
|
2062
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "dir", children: [
|
|
1949
2063
|
s.next,
|
|
1950
|
-
/* @__PURE__ */ (0,
|
|
2064
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev" })
|
|
1951
2065
|
] }),
|
|
1952
|
-
/* @__PURE__ */ (0,
|
|
2066
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ttl", children: next.title })
|
|
1953
2067
|
] }) : null
|
|
1954
2068
|
] });
|
|
1955
2069
|
}
|
|
1956
2070
|
function OlderNav({ href, c }) {
|
|
1957
|
-
return /* @__PURE__ */ (0,
|
|
1958
|
-
/* @__PURE__ */ (0,
|
|
1959
|
-
/* @__PURE__ */ (0,
|
|
2071
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("nav", { className: "hyle-pagination", "aria-label": c.s.pager, children: [
|
|
2072
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "sp" }),
|
|
2073
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(c.Link, { className: "hyle-btn sm", href, rel: "next", children: [
|
|
1960
2074
|
c.s.older,
|
|
1961
|
-
/* @__PURE__ */ (0,
|
|
2075
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev" })
|
|
1962
2076
|
] })
|
|
1963
2077
|
] });
|
|
1964
2078
|
}
|
|
@@ -1969,9 +2083,9 @@ function TocList({ toc }) {
|
|
|
1969
2083
|
if (entry.depth === 3 && last) last.subs.push(entry);
|
|
1970
2084
|
else groups.push({ entry, subs: [] });
|
|
1971
2085
|
}
|
|
1972
|
-
return /* @__PURE__ */ (0,
|
|
1973
|
-
/* @__PURE__ */ (0,
|
|
1974
|
-
subs.length > 0 ? /* @__PURE__ */ (0,
|
|
2086
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { children: groups.map(({ entry, subs }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("li", { children: [
|
|
2087
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("a", { href: `#${scopeId(entry.id)}`, children: entry.text }),
|
|
2088
|
+
subs.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { children: subs.map((sub) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("a", { href: `#${scopeId(sub.id)}`, children: sub.text }) }, sub.id)) }) : null
|
|
1975
2089
|
] }, entry.id)) });
|
|
1976
2090
|
}
|
|
1977
2091
|
function Toc({ toc, c, aside, spy, className }) {
|
|
@@ -1980,21 +2094,21 @@ function Toc({ toc, c, aside, spy, className }) {
|
|
|
1980
2094
|
const { s } = c;
|
|
1981
2095
|
const classes = (own) => className ? `${className} ${own}` : own;
|
|
1982
2096
|
return {
|
|
1983
|
-
narrow: entries.length === 0 ? null : /* @__PURE__ */ (0,
|
|
1984
|
-
/* @__PURE__ */ (0,
|
|
1985
|
-
/* @__PURE__ */ (0,
|
|
2097
|
+
narrow: entries.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { className: classes("hyle-toc-m"), children: [
|
|
2098
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("summary", { children: [
|
|
2099
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "file" }),
|
|
1986
2100
|
s.toc,
|
|
1987
|
-
/* @__PURE__ */ (0,
|
|
2101
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
|
|
1988
2102
|
] }),
|
|
1989
|
-
/* @__PURE__ */ (0,
|
|
2103
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("nav", { className: "hyle-toc-list", "aria-label": s.toc, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TocList, { toc: entries }) })
|
|
1990
2104
|
] }),
|
|
1991
|
-
wide: /* @__PURE__ */ (0,
|
|
1992
|
-
entries.length === 0 ? null : /* @__PURE__ */ (0,
|
|
1993
|
-
/* @__PURE__ */ (0,
|
|
1994
|
-
/* @__PURE__ */ (0,
|
|
2105
|
+
wide: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("aside", { className: classes("hyle-toc-d"), "aria-label": s.toc, children: [
|
|
2106
|
+
entries.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
2107
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "hyle-toc-title", children: s.toc }),
|
|
2108
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("nav", { className: "hyle-toc-list", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TocList, { toc: entries }) })
|
|
1995
2109
|
] }),
|
|
1996
2110
|
aside,
|
|
1997
|
-
spy && entries.length > 0 ? /* @__PURE__ */ (0,
|
|
2111
|
+
spy && entries.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_toc_spy.TocSpy, { ids: entries.map((t) => scopeId(t.id)) }) : null
|
|
1998
2112
|
] })
|
|
1999
2113
|
};
|
|
2000
2114
|
}
|
|
@@ -2002,27 +2116,27 @@ function Body({ article, components, locale }) {
|
|
|
2002
2116
|
const { content, publication } = article;
|
|
2003
2117
|
const lang = article.fallback ? void 0 : publication.locale;
|
|
2004
2118
|
if (content.format === "hast") {
|
|
2005
|
-
return /* @__PURE__ */ (0,
|
|
2119
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ProseBody, { className: "hyle-body hyle-prose", lang, tree: content.tree, title: publication.title, description: publication.description, components: components ?? {}, locale });
|
|
2006
2120
|
}
|
|
2007
|
-
return /* @__PURE__ */ (0,
|
|
2121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "hyle-body hyle-prose", lang, children: content.format === "html" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TrustedServerHtml, { html: content.html }) : null });
|
|
2008
2122
|
}
|
|
2009
2123
|
function Languages({ alternates, current, c }) {
|
|
2010
2124
|
if (alternates.length < 2) return null;
|
|
2011
2125
|
const { Link, s } = c;
|
|
2012
|
-
return /* @__PURE__ */ (0,
|
|
2013
|
-
/* @__PURE__ */ (0,
|
|
2014
|
-
/* @__PURE__ */ (0,
|
|
2126
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("nav", { className: "hyle-langs", "aria-label": s.languages, children: [
|
|
2127
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: s.readIn }),
|
|
2128
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { children: alternates.map((a) => {
|
|
2015
2129
|
const label = languageName(a.locale, a.locale);
|
|
2016
|
-
return /* @__PURE__ */ (0,
|
|
2130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: a.locale === current ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("a", { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, "aria-current": "true", children: label }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Link, { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, children: label }) }, a.locale);
|
|
2017
2131
|
}) })
|
|
2018
2132
|
] });
|
|
2019
2133
|
}
|
|
2020
2134
|
function LdScript({ json: json2 }) {
|
|
2021
|
-
return /* @__PURE__ */ (0,
|
|
2135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: json2 } });
|
|
2022
2136
|
}
|
|
2023
2137
|
function Crumbs({ items, c }) {
|
|
2024
2138
|
const { Link } = c;
|
|
2025
|
-
return /* @__PURE__ */ (0,
|
|
2139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("nav", { className: "hyle-crumbs", "aria-label": c.s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ol", { children: items.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { "aria-current": i === items.length - 1 ? "page" : void 0, children: i === items.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Link, { href: crumbHref(c.href, b.canonical_path, c.locale), children: b.title }) }, b.canonical_path)) }) });
|
|
2026
2140
|
}
|
|
2027
2141
|
function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, imageWidth, imageHeight, related, ...base }) {
|
|
2028
2142
|
const { publication: pub } = article;
|
|
@@ -2032,66 +2146,66 @@ function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, imageWidth
|
|
|
2032
2146
|
const author = articleAuthor(article, jsonLd)?.name;
|
|
2033
2147
|
const modified = modifiedAt(pub);
|
|
2034
2148
|
const words = wordCountOf(pub);
|
|
2035
|
-
const toc = Toc({ toc: article.toc, c, spy: true, aside: /* @__PURE__ */ (0,
|
|
2149
|
+
const toc = Toc({ toc: article.toc, c, spy: true, aside: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "article.aside", slots: base.slots, className: "hyle-slot-wrap" }) });
|
|
2036
2150
|
const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
|
|
2037
|
-
return /* @__PURE__ */ (0,
|
|
2038
|
-
/* @__PURE__ */ (0,
|
|
2039
|
-
/* @__PURE__ */ (0,
|
|
2040
|
-
/* @__PURE__ */ (0,
|
|
2041
|
-
/* @__PURE__ */ (0,
|
|
2042
|
-
pub.description ? /* @__PURE__ */ (0,
|
|
2043
|
-
/* @__PURE__ */ (0,
|
|
2044
|
-
author ? /* @__PURE__ */ (0,
|
|
2045
|
-
/* @__PURE__ */ (0,
|
|
2046
|
-
/* @__PURE__ */ (0,
|
|
2047
|
-
/* @__PURE__ */ (0,
|
|
2151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Shell, { theme: article.theme, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("article", { className: "hyle-article", "data-hyle-page": "article", lang: c.locale, children: [
|
|
2152
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("header", { className: "hyle-head", children: [
|
|
2153
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "article.before", slots: base.slots, className: "hyle-eyebrow" }),
|
|
2154
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Crumbs, { items: breadcrumbItems(article, jsonLd), c }),
|
|
2155
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h1", { className: "hyle-title", children: pub.title }),
|
|
2156
|
+
pub.description ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
|
|
2157
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-meta", children: [
|
|
2158
|
+
author ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
|
|
2159
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: author.slice(0, 2).toUpperCase() }),
|
|
2160
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
|
|
2161
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "hyle-sr", children: [
|
|
2048
2162
|
s.by,
|
|
2049
2163
|
" "
|
|
2050
2164
|
] }),
|
|
2051
|
-
/* @__PURE__ */ (0,
|
|
2165
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "by", children: author })
|
|
2052
2166
|
] })
|
|
2053
2167
|
] }) : null,
|
|
2054
|
-
/* @__PURE__ */ (0,
|
|
2055
|
-
/* @__PURE__ */ (0,
|
|
2056
|
-
/* @__PURE__ */ (0,
|
|
2168
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
|
|
2169
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "calendar" }),
|
|
2170
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) })
|
|
2057
2171
|
] }),
|
|
2058
|
-
modified ? /* @__PURE__ */ (0,
|
|
2059
|
-
/* @__PURE__ */ (0,
|
|
2172
|
+
modified ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
|
|
2173
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "calendar" }),
|
|
2060
2174
|
s.updated,
|
|
2061
2175
|
" ",
|
|
2062
|
-
/* @__PURE__ */ (0,
|
|
2176
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("time", { dateTime: modified, title: modified, children: formatDate(modified, c.locale) })
|
|
2063
2177
|
] }) : null,
|
|
2064
|
-
words ? /* @__PURE__ */ (0,
|
|
2065
|
-
/* @__PURE__ */ (0,
|
|
2178
|
+
words ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
|
|
2179
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "clock" }),
|
|
2066
2180
|
s.readingTime.replace("{n}", String(readingMinutes(words)))
|
|
2067
2181
|
] }) : null,
|
|
2068
|
-
/* @__PURE__ */ (0,
|
|
2069
|
-
/* @__PURE__ */ (0,
|
|
2070
|
-
/* @__PURE__ */ (0,
|
|
2182
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { children: [
|
|
2183
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "globe" }),
|
|
2184
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { lang: pub.locale, children: languageName(pub.locale, c.locale) })
|
|
2071
2185
|
] }),
|
|
2072
|
-
/* @__PURE__ */ (0,
|
|
2186
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "article.meta", slots: base.slots, tag: "span" })
|
|
2073
2187
|
] }),
|
|
2074
|
-
/* @__PURE__ */ (0,
|
|
2075
|
-
notTranslated ? /* @__PURE__ */ (0,
|
|
2076
|
-
/* @__PURE__ */ (0,
|
|
2077
|
-
/* @__PURE__ */ (0,
|
|
2078
|
-
/* @__PURE__ */ (0,
|
|
2188
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Languages, { alternates: article.alternates, current: pub.locale, c }),
|
|
2189
|
+
notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
|
|
2190
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "alert" }),
|
|
2191
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
|
|
2192
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("b", { children: notTranslated }),
|
|
2079
2193
|
" ",
|
|
2080
2194
|
s.fallbackBody
|
|
2081
2195
|
] })
|
|
2082
2196
|
] }) : null
|
|
2083
2197
|
] }),
|
|
2084
2198
|
toc.narrow,
|
|
2085
|
-
/* @__PURE__ */ (0,
|
|
2086
|
-
engagement ? /* @__PURE__ */ (0,
|
|
2087
|
-
/* @__PURE__ */ (0,
|
|
2088
|
-
related ? /* @__PURE__ */ (0,
|
|
2089
|
-
related.items.length > 0 ? /* @__PURE__ */ (0,
|
|
2090
|
-
article.children.length > 0 ? /* @__PURE__ */ (0,
|
|
2199
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Body, { article, components: base.components, locale: c.locale }),
|
|
2200
|
+
engagement ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_comments.Comments, { path: pub.canonical_path, endpoint: engagement.endpoint ?? "/api/hyle/engage", signInHref: engagement.signInHref, locale: c.locale, labels: s.comments }) : null,
|
|
2201
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Pager, { prev: article.prev, next: article.next, c }),
|
|
2202
|
+
related ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
2203
|
+
related.items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HyleListView, { items: related.items, title: related.title ?? s.moreInSection, ...base, locale: c.locale }) : null,
|
|
2204
|
+
article.children.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HyleListView, { items: article.children.map((child) => ({ ...child, description: null, published_at: "" })), title: s.subPages, ...base, locale: c.locale }) : null
|
|
2091
2205
|
] }) : null,
|
|
2092
|
-
/* @__PURE__ */ (0,
|
|
2206
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "article.after", slots: base.slots, className: "hyle-after" }),
|
|
2093
2207
|
toc.wide,
|
|
2094
|
-
jsonLdOrigin ? /* @__PURE__ */ (0,
|
|
2208
|
+
jsonLdOrigin ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(LdScript, { json: articleJsonLd({ article, origin: jsonLdOrigin, href: c.href, jsonLd, imageUrl, imageWidth, imageHeight }) }) : null
|
|
2095
2209
|
] }) });
|
|
2096
2210
|
}
|
|
2097
2211
|
function ListPage({ list, olderHref, description, origin, path, jsonLd, cursor, ...base }) {
|
|
@@ -2102,37 +2216,37 @@ function ListPage({ list, olderHref, description, origin, path, jsonLd, cursor,
|
|
|
2102
2216
|
for (const item of list.items) groups.set(item.published_at.slice(0, 7), [...groups.get(item.published_at.slice(0, 7)) ?? [], item]);
|
|
2103
2217
|
const notTranslated = list.fallback ? s.fallbackTitle.replace("{language}", languageName(list.fallback.requested_locale, c.locale)) : void 0;
|
|
2104
2218
|
const jsonLdOrigin = bareOrigin(origin);
|
|
2105
|
-
return /* @__PURE__ */ (0,
|
|
2106
|
-
/* @__PURE__ */ (0,
|
|
2107
|
-
/* @__PURE__ */ (0,
|
|
2108
|
-
description ? /* @__PURE__ */ (0,
|
|
2109
|
-
/* @__PURE__ */ (0,
|
|
2110
|
-
notTranslated ? /* @__PURE__ */ (0,
|
|
2111
|
-
/* @__PURE__ */ (0,
|
|
2112
|
-
/* @__PURE__ */ (0,
|
|
2113
|
-
/* @__PURE__ */ (0,
|
|
2219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Shell, { theme: list.theme, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-listpage", "data-hyle-page": "list", lang: c.locale, children: [
|
|
2220
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("header", { className: "hyle-head", children: [
|
|
2221
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h1", { className: "hyle-title", children: list.section.title }),
|
|
2222
|
+
description ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "hyle-desc", children: description }) : null,
|
|
2223
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "list.header", slots: base.slots, className: "hyle-slot-wrap" }),
|
|
2224
|
+
notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
|
|
2225
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "alert" }),
|
|
2226
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
|
|
2227
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("b", { children: notTranslated }),
|
|
2114
2228
|
" ",
|
|
2115
2229
|
s.fallbackBody
|
|
2116
2230
|
] })
|
|
2117
2231
|
] }) : null
|
|
2118
2232
|
] }),
|
|
2119
|
-
list.items.length === 0 ? /* @__PURE__ */ (0,
|
|
2120
|
-
/* @__PURE__ */ (0,
|
|
2121
|
-
/* @__PURE__ */ (0,
|
|
2122
|
-
/* @__PURE__ */ (0,
|
|
2123
|
-
/* @__PURE__ */ (0,
|
|
2124
|
-
] }) : [...groups].map(([month, items]) => /* @__PURE__ */ (0,
|
|
2125
|
-
/* @__PURE__ */ (0,
|
|
2126
|
-
/* @__PURE__ */ (0,
|
|
2127
|
-
/* @__PURE__ */ (0,
|
|
2128
|
-
/* @__PURE__ */ (0,
|
|
2129
|
-
/* @__PURE__ */ (0,
|
|
2130
|
-
item.description ? /* @__PURE__ */ (0,
|
|
2233
|
+
list.items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-empty", "data-slot-state": "empty", children: [
|
|
2234
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "file" }),
|
|
2235
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { children: s.emptyTitle }),
|
|
2236
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: s.emptyBody }),
|
|
2237
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "list.empty", slots: base.slots })
|
|
2238
|
+
] }) : [...groups].map(([month, items]) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { "aria-label": formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }), children: [
|
|
2239
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { className: "hyle-year", children: formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }) }),
|
|
2240
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { className: "hyle-items", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: Row ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
|
|
2241
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }),
|
|
2242
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
|
|
2243
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "t", children: item.title }),
|
|
2244
|
+
item.description ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: item.description }) : null
|
|
2131
2245
|
] })
|
|
2132
2246
|
] }) }, item.canonical_path)) })
|
|
2133
2247
|
] }, month)),
|
|
2134
|
-
olderHref ? /* @__PURE__ */ (0,
|
|
2135
|
-
jsonLdOrigin && path ? /* @__PURE__ */ (0,
|
|
2248
|
+
olderHref ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(OlderNav, { href: olderHref, c }) : null,
|
|
2249
|
+
jsonLdOrigin && path ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(LdScript, { json: listJsonLd({ list, origin: jsonLdOrigin, href: c.href, path, locale: c.locale, description, jsonLd, cursor }) }) : null
|
|
2136
2250
|
] }) });
|
|
2137
2251
|
}
|
|
2138
2252
|
|
|
@@ -2142,7 +2256,7 @@ var import_reactions = require("./reactions.cjs");
|
|
|
2142
2256
|
|
|
2143
2257
|
// src/react/docs.tsx
|
|
2144
2258
|
var import_docs_enhance = require("./docs-enhance.cjs");
|
|
2145
|
-
var
|
|
2259
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2146
2260
|
var ROOT_ID = "hyle-docs";
|
|
2147
2261
|
var NAV_ID = "hyle-docs-nav";
|
|
2148
2262
|
function navTreeOf(article) {
|
|
@@ -2166,15 +2280,15 @@ function pathTo(nodes, path) {
|
|
|
2166
2280
|
}
|
|
2167
2281
|
function Branch({ nodes, current, onPath, c }) {
|
|
2168
2282
|
const { Link } = c;
|
|
2169
|
-
return /* @__PURE__ */ (0,
|
|
2170
|
-
const link = /* @__PURE__ */ (0,
|
|
2171
|
-
if (node.children.length === 0) return /* @__PURE__ */ (0,
|
|
2172
|
-
return /* @__PURE__ */ (0,
|
|
2173
|
-
/* @__PURE__ */ (0,
|
|
2174
|
-
/* @__PURE__ */ (0,
|
|
2283
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { children: nodes.map((node) => {
|
|
2284
|
+
const link = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Link, { href: c.href(node.canonical_path), ...node.canonical_path === current ? { "aria-current": "page" } : {}, children: node.title });
|
|
2285
|
+
if (node.children.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("li", { children: link }, node.canonical_path);
|
|
2286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("details", { ...onPath.has(node.canonical_path) ? { open: true } : {}, children: [
|
|
2287
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("summary", { children: [
|
|
2288
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "chev" }),
|
|
2175
2289
|
link
|
|
2176
2290
|
] }),
|
|
2177
|
-
/* @__PURE__ */ (0,
|
|
2291
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Branch, { nodes: node.children, current, onPath, c })
|
|
2178
2292
|
] }) }, node.canonical_path);
|
|
2179
2293
|
}) });
|
|
2180
2294
|
}
|
|
@@ -2188,47 +2302,47 @@ function DocsPage({ article, ...base }) {
|
|
|
2188
2302
|
const siteName = article.breadcrumbs[0]?.title ?? "";
|
|
2189
2303
|
const headingIds = article.toc.filter((t) => t.depth === 2 || t.depth === 3).map((t) => scopeId(t.id));
|
|
2190
2304
|
const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
|
|
2191
|
-
return /* @__PURE__ */ (0,
|
|
2192
|
-
/* @__PURE__ */ (0,
|
|
2193
|
-
/* @__PURE__ */ (0,
|
|
2194
|
-
/* @__PURE__ */ (0,
|
|
2305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Shell, { theme: article.theme, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "hyle-docs", id: ROOT_ID, lang: c.locale, children: [
|
|
2306
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_docs_enhance.DocsEnhance, { headingIds, rootId: ROOT_ID }),
|
|
2307
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("button", { type: "button", className: "hyle-nav-bar", popoverTarget: NAV_ID, children: [
|
|
2308
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "file" }),
|
|
2195
2309
|
s.menu,
|
|
2196
|
-
/* @__PURE__ */ (0,
|
|
2197
|
-
/* @__PURE__ */ (0,
|
|
2310
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "cur", children: pub.title }),
|
|
2311
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
|
|
2198
2312
|
] }),
|
|
2199
|
-
/* @__PURE__ */ (0,
|
|
2200
|
-
/* @__PURE__ */ (0,
|
|
2201
|
-
/* @__PURE__ */ (0,
|
|
2202
|
-
/* @__PURE__ */ (0,
|
|
2203
|
-
/* @__PURE__ */ (0,
|
|
2313
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("aside", { className: "hyle-nav-d", id: NAV_ID, popover: "auto", "aria-label": s.docs, children: [
|
|
2314
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "hyle-side-head", children: [
|
|
2315
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("b", { children: siteName }),
|
|
2316
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { name: "docs.version", slots: base.slots, tag: "span" }),
|
|
2317
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: "hyle-nav-x", popoverTarget: NAV_ID, popoverTargetAction: "hide", "aria-label": s.closeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "x" }) })
|
|
2204
2318
|
] }),
|
|
2205
|
-
/* @__PURE__ */ (0,
|
|
2206
|
-
/* @__PURE__ */ (0,
|
|
2207
|
-
/* @__PURE__ */ (0,
|
|
2319
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
|
|
2320
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Branch, { nodes: tree, current: pub.canonical_path, onPath, c }) }),
|
|
2321
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
|
|
2208
2322
|
] }),
|
|
2209
|
-
/* @__PURE__ */ (0,
|
|
2210
|
-
notTranslated ? /* @__PURE__ */ (0,
|
|
2211
|
-
/* @__PURE__ */ (0,
|
|
2212
|
-
/* @__PURE__ */ (0,
|
|
2213
|
-
/* @__PURE__ */ (0,
|
|
2323
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
|
|
2324
|
+
notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
|
|
2325
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "alert" }),
|
|
2326
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
|
|
2327
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("b", { children: notTranslated }),
|
|
2214
2328
|
" ",
|
|
2215
2329
|
s.fallbackBody
|
|
2216
2330
|
] })
|
|
2217
2331
|
] }) : null,
|
|
2218
|
-
/* @__PURE__ */ (0,
|
|
2219
|
-
/* @__PURE__ */ (0,
|
|
2220
|
-
pub.description ? /* @__PURE__ */ (0,
|
|
2221
|
-
/* @__PURE__ */ (0,
|
|
2222
|
-
/* @__PURE__ */ (0,
|
|
2332
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
|
|
2333
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h1", { className: "hyle-title", children: pub.title }),
|
|
2334
|
+
pub.description ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
|
|
2335
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "hyle-updated", children: [
|
|
2336
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { name: "calendar" }),
|
|
2223
2337
|
s.updated,
|
|
2224
2338
|
" ",
|
|
2225
|
-
/* @__PURE__ */ (0,
|
|
2339
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("time", { dateTime: pub.updated_at, title: pub.updated_at, children: formatDate(pub.updated_at, c.locale) })
|
|
2226
2340
|
] }),
|
|
2227
2341
|
toc.narrow,
|
|
2228
|
-
/* @__PURE__ */ (0,
|
|
2229
|
-
/* @__PURE__ */ (0,
|
|
2230
|
-
/* @__PURE__ */ (0,
|
|
2231
|
-
/* @__PURE__ */ (0,
|
|
2342
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Body, { article, components: base.components, locale: c.locale }),
|
|
2343
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Pager, { prev: article.prev, next: article.next, c }),
|
|
2344
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" }),
|
|
2345
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "hyle-docs-end", "aria-hidden": "true" })
|
|
2232
2346
|
] }),
|
|
2233
2347
|
toc.wide
|
|
2234
2348
|
] }) });
|
|
@@ -2256,7 +2370,7 @@ function sitePathFrom(basePath, segments) {
|
|
|
2256
2370
|
return void 0;
|
|
2257
2371
|
}
|
|
2258
2372
|
if (segment !== segment.normalize("NFC")) return void 0;
|
|
2259
|
-
if (segment === "" || segment === "." || segment
|
|
2373
|
+
if (segment === "" || segment === "." || segment.includes("..") || /[/\\\u0000-\u001f\u007f]|%[0-9a-f]{2}/i.test(segment)) return void 0;
|
|
2260
2374
|
decoded.push(segment);
|
|
2261
2375
|
}
|
|
2262
2376
|
const path = decoded.length === 0 ? basePath || "/" : `${basePath}/${decoded.join("/")}`;
|
|
@@ -2318,9 +2432,10 @@ function routeContext(options, params) {
|
|
|
2318
2432
|
const toHref = (sitePath, linkLocale = locale) => (linkLocale ? prefix(linkLocale) : "") + sitePath;
|
|
2319
2433
|
return { basePath, path, locale, toHref };
|
|
2320
2434
|
}
|
|
2321
|
-
function
|
|
2435
|
+
function isNotFoundError(error, cursor) {
|
|
2322
2436
|
(0, import_navigation.unstable_rethrow)(error);
|
|
2323
|
-
|
|
2437
|
+
if (!(error instanceof Cp1ClientError)) return false;
|
|
2438
|
+
return error.status === 404 && error.code === "NOT_FOUND" || cursor !== void 0 && error.status === 400 && error.code === "VALIDATION_ERROR";
|
|
2324
2439
|
}
|
|
2325
2440
|
|
|
2326
2441
|
// src/next/embed.tsx
|
|
@@ -2432,6 +2547,10 @@ function sameOriginProblem(req, write, allowedOrigins) {
|
|
|
2432
2547
|
const site = req.headers.get("sec-fetch-site");
|
|
2433
2548
|
if (site !== null && site !== "same-origin") return true;
|
|
2434
2549
|
if (!write) return false;
|
|
2550
|
+
if (req.headers.get(ENGAGE_CSRF_HEADER) !== "1") return true;
|
|
2551
|
+
return originMismatch(req, allowedOrigins);
|
|
2552
|
+
}
|
|
2553
|
+
function originMismatch(req, allowedOrigins) {
|
|
2435
2554
|
const origin = req.headers.get("origin");
|
|
2436
2555
|
if (origin === null) return true;
|
|
2437
2556
|
let parsed;
|
|
@@ -2440,7 +2559,6 @@ function sameOriginProblem(req, write, allowedOrigins) {
|
|
|
2440
2559
|
} catch {
|
|
2441
2560
|
return true;
|
|
2442
2561
|
}
|
|
2443
|
-
if (req.headers.get(ENGAGE_CSRF_HEADER) !== "1") return true;
|
|
2444
2562
|
if (allowedOrigins) return !allowedOrigins.some((o) => safeOrigin(o) === parsed.origin);
|
|
2445
2563
|
const host = req.headers.get("x-forwarded-host")?.split(",")[0]?.trim() || req.headers.get("host") || new URL(req.url).host;
|
|
2446
2564
|
const proto = req.headers.get("x-forwarded-proto")?.split(",")[0]?.trim().toLowerCase();
|
|
@@ -2621,7 +2739,9 @@ function createEngagementRoute(options) {
|
|
|
2621
2739
|
redirect: "error",
|
|
2622
2740
|
signal: AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS2)
|
|
2623
2741
|
});
|
|
2624
|
-
|
|
2742
|
+
const text = await readCapped(res, MAX_RESPONSE_BYTES);
|
|
2743
|
+
const status = res.status === 404 && !isNotFoundBody(res.status, text) ? 502 : res.status;
|
|
2744
|
+
return { status, ok: res.ok, text, retryAfter: res.headers.get("retry-after"), throttle: res.headers.get("hyle-throttle") };
|
|
2625
2745
|
};
|
|
2626
2746
|
try {
|
|
2627
2747
|
const out = route.action(req.method) === "comments.list" ? await shared(`${viewer?.reader.sub ?? ""}
|
|
@@ -2638,12 +2758,12 @@ ${built.query.toString()}`, () => listing(viewer, call)) : await call();
|
|
|
2638
2758
|
}
|
|
2639
2759
|
|
|
2640
2760
|
// src/next/embed.tsx
|
|
2641
|
-
var
|
|
2642
|
-
async function resolveEmbed(options, run) {
|
|
2761
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2762
|
+
async function resolveEmbed(options, run, cursor) {
|
|
2643
2763
|
try {
|
|
2644
2764
|
return { result: await run() };
|
|
2645
2765
|
} catch (error) {
|
|
2646
|
-
if (
|
|
2766
|
+
if (isNotFoundError(error, cursor)) return {};
|
|
2647
2767
|
console.error(`hyle: ${error instanceof Error ? error.name : "UnknownError"}`);
|
|
2648
2768
|
return { failure: options.onError ? options.onError(error) : null };
|
|
2649
2769
|
}
|
|
@@ -2653,10 +2773,11 @@ async function HyleList({ options, limit = 5, locale, layout, title, headingLeve
|
|
|
2653
2773
|
const route = routeContext(locale ? { ...options, locale } : options, {});
|
|
2654
2774
|
const path = sitePathFrom(route.basePath, void 0);
|
|
2655
2775
|
if (path === void 0) return null;
|
|
2656
|
-
const
|
|
2776
|
+
const after = validCursor(cursor);
|
|
2777
|
+
const { result, failure } = await resolveEmbed(options, () => resolve(path, route.locale, limit, after), after);
|
|
2657
2778
|
if (failure !== void 0) return failure;
|
|
2658
2779
|
const next = olderHref && result?.kind === "list" ? validCursor(result.next_cursor) : void 0;
|
|
2659
|
-
return /* @__PURE__ */ (0,
|
|
2780
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HyleListView, { items: result?.kind === "list" ? result.items : [], theme: result?.kind === "list" ? result.theme : void 0, layout, title, headingLevel, moreHref, olderHref: next ? olderHref?.(next) : void 0, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
|
|
2660
2781
|
}
|
|
2661
2782
|
async function HyleArticle({ options, path, locale, headingLevel }) {
|
|
2662
2783
|
if (!isSitePath2(path)) return null;
|
|
@@ -2665,7 +2786,7 @@ async function HyleArticle({ options, path, locale, headingLevel }) {
|
|
|
2665
2786
|
const { result, failure } = await resolveEmbed(options, () => resolve(path, route.locale));
|
|
2666
2787
|
if (failure !== void 0) return failure;
|
|
2667
2788
|
if (result?.kind !== "article") return null;
|
|
2668
|
-
return /* @__PURE__ */ (0,
|
|
2789
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HyleArticleView, { article: result, headingLevel, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
|
|
2669
2790
|
}
|
|
2670
2791
|
var MAX_LISTING_BYTES = 4 * 1024 * 1024;
|
|
2671
2792
|
var COMMENTS_TIMEOUT_MS = 1e4;
|
|
@@ -2685,7 +2806,7 @@ async function HyleComments({ options, path, revalidate = 60, interactive }) {
|
|
|
2685
2806
|
};
|
|
2686
2807
|
const res = await fetch(`${options.baseUrl.replace(/\/+$/, "")}/cp1/engage/comments?${new URLSearchParams({ path })}`, init);
|
|
2687
2808
|
if (!res.ok) {
|
|
2688
|
-
if (res
|
|
2809
|
+
if (!await isNotFoundResponse(res)) console.error(`hyle: comments answered HTTP ${res.status}`);
|
|
2689
2810
|
return null;
|
|
2690
2811
|
}
|
|
2691
2812
|
listing = parseListing(JSON.parse(await readCapped(res, MAX_LISTING_BYTES)).data);
|
|
@@ -2697,13 +2818,13 @@ async function HyleComments({ options, path, revalidate = 60, interactive }) {
|
|
|
2697
2818
|
return null;
|
|
2698
2819
|
}
|
|
2699
2820
|
if (!listing) return null;
|
|
2700
|
-
if (!interactive) return /* @__PURE__ */ (0,
|
|
2821
|
+
if (!interactive) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HyleCommentsView, { listing, locale });
|
|
2701
2822
|
const config = interactive === true ? {} : interactive;
|
|
2702
|
-
return /* @__PURE__ */ (0,
|
|
2823
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_comments2.Comments, { path, endpoint: config.endpoint ?? "/api/hyle/engage", signInHref: config.signInHref, locale, labels: stringsFor(locale).comments, initial: listing, initialAt: fetchedAt }) });
|
|
2703
2824
|
}
|
|
2704
2825
|
|
|
2705
2826
|
// src/next/page.tsx
|
|
2706
|
-
var
|
|
2827
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2707
2828
|
function hylePage(options) {
|
|
2708
2829
|
const resolve = resolverFor(options);
|
|
2709
2830
|
async function relatedItems(article) {
|
|
@@ -2716,21 +2837,22 @@ function hylePage(options) {
|
|
|
2716
2837
|
return async function HylePage({ params, searchParams }) {
|
|
2717
2838
|
const { path, locale, toHref } = routeContext(options, await params ?? {});
|
|
2718
2839
|
if (path === void 0) (0, import_navigation3.notFound)();
|
|
2840
|
+
let cursor;
|
|
2719
2841
|
try {
|
|
2720
|
-
|
|
2842
|
+
cursor = options.paginate === "searchParams" ? validCursor((await searchParams)?.cursor) : void 0;
|
|
2721
2843
|
const result = await resolve(path, locale, options.listLimit, cursor, options.layout === "docs" ? "tree" : void 0);
|
|
2722
2844
|
switch (result.kind) {
|
|
2723
2845
|
case "article": {
|
|
2724
2846
|
const image = articleImage(options, result);
|
|
2725
2847
|
const related = options.related && options.layout !== "docs" ? await relatedItems(result) : void 0;
|
|
2726
2848
|
const props = { article: result, components: options.components, slots: options.slots, locale, toHref };
|
|
2727
|
-
return options.layout === "docs" ? /* @__PURE__ */ (0,
|
|
2849
|
+
return options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ArticlePage, { ...props, origin: options.siteOrigin, jsonLd: options.jsonLd, imageUrl: image?.url, imageWidth: image?.width, imageHeight: image?.height, related, ...options.engagement ? { engagement: options.engagement } : {} });
|
|
2728
2850
|
}
|
|
2729
2851
|
case "list": {
|
|
2730
2852
|
const list = options.list?.title ? { ...result, section: { ...result.section, title: options.list.title } } : result;
|
|
2731
2853
|
const next = options.paginate === "searchParams" ? validCursor(result.next_cursor) : void 0;
|
|
2732
2854
|
const olderHref = next ? `${toHref(path)}?cursor=${next}` : void 0;
|
|
2733
|
-
return /* @__PURE__ */ (0,
|
|
2855
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ListPage, { list, ...olderHref ? { olderHref } : {}, ...options.list?.description ? { description: options.list.description } : {}, components: options.components, slots: options.slots, locale, toHref, origin: options.siteOrigin, path, jsonLd: options.jsonLd, cursor });
|
|
2734
2856
|
}
|
|
2735
2857
|
case "redirect": {
|
|
2736
2858
|
const to = safeRedirectTarget(result.to);
|
|
@@ -2745,7 +2867,7 @@ function hylePage(options) {
|
|
|
2745
2867
|
(0, import_navigation3.notFound)();
|
|
2746
2868
|
}
|
|
2747
2869
|
} catch (error) {
|
|
2748
|
-
if (
|
|
2870
|
+
if (isNotFoundError(error, cursor)) (0, import_navigation3.notFound)();
|
|
2749
2871
|
if (!options.onError) throw error;
|
|
2750
2872
|
console.error(`hyle: ${error instanceof Error ? error.name : "UnknownError"}`);
|
|
2751
2873
|
return options.onError(error);
|
|
@@ -2846,8 +2968,9 @@ function hyleMetadata(options) {
|
|
|
2846
2968
|
};
|
|
2847
2969
|
return Object.keys(types).length ? { ...alternates, types } : alternates;
|
|
2848
2970
|
};
|
|
2971
|
+
let cursor;
|
|
2849
2972
|
try {
|
|
2850
|
-
|
|
2973
|
+
cursor = options.paginate === "searchParams" ? validCursor((await searchParams)?.cursor) : void 0;
|
|
2851
2974
|
const result = await resolve(path, locale, options.listLimit, cursor, options.layout === "docs" ? "tree" : void 0);
|
|
2852
2975
|
const parentMeta = parent ? await parent : void 0;
|
|
2853
2976
|
const parentImages = parentMeta?.openGraph?.images;
|
|
@@ -2923,7 +3046,7 @@ function hyleMetadata(options) {
|
|
|
2923
3046
|
} : {}
|
|
2924
3047
|
};
|
|
2925
3048
|
} catch (error) {
|
|
2926
|
-
if (
|
|
3049
|
+
if (isNotFoundError(error, cursor)) return {};
|
|
2927
3050
|
throw error;
|
|
2928
3051
|
}
|
|
2929
3052
|
};
|
|
@@ -3040,10 +3163,7 @@ function mountsLoader(config) {
|
|
|
3040
3163
|
lastKnownGood.set(key, { loaded, at: Date.now() });
|
|
3041
3164
|
return loaded;
|
|
3042
3165
|
} catch (error) {
|
|
3043
|
-
|
|
3044
|
-
lastKnownGood.delete(key);
|
|
3045
|
-
return NONE;
|
|
3046
|
-
}
|
|
3166
|
+
(0, import_navigation5.unstable_rethrow)(error);
|
|
3047
3167
|
if (error instanceof Cp1ClientError && (error.status === 401 || error.status === 403)) {
|
|
3048
3168
|
lastKnownGood.delete(key);
|
|
3049
3169
|
throw error;
|
|
@@ -3175,7 +3295,7 @@ function createMarkdownRoute(options) {
|
|
|
3175
3295
|
}
|
|
3176
3296
|
return reply(null, 404);
|
|
3177
3297
|
} catch (error) {
|
|
3178
|
-
if (
|
|
3298
|
+
if (isNotFoundError(error)) return reply(null, 404);
|
|
3179
3299
|
console.error(`hyle: ${error instanceof Error ? error.name : "UnknownError"}`);
|
|
3180
3300
|
return reply(null, 502);
|
|
3181
3301
|
}
|
|
@@ -3226,8 +3346,40 @@ var DEFAULT_TIMEOUT_MS3 = 3e4;
|
|
|
3226
3346
|
var CACHE_CONTROL = "public, max-age=3600, s-maxage=86400, stale-while-revalidate=86400";
|
|
3227
3347
|
var PARTIAL_CACHE_CONTROL = "no-store";
|
|
3228
3348
|
var SAFE_HEADERS = { "X-Content-Type-Options": "nosniff", "Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox" };
|
|
3349
|
+
var PRIVATE_HEADERS = { "Cache-Control": "no-store", "Referrer-Policy": "no-referrer", "X-Robots-Tag": "noindex, nofollow" };
|
|
3229
3350
|
var empty = (status, headers = {}) => new Response(null, { status, headers: { "Cache-Control": "no-store", ...headers } });
|
|
3230
3351
|
var isSwitchedOff3 = (value) => ["0", "false"].includes(value?.trim().toLowerCase() ?? "");
|
|
3352
|
+
var THEME_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
3353
|
+
var OUTDATED_THEME_CACHE_CONTROL = "public, max-age=60";
|
|
3354
|
+
var THEME_SCOPE_HEADER = "cp-theme-scope";
|
|
3355
|
+
var MAX_THEME_BYTES = 256 * 1024;
|
|
3356
|
+
var sha256Hex = async (text) => Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text))), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
3357
|
+
async function serveTheme(client, scope, hash, timeoutMs, head) {
|
|
3358
|
+
try {
|
|
3359
|
+
const upstream = await client.theme({ timeoutMs });
|
|
3360
|
+
const type = upstream.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
|
|
3361
|
+
if (upstream.status === 404) return empty(await isNotFoundResponse(upstream) ? 404 : 502);
|
|
3362
|
+
if (upstream.status !== 200 || type !== "text/css") {
|
|
3363
|
+
void upstream.body?.cancel().catch(() => {
|
|
3364
|
+
});
|
|
3365
|
+
return empty(502);
|
|
3366
|
+
}
|
|
3367
|
+
const css = await readCapped(upstream, MAX_THEME_BYTES);
|
|
3368
|
+
const current = await sha256Hex(css);
|
|
3369
|
+
if (current !== hash && upstream.headers.get(THEME_SCOPE_HEADER) !== scope) return empty(404);
|
|
3370
|
+
const cache = current === hash ? THEME_CACHE_CONTROL : OUTDATED_THEME_CACHE_CONTROL;
|
|
3371
|
+
const headers = { "Content-Type": "text/css; charset=utf-8", "Cache-Control": cache, ETag: `"${current}"`, ...SAFE_HEADERS };
|
|
3372
|
+
return new Response(head ? null : css, { status: 200, headers });
|
|
3373
|
+
} catch {
|
|
3374
|
+
return empty(502);
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3377
|
+
function protectedAccessFor(req, pageId) {
|
|
3378
|
+
if (!PROTECTED_ID.test(pageId)) return void 0;
|
|
3379
|
+
const name = protectedCookieName(pageId);
|
|
3380
|
+
const password = req.headers.get("cookie")?.split(";").map((c) => c.trim()).find((c) => c.startsWith(`${name}=`))?.slice(name.length + 1);
|
|
3381
|
+
return password !== void 0 && PROTECTED_PASSWORD.test(password) ? { pageId, password } : void 0;
|
|
3382
|
+
}
|
|
3231
3383
|
function capped(body, max) {
|
|
3232
3384
|
let seen = 0;
|
|
3233
3385
|
return body.pipeThrough(
|
|
@@ -3244,18 +3396,33 @@ function createAssetRoute(options) {
|
|
|
3244
3396
|
let client;
|
|
3245
3397
|
const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
3246
3398
|
async function serve(req, ctx2, head) {
|
|
3399
|
+
const query = new URL(req.url).searchParams;
|
|
3400
|
+
const previewToken = query.get(PREVIEW_PARAM);
|
|
3401
|
+
const pageId = query.get(PROTECTED_PARAM);
|
|
3402
|
+
const res = await relay(req, ctx2, head, previewToken, pageId);
|
|
3403
|
+
if (previewToken !== null || pageId !== null) for (const [name, value] of Object.entries(PRIVATE_HEADERS)) res.headers.set(name, value);
|
|
3404
|
+
return res;
|
|
3405
|
+
}
|
|
3406
|
+
async function relay(req, ctx2, head, previewToken, pageId) {
|
|
3247
3407
|
if (isSwitchedOff3((options.env ?? process.env).HYLE_CONTENT_ENABLED)) return empty(404);
|
|
3248
3408
|
const file = (await ctx2.params).file;
|
|
3249
|
-
|
|
3409
|
+
const [, themeScope, themeHash] = typeof file === "string" ? THEME_FILE.exec(file) ?? [] : [];
|
|
3410
|
+
if (typeof file !== "string" || !themeHash && !ASSET_FILE.test(file)) return empty(404);
|
|
3411
|
+
if (previewToken !== null && !PREVIEW_TOKEN.test(previewToken)) return empty(404);
|
|
3412
|
+
const protectedAccess = pageId === null ? void 0 : protectedAccessFor(req, pageId);
|
|
3413
|
+
if (pageId !== null && protectedAccess === void 0) return empty(404);
|
|
3250
3414
|
try {
|
|
3251
3415
|
client ??= createHyleClient({ baseUrl: options.baseUrl?.trim() ?? "", token: options.token?.trim() ?? "", ...options.fetch ? { fetch: options.fetch } : {} });
|
|
3252
3416
|
} catch {
|
|
3253
3417
|
return empty(404);
|
|
3254
3418
|
}
|
|
3419
|
+
if (themeScope && themeHash) return serveTheme(client, themeScope, themeHash, options.timeoutMs ?? DEFAULT_TIMEOUT_MS3, head);
|
|
3255
3420
|
let upstream;
|
|
3256
3421
|
try {
|
|
3257
3422
|
upstream = await client.asset(file, {
|
|
3258
3423
|
timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS3,
|
|
3424
|
+
...previewToken === null ? {} : { previewToken },
|
|
3425
|
+
...protectedAccess === void 0 ? {} : { protectedAccess },
|
|
3259
3426
|
headers: { range: req.headers.get("range"), "if-range": req.headers.get("if-range"), "if-none-match": req.headers.get("if-none-match") }
|
|
3260
3427
|
});
|
|
3261
3428
|
} catch {
|
|
@@ -3268,10 +3435,16 @@ function createAssetRoute(options) {
|
|
|
3268
3435
|
drop();
|
|
3269
3436
|
return new Response(null, { status: 304, headers: { "Cache-Control": CACHE_CONTROL, Vary: "Range", ...SAFE_HEADERS, ...etag ? { ETag: etag } : {} } });
|
|
3270
3437
|
}
|
|
3271
|
-
if (upstream.status === 404
|
|
3438
|
+
if (upstream.status === 404) return empty(await isNotFoundResponse(upstream) ? 404 : 502);
|
|
3439
|
+
if (upstream.status === 416) {
|
|
3440
|
+
drop();
|
|
3441
|
+
const range = upstream.headers.get("content-range");
|
|
3442
|
+
return empty(416, range ? { "Content-Range": range } : {});
|
|
3443
|
+
}
|
|
3444
|
+
if (upstream.status === 429 && (previewToken !== null || pageId !== null)) {
|
|
3272
3445
|
drop();
|
|
3273
|
-
const
|
|
3274
|
-
return empty(
|
|
3446
|
+
const wait = upstream.headers.get("retry-after");
|
|
3447
|
+
return empty(429, wait ? { "Retry-After": wait } : {});
|
|
3275
3448
|
}
|
|
3276
3449
|
const type = upstream.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase();
|
|
3277
3450
|
const length = Number(upstream.headers.get("content-length"));
|
|
@@ -3295,7 +3468,7 @@ function createAssetRoute(options) {
|
|
|
3295
3468
|
}
|
|
3296
3469
|
|
|
3297
3470
|
// src/next/og.tsx
|
|
3298
|
-
var
|
|
3471
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3299
3472
|
var SIZE = { width: 1200, height: 630 };
|
|
3300
3473
|
var MAX_TITLE = 140;
|
|
3301
3474
|
function createOgImageRoute(options) {
|
|
@@ -3320,14 +3493,14 @@ function createOgImageRoute(options) {
|
|
|
3320
3493
|
if (result.kind !== "article") return new Response(null, { status: 404 });
|
|
3321
3494
|
title = result.publication.title;
|
|
3322
3495
|
} catch (error) {
|
|
3323
|
-
return new Response(null, { status:
|
|
3496
|
+
return new Response(null, { status: isNotFoundError(error) ? 404 : 502 });
|
|
3324
3497
|
}
|
|
3325
3498
|
const chars = [...title];
|
|
3326
3499
|
const shown = chars.length > MAX_TITLE ? `${chars.slice(0, MAX_TITLE - 1).join("")}\u2026` : title;
|
|
3327
3500
|
return new import_og.ImageResponse(
|
|
3328
|
-
/* @__PURE__ */ (0,
|
|
3329
|
-
/* @__PURE__ */ (0,
|
|
3330
|
-
options.siteName ? /* @__PURE__ */ (0,
|
|
3501
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { style: { display: "flex", flexDirection: "column", justifyContent: "space-between", width: "100%", height: "100%", padding: 80, background: "#111827", color: "#ffffff" }, children: [
|
|
3502
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { style: { fontSize: 64, fontWeight: 700, lineHeight: 1.2 }, children: shown }),
|
|
3503
|
+
options.siteName ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { style: { fontSize: 32, color: "#9ca3af" }, children: options.siteName }) : null
|
|
3331
3504
|
] }),
|
|
3332
3505
|
// shortcut: @vercel/og fetches Google Fonts / emoji assets at render time for non-Latin titles and emoji (no switch to disable it), upgrade to a satori render with bundled fonts if a host needs zero egress.
|
|
3333
3506
|
{ ...SIZE, headers: { "cache-control": "public, max-age=3600, s-maxage=31536000, immutable" } }
|
|
@@ -3335,6 +3508,107 @@ function createOgImageRoute(options) {
|
|
|
3335
3508
|
}
|
|
3336
3509
|
};
|
|
3337
3510
|
}
|
|
3511
|
+
|
|
3512
|
+
// src/next/preview.tsx
|
|
3513
|
+
var import_navigation7 = require("next/navigation");
|
|
3514
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3515
|
+
function drawArticle(article, options) {
|
|
3516
|
+
const { locale } = article.publication;
|
|
3517
|
+
const toHref = (sitePath, linkLocale = locale) => (options.localePrefix?.(linkLocale) ?? "") + sitePath;
|
|
3518
|
+
const props = { article, components: options.components, slots: options.slots, locale, toHref };
|
|
3519
|
+
return options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ArticlePage, { ...props });
|
|
3520
|
+
}
|
|
3521
|
+
var hylePreviewMetadata = { robots: { index: false, follow: false }, referrer: "no-referrer" };
|
|
3522
|
+
var BANNER = {
|
|
3523
|
+
position: "sticky",
|
|
3524
|
+
top: 0,
|
|
3525
|
+
zIndex: 2147483647,
|
|
3526
|
+
padding: "8px 16px",
|
|
3527
|
+
background: "#fde047",
|
|
3528
|
+
color: "#1a1a1a",
|
|
3529
|
+
font: "600 14px/1.4 system-ui, sans-serif",
|
|
3530
|
+
textAlign: "center"
|
|
3531
|
+
};
|
|
3532
|
+
function hylePreviewPage(options) {
|
|
3533
|
+
return async function HylePreviewPage({ searchParams }) {
|
|
3534
|
+
const { token } = await searchParams ?? {};
|
|
3535
|
+
const result = await createHyleClient(options).preview(typeof token === "string" ? token : void 0);
|
|
3536
|
+
if (result.kind !== "preview") (0, import_navigation7.notFound)();
|
|
3537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
3538
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "robots", content: "noindex, nofollow" }),
|
|
3539
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("meta", { name: "referrer", content: "no-referrer" }),
|
|
3540
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { role: "status", style: BANNER, children: "Unpublished draft preview" }),
|
|
3541
|
+
drawArticle(result.article, options)
|
|
3542
|
+
] });
|
|
3543
|
+
};
|
|
3544
|
+
}
|
|
3545
|
+
|
|
3546
|
+
// src/next/protected.tsx
|
|
3547
|
+
var import_headers = require("next/headers");
|
|
3548
|
+
var import_navigation8 = require("next/navigation");
|
|
3549
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3550
|
+
var hyleProtectedMetadata = { robots: { index: false, follow: false }, referrer: "same-origin" };
|
|
3551
|
+
var COOKIE_MAX_AGE_SECONDS = 12 * 60 * 60;
|
|
3552
|
+
var UNLOCK_MAX_BYTES = 1024;
|
|
3553
|
+
var PRIVATE_HEADERS2 = { "Cache-Control": "no-store", "Referrer-Policy": "no-referrer", "X-Robots-Tag": "noindex, nofollow" };
|
|
3554
|
+
var PASSWORD_FIELD = "hyle-protected-password";
|
|
3555
|
+
var ERROR_ID = "hyle-protected-error";
|
|
3556
|
+
function PasswordForm({ pageId, failed }) {
|
|
3557
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("main", { children: [
|
|
3558
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("h1", { children: "Protected page" }),
|
|
3559
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("form", { method: "post", action: `/p/${pageId}/unlock`, autoComplete: "off", children: [
|
|
3560
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { htmlFor: PASSWORD_FIELD, children: "Password" }),
|
|
3561
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3562
|
+
"input",
|
|
3563
|
+
{
|
|
3564
|
+
id: PASSWORD_FIELD,
|
|
3565
|
+
name: "password",
|
|
3566
|
+
type: "password",
|
|
3567
|
+
autoComplete: "off",
|
|
3568
|
+
spellCheck: false,
|
|
3569
|
+
required: true,
|
|
3570
|
+
pattern: "[A-Za-z0-9]{16}",
|
|
3571
|
+
title: "16 letters or digits",
|
|
3572
|
+
"aria-invalid": failed || void 0,
|
|
3573
|
+
"aria-describedby": failed ? ERROR_ID : void 0
|
|
3574
|
+
}
|
|
3575
|
+
),
|
|
3576
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "submit", children: "Open" }),
|
|
3577
|
+
failed ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { id: ERROR_ID, role: "alert", children: "Wrong or expired password." }) : null
|
|
3578
|
+
] })
|
|
3579
|
+
] });
|
|
3580
|
+
}
|
|
3581
|
+
function hyleProtectedPage(options) {
|
|
3582
|
+
return async function HyleProtectedPage({ params }) {
|
|
3583
|
+
const { id } = await params;
|
|
3584
|
+
if (typeof id !== "string" || !PROTECTED_ID.test(id)) (0, import_navigation8.notFound)();
|
|
3585
|
+
const password = (await (0, import_headers.cookies)()).get(protectedCookieName(id))?.value;
|
|
3586
|
+
const result = password === void 0 ? void 0 : await createHyleClient(options).protected(id, password);
|
|
3587
|
+
if (result?.kind === "disabled") (0, import_navigation8.notFound)();
|
|
3588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
3589
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("meta", { name: "robots", content: "noindex, nofollow" }),
|
|
3590
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("meta", { name: "referrer", content: "same-origin" }),
|
|
3591
|
+
result?.kind === "protected" ? drawArticle(result.article, options) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(PasswordForm, { pageId: id, failed: result !== void 0 })
|
|
3592
|
+
] });
|
|
3593
|
+
};
|
|
3594
|
+
}
|
|
3595
|
+
function createProtectedUnlockRoute() {
|
|
3596
|
+
return {
|
|
3597
|
+
async POST(req, ctx2) {
|
|
3598
|
+
const { id } = await ctx2.params;
|
|
3599
|
+
if (typeof id !== "string" || !PROTECTED_ID.test(id)) return new Response(null, { status: 404, headers: PRIVATE_HEADERS2 });
|
|
3600
|
+
const site = req.headers.get("sec-fetch-site");
|
|
3601
|
+
if (site === null ? originMismatch(req) : site !== "same-origin") return new Response(null, { status: 403, headers: PRIVATE_HEADERS2 });
|
|
3602
|
+
if (!/^application\/x-www-form-urlencoded(\s*;|$)/i.test(req.headers.get("content-type") ?? "")) return new Response(null, { status: 415, headers: PRIVATE_HEADERS2 });
|
|
3603
|
+
if (Number(req.headers.get("content-length")) > UNLOCK_MAX_BYTES) return new Response(null, { status: 413, headers: PRIVATE_HEADERS2 });
|
|
3604
|
+
const form = await readCapped(new Response(req.body), UNLOCK_MAX_BYTES).catch(() => void 0);
|
|
3605
|
+
if (form === void 0) return new Response(null, { status: 413, headers: PRIVATE_HEADERS2 });
|
|
3606
|
+
const password = new URLSearchParams(form).get("password") ?? "";
|
|
3607
|
+
const cookie = PROTECTED_PASSWORD.test(password) ? { "Set-Cookie": `${protectedCookieName(id)}=${password}; Max-Age=${COOKIE_MAX_AGE_SECONDS}; Path=/; HttpOnly; Secure; SameSite=Lax` } : {};
|
|
3608
|
+
return new Response(null, { status: 303, headers: { ...PRIVATE_HEADERS2, Location: `/p/${id}`, ...cookie } });
|
|
3609
|
+
}
|
|
3610
|
+
};
|
|
3611
|
+
}
|
|
3338
3612
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3339
3613
|
0 && (module.exports = {
|
|
3340
3614
|
ENGAGE_CSRF_HEADER,
|
|
@@ -3348,12 +3622,17 @@ function createOgImageRoute(options) {
|
|
|
3348
3622
|
createLlmsTxtRoute,
|
|
3349
3623
|
createMarkdownRoute,
|
|
3350
3624
|
createOgImageRoute,
|
|
3625
|
+
createProtectedUnlockRoute,
|
|
3351
3626
|
createRevalidateRoute,
|
|
3352
3627
|
fetchResolver,
|
|
3353
3628
|
hyleFeed,
|
|
3354
3629
|
hyleFeedLink,
|
|
3355
3630
|
hyleMetadata,
|
|
3356
3631
|
hylePage,
|
|
3632
|
+
hylePreviewMetadata,
|
|
3633
|
+
hylePreviewPage,
|
|
3634
|
+
hyleProtectedMetadata,
|
|
3635
|
+
hyleProtectedPage,
|
|
3357
3636
|
hyleRootMetadata,
|
|
3358
3637
|
hyleRootPage,
|
|
3359
3638
|
hyleRootSitemap,
|