@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/CHANGELOG.md +12 -0
- package/LICENSE +21 -0
- package/README.md +54 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.js +476 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +813 -0
- package/dist/index.js.map +1 -0
- package/package.json +136 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial Quartz community plugin template.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Quartz Community
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# @quartz-community/table-of-contents
|
|
2
|
+
|
|
3
|
+
Renders an interactive table of contents for pages. Also includes a transformer that extracts heading structure from markdown.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx quartz plugin add github:quartz-community/table-of-contents
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```yaml title="quartz.config.yaml"
|
|
14
|
+
plugins:
|
|
15
|
+
- source: github:quartz-community/table-of-contents
|
|
16
|
+
enabled: true
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
For advanced use cases, you can override in TypeScript:
|
|
20
|
+
|
|
21
|
+
```ts title="quartz.ts (override)"
|
|
22
|
+
import * as ExternalPlugin from "./.quartz/plugins";
|
|
23
|
+
|
|
24
|
+
// Transformer
|
|
25
|
+
ExternalPlugin.TableOfContentsTransformer({ maxDepth: 3 });
|
|
26
|
+
|
|
27
|
+
// Component
|
|
28
|
+
ExternalPlugin.TableOfContents({ layout: "modern" });
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Configuration
|
|
32
|
+
|
|
33
|
+
### Component Options
|
|
34
|
+
|
|
35
|
+
| Option | Type | Default | Description |
|
|
36
|
+
| -------- | ---------------------- | ---------- | ------------------------------------------ |
|
|
37
|
+
| `layout` | `"modern" \| "legacy"` | `"modern"` | The layout style of the table of contents. |
|
|
38
|
+
|
|
39
|
+
### Transformer Options
|
|
40
|
+
|
|
41
|
+
| Option | Type | Default | Description |
|
|
42
|
+
| ------------------- | --------- | ------- | ------------------------------------------------------------------------ |
|
|
43
|
+
| `maxDepth` | `number` | `3` | The maximum heading depth to include in the table of contents (1-6). |
|
|
44
|
+
| `minEntries` | `number` | `1` | The minimum number of entries required to display the table of contents. |
|
|
45
|
+
| `showByDefault` | `boolean` | `true` | Whether to show the table of contents by default. |
|
|
46
|
+
| `collapseByDefault` | `boolean` | `false` | Whether to collapse the table of contents by default. |
|
|
47
|
+
|
|
48
|
+
## Documentation
|
|
49
|
+
|
|
50
|
+
See the [Quartz documentation](https://quartz.jzhao.xyz/plugins/TableOfContents) for more information.
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
MIT
|
|
@@ -0,0 +1,476 @@
|
|
|
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 slug = 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: `#${slug}`, "data-for": slug, children: text }) }, slug);
|
|
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 slug = 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: `#${slug}`, "data-for": slug, children: text }) }, slug);
|
|
467
|
+
}) })
|
|
468
|
+
] });
|
|
469
|
+
};
|
|
470
|
+
LegacyTableOfContents.css = legacyToc_default;
|
|
471
|
+
return layout === "modern" ? TableOfContents : LegacyTableOfContents;
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
export { TableOfContents_default as TableOfContents };
|
|
475
|
+
//# sourceMappingURL=index.js.map
|
|
476
|
+
//# sourceMappingURL=index.js.map
|