@quartz-community/table-of-contents 0.1.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/dist/index.js ADDED
@@ -0,0 +1,813 @@
1
+ // node_modules/@quartz-community/utils/dist/lang.js
2
+ function classNames(...classes) {
3
+ return classes.filter(Boolean).join(" ");
4
+ }
5
+
6
+ // src/i18n/locales/en-US.ts
7
+ var en_US_default = {
8
+ components: {
9
+ tableOfContents: {
10
+ title: "Table of Contents"
11
+ }
12
+ }
13
+ };
14
+
15
+ // src/i18n/locales/ar-SA.ts
16
+ var ar_SA_default = {
17
+ components: {
18
+ tableOfContents: {
19
+ title: "\u0641\u0647\u0631\u0633 \u0627\u0644\u0645\u062D\u062A\u0648\u064A\u0627\u062A"
20
+ }
21
+ }
22
+ };
23
+
24
+ // src/i18n/locales/ca-ES.ts
25
+ var ca_ES_default = {
26
+ components: {
27
+ tableOfContents: {
28
+ title: "Taula de Continguts"
29
+ }
30
+ }
31
+ };
32
+
33
+ // src/i18n/locales/cs-CZ.ts
34
+ var cs_CZ_default = {
35
+ components: {
36
+ tableOfContents: {
37
+ title: "Obsah"
38
+ }
39
+ }
40
+ };
41
+
42
+ // src/i18n/locales/de-DE.ts
43
+ var de_DE_default = {
44
+ components: {
45
+ tableOfContents: {
46
+ title: "Inhaltsverzeichnis"
47
+ }
48
+ }
49
+ };
50
+
51
+ // src/i18n/locales/en-GB.ts
52
+ var en_GB_default = {
53
+ components: {
54
+ tableOfContents: {
55
+ title: "Table of Contents"
56
+ }
57
+ }
58
+ };
59
+
60
+ // src/i18n/locales/es-ES.ts
61
+ var es_ES_default = {
62
+ components: {
63
+ tableOfContents: {
64
+ title: "Tabla de Contenidos"
65
+ }
66
+ }
67
+ };
68
+
69
+ // src/i18n/locales/fa-IR.ts
70
+ var fa_IR_default = {
71
+ components: {
72
+ tableOfContents: {
73
+ title: "\u0641\u0647\u0631\u0633\u062A"
74
+ }
75
+ }
76
+ };
77
+
78
+ // src/i18n/locales/fi-FI.ts
79
+ var fi_FI_default = {
80
+ components: {
81
+ tableOfContents: {
82
+ title: "Sis\xE4llysluettelo"
83
+ }
84
+ }
85
+ };
86
+
87
+ // src/i18n/locales/fr-FR.ts
88
+ var fr_FR_default = {
89
+ components: {
90
+ tableOfContents: {
91
+ title: "Table des Mati\xE8res"
92
+ }
93
+ }
94
+ };
95
+
96
+ // src/i18n/locales/he-IL.ts
97
+ var he_IL_default = {
98
+ components: {
99
+ tableOfContents: {
100
+ title: "\u05EA\u05D5\u05DB\u05DF \u05E2\u05E0\u05D9\u05D9\u05E0\u05D9\u05DD"
101
+ }
102
+ }
103
+ };
104
+
105
+ // src/i18n/locales/hu-HU.ts
106
+ var hu_HU_default = {
107
+ components: {
108
+ tableOfContents: {
109
+ title: "Tartalomjegyz\xE9k"
110
+ }
111
+ }
112
+ };
113
+
114
+ // src/i18n/locales/id-ID.ts
115
+ var id_ID_default = {
116
+ components: {
117
+ tableOfContents: {
118
+ title: "Daftar Isi"
119
+ }
120
+ }
121
+ };
122
+
123
+ // src/i18n/locales/it-IT.ts
124
+ var it_IT_default = {
125
+ components: {
126
+ tableOfContents: {
127
+ title: "Indice"
128
+ }
129
+ }
130
+ };
131
+
132
+ // src/i18n/locales/ja-JP.ts
133
+ var ja_JP_default = {
134
+ components: {
135
+ tableOfContents: {
136
+ title: "\u76EE\u6B21"
137
+ }
138
+ }
139
+ };
140
+
141
+ // src/i18n/locales/kk-KZ.ts
142
+ var kk_KZ_default = {
143
+ components: {
144
+ tableOfContents: {
145
+ title: "\u041C\u0430\u0437\u043C\u04B1\u043D\u044B"
146
+ }
147
+ }
148
+ };
149
+
150
+ // src/i18n/locales/ko-KR.ts
151
+ var ko_KR_default = {
152
+ components: {
153
+ tableOfContents: {
154
+ title: "\uBAA9\uCC28"
155
+ }
156
+ }
157
+ };
158
+
159
+ // src/i18n/locales/lt-LT.ts
160
+ var lt_LT_default = {
161
+ components: {
162
+ tableOfContents: {
163
+ title: "Turinys"
164
+ }
165
+ }
166
+ };
167
+
168
+ // src/i18n/locales/nb-NO.ts
169
+ var nb_NO_default = {
170
+ components: {
171
+ tableOfContents: {
172
+ title: "Oversikt"
173
+ }
174
+ }
175
+ };
176
+
177
+ // src/i18n/locales/nl-NL.ts
178
+ var nl_NL_default = {
179
+ components: {
180
+ tableOfContents: {
181
+ title: "Inhoudsopgave"
182
+ }
183
+ }
184
+ };
185
+
186
+ // src/i18n/locales/pl-PL.ts
187
+ var pl_PL_default = {
188
+ components: {
189
+ tableOfContents: {
190
+ title: "Spis tre\u015Bci"
191
+ }
192
+ }
193
+ };
194
+
195
+ // src/i18n/locales/pt-BR.ts
196
+ var pt_BR_default = {
197
+ components: {
198
+ tableOfContents: {
199
+ title: "Sum\xE1rio"
200
+ }
201
+ }
202
+ };
203
+
204
+ // src/i18n/locales/ro-RO.ts
205
+ var ro_RO_default = {
206
+ components: {
207
+ tableOfContents: {
208
+ title: "Cuprins"
209
+ }
210
+ }
211
+ };
212
+
213
+ // src/i18n/locales/ru-RU.ts
214
+ var ru_RU_default = {
215
+ components: {
216
+ tableOfContents: {
217
+ title: "\u041E\u0433\u043B\u0430\u0432\u043B\u0435\u043D\u0438\u0435"
218
+ }
219
+ }
220
+ };
221
+
222
+ // src/i18n/locales/th-TH.ts
223
+ var th_TH_default = {
224
+ components: {
225
+ tableOfContents: {
226
+ title: "\u0E2A\u0E32\u0E23\u0E1A\u0E31\u0E0D"
227
+ }
228
+ }
229
+ };
230
+
231
+ // src/i18n/locales/tr-TR.ts
232
+ var tr_TR_default = {
233
+ components: {
234
+ tableOfContents: {
235
+ title: "\u0130\xE7indekiler"
236
+ }
237
+ }
238
+ };
239
+
240
+ // src/i18n/locales/uk-UA.ts
241
+ var uk_UA_default = {
242
+ components: {
243
+ tableOfContents: {
244
+ title: "\u0417\u043C\u0456\u0441\u0442"
245
+ }
246
+ }
247
+ };
248
+
249
+ // src/i18n/locales/vi-VN.ts
250
+ var vi_VN_default = {
251
+ components: {
252
+ tableOfContents: {
253
+ title: "M\u1EE5c l\u1EE5c"
254
+ }
255
+ }
256
+ };
257
+
258
+ // src/i18n/locales/zh-CN.ts
259
+ var zh_CN_default = {
260
+ components: {
261
+ tableOfContents: {
262
+ title: "\u76EE\u5F55"
263
+ }
264
+ }
265
+ };
266
+
267
+ // src/i18n/locales/zh-TW.ts
268
+ var zh_TW_default = {
269
+ components: {
270
+ tableOfContents: {
271
+ title: "\u76EE\u9304"
272
+ }
273
+ }
274
+ };
275
+
276
+ // src/i18n/index.ts
277
+ var locales = {
278
+ "en-US": en_US_default,
279
+ "ar-SA": ar_SA_default,
280
+ "ca-ES": ca_ES_default,
281
+ "cs-CZ": cs_CZ_default,
282
+ "de-DE": de_DE_default,
283
+ "en-GB": en_GB_default,
284
+ "es-ES": es_ES_default,
285
+ "fa-IR": fa_IR_default,
286
+ "fi-FI": fi_FI_default,
287
+ "fr-FR": fr_FR_default,
288
+ "he-IL": he_IL_default,
289
+ "hu-HU": hu_HU_default,
290
+ "id-ID": id_ID_default,
291
+ "it-IT": it_IT_default,
292
+ "ja-JP": ja_JP_default,
293
+ "kk-KZ": kk_KZ_default,
294
+ "ko-KR": ko_KR_default,
295
+ "lt-LT": lt_LT_default,
296
+ "nb-NO": nb_NO_default,
297
+ "nl-NL": nl_NL_default,
298
+ "pl-PL": pl_PL_default,
299
+ "pt-BR": pt_BR_default,
300
+ "ro-RO": ro_RO_default,
301
+ "ru-RU": ru_RU_default,
302
+ "th-TH": th_TH_default,
303
+ "tr-TR": tr_TR_default,
304
+ "uk-UA": uk_UA_default,
305
+ "vi-VN": vi_VN_default,
306
+ "zh-CN": zh_CN_default,
307
+ "zh-TW": zh_TW_default
308
+ };
309
+ function i18n(locale) {
310
+ return locales[locale] || en_US_default;
311
+ }
312
+
313
+ // src/components/styles/legacyToc.scss
314
+ var legacyToc_default = "details.toc summary {\n cursor: pointer;\n}\ndetails.toc summary::marker {\n color: var(--dark);\n}\ndetails.toc summary > * {\n padding-left: 0.25rem;\n display: inline-block;\n margin: 0;\n}\ndetails.toc ul {\n list-style: none;\n margin: 0.5rem 1.25rem;\n padding: 0;\n}\ndetails.toc .depth-1 {\n padding-left: calc(1rem * 1);\n}\ndetails.toc .depth-2 {\n padding-left: calc(1rem * 2);\n}\ndetails.toc .depth-3 {\n padding-left: calc(1rem * 3);\n}\ndetails.toc .depth-4 {\n padding-left: calc(1rem * 4);\n}\ndetails.toc .depth-5 {\n padding-left: calc(1rem * 5);\n}\ndetails.toc .depth-6 {\n padding-left: calc(1rem * 6);\n}";
315
+
316
+ // src/components/styles/toc.scss
317
+ var toc_default = ".toc {\n display: flex;\n flex-direction: column;\n overflow-y: hidden;\n min-height: 1.4rem;\n flex: 0 0.5 auto;\n}\n.toc:has(button.toc-header.collapsed) {\n flex: 0 1 1.4rem;\n}\n\nbutton.toc-header {\n background-color: transparent;\n border: none;\n text-align: left;\n cursor: pointer;\n padding: 0;\n color: var(--dark);\n display: flex;\n align-items: center;\n}\nbutton.toc-header h3 {\n font-size: 1rem;\n display: inline-block;\n margin: 0;\n}\nbutton.toc-header .fold {\n margin-left: 0.5rem;\n transition: transform 0.3s ease;\n opacity: 0.8;\n}\nbutton.toc-header.collapsed .fold {\n transform: rotateZ(-90deg);\n}\n\nul.toc-content.overflow {\n list-style: none;\n position: relative;\n margin: 0.5rem 0;\n padding: 0;\n max-height: calc(100% - 2rem);\n overscroll-behavior: contain;\n list-style: none;\n}\nul.toc-content.overflow > li > a {\n color: var(--dark);\n opacity: 0.35;\n transition: 0.5s ease opacity, 0.3s ease color;\n}\nul.toc-content.overflow > li > a.in-view {\n opacity: 0.75;\n}\nul.toc-content.overflow .depth-0 {\n padding-left: calc(1rem * 0);\n}\nul.toc-content.overflow .depth-1 {\n padding-left: calc(1rem * 1);\n}\nul.toc-content.overflow .depth-2 {\n padding-left: calc(1rem * 2);\n}\nul.toc-content.overflow .depth-3 {\n padding-left: calc(1rem * 3);\n}\nul.toc-content.overflow .depth-4 {\n padding-left: calc(1rem * 4);\n}\nul.toc-content.overflow .depth-5 {\n padding-left: calc(1rem * 5);\n}\nul.toc-content.overflow .depth-6 {\n padding-left: calc(1rem * 6);\n}";
318
+
319
+ // src/components/scripts/toc.inline.ts
320
+ var toc_inline_default = 'var i=new IntersectionObserver(t=>{for(let e of t){let n=e.target.id,o=document.querySelectorAll(`a[data-for="${n}"]`),s=e.rootBounds?.height;s&&o.length>0&&(e.boundingClientRect.y<s?o.forEach(c=>c.classList.add("in-view")):o.forEach(c=>c.classList.remove("in-view")))}});function r(){this.classList.toggle("collapsed"),this.setAttribute("aria-expanded",this.getAttribute("aria-expanded")==="true"?"false":"true");let t=this.nextElementSibling;t&&t.classList.toggle("collapsed")}function a(){let t=Array.from(document.getElementsByClassName("toc"));for(let e of t){let n=e.querySelector(".toc-header"),o=e.querySelector(".toc-content");if(!n||!o)return;n.addEventListener("click",r);let s=()=>n.removeEventListener("click",r);window.addCleanup&&window.addCleanup(s)}}function d(){a(),i.disconnect(),document.querySelectorAll("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").forEach(e=>i.observe(e))}document.addEventListener("nav",d);document.addEventListener("render",d);\n';
321
+ var l;
322
+ l = { __e: function(n2, l2, u3, t2) {
323
+ for (var i2, r2, o2; l2 = l2.__; ) if ((i2 = l2.__c) && !i2.__) try {
324
+ if ((r2 = i2.constructor) && null != r2.getDerivedStateFromError && (i2.setState(r2.getDerivedStateFromError(n2)), o2 = i2.__d), null != i2.componentDidCatch && (i2.componentDidCatch(n2, t2 || {}), o2 = i2.__d), o2) return i2.__E = i2;
325
+ } catch (l3) {
326
+ n2 = l3;
327
+ }
328
+ throw n2;
329
+ } }, "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, Math.random().toString(8);
330
+
331
+ // node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
332
+ var f2 = 0;
333
+ function u2(e2, t2, n2, o2, i2, u3) {
334
+ t2 || (t2 = {});
335
+ var a2, c2, p2 = t2;
336
+ if ("ref" in p2) for (c2 in p2 = {}, t2) "ref" == c2 ? a2 = t2[c2] : p2[c2] = t2[c2];
337
+ var l2 = { type: e2, props: p2, key: n2, ref: a2, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --f2, __i: -1, __u: 0, __source: i2, __self: u3 };
338
+ if ("function" == typeof e2 && (a2 = e2.defaultProps)) for (c2 in a2) void 0 === p2[c2] && (p2[c2] = a2[c2]);
339
+ return l.vnode && l.vnode(l2), l2;
340
+ }
341
+
342
+ // src/components/OverflowList.tsx
343
+ var OverflowList = ({
344
+ children,
345
+ ...props
346
+ }) => {
347
+ return /* @__PURE__ */ u2("ul", { ...props, class: [props.class, "overflow"].filter(Boolean).join(" "), id: props.id, children: [
348
+ children,
349
+ /* @__PURE__ */ u2("li", { class: "overflow-end" })
350
+ ] });
351
+ };
352
+ var numLists = 0;
353
+ var OverflowList_default = () => {
354
+ const id = `list-${numLists++}`;
355
+ return {
356
+ OverflowList: (props) => /* @__PURE__ */ u2(OverflowList, { ...props, id }),
357
+ overflowListAfterDOMLoaded: `
358
+ document.addEventListener("nav", (e) => {
359
+ const observer = new IntersectionObserver((entries) => {
360
+ for (const entry of entries) {
361
+ const parentUl = entry.target.parentElement
362
+ if (!parentUl) return
363
+ if (entry.isIntersecting) {
364
+ parentUl.classList.remove("gradient-active")
365
+ } else {
366
+ parentUl.classList.add("gradient-active")
367
+ }
368
+ }
369
+ })
370
+
371
+ const ul = document.getElementById("${id}")
372
+ if (!ul) return
373
+
374
+ const end = ul.querySelector(".overflow-end")
375
+ if (!end) return
376
+
377
+ observer.observe(end)
378
+ const cleanup = () => observer.disconnect()
379
+ if (window.addCleanup) {
380
+ window.addCleanup(cleanup)
381
+ }
382
+ })
383
+ `
384
+ };
385
+ };
386
+
387
+ // src/util/resources.ts
388
+ function concatenateResources(...resources) {
389
+ return resources.filter((resource) => resource !== void 0).flat();
390
+ }
391
+
392
+ // src/components/TableOfContents.tsx
393
+ var defaultOptions = {
394
+ layout: "modern"
395
+ };
396
+ var numTocs = 0;
397
+ var TableOfContents_default = ((opts) => {
398
+ const layout = opts?.layout ?? defaultOptions.layout;
399
+ const { OverflowList: OverflowList2, overflowListAfterDOMLoaded } = OverflowList_default();
400
+ const TableOfContents = (props) => {
401
+ const { fileData, cfg } = props;
402
+ if (!fileData?.toc) {
403
+ return null;
404
+ }
405
+ const id = `toc-${numTocs++}`;
406
+ return /* @__PURE__ */ u2("div", { class: classNames("toc"), children: [
407
+ /* @__PURE__ */ u2(
408
+ "button",
409
+ {
410
+ type: "button",
411
+ class: fileData.collapseToc ? "collapsed toc-header" : "toc-header",
412
+ "aria-controls": id,
413
+ "aria-expanded": !fileData.collapseToc,
414
+ children: [
415
+ /* @__PURE__ */ u2("h3", { children: i18n(cfg.locale).components.tableOfContents.title }),
416
+ /* @__PURE__ */ u2(
417
+ "svg",
418
+ {
419
+ xmlns: "http://www.w3.org/2000/svg",
420
+ width: "24",
421
+ height: "24",
422
+ viewBox: "0 0 24 24",
423
+ fill: "none",
424
+ stroke: "currentColor",
425
+ "stroke-width": "2",
426
+ "stroke-linecap": "round",
427
+ "stroke-linejoin": "round",
428
+ class: "fold",
429
+ children: /* @__PURE__ */ u2("polyline", { points: "6 9 12 15 18 9" })
430
+ }
431
+ )
432
+ ]
433
+ }
434
+ ),
435
+ /* @__PURE__ */ u2(
436
+ OverflowList2,
437
+ {
438
+ id,
439
+ class: fileData.collapseToc ? "collapsed toc-content" : "toc-content",
440
+ children: fileData.toc.map((tocEntry) => {
441
+ const slug2 = String(tocEntry.slug);
442
+ const depth = String(tocEntry.depth);
443
+ const text = String(tocEntry.text);
444
+ return /* @__PURE__ */ u2("li", { class: `depth-${depth}`, children: /* @__PURE__ */ u2("a", { href: `#${slug2}`, "data-for": slug2, children: text }) }, slug2);
445
+ })
446
+ }
447
+ )
448
+ ] });
449
+ };
450
+ TableOfContents.css = toc_default;
451
+ TableOfContents.afterDOMLoaded = concatenateResources(
452
+ toc_inline_default,
453
+ overflowListAfterDOMLoaded
454
+ );
455
+ const LegacyTableOfContents = (props) => {
456
+ const { fileData, cfg } = props;
457
+ if (!fileData?.toc) {
458
+ return null;
459
+ }
460
+ return /* @__PURE__ */ u2("details", { class: "toc", open: !fileData.collapseToc, children: [
461
+ /* @__PURE__ */ u2("summary", { children: /* @__PURE__ */ u2("h3", { children: i18n(cfg.locale).components.tableOfContents.title }) }),
462
+ /* @__PURE__ */ u2("ul", { children: fileData.toc.map((tocEntry) => {
463
+ const slug2 = String(tocEntry.slug);
464
+ const depth = String(tocEntry.depth);
465
+ const text = String(tocEntry.text);
466
+ return /* @__PURE__ */ u2("li", { class: `depth-${depth}`, children: /* @__PURE__ */ u2("a", { href: `#${slug2}`, "data-for": slug2, children: text }) }, slug2);
467
+ }) })
468
+ ] });
469
+ };
470
+ LegacyTableOfContents.css = legacyToc_default;
471
+ return layout === "modern" ? TableOfContents : LegacyTableOfContents;
472
+ });
473
+
474
+ // node_modules/unist-util-is/lib/index.js
475
+ var convert = (
476
+ // Note: overloads in JSDoc can’t yet use different `@template`s.
477
+ /**
478
+ * @type {(
479
+ * (<Condition extends string>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & {type: Condition}) &
480
+ * (<Condition extends Props>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Condition) &
481
+ * (<Condition extends TestFunction>(test: Condition) => (node: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node & Predicate<Condition, Node>) &
482
+ * ((test?: null | undefined) => (node?: unknown, index?: number | null | undefined, parent?: Parent | null | undefined, context?: unknown) => node is Node) &
483
+ * ((test?: Test) => Check)
484
+ * )}
485
+ */
486
+ /**
487
+ * @param {Test} [test]
488
+ * @returns {Check}
489
+ */
490
+ (function(test) {
491
+ if (test === null || test === void 0) {
492
+ return ok;
493
+ }
494
+ if (typeof test === "function") {
495
+ return castFactory(test);
496
+ }
497
+ if (typeof test === "object") {
498
+ return Array.isArray(test) ? anyFactory(test) : (
499
+ // Cast because `ReadonlyArray` goes into the above but `isArray`
500
+ // narrows to `Array`.
501
+ propertiesFactory(
502
+ /** @type {Props} */
503
+ test
504
+ )
505
+ );
506
+ }
507
+ if (typeof test === "string") {
508
+ return typeFactory(test);
509
+ }
510
+ throw new Error("Expected function, string, or object as test");
511
+ })
512
+ );
513
+ function anyFactory(tests) {
514
+ const checks = [];
515
+ let index = -1;
516
+ while (++index < tests.length) {
517
+ checks[index] = convert(tests[index]);
518
+ }
519
+ return castFactory(any);
520
+ function any(...parameters) {
521
+ let index2 = -1;
522
+ while (++index2 < checks.length) {
523
+ if (checks[index2].apply(this, parameters)) return true;
524
+ }
525
+ return false;
526
+ }
527
+ }
528
+ function propertiesFactory(check) {
529
+ const checkAsRecord = (
530
+ /** @type {Record<string, unknown>} */
531
+ check
532
+ );
533
+ return castFactory(all2);
534
+ function all2(node2) {
535
+ const nodeAsRecord = (
536
+ /** @type {Record<string, unknown>} */
537
+ /** @type {unknown} */
538
+ node2
539
+ );
540
+ let key;
541
+ for (key in check) {
542
+ if (nodeAsRecord[key] !== checkAsRecord[key]) return false;
543
+ }
544
+ return true;
545
+ }
546
+ }
547
+ function typeFactory(check) {
548
+ return castFactory(type);
549
+ function type(node2) {
550
+ return node2 && node2.type === check;
551
+ }
552
+ }
553
+ function castFactory(testFunction) {
554
+ return check;
555
+ function check(value, index, parent) {
556
+ return Boolean(
557
+ looksLikeANode(value) && testFunction.call(
558
+ this,
559
+ value,
560
+ typeof index === "number" ? index : void 0,
561
+ parent || void 0
562
+ )
563
+ );
564
+ }
565
+ }
566
+ function ok() {
567
+ return true;
568
+ }
569
+ function looksLikeANode(value) {
570
+ return value !== null && typeof value === "object" && "type" in value;
571
+ }
572
+
573
+ // node_modules/unist-util-visit-parents/lib/color.node.js
574
+ function color(d2) {
575
+ return "\x1B[33m" + d2 + "\x1B[39m";
576
+ }
577
+
578
+ // node_modules/unist-util-visit-parents/lib/index.js
579
+ var empty = [];
580
+ var CONTINUE = true;
581
+ var EXIT = false;
582
+ var SKIP = "skip";
583
+ function visitParents(tree, test, visitor, reverse) {
584
+ let check;
585
+ if (typeof test === "function" && typeof visitor !== "function") {
586
+ reverse = visitor;
587
+ visitor = test;
588
+ } else {
589
+ check = test;
590
+ }
591
+ const is2 = convert(check);
592
+ const step = reverse ? -1 : 1;
593
+ factory(tree, void 0, [])();
594
+ function factory(node2, index, parents) {
595
+ const value = (
596
+ /** @type {Record<string, unknown>} */
597
+ node2 && typeof node2 === "object" ? node2 : {}
598
+ );
599
+ if (typeof value.type === "string") {
600
+ const name = (
601
+ // `hast`
602
+ typeof value.tagName === "string" ? value.tagName : (
603
+ // `xast`
604
+ typeof value.name === "string" ? value.name : void 0
605
+ )
606
+ );
607
+ Object.defineProperty(visit2, "name", {
608
+ value: "node (" + color(node2.type + (name ? "<" + name + ">" : "")) + ")"
609
+ });
610
+ }
611
+ return visit2;
612
+ function visit2() {
613
+ let result = empty;
614
+ let subresult;
615
+ let offset;
616
+ let grandparents;
617
+ if (!test || is2(node2, index, parents[parents.length - 1] || void 0)) {
618
+ result = toResult(visitor(node2, parents));
619
+ if (result[0] === EXIT) {
620
+ return result;
621
+ }
622
+ }
623
+ if ("children" in node2 && node2.children) {
624
+ const nodeAsParent = (
625
+ /** @type {UnistParent} */
626
+ node2
627
+ );
628
+ if (nodeAsParent.children && result[0] !== SKIP) {
629
+ offset = (reverse ? nodeAsParent.children.length : -1) + step;
630
+ grandparents = parents.concat(nodeAsParent);
631
+ while (offset > -1 && offset < nodeAsParent.children.length) {
632
+ const child = nodeAsParent.children[offset];
633
+ subresult = factory(child, offset, grandparents)();
634
+ if (subresult[0] === EXIT) {
635
+ return subresult;
636
+ }
637
+ offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
638
+ }
639
+ }
640
+ }
641
+ return result;
642
+ }
643
+ }
644
+ }
645
+ function toResult(value) {
646
+ if (Array.isArray(value)) {
647
+ return value;
648
+ }
649
+ if (typeof value === "number") {
650
+ return [CONTINUE, value];
651
+ }
652
+ return value === null || value === void 0 ? empty : [value];
653
+ }
654
+
655
+ // node_modules/unist-util-visit/lib/index.js
656
+ function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
657
+ let reverse;
658
+ let test;
659
+ let visitor;
660
+ {
661
+ test = testOrVisitor;
662
+ visitor = visitorOrReverse;
663
+ reverse = maybeReverse;
664
+ }
665
+ visitParents(tree, test, overload, reverse);
666
+ function overload(node2, parents) {
667
+ const parent = parents[parents.length - 1];
668
+ const index = parent ? parent.children.indexOf(node2) : void 0;
669
+ return visitor(node2, index, parent);
670
+ }
671
+ }
672
+
673
+ // node_modules/mdast-util-to-string/lib/index.js
674
+ var emptyOptions = {};
675
+ function toString(value, options) {
676
+ const settings = emptyOptions;
677
+ const includeImageAlt = typeof settings.includeImageAlt === "boolean" ? settings.includeImageAlt : true;
678
+ const includeHtml = typeof settings.includeHtml === "boolean" ? settings.includeHtml : true;
679
+ return one(value, includeImageAlt, includeHtml);
680
+ }
681
+ function one(value, includeImageAlt, includeHtml) {
682
+ if (node(value)) {
683
+ if ("value" in value) {
684
+ return value.type === "html" && !includeHtml ? "" : value.value;
685
+ }
686
+ if (includeImageAlt && "alt" in value && value.alt) {
687
+ return value.alt;
688
+ }
689
+ if ("children" in value) {
690
+ return all(value.children, includeImageAlt, includeHtml);
691
+ }
692
+ }
693
+ if (Array.isArray(value)) {
694
+ return all(value, includeImageAlt, includeHtml);
695
+ }
696
+ return "";
697
+ }
698
+ function all(values, includeImageAlt, includeHtml) {
699
+ const result = [];
700
+ let index = -1;
701
+ while (++index < values.length) {
702
+ result[index] = one(values[index], includeImageAlt, includeHtml);
703
+ }
704
+ return result.join("");
705
+ }
706
+ function node(value) {
707
+ return Boolean(value && typeof value === "object");
708
+ }
709
+
710
+ // node_modules/github-slugger/regex.js
711
+ var regex = /[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08C8-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF0-\u0AF8\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B54\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B70\u0B72-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BF0-\u0BFF\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5B-\u0C5F\u0C64\u0C65\u0C70-\u0C7F\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0CFF\u0D0D\u0D11\u0D45\u0D49\u0D4F-\u0D53\u0D58-\u0D5E\u0D64\u0D65\u0D70-\u0D79\u0D80\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DE5\u0DF0\u0DF1\u0DF4-\u0E00\u0E3B-\u0E3F\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F17\u0F1A-\u0F1F\u0F2A-\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F48\u0F6D-\u0F70\u0F85\u0F98\u0FBD-\u0FC5\u0FC7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1AC1-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\u9FFD-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA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\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]/g;
712
+
713
+ // node_modules/github-slugger/index.js
714
+ var own = Object.hasOwnProperty;
715
+ var BananaSlug = class {
716
+ /**
717
+ * Create a new slug class.
718
+ */
719
+ constructor() {
720
+ this.occurrences;
721
+ this.reset();
722
+ }
723
+ /**
724
+ * Generate a unique slug.
725
+ *
726
+ * Tracks previously generated slugs: repeated calls with the same value
727
+ * will result in different slugs.
728
+ * Use the `slug` function to get same slugs.
729
+ *
730
+ * @param {string} value
731
+ * String of text to slugify
732
+ * @param {boolean} [maintainCase=false]
733
+ * Keep the current case, otherwise make all lowercase
734
+ * @return {string}
735
+ * A unique slug string
736
+ */
737
+ slug(value, maintainCase) {
738
+ const self = this;
739
+ let result = slug(value, maintainCase === true);
740
+ const originalSlug = result;
741
+ while (own.call(self.occurrences, result)) {
742
+ self.occurrences[originalSlug]++;
743
+ result = originalSlug + "-" + self.occurrences[originalSlug];
744
+ }
745
+ self.occurrences[result] = 0;
746
+ return result;
747
+ }
748
+ /**
749
+ * Reset - Forget all previous slugs
750
+ *
751
+ * @return void
752
+ */
753
+ reset() {
754
+ this.occurrences = /* @__PURE__ */ Object.create(null);
755
+ }
756
+ };
757
+ function slug(value, maintainCase) {
758
+ if (typeof value !== "string") return "";
759
+ if (!maintainCase) value = value.toLowerCase();
760
+ return value.replace(regex, "").replace(/ /g, "-");
761
+ }
762
+
763
+ // src/transformer.ts
764
+ var defaultOptions2 = {
765
+ maxDepth: 3,
766
+ minEntries: 1,
767
+ showByDefault: true,
768
+ collapseByDefault: false
769
+ };
770
+ var slugAnchor = new BananaSlug();
771
+ var TableOfContentsTransformer = (userOpts) => {
772
+ const opts = { ...defaultOptions2, ...userOpts };
773
+ return {
774
+ name: "TableOfContents",
775
+ markdownPlugins() {
776
+ return [
777
+ () => {
778
+ return async (tree, file) => {
779
+ const frontmatter = file.data.frontmatter;
780
+ const display = frontmatter?.enableToc ?? opts.showByDefault;
781
+ if (display) {
782
+ slugAnchor.reset();
783
+ const toc = [];
784
+ let highestDepth = opts.maxDepth;
785
+ visit(tree, "heading", (node2) => {
786
+ if (node2.depth <= opts.maxDepth) {
787
+ const text = toString(node2);
788
+ highestDepth = Math.min(highestDepth, node2.depth);
789
+ toc.push({
790
+ depth: node2.depth,
791
+ text,
792
+ slug: slugAnchor.slug(text)
793
+ });
794
+ }
795
+ });
796
+ if (toc.length > 0 && toc.length > opts.minEntries) {
797
+ file.data.toc = toc.map((entry) => ({
798
+ ...entry,
799
+ depth: entry.depth - highestDepth
800
+ }));
801
+ file.data.collapseToc = opts.collapseByDefault;
802
+ }
803
+ }
804
+ };
805
+ }
806
+ ];
807
+ }
808
+ };
809
+ };
810
+
811
+ export { TableOfContents_default as TableOfContents, TableOfContentsTransformer };
812
+ //# sourceMappingURL=index.js.map
813
+ //# sourceMappingURL=index.js.map