@tdacorp/hyle-sdk 0.14.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +20 -8
  2. package/dist/check-routes-bin.js +10 -8
  3. package/dist/{chunk-4V4VKB3O.js → chunk-DMK4XQLU.js} +470 -385
  4. package/dist/{chunk-R5EMI4HQ.js → chunk-PJMJMP66.js} +3 -1
  5. package/dist/comments.cjs +6 -4
  6. package/dist/comments.js +6 -5
  7. package/dist/{diagram-viewer-DYX6R63Y.js → diagram-viewer-FJPED4SN.js} +46 -26
  8. package/dist/{embed-B76zRRPa.d.cts → embed-BmdwA2G9.d.cts} +9 -4
  9. package/dist/{embed-SqOBGI-E.d.ts → embed-DNTZ2UXv.d.ts} +9 -4
  10. package/dist/index.d.cts +2 -2
  11. package/dist/index.d.ts +2 -2
  12. package/dist/labels-nmukKYgL.d.cts +37 -0
  13. package/dist/labels-nmukKYgL.d.ts +37 -0
  14. package/dist/mermaid-diagram.cjs +59 -30
  15. package/dist/mermaid-diagram.d.cts +4 -37
  16. package/dist/mermaid-diagram.d.ts +4 -37
  17. package/dist/mermaid-diagram.js +7 -5
  18. package/dist/mermaid-image.cjs +1382 -0
  19. package/dist/mermaid-image.d.cts +29 -0
  20. package/dist/mermaid-image.d.ts +29 -0
  21. package/dist/mermaid-image.js +94 -0
  22. package/dist/next.cjs +1330 -1118
  23. package/dist/next.d.cts +61 -11
  24. package/dist/next.d.ts +61 -11
  25. package/dist/next.js +922 -793
  26. package/dist/react.cjs +267 -184
  27. package/dist/react.d.cts +29 -6
  28. package/dist/react.d.ts +29 -6
  29. package/dist/react.js +1 -1
  30. package/dist/{resolve-DC2ccfwA.d.ts → resolve-Ae7UFjsQ.d.ts} +1 -1
  31. package/dist/{resolve-DKLVftk_.d.cts → resolve-euZ4-aC9.d.cts} +1 -1
  32. package/dist/styles.css +11 -22
  33. package/dist/{types-ByodIyEv.d.cts → types-Czt887Iv.d.cts} +19 -3
  34. package/dist/{types-ByodIyEv.d.ts → types-Czt887Iv.d.ts} +19 -3
  35. package/dist/use-cache.d.cts +2 -2
  36. package/dist/use-cache.d.ts +2 -2
  37. package/package.json +1 -1
