@stacksjs/bunpress 0.1.9 → 0.1.11

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.
@@ -0,0 +1,1189 @@
1
+ // @bun
2
+ import{loadConfig as h}from"bunfig";var j={docsDir:"./docs",outDir:"./dist",theme:"vitepress",nav:[{text:"Guide",link:"/install"},{text:"API",link:"/advanced#api-reference"},{text:"Examples",link:"/examples"}],plugins:[],markdown:{title:"BunPress Documentation",meta:{description:"Documentation built with BunPress",generator:"BunPress",viewport:"width=device-width, initial-scale=1.0"},sidebar:{"/":[{text:"Getting Started",items:[{text:"Introduction",link:"/"},{text:"Installation",link:"/install"},{text:"Quick Start",link:"/quick-start"},{text:"Usage",link:"/usage"},{text:"Configuration",link:"/config"}]},{text:"Core Features",items:[{text:"Features Overview",link:"/features"},{text:"Markdown Extensions",link:"/markdown-extensions"},{text:"Syntax Highlighting",link:"/syntax-highlighting"},{text:"Table of Contents",link:"/table-of-contents"},{text:"CLI Commands",link:"/cli"}]},{text:"SEO & Analytics",items:[{text:"SEO Features",link:"/seo"},{text:"Analytics (Fathom)",link:"/config#fathom-analytics"}]},{text:"Advanced",items:[{text:"Advanced Usage",link:"/advanced"},{text:"Examples",link:"/examples"},{text:"Best Practices",link:"/best-practices"}]},{text:"More",items:[{text:"Showcase",link:"/showcase"},{text:"Partners",link:"/partners"},{text:"License",link:"/license"},{text:"Postcardware",link:"/postcardware"}]}]},css:`
3
+ /* Additional BunPress customizations */
4
+ /* Note: Base styles are provided by the VitePress theme */
5
+
6
+ /* Copy button for code blocks */
7
+ .copy-code-button {
8
+ position: absolute;
9
+ top: 12px;
10
+ right: 12px;
11
+ padding: 6px 8px;
12
+ background-color: var(--bp-code-copy-code-bg, var(--bp-c-bg-soft, #f6f6f7));
13
+ border: 1px solid var(--bp-code-copy-code-border-color, var(--bp-c-divider, #e2e2e3));
14
+ border-radius: 4px;
15
+ cursor: pointer;
16
+ opacity: 0;
17
+ transition: opacity 0.2s ease, background-color 0.2s ease;
18
+ z-index: 3;
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: center;
22
+ }
23
+
24
+ pre:hover .copy-code-button {
25
+ opacity: 1;
26
+ }
27
+
28
+ .copy-code-button:hover {
29
+ background-color: var(--bp-code-copy-code-hover-bg, var(--bp-c-bg, #ffffff));
30
+ border-color: var(--bp-code-copy-code-hover-border-color, var(--bp-c-divider, #e2e2e3));
31
+ }
32
+
33
+ .copy-code-button.copied {
34
+ opacity: 1;
35
+ background-color: var(--bp-c-success-soft, rgba(16, 185, 129, 0.14));
36
+ border-color: var(--bp-c-success-1, #18794e);
37
+ }
38
+
39
+ .copy-code-button svg {
40
+ width: 16px;
41
+ height: 16px;
42
+ color: var(--bp-c-text-2, #67676c);
43
+ }
44
+
45
+ .copy-code-button.copied svg {
46
+ color: var(--bp-c-success-1, #18794e);
47
+ }
48
+
49
+ /* Code block backgrounds fix - using !important to override any inline styles */
50
+ pre,
51
+ pre[data-lang],
52
+ article pre,
53
+ .bp-doc pre {
54
+ position: relative;
55
+ background-color: #f6f6f7 !important;
56
+ border-radius: 8px;
57
+ margin: 16px 0;
58
+ overflow-x: auto;
59
+ }
60
+
61
+ pre code,
62
+ pre[data-lang] code,
63
+ article pre code,
64
+ .bp-doc pre code {
65
+ display: block;
66
+ padding: 20px 24px;
67
+ background-color: transparent !important;
68
+ background: transparent !important;
69
+ font-size: 14px;
70
+ line-height: 1.7;
71
+ color: #24292f;
72
+ }
73
+
74
+ /* Dark mode code blocks */
75
+ html.dark pre,
76
+ html.dark pre[data-lang],
77
+ html.dark article pre,
78
+ html.dark .bp-doc pre {
79
+ background-color: #161618 !important;
80
+ }
81
+
82
+ html.dark pre code,
83
+ html.dark pre[data-lang] code {
84
+ color: #e6edf3;
85
+ }
86
+
87
+ /* Code groups - tabbed code blocks */
88
+ .code-group {
89
+ margin: 16px 0;
90
+ border-radius: 8px;
91
+ overflow: hidden;
92
+ border: 1px solid #e2e2e3;
93
+ background-color: #f6f6f7 !important;
94
+ }
95
+
96
+ html.dark .code-group {
97
+ border-color: #3c3f44;
98
+ background-color: #161618 !important;
99
+ }
100
+
101
+ .code-group-tabs {
102
+ display: flex;
103
+ background-color: #f6f6f7 !important;
104
+ border-bottom: 1px solid #e2e2e3;
105
+ overflow-x: auto;
106
+ }
107
+
108
+ html.dark .code-group-tabs {
109
+ background-color: #161618 !important;
110
+ border-bottom-color: #3c3f44;
111
+ }
112
+
113
+ .code-group-tab {
114
+ padding: 12px 16px;
115
+ font-size: 14px;
116
+ font-weight: 500;
117
+ color: #67676c;
118
+ background: transparent;
119
+ border: none;
120
+ border-bottom: 2px solid transparent;
121
+ cursor: pointer;
122
+ white-space: nowrap;
123
+ transition: color 0.2s, border-color 0.2s;
124
+ }
125
+
126
+ .code-group-tab:hover {
127
+ color: #3c3c43;
128
+ }
129
+
130
+ .code-group-tab.active {
131
+ color: #3451b2;
132
+ border-bottom-color: #3451b2;
133
+ }
134
+
135
+ html.dark .code-group-tab {
136
+ color: #9ca3af;
137
+ }
138
+
139
+ html.dark .code-group-tab:hover {
140
+ color: #e6edf3;
141
+ }
142
+
143
+ html.dark .code-group-tab.active {
144
+ color: #a8b1ff;
145
+ border-bottom-color: #a8b1ff;
146
+ }
147
+
148
+ .code-group-panels {
149
+ background-color: #f6f6f7 !important;
150
+ }
151
+
152
+ html.dark .code-group-panels {
153
+ background-color: #161618 !important;
154
+ }
155
+
156
+ .code-group-panel {
157
+ display: none;
158
+ }
159
+
160
+ .code-group-panel.active {
161
+ display: block;
162
+ }
163
+
164
+ .code-group-panel pre,
165
+ .code-group pre {
166
+ margin: 0 !important;
167
+ border-radius: 0 !important;
168
+ border: none !important;
169
+ background-color: #f6f6f7 !important;
170
+ }
171
+
172
+ html.dark .code-group-panel pre,
173
+ html.dark .code-group pre {
174
+ background-color: #161618 !important;
175
+ }
176
+
177
+ /* Language label positioning */
178
+ pre[data-lang]::before {
179
+ content: attr(data-lang);
180
+ position: absolute;
181
+ top: 8px;
182
+ right: 48px;
183
+ font-size: 12px;
184
+ font-weight: 500;
185
+ color: #9ca3af;
186
+ text-transform: lowercase;
187
+ pointer-events: none;
188
+ z-index: 2;
189
+ }
190
+
191
+ /* Adjust copy button position to not overlap language label */
192
+ pre .copy-code-button {
193
+ top: 8px;
194
+ right: 8px;
195
+ }
196
+
197
+ /* Heading spacing - add margin below headings */
198
+ article h1,
199
+ article h2,
200
+ article h3,
201
+ article h4,
202
+ article h5,
203
+ article h6,
204
+ .bp-doc h1,
205
+ .bp-doc h2,
206
+ .bp-doc h3,
207
+ .bp-doc h4,
208
+ .bp-doc h5,
209
+ .bp-doc h6 {
210
+ margin-bottom: 16px;
211
+ }
212
+
213
+ article h2,
214
+ .bp-doc h2 {
215
+ margin-top: 48px;
216
+ margin-bottom: 24px;
217
+ }
218
+
219
+ article h3,
220
+ .bp-doc h3 {
221
+ margin-top: 32px;
222
+ margin-bottom: 16px;
223
+ }
224
+
225
+ article h4,
226
+ .bp-doc h4 {
227
+ margin-top: 24px;
228
+ margin-bottom: 12px;
229
+ }
230
+
231
+ /* List styling with proper indentation */
232
+ article ul,
233
+ article ol,
234
+ .bp-doc ul,
235
+ .bp-doc ol {
236
+ padding-left: 1.5rem;
237
+ margin: 16px 0;
238
+ }
239
+
240
+ article ul,
241
+ .bp-doc ul {
242
+ list-style-type: disc;
243
+ }
244
+
245
+ article ol,
246
+ .bp-doc ol {
247
+ list-style-type: decimal;
248
+ }
249
+
250
+ article li,
251
+ .bp-doc li {
252
+ margin: 8px 0;
253
+ line-height: 1.7;
254
+ }
255
+
256
+ /* Nested lists */
257
+ article ul ul,
258
+ article ol ul,
259
+ article ul ol,
260
+ article ol ol,
261
+ .bp-doc ul ul,
262
+ .bp-doc ol ul,
263
+ .bp-doc ul ol,
264
+ .bp-doc ol ol {
265
+ margin: 8px 0;
266
+ padding-left: 1.5rem;
267
+ }
268
+
269
+ article ul ul,
270
+ .bp-doc ul ul {
271
+ list-style-type: circle;
272
+ }
273
+
274
+ article ul ul ul,
275
+ .bp-doc ul ul ul {
276
+ list-style-type: square;
277
+ }
278
+
279
+ /* Enhanced Tables */
280
+ .table-responsive {
281
+ overflow-x: auto;
282
+ margin: 16px 0;
283
+ border-radius: 8px;
284
+ border: 1px solid var(--bp-c-divider, #e2e2e3);
285
+ }
286
+
287
+ .enhanced-table {
288
+ width: 100%;
289
+ border-collapse: collapse;
290
+ font-size: 14px;
291
+ background-color: var(--bp-c-bg, #ffffff);
292
+ }
293
+
294
+ .enhanced-table thead {
295
+ background-color: var(--bp-c-bg-soft, #f6f6f7);
296
+ }
297
+
298
+ .enhanced-table th {
299
+ padding: 12px 16px;
300
+ font-weight: 600;
301
+ color: var(--bp-c-text-2, #67676c);
302
+ border-bottom: 2px solid var(--bp-c-divider, #e2e2e3);
303
+ white-space: nowrap;
304
+ }
305
+
306
+ .enhanced-table td {
307
+ padding: 12px 16px;
308
+ color: var(--bp-c-text-1, #3c3c43);
309
+ border-bottom: 1px solid var(--bp-c-divider, #e2e2e3);
310
+ }
311
+
312
+ .enhanced-table tbody tr:nth-child(2n) {
313
+ background-color: var(--bp-c-bg-soft, #f6f6f7);
314
+ }
315
+
316
+ .enhanced-table tbody tr:hover {
317
+ background-color: var(--bp-c-default-soft, rgba(142, 150, 170, 0.14));
318
+ transition: background-color 0.2s ease;
319
+ }
320
+
321
+ /* Image Captions */
322
+ .image-figure {
323
+ margin: 24px 0;
324
+ text-align: center;
325
+ }
326
+
327
+ .image-figure img {
328
+ max-width: 100%;
329
+ height: auto;
330
+ border-radius: 8px;
331
+ border: 1px solid var(--bp-c-divider, #e2e2e3);
332
+ }
333
+
334
+ .image-figure figcaption {
335
+ margin-top: 12px;
336
+ font-size: 14px;
337
+ color: var(--bp-c-text-2, #67676c);
338
+ font-style: italic;
339
+ text-align: center;
340
+ }
341
+
342
+ /* Regular images (without captions) */
343
+ article img:not(.image-figure img) {
344
+ max-width: 100%;
345
+ height: auto;
346
+ border-radius: 8px;
347
+ margin: 16px 0;
348
+ }
349
+
350
+ /* Raw Container - No styling */
351
+ .bp-raw {
352
+ margin: 16px 0;
353
+ }
354
+
355
+ /* Copy Page Dropdown */
356
+ .copy-page-dropdown {
357
+ position: absolute;
358
+ right: 0;
359
+ top: 50%;
360
+ transform: translateY(-50%);
361
+ display: none; /* Hidden until JS positions it */
362
+ z-index: 10;
363
+ }
364
+
365
+ .copy-page-dropdown.positioned {
366
+ display: inline-block;
367
+ }
368
+
369
+ /* Page header row with H1 and Copy button */
370
+ .bp-page-header {
371
+ display: flex;
372
+ align-items: flex-start;
373
+ justify-content: space-between;
374
+ gap: 16px;
375
+ position: relative;
376
+ margin-bottom: 16px;
377
+ }
378
+
379
+ .bp-page-header h1 {
380
+ margin: 0;
381
+ flex: 1;
382
+ min-width: 0;
383
+ }
384
+
385
+ .bp-page-header .copy-page-dropdown {
386
+ position: relative;
387
+ right: auto;
388
+ top: auto;
389
+ transform: none;
390
+ flex-shrink: 0;
391
+ margin-top: 4px;
392
+ display: inline-block;
393
+ }
394
+
395
+ .bp-page-header .copy-page-dropdown.positioned {
396
+ display: inline-block;
397
+ }
398
+
399
+ /* Split button group */
400
+ .copy-page-button-group {
401
+ display: flex;
402
+ align-items: stretch;
403
+ }
404
+
405
+ .copy-page-button {
406
+ display: flex;
407
+ align-items: center;
408
+ gap: 8px;
409
+ padding: 8px 12px;
410
+ background-color: var(--bp-c-bg-soft, #f6f6f7);
411
+ border: 1px solid var(--bp-c-divider, #e2e2e3);
412
+ color: var(--bp-c-text-1, #3c3c43);
413
+ font-size: 14px;
414
+ font-weight: 500;
415
+ cursor: pointer;
416
+ transition: all 0.2s ease;
417
+ }
418
+
419
+ .copy-page-button.copy-page-main {
420
+ border-radius: 8px 0 0 8px;
421
+ border-right: none;
422
+ padding-right: 12px;
423
+ }
424
+
425
+ .copy-page-button.copy-page-toggle {
426
+ border-radius: 0 8px 8px 0;
427
+ padding: 8px 8px;
428
+ border-left: 1px solid var(--bp-c-divider, #e2e2e3);
429
+ }
430
+
431
+ .copy-page-button:hover {
432
+ background-color: var(--bp-c-bg, #ffffff);
433
+ }
434
+
435
+ .copy-page-button-group:hover .copy-page-button {
436
+ border-color: var(--bp-c-brand-1, #5672cd);
437
+ }
438
+
439
+ .copy-page-button-group:hover .copy-page-toggle {
440
+ border-left-color: var(--bp-c-brand-1, #5672cd);
441
+ }
442
+
443
+ .copy-page-button svg {
444
+ width: 16px;
445
+ height: 16px;
446
+ }
447
+
448
+ .copy-page-button .chevron {
449
+ width: 12px;
450
+ height: 12px;
451
+ transition: transform 0.2s ease;
452
+ }
453
+
454
+ .copy-page-dropdown.open .copy-page-button .chevron {
455
+ transform: rotate(180deg);
456
+ }
457
+
458
+ /* Copied state */
459
+ .copy-page-button.copied {
460
+ background-color: var(--bp-c-success-soft, rgba(16, 185, 129, 0.14));
461
+ }
462
+
463
+ .copy-page-button.copied .copy-icon {
464
+ display: none;
465
+ }
466
+
467
+ .copy-page-button.copied .check-icon {
468
+ display: block !important;
469
+ color: var(--bp-c-success-1, #18794e);
470
+ }
471
+
472
+ .copy-page-button.copied .button-text {
473
+ color: var(--bp-c-success-1, #18794e);
474
+ }
475
+
476
+ .copy-page-menu {
477
+ position: absolute;
478
+ top: calc(100% + 8px);
479
+ right: 0;
480
+ min-width: 280px;
481
+ background-color: var(--bp-c-bg, #ffffff);
482
+ border: 1px solid var(--bp-c-divider, #e2e2e3);
483
+ border-radius: 12px;
484
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
485
+ opacity: 0;
486
+ visibility: hidden;
487
+ transform: translateY(-8px);
488
+ transition: all 0.2s ease;
489
+ z-index: 100;
490
+ overflow: hidden;
491
+ }
492
+
493
+ .copy-page-dropdown.open .copy-page-menu {
494
+ opacity: 1;
495
+ visibility: visible;
496
+ transform: translateY(0);
497
+ }
498
+
499
+ .copy-page-menu-item {
500
+ display: flex;
501
+ align-items: center;
502
+ gap: 12px;
503
+ padding: 12px 16px;
504
+ color: var(--bp-c-text-1, #3c3c43);
505
+ text-decoration: none;
506
+ cursor: pointer;
507
+ transition: background-color 0.15s ease;
508
+ }
509
+
510
+ .copy-page-menu-item:hover {
511
+ background-color: var(--bp-c-bg-soft, #f6f6f7);
512
+ }
513
+
514
+ .copy-page-menu-item .icon {
515
+ width: 24px;
516
+ height: 24px;
517
+ display: flex;
518
+ align-items: center;
519
+ justify-content: center;
520
+ flex-shrink: 0;
521
+ }
522
+
523
+ .copy-page-menu-item .icon svg {
524
+ width: 20px;
525
+ height: 20px;
526
+ }
527
+
528
+ .copy-page-menu-item .icon img {
529
+ width: 20px;
530
+ height: 20px;
531
+ border-radius: 4px;
532
+ }
533
+
534
+ .copy-page-menu-item .content {
535
+ flex: 1;
536
+ min-width: 0;
537
+ }
538
+
539
+ .copy-page-menu-item .title {
540
+ font-size: 14px;
541
+ font-weight: 500;
542
+ color: var(--bp-c-text-1, #3c3c43);
543
+ display: flex;
544
+ align-items: center;
545
+ gap: 4px;
546
+ }
547
+
548
+ .copy-page-menu-item .title .external-icon {
549
+ width: 12px;
550
+ height: 12px;
551
+ opacity: 0.6;
552
+ }
553
+
554
+ .copy-page-menu-item .description {
555
+ font-size: 12px;
556
+ color: var(--bp-c-text-2, #67676c);
557
+ margin-top: 2px;
558
+ }
559
+
560
+ .copy-page-menu-divider {
561
+ height: 1px;
562
+ background-color: var(--bp-c-divider, #e2e2e3);
563
+ margin: 4px 0;
564
+ }
565
+
566
+ .copy-page-menu-item.copied .title {
567
+ color: var(--bp-c-success-1, #18794e);
568
+ }
569
+
570
+ /* Dark mode support */
571
+ html.dark .copy-page-menu {
572
+ background-color: var(--bp-c-bg, #1a1a1a);
573
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
574
+ }
575
+
576
+ /* Toast notification */
577
+ .bp-toast {
578
+ position: fixed;
579
+ bottom: 24px;
580
+ left: 50%;
581
+ transform: translateX(-50%) translateY(100px);
582
+ display: flex;
583
+ align-items: center;
584
+ gap: 10px;
585
+ padding: 12px 20px;
586
+ background-color: var(--bp-c-bg, #ffffff);
587
+ border: 1px solid var(--bp-c-divider, #e2e2e3);
588
+ border-radius: 8px;
589
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
590
+ font-size: 14px;
591
+ font-weight: 500;
592
+ color: var(--bp-c-text-1, #3c3c43);
593
+ z-index: 9999;
594
+ opacity: 0;
595
+ transition: transform 0.3s ease, opacity 0.3s ease;
596
+ }
597
+
598
+ .bp-toast.show {
599
+ transform: translateX(-50%) translateY(0);
600
+ opacity: 1;
601
+ }
602
+
603
+ html.dark .bp-toast {
604
+ background-color: var(--bp-c-bg, #1a1a1a);
605
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
606
+ }
607
+
608
+ /* Theme Toggle Button */
609
+ .theme-toggle {
610
+ display: flex;
611
+ align-items: center;
612
+ justify-content: center;
613
+ width: 36px;
614
+ height: 36px;
615
+ padding: 0;
616
+ background: transparent;
617
+ border: 1px solid transparent;
618
+ border-radius: 8px;
619
+ cursor: pointer;
620
+ color: #6b7280;
621
+ transition: color 0.2s, background-color 0.2s, border-color 0.2s;
622
+ }
623
+
624
+ .theme-toggle:hover {
625
+ color: #3c3c43;
626
+ background-color: #f6f6f7;
627
+ border-color: #e2e2e3;
628
+ }
629
+
630
+ html.dark .theme-toggle {
631
+ color: #9ca3af;
632
+ }
633
+
634
+ html.dark .theme-toggle:hover {
635
+ color: #e6edf3;
636
+ background-color: #2e2e32;
637
+ border-color: #3c3f44;
638
+ }
639
+
640
+ .theme-toggle svg {
641
+ width: 20px;
642
+ height: 20px;
643
+ }
644
+
645
+ /* Show sun icon in dark mode, moon icon in light mode */
646
+ .theme-toggle .sun-icon {
647
+ display: none;
648
+ }
649
+
650
+ .theme-toggle .moon-icon {
651
+ display: block;
652
+ }
653
+
654
+ html.dark .theme-toggle .sun-icon {
655
+ display: block;
656
+ }
657
+
658
+ html.dark .theme-toggle .moon-icon {
659
+ display: none;
660
+ }
661
+ `,scripts:[`
662
+ // Theme toggle functionality
663
+ function getPreferredTheme() {
664
+ // A site can force a theme (config darkMode: 'dark' | 'light'), SSR'd as
665
+ // data-theme-mode on <html>. Honor it over localStorage/system so a forced
666
+ // theme is never overridden (and the SSR'd class is never stripped).
667
+ const forced = document.documentElement.getAttribute('data-theme-mode');
668
+ if (forced === 'dark' || forced === 'light') {
669
+ return forced;
670
+ }
671
+ // Check localStorage next
672
+ const stored = localStorage.getItem('bunpress-theme');
673
+ if (stored) {
674
+ return stored;
675
+ }
676
+ // Fall back to system preference
677
+ return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
678
+ }
679
+
680
+ function setTheme(theme) {
681
+ if (theme === 'dark') {
682
+ document.documentElement.classList.add('dark');
683
+ }
684
+ else {
685
+ document.documentElement.classList.remove('dark');
686
+ }
687
+ localStorage.setItem('bunpress-theme', theme);
688
+ }
689
+
690
+ function toggleTheme() {
691
+ const currentTheme = document.documentElement.classList.contains('dark') ? 'dark' : 'light';
692
+ const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
693
+ setTheme(newTheme);
694
+ }
695
+
696
+ // Initialize theme on page load
697
+ (function() {
698
+ const forced = document.documentElement.getAttribute('data-theme-mode');
699
+ const theme = getPreferredTheme();
700
+ setTheme(theme);
701
+
702
+ // A forced theme has no alternate to switch to; hide the toggle so nobody
703
+ // lands on a broken half-themed page from clicking it.
704
+ if (forced === 'dark' || forced === 'light') {
705
+ const toggle = document.querySelector('.theme-toggle');
706
+ if (toggle)
707
+ toggle.style.display = 'none';
708
+ return;
709
+ }
710
+
711
+ // Listen for system theme changes. Skip when the site forces a theme, and
712
+ // only auto-switch if the user hasn't manually set a preference.
713
+ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
714
+ const forced = document.documentElement.getAttribute('data-theme-mode');
715
+ if (forced === 'dark' || forced === 'light')
716
+ return;
717
+ if (!localStorage.getItem('bunpress-theme')) {
718
+ setTheme(e.matches ? 'dark' : 'light');
719
+ }
720
+ });
721
+ })();
722
+
723
+ function switchCodeTab(groupId, panelIndex) {
724
+ const group = document.getElementById(groupId);
725
+ if (!group) return;
726
+
727
+ // Update tabs
728
+ const tabs = group.querySelectorAll('.code-group-tab');
729
+ tabs.forEach((tab, index) => {
730
+ if (index === panelIndex) {
731
+ tab.classList.add('active');
732
+ }
733
+ else {
734
+ tab.classList.remove('active');
735
+ }
736
+ });
737
+
738
+ // Update panels
739
+ const panels = group.querySelectorAll('.code-group-panel');
740
+ panels.forEach((panel, index) => {
741
+ if (index === panelIndex) {
742
+ panel.classList.add('active');
743
+ }
744
+ else {
745
+ panel.classList.remove('active');
746
+ }
747
+ });
748
+ }
749
+
750
+ // Fallback copy function for browsers that don't support clipboard API
751
+ function fallbackCopyToClipboard(text) {
752
+ const textArea = document.createElement('textarea');
753
+ textArea.value = text;
754
+ textArea.style.position = 'fixed';
755
+ textArea.style.left = '-9999px';
756
+ textArea.style.top = '-9999px';
757
+ document.body.appendChild(textArea);
758
+ textArea.focus();
759
+ textArea.select();
760
+
761
+ try {
762
+ document.execCommand('copy');
763
+ document.body.removeChild(textArea);
764
+ return true;
765
+ }
766
+ catch (err) {
767
+ document.body.removeChild(textArea);
768
+ return false;
769
+ }
770
+ }
771
+
772
+ // Copy to clipboard with fallback
773
+ function copyToClipboard(text) {
774
+ return new Promise((resolve, reject) => {
775
+ // Try modern clipboard API first
776
+ if (navigator.clipboard && window.isSecureContext) {
777
+ navigator.clipboard.writeText(text)
778
+ .then(resolve)
779
+ .catch(() => {
780
+ // Fallback to execCommand
781
+ if (fallbackCopyToClipboard(text)) {
782
+ resolve();
783
+ }
784
+ else {
785
+ reject(new Error('Copy failed'));
786
+ }
787
+ });
788
+ }
789
+ else {
790
+ // Use fallback directly
791
+ if (fallbackCopyToClipboard(text)) {
792
+ resolve();
793
+ }
794
+ else {
795
+ reject(new Error('Copy failed'));
796
+ }
797
+ }
798
+ });
799
+ }
800
+
801
+ function copyCode(button) {
802
+ const pre = button.closest('pre');
803
+ if (!pre) return;
804
+
805
+ const code = pre.querySelector('code');
806
+ if (!code) return;
807
+
808
+ // Get text content from code block
809
+ const text = code.textContent || '';
810
+
811
+ // Copy to clipboard using fallback-enabled function
812
+ copyToClipboard(text).then(() => {
813
+ // Show copied state
814
+ button.classList.add('copied');
815
+
816
+ // Change icon to checkmark
817
+ const svg = button.querySelector('svg');
818
+ if (svg) {
819
+ svg.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>';
820
+ }
821
+
822
+ // Reset after 2 seconds
823
+ setTimeout(() => {
824
+ button.classList.remove('copied');
825
+ if (svg) {
826
+ svg.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>';
827
+ }
828
+ }, 2000);
829
+ }).catch(err => {
830
+ console.error('Failed to copy code:', err);
831
+ });
832
+ }
833
+
834
+ // Add copy buttons to all code blocks when page loads
835
+ if (typeof document !== 'undefined') {
836
+ document.addEventListener('DOMContentLoaded', () => {
837
+ const codeBlocks = document.querySelectorAll('pre > code');
838
+ codeBlocks.forEach(code => {
839
+ const pre = code.parentElement;
840
+ if (!pre || pre.querySelector('.copy-code-button')) return;
841
+
842
+ const button = document.createElement('button');
843
+ button.className = 'copy-code-button';
844
+ button.setAttribute('onclick', 'copyCode(this)');
845
+ button.setAttribute('aria-label', 'Copy code');
846
+ button.innerHTML = \`<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
847
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
848
+ </svg>\`;
849
+
850
+ pre.appendChild(button);
851
+ });
852
+
853
+ // Position Copy Page dropdown next to H1
854
+ const h1 = document.querySelector('article.bp-doc h1');
855
+ const dropdown = document.getElementById('copy-page-dropdown');
856
+ if (h1 && dropdown) {
857
+ // Create wrapper div for H1 and dropdown
858
+ const wrapper = document.createElement('div');
859
+ wrapper.className = 'bp-page-header';
860
+
861
+ // Insert wrapper before H1
862
+ h1.parentNode.insertBefore(wrapper, h1);
863
+
864
+ // Move H1 and dropdown into wrapper
865
+ wrapper.appendChild(h1);
866
+ wrapper.appendChild(dropdown);
867
+
868
+ // Show dropdown now that it's positioned
869
+ dropdown.classList.add('positioned');
870
+ }
871
+ });
872
+ }
873
+
874
+ // Copy Page Dropdown functionality
875
+ function toggleCopyPageDropdown(event) {
876
+ event.stopPropagation();
877
+ const dropdown = document.querySelector('.copy-page-dropdown');
878
+ if (dropdown) {
879
+ dropdown.classList.toggle('open');
880
+ }
881
+ }
882
+
883
+ function closeCopyPageDropdown() {
884
+ const dropdown = document.querySelector('.copy-page-dropdown');
885
+ if (dropdown) {
886
+ dropdown.classList.remove('open');
887
+ }
888
+ }
889
+
890
+ // Direct copy button (left side of split button)
891
+ function copyPageDirect(event) {
892
+ event.preventDefault();
893
+ event.stopPropagation();
894
+
895
+ const markdown = getPageAsMarkdown();
896
+ const button = event.currentTarget;
897
+ const textEl = button.querySelector('.button-text');
898
+
899
+ copyToClipboard(markdown).then(() => {
900
+ // Show copied state
901
+ button.classList.add('copied');
902
+ textEl.textContent = 'Copied!';
903
+
904
+ // Reset after delay
905
+ setTimeout(() => {
906
+ button.classList.remove('copied');
907
+ textEl.textContent = 'Copy page';
908
+ }, 2000);
909
+ }).catch(err => {
910
+ console.error('Failed to copy:', err);
911
+ showToast('Failed to copy. Please try again.');
912
+ });
913
+ }
914
+
915
+ // Get the page content as markdown-formatted text for LLMs
916
+ function getPageAsMarkdown() {
917
+ const article = document.querySelector('article.bp-doc');
918
+ if (!article) return '';
919
+
920
+ const title = document.querySelector('h1')?.textContent || document.title;
921
+ const url = window.location.href;
922
+
923
+ // Clone the article to avoid modifying the original
924
+ const clone = article.cloneNode(true);
925
+
926
+ // Remove copy buttons and other UI elements
927
+ clone.querySelectorAll('.copy-code-button, .copy-page-dropdown').forEach(el => el.remove());
928
+
929
+ // Convert HTML back to a readable markdown-like format
930
+ let content = '';
931
+
932
+ function processNode(node, depth = 0) {
933
+ if (node.nodeType === Node.TEXT_NODE) {
934
+ return node.textContent;
935
+ }
936
+
937
+ if (node.nodeType !== Node.ELEMENT_NODE) return '';
938
+
939
+ const tag = node.tagName.toLowerCase();
940
+ let text = '';
941
+
942
+ switch(tag) {
943
+ case 'h1':
944
+ text = \`# \${node.textContent}\\n\\n\`;
945
+ break;
946
+ case 'h2':
947
+ text = \`## \${node.textContent}\\n\\n\`;
948
+ break;
949
+ case 'h3':
950
+ text = \`### \${node.textContent}\\n\\n\`;
951
+ break;
952
+ case 'h4':
953
+ text = \`#### \${node.textContent}\\n\\n\`;
954
+ break;
955
+ case 'h5':
956
+ text = \`##### \${node.textContent}\\n\\n\`;
957
+ break;
958
+ case 'h6':
959
+ text = \`###### \${node.textContent}\\n\\n\`;
960
+ break;
961
+ case 'p':
962
+ text = Array.from(node.childNodes).map(n => processNode(n, depth)).join('') + '\\n\\n';
963
+ break;
964
+ case 'pre':
965
+ const code = node.querySelector('code');
966
+ const lang = code?.className?.match(/language-(\\w+)/)?.[1] || '';
967
+ text = '\`\`\`' + lang + '\\n' + (code?.textContent || node.textContent) + '\\n\`\`\`\\n\\n';
968
+ break;
969
+ case 'code':
970
+ if (node.parentElement?.tagName.toLowerCase() !== 'pre') {
971
+ text = '\`' + node.textContent + '\`';
972
+ }
973
+ break;
974
+ case 'strong':
975
+ case 'b':
976
+ text = \`**\${node.textContent}**\`;
977
+ break;
978
+ case 'em':
979
+ case 'i':
980
+ text = \`*\${node.textContent}*\`;
981
+ break;
982
+ case 'a':
983
+ const href = node.getAttribute('href');
984
+ text = \`[\${node.textContent}](\${href?.startsWith('/') ? window.location.origin + href : href})\`;
985
+ break;
986
+ case 'ul':
987
+ text = \`\${Array.from(node.children).map(li => \`- \${li.textContent}\`).join('\\n')}\\n\\n\`;
988
+ break;
989
+ case 'ol':
990
+ text = \`\${Array.from(node.children).map((li, i) => \`\${i + 1}. \${li.textContent}\`).join('\\n')}\\n\\n\`;
991
+ break;
992
+ case 'blockquote':
993
+ text = \`\${node.textContent.split('\\n').map(line => \`> \${line}\`).join('\\n')}\\n\\n\`;
994
+ break;
995
+ case 'hr':
996
+ text = '---\\n\\n';
997
+ break;
998
+ case 'br':
999
+ text = '\\n';
1000
+ break;
1001
+ case 'table':
1002
+ // Simple table handling
1003
+ const rows = node.querySelectorAll('tr');
1004
+ rows.forEach((row, i) => {
1005
+ const cells = row.querySelectorAll('th, td');
1006
+ text += \`| \${Array.from(cells).map(c => c.textContent.trim()).join(' | ')} |\\n\`;
1007
+ if (i === 0) {
1008
+ text += \`| \${Array.from(cells).map(() => '---').join(' | ')} |\\n\`;
1009
+ }
1010
+ });
1011
+ text += '\\n';
1012
+ break;
1013
+ default:
1014
+ // For other elements, just process children
1015
+ text = Array.from(node.childNodes).map(n => processNode(n, depth)).join('');
1016
+ }
1017
+
1018
+ return text;
1019
+ }
1020
+
1021
+ content = Array.from(clone.childNodes).map(n => processNode(n)).join('');
1022
+
1023
+ // Clean up extra newlines
1024
+ content = content.replace(/\\n{3,}/g, '\\n\\n').trim();
1025
+
1026
+ return \`# \${title}\\n\\nSource: \${url}\\n\\n\${content}\`;
1027
+ }
1028
+
1029
+ // Show toast notification
1030
+ function showToast(message, duration = 3000) {
1031
+ // Remove existing toast
1032
+ const existingToast = document.querySelector('.bp-toast');
1033
+ if (existingToast) {
1034
+ existingToast.remove();
1035
+ }
1036
+
1037
+ const toast = document.createElement('div');
1038
+ toast.className = 'bp-toast';
1039
+ toast.innerHTML = \`
1040
+ <svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="width: 20px; height: 20px; color: #10b981;">
1041
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
1042
+ </svg>
1043
+ <span>\${message}</span>
1044
+ \`;
1045
+ document.body.appendChild(toast);
1046
+
1047
+ // Trigger animation
1048
+ requestAnimationFrame(() => {
1049
+ toast.classList.add('show');
1050
+ });
1051
+
1052
+ setTimeout(() => {
1053
+ toast.classList.remove('show');
1054
+ setTimeout(() => toast.remove(), 300);
1055
+ }, duration);
1056
+ }
1057
+
1058
+ function copyPageAsMarkdown(event) {
1059
+ event.preventDefault();
1060
+ event.stopPropagation();
1061
+
1062
+ const markdown = getPageAsMarkdown();
1063
+
1064
+ copyToClipboard(markdown).then(() => {
1065
+ // Update button to show copied state
1066
+ const menuItem = event.currentTarget;
1067
+ const iconEl = menuItem.querySelector('.icon svg');
1068
+ const titleEl = menuItem.querySelector('.title');
1069
+ const originalIcon = iconEl.outerHTML;
1070
+ const originalTitle = titleEl.textContent;
1071
+
1072
+ // Show checkmark icon
1073
+ iconEl.outerHTML = '<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="color: #10b981;"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg>';
1074
+ titleEl.textContent = 'Copied to clipboard!';
1075
+ menuItem.classList.add('copied');
1076
+
1077
+ // Show toast
1078
+ showToast('Page copied as Markdown');
1079
+
1080
+ setTimeout(() => {
1081
+ menuItem.querySelector('.icon').innerHTML = originalIcon;
1082
+ titleEl.textContent = originalTitle;
1083
+ menuItem.classList.remove('copied');
1084
+ closeCopyPageDropdown();
1085
+ }, 1500);
1086
+ }).catch(err => {
1087
+ console.error('Failed to copy:', err);
1088
+ showToast('Failed to copy. Please try again.');
1089
+ });
1090
+ }
1091
+
1092
+ function viewAsMarkdown(event) {
1093
+ event.preventDefault();
1094
+ const markdown = getPageAsMarkdown();
1095
+ const blob = new Blob([markdown], { type: 'text/plain' });
1096
+ const url = URL.createObjectURL(blob);
1097
+ window.open(url, '_blank');
1098
+ closeCopyPageDropdown();
1099
+ }
1100
+
1101
+ function openInChatGPT(event) {
1102
+ event.preventDefault();
1103
+ event.stopPropagation();
1104
+
1105
+ const title = document.querySelector('h1')?.textContent || document.title;
1106
+ const pageUrl = window.location.href;
1107
+ const markdown = getPageAsMarkdown();
1108
+
1109
+ const prompt = \`Please help me understand this documentation page:
1110
+
1111
+ Title: \${title}
1112
+ URL: \${pageUrl}
1113
+
1114
+ ---
1115
+
1116
+ \${markdown}\`;
1117
+
1118
+ copyToClipboard(prompt).then(() => {
1119
+ showToast('Content copied! Paste it in ChatGPT');
1120
+ closeCopyPageDropdown();
1121
+ setTimeout(() => {
1122
+ window.open('https://chat.openai.com/', '_blank');
1123
+ }, 500);
1124
+ }).catch(err => {
1125
+ console.error('Failed to copy:', err);
1126
+ showToast('Failed to copy. Please try again.');
1127
+ });
1128
+ }
1129
+
1130
+ function openInClaude(event) {
1131
+ event.preventDefault();
1132
+ event.stopPropagation();
1133
+
1134
+ const title = document.querySelector('h1')?.textContent || document.title;
1135
+ const pageUrl = window.location.href;
1136
+ const markdown = getPageAsMarkdown();
1137
+
1138
+ const prompt = \`Please help me understand this documentation page:
1139
+
1140
+ Title: \${title}
1141
+ URL: \${pageUrl}
1142
+
1143
+ ---
1144
+
1145
+ \${markdown}\`;
1146
+
1147
+ copyToClipboard(prompt).then(() => {
1148
+ showToast('Content copied! Paste it in Claude');
1149
+ closeCopyPageDropdown();
1150
+ setTimeout(() => {
1151
+ window.open('https://claude.ai/new', '_blank');
1152
+ }, 500);
1153
+ }).catch(err => {
1154
+ console.error('Failed to copy:', err);
1155
+ showToast('Failed to copy. Please try again.');
1156
+ });
1157
+ }
1158
+
1159
+ function openInPerplexity(event) {
1160
+ event.preventDefault();
1161
+ event.stopPropagation();
1162
+
1163
+ const title = document.querySelector('h1')?.textContent || document.title;
1164
+ const pageUrl = window.location.href;
1165
+
1166
+ // Perplexity supports URL-based search
1167
+ const query = encodeURIComponent(\`Explain this documentation: "\${title}" \${pageUrl}\`);
1168
+ closeCopyPageDropdown();
1169
+ window.open(\`https://www.perplexity.ai/search?q=\${query}\`, '_blank');
1170
+ }
1171
+
1172
+ // Close dropdown when clicking outside
1173
+ if (typeof document !== 'undefined') {
1174
+ document.addEventListener('click', (event) => {
1175
+ const dropdown = document.querySelector('.copy-page-dropdown');
1176
+ if (dropdown && !dropdown.contains(event.target)) {
1177
+ closeCopyPageDropdown();
1178
+ }
1179
+ });
1180
+
1181
+ // Close dropdown on escape key
1182
+ document.addEventListener('keydown', (event) => {
1183
+ if (event.key === 'Escape') {
1184
+ closeCopyPageDropdown();
1185
+ }
1186
+ });
1187
+ }
1188
+ `],preserveDirectoryStructure:!0,features:{inlineFormatting:!0,containers:!0,githubAlerts:!0,codeBlocks:{lineHighlighting:!0,lineNumbers:!0,focus:!0,diffs:!0,errorWarningMarkers:!0},codeGroups:!0,codeImports:!0,inlineToc:!0,customAnchors:!0,emoji:!0,badges:!0,includes:!0,externalLinks:{autoTarget:!0,autoRel:!0,showIcon:!0},imageLazyLoading:!0,tables:{alignment:!0,enhancedStyling:!0,responsive:!0}},syntaxHighlightTheme:"github-light"},verbose:!1,sitemap:{enabled:!0,filename:"sitemap.xml",defaultPriority:0.5,defaultChangefreq:"monthly",maxUrlsPerFile:50000,useSitemapIndex:!1},robots:{enabled:!0,filename:"robots.txt"}},q=await h({name:"bunpress",alias:"docs",defaultConfig:j});async function x(){return q}
1189
+ export{j as P,q as Q,x as R};