@@ -58,9 +58,7 @@ function Icon({ name, className }) {
58
58
 
59
59
  // src/react/content.tsx
60
60
  import { MermaidDiagram } from "./mermaid-diagram.js";
61
-
62
- // src/react/mermaid-config.ts
63
- var MAX_MERMAID_SOURCE = 2e4;
61
+ import { MermaidImage } from "./mermaid-image.js";
64
62
 
65
63
  // src/react/sanitize.ts
66
64
  var HastLimitError = class extends Error {
@@ -72,7 +70,7 @@ var HastLimitError = class extends Error {
72
70
  var MAX_NODES = 2e4;
73
71
  var MAX_TEXT = 512 * 1024;
74
72
  var MAX_DEPTH = 128;
75
- var MAX_SRCDOC = 64 * 1024;
73
+ var MAX_SRCDOC = 1024 * 1024;
76
74
  var DROP = /* @__PURE__ */ new Set(["script", "style", "template", "noscript"]);
77
75
  var VOID = /* @__PURE__ */ new Set(["br", "hr", "img", "input", "path"]);
78
76
  var isString = (v) => typeof v === "string";
@@ -89,6 +87,7 @@ var classTokens = (v) => {
89
87
  };
90
88
  var isClass = (v) => classTokens(v) !== void 0;
91
89
  var isAlign = matches(/^(left|right|center)$/);
90
+ var isPixels = (v) => typeof v === "number" ? Number.isInteger(v) && v > 0 : typeof v === "string" && /^[1-9]\d*$/.test(v);
92
91
  var isLength = matches(/^[\d.]+(em|px|%)?$/);
93
92
  var STYLE_PROPS = /* @__PURE__ */ new Set(["height", "vertical-align", "margin-left", "margin-right", "margin-top", "margin-bottom", "top", "width", "min-width", "border-bottom-width", "padding-left"]);
94
93
  var STYLE_LENGTH = /^(-?\d+(?:\.\d+)?)(em|px|%)?$/;
@@ -125,10 +124,14 @@ var MERMAID_SRCDOC = new RegExp(
125
124
  var isMermaidSrcdoc = (v) => typeof v === "string" && v.length <= MAX_SRCDOC && MERMAID_SRCDOC.test(v);
126
125
  var ENTITIES = { "&#x3c;": "<", "&#x26;": "&", "&lt;": "<", "&gt;": ">", "&amp;": "&", "&quot;": '"', "&#x27;": "'" };
127
126
  function mermaidSource(srcDoc) {
128
- const text = MERMAID_SRCDOC.exec(srcDoc)?.[1]?.replace(/&(?:#x3c|#x26|#x27|lt|gt|amp|quot);/gi, (e) => ENTITIES[e.toLowerCase()]);
129
- return text === void 0 || text.length > MAX_MERMAID_SOURCE ? void 0 : text;
127
+ return MERMAID_SRCDOC.exec(srcDoc)?.[1]?.replace(/&(?:#x3c|#x26|#x27|lt|gt|amp|quot);/gi, (e) => ENTITIES[e.toLowerCase()]);
128
+ }
129
+ var RENDER_REF = /^(\/assets\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.svg) ([1-9]\d{0,5}) ([1-9]\d{0,5})$/;
130
+ var isRenderRef = matches(RENDER_REF);
131
+ function diagramRender(value) {
132
+ const m = typeof value === "string" ? RENDER_REF.exec(value) : null;
133
+ return m ? { src: hostAssetSrc(m[1]), width: Number(m[2]), height: Number(m[3]) } : void 0;
130
134
  }
131
- var MERMAID_FRAME_CSP = `default-src 'none'; script-src ${MERMAID_SCRIPT_URL} 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:`;
132
135
  var heading = { id: isIdValue, className: isClass };
133
136
  var ATTRS = new Map(
134
137
  Object.entries({
@@ -153,7 +156,7 @@ var ATTRS = new Map(
153
156
  h5: heading,
154
157
  h6: heading,
155
158
  a: { href: isHref, id: isIdValue, ariaDescribedBy: isIdValue, ariaLabel: isString, dataFootnoteRef: isScalar, dataFootnoteBackref: isScalar, className: isClass },
156
- img: { src: isSrc, alt: isString },
159
+ img: { src: isSrc, alt: isString, width: isPixels, height: isPixels },
157
160
  table: {},
158
161
  th: { scope: matches(/^(row|col|rowgroup|colgroup)$/), align: isAlign },
159
162
  td: { align: isAlign },
@@ -167,7 +170,7 @@ var ATTRS = new Map(
167
170
  video: { src: isSrc, controls: isScalar },
168
171
  audio: { src: isSrc, controls: isScalar },
169
172
  // hyle's sandboxed Mermaid frame (ADR 0001). The renderer emits `sandbox` as ["allow-scripts"]; it is normalized below.
170
- iframe: { sandbox: (v) => v === "allow-scripts" || Array.isArray(v) && v.length === 1 && v[0] === "allow-scripts", srcdoc: isMermaidSrcdoc }
173
+ iframe: { sandbox: (v) => v === "allow-scripts" || Array.isArray(v) && v.length === 1 && v[0] === "allow-scripts", srcdoc: isMermaidSrcdoc, dataLight: isRenderRef, dataDark: isRenderRef }
171
174
  })
172
175
  );
173
176
  var isObject = (v) => typeof v === "object" && v !== null;
@@ -541,11 +544,17 @@ var en = {
541
544
  caution: "Caution",
542
545
  diagram: "Diagram",
543
546
  diagramError: "This diagram could not be rendered.",
547
+ diagramLoading: "Loading the diagram",
548
+ diagramSource: "Diagram source",
544
549
  contentError: "This content cannot be displayed.",
545
550
  fallbackTitle: "Not translated into {language} yet.",
546
551
  fallbackBody: "You are reading the original.",
552
+ readingTime: "{n} min read",
553
+ readingTimeLabel: "Reading time",
547
554
  older: "Older posts",
548
555
  viewAll: "View all",
556
+ moreInSection: "More in this section",
557
+ subPages: "In this section",
549
558
  readAtSource: "Read at source",
550
559
  emptyTitle: "Nothing published here yet",
551
560
  emptyBody: "Documents published to this section will appear here, newest first.",
@@ -587,11 +596,17 @@ var fr = {
587
596
  caution: "Danger",
588
597
  diagram: "Sch\xE9ma",
589
598
  diagramError: "Ce sch\xE9ma n'a pas pu \xEAtre affich\xE9.",
599
+ diagramLoading: "Chargement du sch\xE9ma",
600
+ diagramSource: "Source du sch\xE9ma",
590
601
  contentError: "Ce contenu ne peut pas \xEAtre affich\xE9.",
591
602
  fallbackTitle: "Pas encore traduit en {language}.",
592
603
  fallbackBody: "Vous lisez l'original.",
604
+ readingTime: "{n} min de lecture",
605
+ readingTimeLabel: "Temps de lecture",
593
606
  older: "Articles plus anciens",
594
607
  viewAll: "Tout voir",
608
+ moreInSection: "Plus dans cette section",
609
+ subPages: "Dans cette section",
595
610
  readAtSource: "Lire \xE0 la source",
596
611
  emptyTitle: "Rien n'est encore publi\xE9 ici",
597
612
  emptyBody: "Les documents publi\xE9s dans cette section appara\xEEtront ici, du plus r\xE9cent au plus ancien.",
@@ -633,11 +648,17 @@ var es = {
633
648
  caution: "Peligro",
634
649
  diagram: "Diagrama",
635
650
  diagramError: "No se pudo mostrar este diagrama.",
651
+ diagramLoading: "Cargando el diagrama",
652
+ diagramSource: "C\xF3digo del diagrama",
636
653
  contentError: "No se puede mostrar este contenido.",
637
654
  fallbackTitle: "A\xFAn no est\xE1 traducida al {language}.",
638
655
  fallbackBody: "Est\xE1s leyendo el original.",
656
+ readingTime: "{n} min de lectura",
657
+ readingTimeLabel: "Tiempo de lectura",
639
658
  older: "Entradas anteriores",
640
659
  viewAll: "Ver todo",
660
+ moreInSection: "M\xE1s en esta secci\xF3n",
661
+ subPages: "En esta secci\xF3n",
641
662
  readAtSource: "Leer en la fuente",
642
663
  emptyTitle: "A\xFAn no hay nada publicado aqu\xED",
643
664
  emptyBody: "Los documentos publicados en esta secci\xF3n aparecer\xE1n aqu\xED, del m\xE1s reciente al m\xE1s antiguo.",
@@ -700,7 +721,12 @@ function buildComponents(c, s) {
700
721
  }
701
722
  return /* @__PURE__ */ jsx3("a", { href: url, rel: "noopener noreferrer", ...rest, children });
702
723
  };
703
- const Image = (props) => typeof props.src === "string" ? /* @__PURE__ */ jsx3(Img, { loading: "lazy", decoding: "async", ...props }) : null;
724
+ let images = 0;
725
+ const Image = (props) => {
726
+ if (typeof props.src !== "string") return null;
727
+ const first = images++ === 0;
728
+ return /* @__PURE__ */ jsx3(Img, { loading: first ? "eager" : "lazy", ...first ? { fetchPriority: "high" } : {}, decoding: "async", ...props });
729
+ };
704
730
  const Pre = ({ children, ...rest }) => {
705
731
  const code = Children.toArray(children).find(isValidElement);
706
732
  const language = /(?:^|\s)language-([\w-]+)/.exec(code?.props.className ?? "")?.[1];
@@ -724,12 +750,18 @@ function buildComponents(c, s) {
724
750
  ] })
725
751
  ] });
726
752
  };
727
- const Frame = ({ srcDoc, sandbox }) => {
753
+ const Frame = (props) => {
754
+ const { srcDoc } = props;
728
755
  if (typeof srcDoc !== "string") return null;
729
756
  const source = mermaidSource(srcDoc);
730
757
  if (c.Mermaid) return /* @__PURE__ */ jsx3(c.Mermaid, { srcDoc, source, title: s.diagram });
731
- if (source !== void 0) return /* @__PURE__ */ jsx3(MermaidDiagram, { source, title: s.diagram, errorText: s.diagramError, labels: s.viewer });
732
- return /* @__PURE__ */ jsx3("figure", { className: "hyle-mermaid", "data-slot-component": "Mermaid", children: /* @__PURE__ */ jsx3("iframe", { srcDoc, sandbox: String(sandbox), title: s.diagram, loading: "lazy", referrerPolicy: "no-referrer", ...{ csp: MERMAID_FRAME_CSP } }) });
758
+ if (source === void 0) return null;
759
+ const light = diagramRender(props["data-light"]);
760
+ const dark = diagramRender(props["data-dark"]);
761
+ if (light && dark) {
762
+ return /* @__PURE__ */ jsx3(MermaidImage, { source, title: s.diagram, errorText: s.diagramError, loadingText: s.diagramLoading, sourceLabel: s.diagramSource, light, dark, labels: s.viewer });
763
+ }
764
+ return /* @__PURE__ */ jsx3(MermaidDiagram, { source, title: s.diagram, errorText: s.diagramError, loadingText: s.diagramLoading, labels: s.viewer });
733
765
  };
734
766
  const Heading = (level) => function HyleHeading({ id, children, ...rest }) {
735
767
  const Tag = `h${level}`;
@@ -774,12 +806,261 @@ import { MermaidDiagram as MermaidDiagram2 } from "./mermaid-diagram.js";
774
806
  // src/react/pages.tsx
775
807
  import { Comments } from "./comments.js";
776
808
 
809
+ // src/react/comments-api.ts
810
+ var isObject2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
811
+ var count = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? Math.trunc(v) : 0;
812
+ function toComment(raw) {
813
+ if (!isObject2(raw) || typeof raw.id !== "string" || typeof raw.created_at !== "string") return void 0;
814
+ const depth = typeof raw.depth === "number" ? Math.min(4, Math.max(1, Math.trunc(raw.depth))) : 1;
815
+ const author = isObject2(raw.author) && typeof raw.author.name === "string" ? raw.author.name : void 0;
816
+ const name = typeof raw.author_name === "string" ? raw.author_name : author;
817
+ const body = isObject2(raw.body) && raw.body.format === "hast" ? { format: "hast", tree: raw.body.tree } : null;
818
+ const removed = raw.removed === true || body === null;
819
+ return {
820
+ id: raw.id,
821
+ parent_id: typeof raw.parent_id === "string" ? raw.parent_id : null,
822
+ depth,
823
+ author_name: name ?? null,
824
+ created_at: raw.created_at,
825
+ edited_at: typeof raw.edited_at === "string" ? raw.edited_at : null,
826
+ like_count: count(raw.like_count),
827
+ removed,
828
+ ...removed && (raw.removed_by === "moderator" || raw.removed_by === "author") ? { removed_by: raw.removed_by } : {},
829
+ body,
830
+ // Viewer members exist only on a live comment of a viewer-aware listing; a tombstone never carries them.
831
+ ...!removed && typeof raw.mine === "boolean" ? { mine: raw.mine, liked_by_me: raw.liked_by_me === true, can_edit_until: typeof raw.can_edit_until === "string" ? raw.can_edit_until : null } : {}
832
+ };
833
+ }
834
+ function toHeld(raw) {
835
+ if (!isObject2(raw) || typeof raw.id !== "string" || typeof raw.created_at !== "string" || !isObject2(raw.body) || raw.body.format !== "hast") return void 0;
836
+ const author = isObject2(raw.author) && typeof raw.author.name === "string" ? raw.author.name : null;
837
+ return {
838
+ id: raw.id,
839
+ parent_id: typeof raw.parent_id === "string" ? raw.parent_id : null,
840
+ depth: typeof raw.depth === "number" ? Math.min(4, Math.max(1, Math.trunc(raw.depth))) : 1,
841
+ author_name: author,
842
+ created_at: raw.created_at,
843
+ edited_at: typeof raw.edited_at === "string" ? raw.edited_at : null,
844
+ can_edit_until: typeof raw.can_edit_until === "string" ? raw.can_edit_until : null,
845
+ body: { format: "hast", tree: raw.body.tree }
846
+ };
847
+ }
848
+ function parseListing(data) {
849
+ if (!isObject2(data) || data.kind !== "comments" || !Array.isArray(data.comments)) return void 0;
850
+ const comments = data.comments.map(toComment).filter((c) => c !== void 0);
851
+ const viewer = Array.isArray(data.mine_held) ? { liked_by_me: data.liked_by_me === true, mine_held: data.mine_held.slice(0, 5).map(toHeld).filter((h) => h !== void 0) } : {};
852
+ return { cp: 1, kind: "comments", publication_id: String(data.publication_id ?? ""), comment_count: count(data.comment_count), like_count: count(data.like_count), truncated: data.truncated === true, comments, ...viewer };
853
+ }
854
+ var untilMs = (iso) => {
855
+ const t = iso ? Date.parse(iso) : NaN;
856
+ return Number.isFinite(t) ? t : void 0;
857
+ };
858
+ function buildThread(listing, localHeld) {
859
+ const byId = /* @__PURE__ */ new Map();
860
+ const roots = [];
861
+ const place = (node, parentId) => {
862
+ const parent = parentId ? byId.get(parentId) : void 0;
863
+ (parent ? parent.kids : roots).push(node);
864
+ };
865
+ for (const c of listing.comments) {
866
+ if (byId.has(c.id)) continue;
867
+ const removed = c.removed;
868
+ const node = {
869
+ id: c.id,
870
+ depth: c.depth,
871
+ status: removed ? "removed" : "visible",
872
+ removedBy: removed ? c.removed_by : void 0,
873
+ mine: !removed && c.mine === true,
874
+ canEditUntil: untilMs(c.can_edit_until),
875
+ likedByMe: !removed && c.liked_by_me === true,
876
+ name: removed ? null : c.author_name ?? null,
877
+ createdAt: c.created_at,
878
+ editedAt: c.edited_at,
879
+ likes: c.like_count,
880
+ tree: c.body?.tree,
881
+ text: void 0,
882
+ kids: []
883
+ };
884
+ place(node, c.parent_id === c.id ? null : c.parent_id);
885
+ byId.set(c.id, node);
886
+ }
887
+ const mine = [];
888
+ const addHeld = (node, parentId, oldestFirst) => {
889
+ const parent = parentId ? byId.get(parentId) : void 0;
890
+ if (parent) parent.kids.push(node);
891
+ else if (oldestFirst) mine.unshift(node);
892
+ else mine.push(node);
893
+ };
894
+ const heldIds = /* @__PURE__ */ new Set();
895
+ for (const h of listing.mine_held ?? []) {
896
+ heldIds.add(h.id);
897
+ const parent = h.parent_id ? byId.get(h.parent_id) : void 0;
898
+ addHeld({ id: h.id, depth: Math.min(4, (parent?.depth ?? h.depth - 1) + 1), status: "held", removedBy: void 0, mine: true, canEditUntil: untilMs(h.can_edit_until), likedByMe: false, name: h.author_name, createdAt: h.created_at, editedAt: h.edited_at, likes: 0, tree: h.body?.tree, text: void 0, kids: [] }, h.parent_id, true);
899
+ }
900
+ if (listing.mine_held === void 0) {
901
+ for (const h of localHeld) {
902
+ if (byId.has(h.id) || heldIds.has(h.id)) continue;
903
+ const parent = h.parentId ? byId.get(h.parentId) : void 0;
904
+ addHeld({ id: h.id, depth: Math.min(4, (parent?.depth ?? 0) + 1), status: "held", removedBy: void 0, mine: true, canEditUntil: void 0, likedByMe: false, name: h.name, createdAt: h.createdAt, editedAt: null, likes: 0, tree: void 0, text: h.text, kids: [] }, h.parentId, false);
905
+ }
906
+ }
907
+ return [...mine, ...roots];
908
+ }
909
+
910
+ // src/react/comments-body.tsx
911
+ import { toJsxRuntime as toJsxRuntime2 } from "hast-util-to-jsx-runtime";
912
+ import { Fragment as Fragment4 } from "react";
913
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
914
+ import { jsx as jsx5 } from "react/jsx-runtime";
915
+ var ALLOWED = /* @__PURE__ */ new Set(["p", "a", "em", "strong", "del", "code", "pre", "blockquote", "ul", "ol", "li", "br"]);
916
+ var LINK_REL = "nofollow ugc noopener noreferrer";
917
+ function narrow(node) {
918
+ if (node.type === "text") return [node];
919
+ if (node.type !== "element") return [];
920
+ const children = node.children.flatMap(narrow);
921
+ if (!ALLOWED.has(node.tagName)) return children;
922
+ if (node.tagName === "a") {
923
+ const href = node.properties.href;
924
+ if (!isSafeUrl(href, "href")) return children;
925
+ return [{ type: "element", tagName: "a", properties: { href: String(href), rel: LINK_REL.split(" ") }, children }];
926
+ }
927
+ return [{ type: "element", tagName: node.tagName, properties: {}, children: node.tagName === "br" ? [] : children }];
928
+ }
929
+ function CommentBody({ tree }) {
930
+ let children;
931
+ try {
932
+ children = sanitizeHast(tree).children.flatMap((n) => narrow(n));
933
+ } catch (error) {
934
+ if (error instanceof HastLimitError) return null;
935
+ throw error;
936
+ }
937
+ return /* @__PURE__ */ jsx5("div", { className: "hyle-cm-body", children: toJsxRuntime2({ type: "root", children }, { Fragment: Fragment4, jsx: jsx4, jsxs: jsxs4, elementAttributeNameCase: "react", stylePropertyNameCase: "dom" }) });
938
+ }
939
+
940
+ // src/react/embed.tsx
941
+ import { Fragment as Fragment5, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
942
+ function HyleListView({ items, layout = "list", title, headingLevel = 2, moreHref, olderHref, ...base }) {
943
+ const c = ctx(base, "en");
944
+ const { s, Link } = c;
945
+ const Row = base.slots?.["list.item"];
946
+ const Heading = `h${headingLevel}`;
947
+ const safe = items.filter((item) => item.canonical_path.startsWith("/"));
948
+ if (safe.length === 0) return base.slots?.["list.empty"] ? /* @__PURE__ */ jsx6("div", { className: "hyle hyle-embed", "data-layout": layout, children: /* @__PURE__ */ jsx6(Slot, { name: "list.empty", slots: base.slots }) }) : null;
949
+ return /* @__PURE__ */ jsxs5("div", { className: "hyle hyle-embed", "data-layout": layout, lang: c.locale, children: [
950
+ title ? /* @__PURE__ */ jsx6(Heading, { className: "hyle-title", children: title }) : null,
951
+ /* @__PURE__ */ jsx6("ul", { className: "hyle-items", children: safe.map((item) => /* @__PURE__ */ jsx6("li", { children: Row ? /* @__PURE__ */ jsx6(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ jsxs5(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
952
+ item.published_at ? /* @__PURE__ */ jsx6("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }) : null,
953
+ /* @__PURE__ */ jsxs5("div", { children: [
954
+ /* @__PURE__ */ jsx6("span", { className: "t", children: item.title }),
955
+ item.description ? /* @__PURE__ */ jsx6("p", { children: item.description }) : null
956
+ ] })
957
+ ] }) }, item.canonical_path)) }),
958
+ olderHref ? /* @__PURE__ */ jsx6(OlderNav, { href: olderHref, c }) : null,
959
+ moreHref ? /* @__PURE__ */ jsx6("a", { className: "hyle-more", href: moreHref, children: s.viewAll }) : null
960
+ ] });
961
+ }
962
+ function HyleArticleView({ article, headingLevel = 2, ...base }) {
963
+ const { publication: pub } = article;
964
+ const c = ctx(base, pub.locale);
965
+ const Heading = `h${headingLevel}`;
966
+ return /* @__PURE__ */ jsx6("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ jsxs5("article", { lang: c.locale, children: [
967
+ /* @__PURE__ */ jsxs5("header", { className: "hyle-head", children: [
968
+ /* @__PURE__ */ jsx6(Heading, { className: "hyle-title", children: pub.title }),
969
+ pub.description ? /* @__PURE__ */ jsx6("p", { className: "hyle-desc", children: pub.description }) : null,
970
+ /* @__PURE__ */ jsx6("div", { className: "hyle-meta", children: /* @__PURE__ */ jsx6("span", { children: /* @__PURE__ */ jsx6("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) }) }) })
971
+ ] }),
972
+ /* @__PURE__ */ jsx6(Body, { article, components: base.components, locale: c.locale }),
973
+ pub.canonical_path.startsWith("/") ? /* @__PURE__ */ jsxs5("a", { className: "hyle-more", href: c.href(pub.canonical_path, pub.locale), rel: "bookmark", children: [
974
+ c.s.readAtSource,
975
+ /* @__PURE__ */ jsxs5("span", { className: "hyle-sr", children: [
976
+ ": ",
977
+ pub.title
978
+ ] })
979
+ ] }) : null
980
+ ] }) });
981
+ }
982
+ var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((w) => [...w][0] ?? "").join("").toUpperCase() || "?";
983
+ function StaticThread({ nodes, locale, s, level = 1 }) {
984
+ return /* @__PURE__ */ jsx6("ol", { className: "hyle-cm-list", role: "list", children: nodes.map((node) => {
985
+ const kids = node.kids.length > 0 && level < 32 ? /* @__PURE__ */ jsx6(StaticThread, { nodes: node.kids, locale, s, level: level + 1 }) : null;
986
+ if (node.status === "removed") {
987
+ const why = node.removedBy === "moderator" ? s.removedByModerator : node.removedBy === "author" ? s.removedByAuthor : s.removed;
988
+ return /* @__PURE__ */ jsxs5("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "removed", "data-removed-by": node.removedBy, children: [
989
+ /* @__PURE__ */ jsxs5("article", { "aria-label": why, children: [
990
+ /* @__PURE__ */ jsx6("span", { className: "hyle-avatar", "aria-hidden": "true", children: /* @__PURE__ */ jsx6(Icon, { name: "ban" }) }),
991
+ /* @__PURE__ */ jsx6("div", { className: "hyle-cm-main", children: /* @__PURE__ */ jsx6("div", { className: "hyle-cm-body", children: /* @__PURE__ */ jsx6("p", { children: why }) }) })
992
+ ] }),
993
+ kids
994
+ ] }, node.id);
995
+ }
996
+ return /* @__PURE__ */ jsxs5("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "visible", children: [
997
+ /* @__PURE__ */ jsxs5("article", { children: [
998
+ /* @__PURE__ */ jsx6("span", { className: "hyle-avatar", "aria-hidden": "true", children: initials(node.name ?? "") }),
999
+ /* @__PURE__ */ jsxs5("div", { className: "hyle-cm-main", children: [
1000
+ /* @__PURE__ */ jsxs5("div", { className: "hyle-cm-by", children: [
1001
+ /* @__PURE__ */ jsx6("b", { children: node.name }),
1002
+ /* @__PURE__ */ jsxs5("span", { children: [
1003
+ /* @__PURE__ */ jsx6("time", { dateTime: node.createdAt, title: node.createdAt, children: formatDate(node.createdAt, locale) }),
1004
+ node.editedAt ? /* @__PURE__ */ jsxs5(Fragment5, { children: [
1005
+ " ",
1006
+ /* @__PURE__ */ jsx6("span", { "aria-hidden": "true", children: "\xB7" }),
1007
+ " ",
1008
+ /* @__PURE__ */ jsx6("span", { children: s.edited })
1009
+ ] }) : null
1010
+ ] })
1011
+ ] }),
1012
+ /* @__PURE__ */ jsx6(CommentBody, { tree: node.tree })
1013
+ ] })
1014
+ ] }),
1015
+ kids
1016
+ ] }, node.id);
1017
+ }) });
1018
+ }
1019
+ function HyleCommentsView({ listing, locale }) {
1020
+ const thread = buildThread(listing, []);
1021
+ if (thread.length === 0) return null;
1022
+ const s = stringsFor(locale).comments;
1023
+ return /* @__PURE__ */ jsx6("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ jsxs5("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", lang: locale, children: [
1024
+ /* @__PURE__ */ jsx6("div", { className: "hyle-cm-head", children: /* @__PURE__ */ jsxs5("h2", { children: [
1025
+ s.heading,
1026
+ " ",
1027
+ /* @__PURE__ */ jsx6("span", { className: "hyle-cm-count", "aria-label": s.countLabel.replace("{n}", String(listing.comment_count)), children: listing.comment_count })
1028
+ ] }) }),
1029
+ /* @__PURE__ */ jsx6(StaticThread, { nodes: thread, locale, s }),
1030
+ listing.truncated ? /* @__PURE__ */ jsx6("p", { className: "hyle-cm-note", children: s.truncated }) : null
1031
+ ] }) });
1032
+ }
1033
+ function HyleCommentsFallback({ locale }) {
1034
+ const s = stringsFor(locale).comments;
1035
+ return /* @__PURE__ */ jsx6("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ jsx6("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", children: /* @__PURE__ */ jsxs5("div", { role: "status", "aria-live": "polite", "aria-busy": "true", children: [
1036
+ /* @__PURE__ */ jsx6("span", { className: "hyle-sr", children: s.loading }),
1037
+ /* @__PURE__ */ jsx6("div", { "aria-hidden": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ jsxs5("div", { className: "hyle-cm-sk", children: [
1038
+ /* @__PURE__ */ jsx6("span", { className: "hyle-sk c" }),
1039
+ /* @__PURE__ */ jsxs5("div", { children: [
1040
+ /* @__PURE__ */ jsx6("span", { className: "hyle-sk l", style: { width: 120 } }),
1041
+ /* @__PURE__ */ jsx6("span", { className: "hyle-sk l", style: { width: "100%" } }),
1042
+ /* @__PURE__ */ jsx6("span", { className: "hyle-sk l", style: { width: "72%" } })
1043
+ ] })
1044
+ ] }, i)) })
1045
+ ] }) }) });
1046
+ }
1047
+
777
1048
  // src/react/seo.ts
778
1049
  var BARE_HTTPS_ORIGIN = /^https:\/\/[^/]+$/;
779
1050
  var bareOrigin = (origin) => origin && BARE_HTTPS_ORIGIN.test(origin) ? origin : void 0;
780
1051
  var absoluteUrl = (origin, href) => origin + encodeURI(href);
781
1052
  var modifiedAt = (pub) => pub.updated_at && Date.parse(pub.updated_at) > Date.parse(pub.published_at) ? pub.updated_at : void 0;
1053
+ var wordCountOf = (pub) => Number.isInteger(pub.word_count) && pub.word_count > 0 ? pub.word_count : void 0;
1054
+ var WORDS_PER_MINUTE = 275;
1055
+ var readingMinutes = (wordCount) => Math.max(1, Math.ceil(wordCount / WORDS_PER_MINUTE));
1056
+ var breadcrumbItems = (article, jsonLd) => [
1057
+ ...jsonLd?.breadcrumbRoot ? [{ title: jsonLd.breadcrumbRoot.name, canonical_path: "/" }] : [],
1058
+ ...article.breadcrumbs
1059
+ ];
1060
+ var crumbHref = (href, path, locale) => path === "/" ? href("/", locale).replace(/(.)\/$/, "$1") : href(path, locale);
782
1061
  function articleAuthor(article, jsonLd) {
1062
+ const authored = article.publication.author;
1063
+ if (authored?.name) return { name: authored.name, ...authored.url ? { url: authored.url } : {} };
783
1064
  const given = jsonLd?.author?.(article);
784
1065
  if (given && typeof given.name === "string" && given.name) return given;
785
1066
  const fromFrontmatter = article.frontmatter.author;
@@ -810,7 +1091,9 @@ function hreflangLanguages(members, defaultLocale, selfUrl, url) {
810
1091
 
811
1092
  // src/react/jsonld.ts
812
1093
  var script = (value) => JSON.stringify(value).replace(/</g, "\\u003c");
813
- function articleJsonLd({ article, origin, href, jsonLd, imageUrl }) {
1094
+ var organization = (publisher) => ({ "@type": "Organization", "@id": publisher.id, name: publisher.name, ...publisher.logo ? { logo: publisher.logo } : {} });
1095
+ var webSite = (website) => ({ "@type": "WebSite", "@id": website.id, name: website.name });
1096
+ function articleJsonLd({ article, origin, href, jsonLd, imageUrl, imageWidth, imageHeight }) {
814
1097
  const { publication: pub } = article;
815
1098
  const url = (path) => absoluteUrl(origin, href(path, pub.locale));
816
1099
  const canonical = url(pub.canonical_path);
@@ -820,7 +1103,9 @@ function articleJsonLd({ article, origin, href, jsonLd, imageUrl }) {
820
1103
  const publisher = jsonLd?.publisher;
821
1104
  const website = jsonLd?.website?.(pub.locale);
822
1105
  const modified = modifiedAt(pub);
823
- const root = jsonLd?.breadcrumbRoot;
1106
+ const words = wordCountOf(pub);
1107
+ const publisherNode = publisher ? organization(publisher) : void 0;
1108
+ const section = article.breadcrumbs[0]?.title;
824
1109
  const graph = [
825
1110
  ...full ? [{
826
1111
  "@type": "WebPage",
@@ -829,8 +1114,8 @@ function articleJsonLd({ article, origin, href, jsonLd, imageUrl }) {
829
1114
  name: pub.title,
830
1115
  ...pub.description ? { description: pub.description } : {},
831
1116
  inLanguage: pub.locale,
832
- ...website ? { isPartOf: { "@id": website.id } } : {},
833
- ...publisher ? { publisher: { "@id": publisher.id } } : {},
1117
+ ...website ? { isPartOf: webSite(website) } : {},
1118
+ ...publisherNode ? { publisher: publisherNode } : {},
834
1119
  breadcrumb: id("breadcrumb"),
835
1120
  mainEntity: id("article")
836
1121
  }] : [],
@@ -839,28 +1124,40 @@ function articleJsonLd({ article, origin, href, jsonLd, imageUrl }) {
839
1124
  ...id("article"),
840
1125
  headline: pub.title,
841
1126
  ...pub.description ? { description: pub.description } : {},
842
- datePublished: pub.published_at.slice(0, 10),
1127
+ datePublished: pub.published_at,
1128
+ ...section ? { articleSection: section } : {},
843
1129
  ...modified ? { dateModified: modified } : {},
1130
+ ...words ? { wordCount: words } : {},
844
1131
  url: canonical,
845
1132
  mainEntityOfPage: full ? id("webpage") : canonical,
846
- ...author ? { author: author.id ? { "@id": author.id } : { "@type": "Person", name: author.name, ...author.url ? { url: author.url } : {} } } : {},
847
- ...publisher ? { publisher: { "@id": publisher.id } } : {},
1133
+ ...author ? { author: { "@type": "Person", ...author.id ? { "@id": author.id } : {}, name: author.name, ...author.url ? { url: author.url } : {} } } : {},
1134
+ ...publisherNode ? { publisher: publisherNode } : {},
848
1135
  inLanguage: pub.locale,
849
- ...imageUrl ? { image: [imageUrl] } : {}
1136
+ ...imageUrl ? { image: imageWidth && imageHeight ? { "@type": "ImageObject", url: imageUrl, width: imageWidth, height: imageHeight } : [imageUrl] } : {}
850
1137
  },
851
1138
  {
852
1139
  "@type": "BreadcrumbList",
853
1140
  ...id("breadcrumb"),
854
- itemListElement: [...root ? [{ name: root.name, item: absoluteUrl(origin, href("/", pub.locale).replace(/(.)\/$/, "$1").replace(/^\/$/, "")) }] : [], ...article.breadcrumbs.map((b) => ({ name: b.title, item: url(b.canonical_path) }))].map((b, i) => ({ "@type": "ListItem", position: i + 1, ...b }))
1141
+ itemListElement: breadcrumbItems(article, jsonLd).map((b, i) => ({
1142
+ "@type": "ListItem",
1143
+ position: i + 1,
1144
+ name: b.title,
1145
+ item: absoluteUrl(origin, crumbHref(href, b.canonical_path, pub.locale).replace(/^\/$/, ""))
1146
+ }))
855
1147
  }
856
1148
  ];
857
1149
  return script({ "@context": "https://schema.org", "@graph": graph });
858
1150
  }
859
- function listJsonLd({ list, origin, href, path, locale, description }) {
1151
+ function listJsonLd({ list, origin, href, path, locale, description, jsonLd, cursor }) {
1152
+ const url = absoluteUrl(origin, href(path)) + (cursor ? `?cursor=${cursor}` : "");
1153
+ const website = jsonLd?.website?.(locale);
860
1154
  return script({
861
1155
  "@context": "https://schema.org",
862
1156
  "@type": "CollectionPage",
863
- url: absoluteUrl(origin, href(path)),
1157
+ ...jsonLd ? { "@id": `${url}#webpage` } : {},
1158
+ url,
1159
+ ...website ? { isPartOf: webSite(website) } : {},
1160
+ ...jsonLd?.publisher ? { publisher: organization(jsonLd.publisher) } : {},
864
1161
  name: list.section.title,
865
1162
  ...description ? { description } : {},
866
1163
  inLanguage: locale,
@@ -872,13 +1169,13 @@ function listJsonLd({ list, origin, href, path, locale, description }) {
872
1169
  }
873
1170
 
874
1171
  // src/react/pages.tsx
875
- import { Fragment as Fragment4, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1172
+ import { Fragment as Fragment6, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
876
1173
  function Slot({ name, slots, tag: Tag = "div", className }) {
877
1174
  const fill = slots?.[name];
878
- return fill ? /* @__PURE__ */ jsx4(Tag, { "data-slot": name, className, children: fill }) : null;
1175
+ return fill ? /* @__PURE__ */ jsx7(Tag, { "data-slot": name, className, children: fill }) : null;
879
1176
  }
880
1177
  function Shell({ children }) {
881
- return /* @__PURE__ */ jsx4("div", { className: "hyle", children: /* @__PURE__ */ jsx4("div", { className: "hyle-page", children }) });
1178
+ return /* @__PURE__ */ jsx7("div", { className: "hyle", children: /* @__PURE__ */ jsx7("div", { className: "hyle-page", children }) });
882
1179
  }
883
1180
  function ctx(p, fallbackLocale) {
884
1181
  const locale = p.locale ?? fallbackLocale;
@@ -887,23 +1184,32 @@ function ctx(p, fallbackLocale) {
887
1184
  function Pager({ prev, next, c }) {
888
1185
  if (!prev && !next) return null;
889
1186
  const { Link, s } = c;
890
- return /* @__PURE__ */ jsxs4("nav", { className: "hyle-pager", "aria-label": s.pager, children: [
891
- prev ? /* @__PURE__ */ jsxs4(Link, { href: c.href(prev.canonical_path), rel: "prev", children: [
892
- /* @__PURE__ */ jsxs4("span", { className: "dir", children: [
893
- /* @__PURE__ */ jsx4(Icon, { name: "chev-left" }),
1187
+ return /* @__PURE__ */ jsxs6("nav", { className: "hyle-pager", "aria-label": s.pager, children: [
1188
+ prev ? /* @__PURE__ */ jsxs6(Link, { href: c.href(prev.canonical_path), rel: "prev", children: [
1189
+ /* @__PURE__ */ jsxs6("span", { className: "dir", children: [
1190
+ /* @__PURE__ */ jsx7(Icon, { name: "chev-left" }),
894
1191
  s.prev
895
1192
  ] }),
896
- /* @__PURE__ */ jsx4("span", { className: "ttl", children: prev.title })
897
- ] }) : /* @__PURE__ */ jsx4("span", { className: "none", "aria-hidden": "true" }),
898
- next ? /* @__PURE__ */ jsxs4(Link, { href: c.href(next.canonical_path), rel: "next", className: "next", children: [
899
- /* @__PURE__ */ jsxs4("span", { className: "dir", children: [
1193
+ /* @__PURE__ */ jsx7("span", { className: "ttl", children: prev.title })
1194
+ ] }) : /* @__PURE__ */ jsx7("span", { className: "none", "aria-hidden": "true" }),
1195
+ next ? /* @__PURE__ */ jsxs6(Link, { href: c.href(next.canonical_path), rel: "next", className: "next", children: [
1196
+ /* @__PURE__ */ jsxs6("span", { className: "dir", children: [
900
1197
  s.next,
901
- /* @__PURE__ */ jsx4(Icon, { name: "chev" })
1198
+ /* @__PURE__ */ jsx7(Icon, { name: "chev" })
902
1199
  ] }),
903
- /* @__PURE__ */ jsx4("span", { className: "ttl", children: next.title })
1200
+ /* @__PURE__ */ jsx7("span", { className: "ttl", children: next.title })
904
1201
  ] }) : null
905
1202
  ] });
906
1203
  }
1204
+ function OlderNav({ href, c }) {
1205
+ return /* @__PURE__ */ jsxs6("nav", { className: "hyle-pagination", "aria-label": c.s.pager, children: [
1206
+ /* @__PURE__ */ jsx7("span", { className: "sp" }),
1207
+ /* @__PURE__ */ jsxs6(c.Link, { className: "hyle-btn sm", href, rel: "next", children: [
1208
+ c.s.older,
1209
+ /* @__PURE__ */ jsx7(Icon, { name: "chev" })
1210
+ ] })
1211
+ ] });
1212
+ }
907
1213
  function TocList({ toc }) {
908
1214
  const groups = [];
909
1215
  for (const entry of toc) {
@@ -911,9 +1217,9 @@ function TocList({ toc }) {
911
1217
  if (entry.depth === 3 && last) last.subs.push(entry);
912
1218
  else groups.push({ entry, subs: [] });
913
1219
  }
914
- return /* @__PURE__ */ jsx4("ul", { children: groups.map(({ entry, subs }) => /* @__PURE__ */ jsxs4("li", { children: [
915
- /* @__PURE__ */ jsx4("a", { href: `#${scopeId(entry.id)}`, children: entry.text }),
916
- subs.length > 0 ? /* @__PURE__ */ jsx4("ul", { children: subs.map((sub) => /* @__PURE__ */ jsx4("li", { children: /* @__PURE__ */ jsx4("a", { href: `#${scopeId(sub.id)}`, children: sub.text }) }, sub.id)) }) : null
1220
+ return /* @__PURE__ */ jsx7("ul", { children: groups.map(({ entry, subs }) => /* @__PURE__ */ jsxs6("li", { children: [
1221
+ /* @__PURE__ */ jsx7("a", { href: `#${scopeId(entry.id)}`, children: entry.text }),
1222
+ subs.length > 0 ? /* @__PURE__ */ jsx7("ul", { children: subs.map((sub) => /* @__PURE__ */ jsx7("li", { children: /* @__PURE__ */ jsx7("a", { href: `#${scopeId(sub.id)}`, children: sub.text }) }, sub.id)) }) : null
917
1223
  ] }, entry.id)) });
918
1224
  }
919
1225
  function Toc({ toc, c, aside }) {
@@ -921,18 +1227,18 @@ function Toc({ toc, c, aside }) {
921
1227
  if (entries.length === 0 && !aside) return { narrow: null, wide: null };
922
1228
  const { s } = c;
923
1229
  return {
924
- narrow: entries.length === 0 ? null : /* @__PURE__ */ jsxs4("details", { className: "hyle-toc-m", children: [
925
- /* @__PURE__ */ jsxs4("summary", { children: [
926
- /* @__PURE__ */ jsx4(Icon, { name: "file" }),
1230
+ narrow: entries.length === 0 ? null : /* @__PURE__ */ jsxs6("details", { className: "hyle-toc-m", children: [
1231
+ /* @__PURE__ */ jsxs6("summary", { children: [
1232
+ /* @__PURE__ */ jsx7(Icon, { name: "file" }),
927
1233
  s.toc,
928
- /* @__PURE__ */ jsx4(Icon, { name: "chev-down", className: "hyle-chev" })
1234
+ /* @__PURE__ */ jsx7(Icon, { name: "chev-down", className: "hyle-chev" })
929
1235
  ] }),
930
- /* @__PURE__ */ jsx4("nav", { className: "hyle-toc-list", "aria-label": s.toc, children: /* @__PURE__ */ jsx4(TocList, { toc: entries }) })
1236
+ /* @__PURE__ */ jsx7("nav", { className: "hyle-toc-list", "aria-label": s.toc, children: /* @__PURE__ */ jsx7(TocList, { toc: entries }) })
931
1237
  ] }),
932
- wide: /* @__PURE__ */ jsxs4("aside", { className: "hyle-toc-d", "aria-label": s.toc, children: [
933
- entries.length === 0 ? null : /* @__PURE__ */ jsxs4(Fragment4, { children: [
934
- /* @__PURE__ */ jsx4("p", { className: "hyle-toc-title", children: s.toc }),
935
- /* @__PURE__ */ jsx4("nav", { className: "hyle-toc-list", children: /* @__PURE__ */ jsx4(TocList, { toc: entries }) })
1238
+ wide: /* @__PURE__ */ jsxs6("aside", { className: "hyle-toc-d", "aria-label": s.toc, children: [
1239
+ entries.length === 0 ? null : /* @__PURE__ */ jsxs6(Fragment6, { children: [
1240
+ /* @__PURE__ */ jsx7("p", { className: "hyle-toc-title", children: s.toc }),
1241
+ /* @__PURE__ */ jsx7("nav", { className: "hyle-toc-list", children: /* @__PURE__ */ jsx7(TocList, { toc: entries }) })
936
1242
  ] }),
937
1243
  aside
938
1244
  ] })
@@ -940,76 +1246,97 @@ function Toc({ toc, c, aside }) {
940
1246
  }
941
1247
  function Body({ article, components, locale }) {
942
1248
  const { content, publication } = article;
943
- return /* @__PURE__ */ jsx4("div", { className: "hyle-body hyle-prose", lang: article.fallback ? void 0 : publication.locale, children: content.format === "hast" ? /* @__PURE__ */ jsx4(HastContent, { tree: content.tree, title: publication.title, description: publication.description, components: components ?? {}, locale }) : content.format === "html" ? /* @__PURE__ */ jsx4(TrustedServerHtml, { html: content.html }) : null });
1249
+ return /* @__PURE__ */ jsx7("div", { className: "hyle-body hyle-prose", lang: article.fallback ? void 0 : publication.locale, children: content.format === "hast" ? /* @__PURE__ */ jsx7(HastContent, { tree: content.tree, title: publication.title, description: publication.description, components: components ?? {}, locale }) : content.format === "html" ? /* @__PURE__ */ jsx7(TrustedServerHtml, { html: content.html }) : null });
944
1250
  }
945
1251
  function Languages({ alternates, current, c }) {
946
1252
  if (alternates.length < 2) return null;
947
1253
  const { Link, s } = c;
948
- return /* @__PURE__ */ jsxs4("nav", { className: "hyle-langs", "aria-label": s.languages, children: [
949
- /* @__PURE__ */ jsx4("span", { children: s.readIn }),
950
- /* @__PURE__ */ jsx4("ul", { children: alternates.map((a) => {
1254
+ return /* @__PURE__ */ jsxs6("nav", { className: "hyle-langs", "aria-label": s.languages, children: [
1255
+ /* @__PURE__ */ jsx7("span", { children: s.readIn }),
1256
+ /* @__PURE__ */ jsx7("ul", { children: alternates.map((a) => {
951
1257
  const label = languageName(a.locale, a.locale);
952
- return /* @__PURE__ */ jsx4("li", { children: a.locale === current ? /* @__PURE__ */ jsx4("a", { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, "aria-current": "true", children: label }) : /* @__PURE__ */ jsx4(Link, { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, children: label }) }, a.locale);
1258
+ return /* @__PURE__ */ jsx7("li", { children: a.locale === current ? /* @__PURE__ */ jsx7("a", { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, "aria-current": "true", children: label }) : /* @__PURE__ */ jsx7(Link, { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, children: label }) }, a.locale);
953
1259
  }) })
954
1260
  ] });
955
1261
  }
956
1262
  function LdScript({ json }) {
957
- return /* @__PURE__ */ jsx4("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: json } });
1263
+ return /* @__PURE__ */ jsx7("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: json } });
1264
+ }
1265
+ function Crumbs({ items, c }) {
1266
+ const { Link } = c;
1267
+ return /* @__PURE__ */ jsx7("nav", { className: "hyle-crumbs", "aria-label": c.s.crumbs, children: /* @__PURE__ */ jsx7("ol", { children: items.map((b, i) => /* @__PURE__ */ jsx7("li", { "aria-current": i === items.length - 1 ? "page" : void 0, children: i === items.length - 1 ? b.title : /* @__PURE__ */ jsx7(Link, { href: crumbHref(c.href, b.canonical_path, c.locale), children: b.title }) }, b.canonical_path)) }) });
958
1268
  }
959
- function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, ...base }) {
1269
+ function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, imageWidth, imageHeight, related, ...base }) {
960
1270
  const { publication: pub } = article;
961
1271
  const c = ctx(base, pub.locale);
962
1272
  const { s } = c;
963
1273
  const jsonLdOrigin = bareOrigin(origin);
964
1274
  const author = articleAuthor(article, jsonLd)?.name;
965
- const toc = Toc({ toc: article.toc, c, aside: /* @__PURE__ */ jsx4(Slot, { name: "article.aside", slots: base.slots, className: "hyle-slot-wrap" }) });
1275
+ const modified = modifiedAt(pub);
1276
+ const words = wordCountOf(pub);
1277
+ const toc = Toc({ toc: article.toc, c, aside: /* @__PURE__ */ jsx7(Slot, { name: "article.aside", slots: base.slots, className: "hyle-slot-wrap" }) });
966
1278
  const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
967
- return /* @__PURE__ */ jsx4(Shell, { children: /* @__PURE__ */ jsxs4("article", { className: "hyle-article", "data-hyle-page": "article", lang: c.locale, children: [
968
- /* @__PURE__ */ jsxs4("header", { className: "hyle-head", children: [
969
- /* @__PURE__ */ jsx4(Slot, { name: "article.before", slots: base.slots, className: "hyle-eyebrow" }),
970
- /* @__PURE__ */ jsx4("h1", { className: "hyle-title", children: pub.title }),
971
- pub.description ? /* @__PURE__ */ jsx4("p", { className: "hyle-desc", children: pub.description }) : null,
972
- /* @__PURE__ */ jsxs4("div", { className: "hyle-meta", children: [
973
- author ? /* @__PURE__ */ jsxs4("span", { children: [
974
- /* @__PURE__ */ jsx4("span", { className: "hyle-avatar", "aria-hidden": "true", children: author.slice(0, 2).toUpperCase() }),
975
- /* @__PURE__ */ jsxs4("span", { children: [
976
- /* @__PURE__ */ jsxs4("span", { className: "hyle-sr", children: [
1279
+ return /* @__PURE__ */ jsx7(Shell, { children: /* @__PURE__ */ jsxs6("article", { className: "hyle-article", "data-hyle-page": "article", lang: c.locale, children: [
1280
+ /* @__PURE__ */ jsxs6("header", { className: "hyle-head", children: [
1281
+ /* @__PURE__ */ jsx7(Slot, { name: "article.before", slots: base.slots, className: "hyle-eyebrow" }),
1282
+ /* @__PURE__ */ jsx7(Crumbs, { items: breadcrumbItems(article, jsonLd), c }),
1283
+ /* @__PURE__ */ jsx7("h1", { className: "hyle-title", children: pub.title }),
1284
+ pub.description ? /* @__PURE__ */ jsx7("p", { className: "hyle-desc", children: pub.description }) : null,
1285
+ /* @__PURE__ */ jsxs6("div", { className: "hyle-meta", children: [
1286
+ author ? /* @__PURE__ */ jsxs6("span", { children: [
1287
+ /* @__PURE__ */ jsx7("span", { className: "hyle-avatar", "aria-hidden": "true", children: author.slice(0, 2).toUpperCase() }),
1288
+ /* @__PURE__ */ jsxs6("span", { children: [
1289
+ /* @__PURE__ */ jsxs6("span", { className: "hyle-sr", children: [
977
1290
  s.by,
978
1291
  " "
979
1292
  ] }),
980
- /* @__PURE__ */ jsx4("span", { className: "by", children: author })
1293
+ /* @__PURE__ */ jsx7("span", { className: "by", children: author })
981
1294
  ] })
982
1295
  ] }) : null,
983
- /* @__PURE__ */ jsxs4("span", { children: [
984
- /* @__PURE__ */ jsx4(Icon, { name: "calendar" }),
985
- /* @__PURE__ */ jsx4("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) })
1296
+ /* @__PURE__ */ jsxs6("span", { children: [
1297
+ /* @__PURE__ */ jsx7(Icon, { name: "calendar" }),
1298
+ /* @__PURE__ */ jsx7("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) })
986
1299
  ] }),
987
- /* @__PURE__ */ jsxs4("span", { children: [
988
- /* @__PURE__ */ jsx4(Icon, { name: "globe" }),
989
- /* @__PURE__ */ jsx4("span", { lang: pub.locale, children: languageName(pub.locale, c.locale) })
1300
+ modified ? /* @__PURE__ */ jsxs6("span", { children: [
1301
+ /* @__PURE__ */ jsx7(Icon, { name: "calendar" }),
1302
+ s.updated,
1303
+ " ",
1304
+ /* @__PURE__ */ jsx7("time", { dateTime: modified, title: modified, children: formatDate(modified, c.locale) })
1305
+ ] }) : null,
1306
+ words ? /* @__PURE__ */ jsxs6("span", { children: [
1307
+ /* @__PURE__ */ jsx7(Icon, { name: "clock" }),
1308
+ s.readingTime.replace("{n}", String(readingMinutes(words)))
1309
+ ] }) : null,
1310
+ /* @__PURE__ */ jsxs6("span", { children: [
1311
+ /* @__PURE__ */ jsx7(Icon, { name: "globe" }),
1312
+ /* @__PURE__ */ jsx7("span", { lang: pub.locale, children: languageName(pub.locale, c.locale) })
990
1313
  ] }),
991
- /* @__PURE__ */ jsx4(Slot, { name: "article.meta", slots: base.slots, tag: "span" })
1314
+ /* @__PURE__ */ jsx7(Slot, { name: "article.meta", slots: base.slots, tag: "span" })
992
1315
  ] }),
993
- /* @__PURE__ */ jsx4(Languages, { alternates: article.alternates, current: pub.locale, c }),
994
- notTranslated ? /* @__PURE__ */ jsxs4("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
995
- /* @__PURE__ */ jsx4(Icon, { name: "alert" }),
996
- /* @__PURE__ */ jsxs4("div", { children: [
997
- /* @__PURE__ */ jsx4("b", { children: notTranslated }),
1316
+ /* @__PURE__ */ jsx7(Languages, { alternates: article.alternates, current: pub.locale, c }),
1317
+ notTranslated ? /* @__PURE__ */ jsxs6("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
1318
+ /* @__PURE__ */ jsx7(Icon, { name: "alert" }),
1319
+ /* @__PURE__ */ jsxs6("div", { children: [
1320
+ /* @__PURE__ */ jsx7("b", { children: notTranslated }),
998
1321
  " ",
999
1322
  s.fallbackBody
1000
1323
  ] })
1001
1324
  ] }) : null
1002
1325
  ] }),
1003
1326
  toc.narrow,
1004
- /* @__PURE__ */ jsx4(Body, { article, components: base.components, locale: c.locale }),
1005
- engagement ? /* @__PURE__ */ jsx4(Comments, { path: pub.canonical_path, endpoint: engagement.endpoint ?? "/api/hyle/engage", signInHref: engagement.signInHref, locale: c.locale, labels: s.comments }) : null,
1006
- /* @__PURE__ */ jsx4(Pager, { prev: article.prev, next: article.next, c }),
1007
- /* @__PURE__ */ jsx4(Slot, { name: "article.after", slots: base.slots, className: "hyle-after" }),
1327
+ /* @__PURE__ */ jsx7(Body, { article, components: base.components, locale: c.locale }),
1328
+ engagement ? /* @__PURE__ */ jsx7(Comments, { path: pub.canonical_path, endpoint: engagement.endpoint ?? "/api/hyle/engage", signInHref: engagement.signInHref, locale: c.locale, labels: s.comments }) : null,
1329
+ /* @__PURE__ */ jsx7(Pager, { prev: article.prev, next: article.next, c }),
1330
+ related ? /* @__PURE__ */ jsxs6(Fragment6, { children: [
1331
+ related.items.length > 0 ? /* @__PURE__ */ jsx7(HyleListView, { items: related.items, title: related.title ?? s.moreInSection, ...base, locale: c.locale }) : null,
1332
+ article.children.length > 0 ? /* @__PURE__ */ jsx7(HyleListView, { items: article.children.map((child) => ({ ...child, description: null, published_at: "" })), title: s.subPages, ...base, locale: c.locale }) : null
1333
+ ] }) : null,
1334
+ /* @__PURE__ */ jsx7(Slot, { name: "article.after", slots: base.slots, className: "hyle-after" }),
1008
1335
  toc.wide,
1009
- jsonLdOrigin ? /* @__PURE__ */ jsx4(LdScript, { json: articleJsonLd({ article, origin: jsonLdOrigin, href: c.href, jsonLd, imageUrl }) }) : null
1336
+ jsonLdOrigin ? /* @__PURE__ */ jsx7(LdScript, { json: articleJsonLd({ article, origin: jsonLdOrigin, href: c.href, jsonLd, imageUrl, imageWidth, imageHeight }) }) : null
1010
1337
  ] }) });
1011
1338
  }
1012
- function ListPage({ list, olderHref, description, origin, path, ...base }) {
1339
+ function ListPage({ list, olderHref, description, origin, path, jsonLd, cursor, ...base }) {
1013
1340
  const c = ctx(base, "en");
1014
1341
  const { s, Link } = c;
1015
1342
  const Row = base.slots?.["list.item"];
@@ -1017,335 +1344,91 @@ function ListPage({ list, olderHref, description, origin, path, ...base }) {
1017
1344
  for (const item of list.items) groups.set(item.published_at.slice(0, 7), [...groups.get(item.published_at.slice(0, 7)) ?? [], item]);
1018
1345
  const notTranslated = list.fallback ? s.fallbackTitle.replace("{language}", languageName(list.fallback.requested_locale, c.locale)) : void 0;
1019
1346
  const jsonLdOrigin = bareOrigin(origin);
1020
- return /* @__PURE__ */ jsx4(Shell, { children: /* @__PURE__ */ jsxs4("div", { className: "hyle-listpage", "data-hyle-page": "list", lang: c.locale, children: [
1021
- /* @__PURE__ */ jsxs4("header", { className: "hyle-head", children: [
1022
- /* @__PURE__ */ jsx4("h1", { className: "hyle-title", children: list.section.title }),
1023
- description ? /* @__PURE__ */ jsx4("p", { className: "hyle-desc", children: description }) : null,
1024
- /* @__PURE__ */ jsx4(Slot, { name: "list.header", slots: base.slots, className: "hyle-slot-wrap" }),
1025
- notTranslated ? /* @__PURE__ */ jsxs4("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
1026
- /* @__PURE__ */ jsx4(Icon, { name: "alert" }),
1027
- /* @__PURE__ */ jsxs4("div", { children: [
1028
- /* @__PURE__ */ jsx4("b", { children: notTranslated }),
1347
+ return /* @__PURE__ */ jsx7(Shell, { children: /* @__PURE__ */ jsxs6("div", { className: "hyle-listpage", "data-hyle-page": "list", lang: c.locale, children: [
1348
+ /* @__PURE__ */ jsxs6("header", { className: "hyle-head", children: [
1349
+ /* @__PURE__ */ jsx7("h1", { className: "hyle-title", children: list.section.title }),
1350
+ description ? /* @__PURE__ */ jsx7("p", { className: "hyle-desc", children: description }) : null,
1351
+ /* @__PURE__ */ jsx7(Slot, { name: "list.header", slots: base.slots, className: "hyle-slot-wrap" }),
1352
+ notTranslated ? /* @__PURE__ */ jsxs6("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
1353
+ /* @__PURE__ */ jsx7(Icon, { name: "alert" }),
1354
+ /* @__PURE__ */ jsxs6("div", { children: [
1355
+ /* @__PURE__ */ jsx7("b", { children: notTranslated }),
1029
1356
  " ",
1030
1357
  s.fallbackBody
1031
1358
  ] })
1032
1359
  ] }) : null
1033
1360
  ] }),
1034
- list.items.length === 0 ? /* @__PURE__ */ jsxs4("div", { className: "hyle-empty", "data-slot-state": "empty", children: [
1035
- /* @__PURE__ */ jsx4(Icon, { name: "file" }),
1036
- /* @__PURE__ */ jsx4("h2", { children: s.emptyTitle }),
1037
- /* @__PURE__ */ jsx4("p", { children: s.emptyBody }),
1038
- /* @__PURE__ */ jsx4(Slot, { name: "list.empty", slots: base.slots })
1039
- ] }) : [...groups].map(([month, items]) => /* @__PURE__ */ jsxs4("section", { "aria-label": formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }), children: [
1040
- /* @__PURE__ */ jsx4("h2", { className: "hyle-year", children: formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }) }),
1041
- /* @__PURE__ */ jsx4("ul", { className: "hyle-items", children: items.map((item) => /* @__PURE__ */ jsx4("li", { children: Row ? /* @__PURE__ */ jsx4(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ jsxs4(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
1042
- /* @__PURE__ */ jsx4("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }),
1043
- /* @__PURE__ */ jsxs4("div", { children: [
1044
- /* @__PURE__ */ jsx4("span", { className: "t", children: item.title }),
1045
- item.description ? /* @__PURE__ */ jsx4("p", { children: item.description }) : null
1361
+ list.items.length === 0 ? /* @__PURE__ */ jsxs6("div", { className: "hyle-empty", "data-slot-state": "empty", children: [
1362
+ /* @__PURE__ */ jsx7(Icon, { name: "file" }),
1363
+ /* @__PURE__ */ jsx7("h2", { children: s.emptyTitle }),
1364
+ /* @__PURE__ */ jsx7("p", { children: s.emptyBody }),
1365
+ /* @__PURE__ */ jsx7(Slot, { name: "list.empty", slots: base.slots })
1366
+ ] }) : [...groups].map(([month, items]) => /* @__PURE__ */ jsxs6("section", { "aria-label": formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }), children: [
1367
+ /* @__PURE__ */ jsx7("h2", { className: "hyle-year", children: formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }) }),
1368
+ /* @__PURE__ */ jsx7("ul", { className: "hyle-items", children: items.map((item) => /* @__PURE__ */ jsx7("li", { children: Row ? /* @__PURE__ */ jsx7(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ jsxs6(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
1369
+ /* @__PURE__ */ jsx7("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }),
1370
+ /* @__PURE__ */ jsxs6("div", { children: [
1371
+ /* @__PURE__ */ jsx7("span", { className: "t", children: item.title }),
1372
+ item.description ? /* @__PURE__ */ jsx7("p", { children: item.description }) : null
1046
1373
  ] })
1047
1374
  ] }) }, item.canonical_path)) })
1048
1375
  ] }, month)),
1049
- olderHref ? /* @__PURE__ */ jsxs4("nav", { className: "hyle-pagination", "aria-label": s.pager, children: [
1050
- /* @__PURE__ */ jsx4("span", { className: "sp" }),
1051
- /* @__PURE__ */ jsxs4(Link, { className: "hyle-btn sm", href: olderHref, rel: "next", children: [
1052
- s.older,
1053
- /* @__PURE__ */ jsx4(Icon, { name: "chev" })
1054
- ] })
1055
- ] }) : null,
1056
- jsonLdOrigin && path ? /* @__PURE__ */ jsx4(LdScript, { json: listJsonLd({ list, origin: jsonLdOrigin, href: c.href, path, locale: c.locale, description }) }) : null
1376
+ olderHref ? /* @__PURE__ */ jsx7(OlderNav, { href: olderHref, c }) : null,
1377
+ jsonLdOrigin && path ? /* @__PURE__ */ jsx7(LdScript, { json: listJsonLd({ list, origin: jsonLdOrigin, href: c.href, path, locale: c.locale, description, jsonLd, cursor }) }) : null
1057
1378
  ] }) });
1058
1379
  }
1059
1380
  function NotFound({ path, homeHref = "/", ...base }) {
1060
1381
  const c = ctx(base, "en");
1061
1382
  const { Link, s } = c;
1062
1383
  const body = base.slots?.["notfound.body"];
1063
- return /* @__PURE__ */ jsx4(Shell, { children: /* @__PURE__ */ jsxs4("section", { className: "hyle-state", "data-hyle-page": "not-found", lang: c.locale, children: [
1064
- /* @__PURE__ */ jsx4("span", { className: "kind", children: s.nfKind }),
1065
- /* @__PURE__ */ jsx4("h1", { children: s.nfTitle }),
1066
- body ? /* @__PURE__ */ jsx4("div", { "data-slot": "notfound.body", children: body }) : /* @__PURE__ */ jsx4("p", { children: s.nfBody }),
1067
- path ? /* @__PURE__ */ jsx4("dl", { className: "hyle-addr", children: /* @__PURE__ */ jsxs4("div", { children: [
1068
- /* @__PURE__ */ jsx4("dt", { children: s.path }),
1069
- /* @__PURE__ */ jsx4("dd", { children: path })
1384
+ return /* @__PURE__ */ jsx7(Shell, { children: /* @__PURE__ */ jsxs6("section", { className: "hyle-state", "data-hyle-page": "not-found", lang: c.locale, children: [
1385
+ /* @__PURE__ */ jsx7("span", { className: "kind", children: s.nfKind }),
1386
+ /* @__PURE__ */ jsx7("h1", { children: s.nfTitle }),
1387
+ body ? /* @__PURE__ */ jsx7("div", { "data-slot": "notfound.body", children: body }) : /* @__PURE__ */ jsx7("p", { children: s.nfBody }),
1388
+ path ? /* @__PURE__ */ jsx7("dl", { className: "hyle-addr", children: /* @__PURE__ */ jsxs6("div", { children: [
1389
+ /* @__PURE__ */ jsx7("dt", { children: s.path }),
1390
+ /* @__PURE__ */ jsx7("dd", { children: path })
1070
1391
  ] }) }) : null,
1071
- /* @__PURE__ */ jsxs4("div", { className: "hyle-actions", children: [
1072
- /* @__PURE__ */ jsx4(Link, { className: "hyle-btn primary", href: c.href(homeHref), children: s.home }),
1073
- /* @__PURE__ */ jsx4(Slot, { name: "notfound.actions", slots: base.slots, tag: "span" })
1392
+ /* @__PURE__ */ jsxs6("div", { className: "hyle-actions", children: [
1393
+ /* @__PURE__ */ jsx7(Link, { className: "hyle-btn primary", href: crumbHref(c.href, homeHref, c.locale), children: s.home }),
1394
+ /* @__PURE__ */ jsx7(Slot, { name: "notfound.actions", slots: base.slots, tag: "span" })
1074
1395
  ] })
1075
1396
  ] }) });
1076
1397
  }
1077
1398
  function Unavailable(base) {
1078
1399
  const c = ctx(base, "en");
1079
- return /* @__PURE__ */ jsx4(Shell, { children: /* @__PURE__ */ jsxs4("section", { className: "hyle-state", "data-hyle-page": "unavailable", lang: c.locale, role: "status", children: [
1080
- /* @__PURE__ */ jsx4("span", { className: "kind", children: c.s.unKind }),
1081
- /* @__PURE__ */ jsx4("h1", { children: c.s.unTitle }),
1082
- /* @__PURE__ */ jsx4("p", { children: c.s.unBody })
1400
+ return /* @__PURE__ */ jsx7(Shell, { children: /* @__PURE__ */ jsxs6("section", { className: "hyle-state", "data-hyle-page": "unavailable", lang: c.locale, role: "status", children: [
1401
+ /* @__PURE__ */ jsx7("span", { className: "kind", children: c.s.unKind }),
1402
+ /* @__PURE__ */ jsx7("h1", { children: c.s.unTitle }),
1403
+ /* @__PURE__ */ jsx7("p", { children: c.s.unBody })
1083
1404
  ] }) });
1084
1405
  }
1085
1406
  function Redirecting({ from, to, ...base }) {
1086
1407
  const c = ctx(base, "en");
1087
1408
  const { Link, s } = c;
1088
1409
  const extra = base.slots?.["redirecting.body"];
1089
- return /* @__PURE__ */ jsx4(Shell, { children: /* @__PURE__ */ jsxs4("section", { className: "hyle-state", "data-hyle-page": "redirecting", role: "status", lang: c.locale, children: [
1090
- /* @__PURE__ */ jsx4("span", { className: "kind", children: s.rdKind }),
1091
- /* @__PURE__ */ jsx4("h1", { children: s.rdTitle }),
1092
- /* @__PURE__ */ jsx4("p", { children: s.rdBody }),
1093
- /* @__PURE__ */ jsxs4("dl", { className: "hyle-addr", children: [
1094
- from ? /* @__PURE__ */ jsxs4("div", { children: [
1095
- /* @__PURE__ */ jsx4("dt", { children: s.from }),
1096
- /* @__PURE__ */ jsx4("dd", { children: from })
1410
+ return /* @__PURE__ */ jsx7(Shell, { children: /* @__PURE__ */ jsxs6("section", { className: "hyle-state", "data-hyle-page": "redirecting", role: "status", lang: c.locale, children: [
1411
+ /* @__PURE__ */ jsx7("span", { className: "kind", children: s.rdKind }),
1412
+ /* @__PURE__ */ jsx7("h1", { children: s.rdTitle }),
1413
+ /* @__PURE__ */ jsx7("p", { children: s.rdBody }),
1414
+ /* @__PURE__ */ jsxs6("dl", { className: "hyle-addr", children: [
1415
+ from ? /* @__PURE__ */ jsxs6("div", { children: [
1416
+ /* @__PURE__ */ jsx7("dt", { children: s.from }),
1417
+ /* @__PURE__ */ jsx7("dd", { children: from })
1097
1418
  ] }) : null,
1098
- /* @__PURE__ */ jsxs4("div", { children: [
1099
- /* @__PURE__ */ jsx4("dt", { children: s.to }),
1100
- /* @__PURE__ */ jsx4("dd", { children: to })
1419
+ /* @__PURE__ */ jsxs6("div", { children: [
1420
+ /* @__PURE__ */ jsx7("dt", { children: s.to }),
1421
+ /* @__PURE__ */ jsx7("dd", { children: to })
1101
1422
  ] })
1102
1423
  ] }),
1103
- /* @__PURE__ */ jsx4("p", { className: "fine", children: /* @__PURE__ */ jsx4(Link, { href: c.href(to), children: s.rdFallback }) }),
1104
- extra ? /* @__PURE__ */ jsx4("p", { "data-slot": "redirecting.body", className: "fine", children: extra }) : null
1424
+ /* @__PURE__ */ jsx7("p", { className: "fine", children: /* @__PURE__ */ jsx7(Link, { href: c.href(to), children: s.rdFallback }) }),
1425
+ extra ? /* @__PURE__ */ jsx7("p", { "data-slot": "redirecting.body", className: "fine", children: extra }) : null
1105
1426
  ] }) });
1106
1427
  }
1107
1428
 
1108
1429
  // src/react/index.ts
1109
1430
  import { Comments as Comments2 } from "./comments.js";
1110
1431
 
1111
- // src/react/comments-api.ts
1112
- var isObject2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
1113
- var count = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? Math.trunc(v) : 0;
1114
- function toComment(raw) {
1115
- if (!isObject2(raw) || typeof raw.id !== "string" || typeof raw.created_at !== "string") return void 0;
1116
- const depth = typeof raw.depth === "number" ? Math.min(4, Math.max(1, Math.trunc(raw.depth))) : 1;
1117
- const author = isObject2(raw.author) && typeof raw.author.name === "string" ? raw.author.name : void 0;
1118
- const name = typeof raw.author_name === "string" ? raw.author_name : author;
1119
- const body = isObject2(raw.body) && raw.body.format === "hast" ? { format: "hast", tree: raw.body.tree } : null;
1120
- const removed = raw.removed === true || body === null;
1121
- return {
1122
- id: raw.id,
1123
- parent_id: typeof raw.parent_id === "string" ? raw.parent_id : null,
1124
- depth,
1125
- author_name: name ?? null,
1126
- created_at: raw.created_at,
1127
- edited_at: typeof raw.edited_at === "string" ? raw.edited_at : null,
1128
- like_count: count(raw.like_count),
1129
- removed,
1130
- ...removed && (raw.removed_by === "moderator" || raw.removed_by === "author") ? { removed_by: raw.removed_by } : {},
1131
- body,
1132
- // Viewer members exist only on a live comment of a viewer-aware listing; a tombstone never carries them.
1133
- ...!removed && typeof raw.mine === "boolean" ? { mine: raw.mine, liked_by_me: raw.liked_by_me === true, can_edit_until: typeof raw.can_edit_until === "string" ? raw.can_edit_until : null } : {}
1134
- };
1135
- }
1136
- function toHeld(raw) {
1137
- if (!isObject2(raw) || typeof raw.id !== "string" || typeof raw.created_at !== "string" || !isObject2(raw.body) || raw.body.format !== "hast") return void 0;
1138
- const author = isObject2(raw.author) && typeof raw.author.name === "string" ? raw.author.name : null;
1139
- return {
1140
- id: raw.id,
1141
- parent_id: typeof raw.parent_id === "string" ? raw.parent_id : null,
1142
- depth: typeof raw.depth === "number" ? Math.min(4, Math.max(1, Math.trunc(raw.depth))) : 1,
1143
- author_name: author,
1144
- created_at: raw.created_at,
1145
- edited_at: typeof raw.edited_at === "string" ? raw.edited_at : null,
1146
- can_edit_until: typeof raw.can_edit_until === "string" ? raw.can_edit_until : null,
1147
- body: { format: "hast", tree: raw.body.tree }
1148
- };
1149
- }
1150
- function parseListing(data) {
1151
- if (!isObject2(data) || data.kind !== "comments" || !Array.isArray(data.comments)) return void 0;
1152
- const comments = data.comments.map(toComment).filter((c) => c !== void 0);
1153
- const viewer = Array.isArray(data.mine_held) ? { liked_by_me: data.liked_by_me === true, mine_held: data.mine_held.slice(0, 5).map(toHeld).filter((h) => h !== void 0) } : {};
1154
- return { cp: 1, kind: "comments", publication_id: String(data.publication_id ?? ""), comment_count: count(data.comment_count), like_count: count(data.like_count), truncated: data.truncated === true, comments, ...viewer };
1155
- }
1156
- var untilMs = (iso) => {
1157
- const t = iso ? Date.parse(iso) : NaN;
1158
- return Number.isFinite(t) ? t : void 0;
1159
- };
1160
- function buildThread(listing, localHeld) {
1161
- const byId = /* @__PURE__ */ new Map();
1162
- const roots = [];
1163
- const place = (node, parentId) => {
1164
- const parent = parentId ? byId.get(parentId) : void 0;
1165
- (parent ? parent.kids : roots).push(node);
1166
- };
1167
- for (const c of listing.comments) {
1168
- if (byId.has(c.id)) continue;
1169
- const removed = c.removed;
1170
- const node = {
1171
- id: c.id,
1172
- depth: c.depth,
1173
- status: removed ? "removed" : "visible",
1174
- removedBy: removed ? c.removed_by : void 0,
1175
- mine: !removed && c.mine === true,
1176
- canEditUntil: untilMs(c.can_edit_until),
1177
- likedByMe: !removed && c.liked_by_me === true,
1178
- name: removed ? null : c.author_name ?? null,
1179
- createdAt: c.created_at,
1180
- editedAt: c.edited_at,
1181
- likes: c.like_count,
1182
- tree: c.body?.tree,
1183
- text: void 0,
1184
- kids: []
1185
- };
1186
- place(node, c.parent_id === c.id ? null : c.parent_id);
1187
- byId.set(c.id, node);
1188
- }
1189
- const mine = [];
1190
- const addHeld = (node, parentId, oldestFirst) => {
1191
- const parent = parentId ? byId.get(parentId) : void 0;
1192
- if (parent) parent.kids.push(node);
1193
- else if (oldestFirst) mine.unshift(node);
1194
- else mine.push(node);
1195
- };
1196
- const heldIds = /* @__PURE__ */ new Set();
1197
- for (const h of listing.mine_held ?? []) {
1198
- heldIds.add(h.id);
1199
- const parent = h.parent_id ? byId.get(h.parent_id) : void 0;
1200
- addHeld({ id: h.id, depth: Math.min(4, (parent?.depth ?? h.depth - 1) + 1), status: "held", removedBy: void 0, mine: true, canEditUntil: untilMs(h.can_edit_until), likedByMe: false, name: h.author_name, createdAt: h.created_at, editedAt: h.edited_at, likes: 0, tree: h.body?.tree, text: void 0, kids: [] }, h.parent_id, true);
1201
- }
1202
- if (listing.mine_held === void 0) {
1203
- for (const h of localHeld) {
1204
- if (byId.has(h.id) || heldIds.has(h.id)) continue;
1205
- const parent = h.parentId ? byId.get(h.parentId) : void 0;
1206
- addHeld({ id: h.id, depth: Math.min(4, (parent?.depth ?? 0) + 1), status: "held", removedBy: void 0, mine: true, canEditUntil: void 0, likedByMe: false, name: h.name, createdAt: h.createdAt, editedAt: null, likes: 0, tree: void 0, text: h.text, kids: [] }, h.parentId, false);
1207
- }
1208
- }
1209
- return [...mine, ...roots];
1210
- }
1211
-
1212
- // src/react/comments-body.tsx
1213
- import { toJsxRuntime as toJsxRuntime2 } from "hast-util-to-jsx-runtime";
1214
- import { Fragment as Fragment5 } from "react";
1215
- import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1216
- import { jsx as jsx6 } from "react/jsx-runtime";
1217
- var ALLOWED = /* @__PURE__ */ new Set(["p", "a", "em", "strong", "del", "code", "pre", "blockquote", "ul", "ol", "li", "br"]);
1218
- var LINK_REL = "nofollow ugc noopener noreferrer";
1219
- function narrow(node) {
1220
- if (node.type === "text") return [node];
1221
- if (node.type !== "element") return [];
1222
- const children = node.children.flatMap(narrow);
1223
- if (!ALLOWED.has(node.tagName)) return children;
1224
- if (node.tagName === "a") {
1225
- const href = node.properties.href;
1226
- if (!isSafeUrl(href, "href")) return children;
1227
- return [{ type: "element", tagName: "a", properties: { href: String(href), rel: LINK_REL.split(" ") }, children }];
1228
- }
1229
- return [{ type: "element", tagName: node.tagName, properties: {}, children: node.tagName === "br" ? [] : children }];
1230
- }
1231
- function CommentBody({ tree }) {
1232
- let children;
1233
- try {
1234
- children = sanitizeHast(tree).children.flatMap((n) => narrow(n));
1235
- } catch (error) {
1236
- if (error instanceof HastLimitError) return null;
1237
- throw error;
1238
- }
1239
- return /* @__PURE__ */ jsx6("div", { className: "hyle-cm-body", children: toJsxRuntime2({ type: "root", children }, { Fragment: Fragment5, jsx: jsx5, jsxs: jsxs5, elementAttributeNameCase: "react", stylePropertyNameCase: "dom" }) });
1240
- }
1241
-
1242
- // src/react/embed.tsx
1243
- import { Fragment as Fragment6, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
1244
- function HyleListView({ items, layout = "list", title, headingLevel = 2, moreHref, ...base }) {
1245
- const c = ctx(base, "en");
1246
- const { s, Link } = c;
1247
- const Row = base.slots?.["list.item"];
1248
- const Heading = `h${headingLevel}`;
1249
- const safe = items.filter((item) => item.canonical_path.startsWith("/"));
1250
- if (safe.length === 0) return base.slots?.["list.empty"] ? /* @__PURE__ */ jsx7("div", { className: "hyle hyle-embed", "data-layout": layout, children: /* @__PURE__ */ jsx7(Slot, { name: "list.empty", slots: base.slots }) }) : null;
1251
- return /* @__PURE__ */ jsxs6("div", { className: "hyle hyle-embed", "data-layout": layout, lang: c.locale, children: [
1252
- title ? /* @__PURE__ */ jsx7(Heading, { className: "hyle-title", children: title }) : null,
1253
- /* @__PURE__ */ jsx7("ul", { className: "hyle-items", children: safe.map((item) => /* @__PURE__ */ jsx7("li", { children: Row ? /* @__PURE__ */ jsx7(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ jsxs6(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
1254
- /* @__PURE__ */ jsx7("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }),
1255
- /* @__PURE__ */ jsxs6("div", { children: [
1256
- /* @__PURE__ */ jsx7("span", { className: "t", children: item.title }),
1257
- item.description ? /* @__PURE__ */ jsx7("p", { children: item.description }) : null
1258
- ] })
1259
- ] }) }, item.canonical_path)) }),
1260
- moreHref ? /* @__PURE__ */ jsx7("a", { className: "hyle-more", href: moreHref, children: s.viewAll }) : null
1261
- ] });
1262
- }
1263
- function HyleArticleView({ article, headingLevel = 2, ...base }) {
1264
- const { publication: pub } = article;
1265
- const c = ctx(base, pub.locale);
1266
- const Heading = `h${headingLevel}`;
1267
- return /* @__PURE__ */ jsx7("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ jsxs6("article", { lang: c.locale, children: [
1268
- /* @__PURE__ */ jsxs6("header", { className: "hyle-head", children: [
1269
- /* @__PURE__ */ jsx7(Heading, { className: "hyle-title", children: pub.title }),
1270
- pub.description ? /* @__PURE__ */ jsx7("p", { className: "hyle-desc", children: pub.description }) : null,
1271
- /* @__PURE__ */ jsx7("div", { className: "hyle-meta", children: /* @__PURE__ */ jsx7("span", { children: /* @__PURE__ */ jsx7("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) }) }) })
1272
- ] }),
1273
- /* @__PURE__ */ jsx7(Body, { article, components: base.components, locale: c.locale }),
1274
- pub.canonical_path.startsWith("/") ? /* @__PURE__ */ jsxs6("a", { className: "hyle-more", href: c.href(pub.canonical_path, pub.locale), rel: "bookmark", children: [
1275
- c.s.readAtSource,
1276
- /* @__PURE__ */ jsxs6("span", { className: "hyle-sr", children: [
1277
- ": ",
1278
- pub.title
1279
- ] })
1280
- ] }) : null
1281
- ] }) });
1282
- }
1283
- var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((w) => [...w][0] ?? "").join("").toUpperCase() || "?";
1284
- function StaticThread({ nodes, locale, s, level = 1 }) {
1285
- return /* @__PURE__ */ jsx7("ol", { className: "hyle-cm-list", role: "list", children: nodes.map((node) => {
1286
- const kids = node.kids.length > 0 && level < 32 ? /* @__PURE__ */ jsx7(StaticThread, { nodes: node.kids, locale, s, level: level + 1 }) : null;
1287
- if (node.status === "removed") {
1288
- const why = node.removedBy === "moderator" ? s.removedByModerator : node.removedBy === "author" ? s.removedByAuthor : s.removed;
1289
- return /* @__PURE__ */ jsxs6("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "removed", "data-removed-by": node.removedBy, children: [
1290
- /* @__PURE__ */ jsxs6("article", { "aria-label": why, children: [
1291
- /* @__PURE__ */ jsx7("span", { className: "hyle-avatar", "aria-hidden": "true", children: /* @__PURE__ */ jsx7(Icon, { name: "ban" }) }),
1292
- /* @__PURE__ */ jsx7("div", { className: "hyle-cm-main", children: /* @__PURE__ */ jsx7("div", { className: "hyle-cm-body", children: /* @__PURE__ */ jsx7("p", { children: why }) }) })
1293
- ] }),
1294
- kids
1295
- ] }, node.id);
1296
- }
1297
- return /* @__PURE__ */ jsxs6("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "visible", children: [
1298
- /* @__PURE__ */ jsxs6("article", { children: [
1299
- /* @__PURE__ */ jsx7("span", { className: "hyle-avatar", "aria-hidden": "true", children: initials(node.name ?? "") }),
1300
- /* @__PURE__ */ jsxs6("div", { className: "hyle-cm-main", children: [
1301
- /* @__PURE__ */ jsxs6("div", { className: "hyle-cm-by", children: [
1302
- /* @__PURE__ */ jsx7("b", { children: node.name }),
1303
- /* @__PURE__ */ jsxs6("span", { children: [
1304
- /* @__PURE__ */ jsx7("time", { dateTime: node.createdAt, title: node.createdAt, children: formatDate(node.createdAt, locale) }),
1305
- node.editedAt ? /* @__PURE__ */ jsxs6(Fragment6, { children: [
1306
- " ",
1307
- /* @__PURE__ */ jsx7("span", { "aria-hidden": "true", children: "\xB7" }),
1308
- " ",
1309
- /* @__PURE__ */ jsx7("span", { children: s.edited })
1310
- ] }) : null
1311
- ] })
1312
- ] }),
1313
- /* @__PURE__ */ jsx7(CommentBody, { tree: node.tree })
1314
- ] })
1315
- ] }),
1316
- kids
1317
- ] }, node.id);
1318
- }) });
1319
- }
1320
- function HyleCommentsView({ listing, locale }) {
1321
- const thread = buildThread(listing, []);
1322
- if (thread.length === 0) return null;
1323
- const s = stringsFor(locale).comments;
1324
- return /* @__PURE__ */ jsx7("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ jsxs6("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", lang: locale, children: [
1325
- /* @__PURE__ */ jsx7("div", { className: "hyle-cm-head", children: /* @__PURE__ */ jsxs6("h2", { children: [
1326
- s.heading,
1327
- " ",
1328
- /* @__PURE__ */ jsx7("span", { className: "hyle-cm-count", "aria-label": s.countLabel.replace("{n}", String(listing.comment_count)), children: listing.comment_count })
1329
- ] }) }),
1330
- /* @__PURE__ */ jsx7(StaticThread, { nodes: thread, locale, s }),
1331
- listing.truncated ? /* @__PURE__ */ jsx7("p", { className: "hyle-cm-note", children: s.truncated }) : null
1332
- ] }) });
1333
- }
1334
- function HyleCommentsFallback({ locale }) {
1335
- const s = stringsFor(locale).comments;
1336
- return /* @__PURE__ */ jsx7("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ jsx7("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", children: /* @__PURE__ */ jsxs6("div", { role: "status", "aria-live": "polite", "aria-busy": "true", children: [
1337
- /* @__PURE__ */ jsx7("span", { className: "hyle-sr", children: s.loading }),
1338
- /* @__PURE__ */ jsx7("div", { "aria-hidden": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ jsxs6("div", { className: "hyle-cm-sk", children: [
1339
- /* @__PURE__ */ jsx7("span", { className: "hyle-sk c" }),
1340
- /* @__PURE__ */ jsxs6("div", { children: [
1341
- /* @__PURE__ */ jsx7("span", { className: "hyle-sk l", style: { width: 120 } }),
1342
- /* @__PURE__ */ jsx7("span", { className: "hyle-sk l", style: { width: "100%" } }),
1343
- /* @__PURE__ */ jsx7("span", { className: "hyle-sk l", style: { width: "72%" } })
1344
- ] })
1345
- ] }, i)) })
1346
- ] }) }) });
1347
- }
1348
-
1349
1432
  // src/react/docs.tsx
1350
1433
  import { DocsEnhance } from "./docs-enhance.js";
1351
1434
  import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
@@ -1448,10 +1531,17 @@ export {
1448
1531
  stringsFor,
1449
1532
  HastContent,
1450
1533
  TrustedServerHtml,
1534
+ parseListing,
1535
+ HyleListView,
1536
+ HyleArticleView,
1537
+ HyleCommentsView,
1538
+ HyleCommentsFallback,
1451
1539
  BARE_HTTPS_ORIGIN,
1452
1540
  bareOrigin,
1453
1541
  absoluteUrl,
1454
1542
  modifiedAt,
1543
+ wordCountOf,
1544
+ readingMinutes,
1455
1545
  articleAuthor,
1456
1546
  validOgImage,
1457
1547
  hreflangLanguages,
@@ -1460,11 +1550,6 @@ export {
1460
1550
  NotFound,
1461
1551
  Unavailable,
1462
1552
  Redirecting,
1463
- parseListing,
1464
- HyleListView,
1465
- HyleArticleView,
1466
- HyleCommentsView,
1467
- HyleCommentsFallback,
1468
1553
  DocsPage,
1469
1554
  MermaidDiagram2 as MermaidDiagram,
1470
1555
  Comments2 as Comments