@stacksjs/bunpress 0.1.8 → 0.1.10

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,1169 @@
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
+ // Check localStorage first
665
+ const stored = localStorage.getItem('bunpress-theme');
666
+ if (stored) {
667
+ return stored;
668
+ }
669
+ // Fall back to system preference
670
+ return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
671
+ }
672
+
673
+ function setTheme(theme) {
674
+ if (theme === 'dark') {
675
+ document.documentElement.classList.add('dark');
676
+ }
677
+ else {
678
+ document.documentElement.classList.remove('dark');
679
+ }
680
+ localStorage.setItem('bunpress-theme', theme);
681
+ }
682
+
683
+ function toggleTheme() {
684
+ const currentTheme = document.documentElement.classList.contains('dark') ? 'dark' : 'light';
685
+ const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
686
+ setTheme(newTheme);
687
+ }
688
+
689
+ // Initialize theme on page load
690
+ (function() {
691
+ const theme = getPreferredTheme();
692
+ setTheme(theme);
693
+
694
+ // Listen for system theme changes
695
+ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
696
+ // Only auto-switch if user hasn't manually set a preference
697
+ if (!localStorage.getItem('bunpress-theme')) {
698
+ setTheme(e.matches ? 'dark' : 'light');
699
+ }
700
+ });
701
+ })();
702
+
703
+ function switchCodeTab(groupId, panelIndex) {
704
+ const group = document.getElementById(groupId);
705
+ if (!group) return;
706
+
707
+ // Update tabs
708
+ const tabs = group.querySelectorAll('.code-group-tab');
709
+ tabs.forEach((tab, index) => {
710
+ if (index === panelIndex) {
711
+ tab.classList.add('active');
712
+ }
713
+ else {
714
+ tab.classList.remove('active');
715
+ }
716
+ });
717
+
718
+ // Update panels
719
+ const panels = group.querySelectorAll('.code-group-panel');
720
+ panels.forEach((panel, index) => {
721
+ if (index === panelIndex) {
722
+ panel.classList.add('active');
723
+ }
724
+ else {
725
+ panel.classList.remove('active');
726
+ }
727
+ });
728
+ }
729
+
730
+ // Fallback copy function for browsers that don't support clipboard API
731
+ function fallbackCopyToClipboard(text) {
732
+ const textArea = document.createElement('textarea');
733
+ textArea.value = text;
734
+ textArea.style.position = 'fixed';
735
+ textArea.style.left = '-9999px';
736
+ textArea.style.top = '-9999px';
737
+ document.body.appendChild(textArea);
738
+ textArea.focus();
739
+ textArea.select();
740
+
741
+ try {
742
+ document.execCommand('copy');
743
+ document.body.removeChild(textArea);
744
+ return true;
745
+ }
746
+ catch (err) {
747
+ document.body.removeChild(textArea);
748
+ return false;
749
+ }
750
+ }
751
+
752
+ // Copy to clipboard with fallback
753
+ function copyToClipboard(text) {
754
+ return new Promise((resolve, reject) => {
755
+ // Try modern clipboard API first
756
+ if (navigator.clipboard && window.isSecureContext) {
757
+ navigator.clipboard.writeText(text)
758
+ .then(resolve)
759
+ .catch(() => {
760
+ // Fallback to execCommand
761
+ if (fallbackCopyToClipboard(text)) {
762
+ resolve();
763
+ }
764
+ else {
765
+ reject(new Error('Copy failed'));
766
+ }
767
+ });
768
+ }
769
+ else {
770
+ // Use fallback directly
771
+ if (fallbackCopyToClipboard(text)) {
772
+ resolve();
773
+ }
774
+ else {
775
+ reject(new Error('Copy failed'));
776
+ }
777
+ }
778
+ });
779
+ }
780
+
781
+ function copyCode(button) {
782
+ const pre = button.closest('pre');
783
+ if (!pre) return;
784
+
785
+ const code = pre.querySelector('code');
786
+ if (!code) return;
787
+
788
+ // Get text content from code block
789
+ const text = code.textContent || '';
790
+
791
+ // Copy to clipboard using fallback-enabled function
792
+ copyToClipboard(text).then(() => {
793
+ // Show copied state
794
+ button.classList.add('copied');
795
+
796
+ // Change icon to checkmark
797
+ const svg = button.querySelector('svg');
798
+ if (svg) {
799
+ svg.innerHTML = '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>';
800
+ }
801
+
802
+ // Reset after 2 seconds
803
+ setTimeout(() => {
804
+ button.classList.remove('copied');
805
+ if (svg) {
806
+ 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>';
807
+ }
808
+ }, 2000);
809
+ }).catch(err => {
810
+ console.error('Failed to copy code:', err);
811
+ });
812
+ }
813
+
814
+ // Add copy buttons to all code blocks when page loads
815
+ if (typeof document !== 'undefined') {
816
+ document.addEventListener('DOMContentLoaded', () => {
817
+ const codeBlocks = document.querySelectorAll('pre > code');
818
+ codeBlocks.forEach(code => {
819
+ const pre = code.parentElement;
820
+ if (!pre || pre.querySelector('.copy-code-button')) return;
821
+
822
+ const button = document.createElement('button');
823
+ button.className = 'copy-code-button';
824
+ button.setAttribute('onclick', 'copyCode(this)');
825
+ button.setAttribute('aria-label', 'Copy code');
826
+ button.innerHTML = \`<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
827
+ <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>
828
+ </svg>\`;
829
+
830
+ pre.appendChild(button);
831
+ });
832
+
833
+ // Position Copy Page dropdown next to H1
834
+ const h1 = document.querySelector('article.bp-doc h1');
835
+ const dropdown = document.getElementById('copy-page-dropdown');
836
+ if (h1 && dropdown) {
837
+ // Create wrapper div for H1 and dropdown
838
+ const wrapper = document.createElement('div');
839
+ wrapper.className = 'bp-page-header';
840
+
841
+ // Insert wrapper before H1
842
+ h1.parentNode.insertBefore(wrapper, h1);
843
+
844
+ // Move H1 and dropdown into wrapper
845
+ wrapper.appendChild(h1);
846
+ wrapper.appendChild(dropdown);
847
+
848
+ // Show dropdown now that it's positioned
849
+ dropdown.classList.add('positioned');
850
+ }
851
+ });
852
+ }
853
+
854
+ // Copy Page Dropdown functionality
855
+ function toggleCopyPageDropdown(event) {
856
+ event.stopPropagation();
857
+ const dropdown = document.querySelector('.copy-page-dropdown');
858
+ if (dropdown) {
859
+ dropdown.classList.toggle('open');
860
+ }
861
+ }
862
+
863
+ function closeCopyPageDropdown() {
864
+ const dropdown = document.querySelector('.copy-page-dropdown');
865
+ if (dropdown) {
866
+ dropdown.classList.remove('open');
867
+ }
868
+ }
869
+
870
+ // Direct copy button (left side of split button)
871
+ function copyPageDirect(event) {
872
+ event.preventDefault();
873
+ event.stopPropagation();
874
+
875
+ const markdown = getPageAsMarkdown();
876
+ const button = event.currentTarget;
877
+ const textEl = button.querySelector('.button-text');
878
+
879
+ copyToClipboard(markdown).then(() => {
880
+ // Show copied state
881
+ button.classList.add('copied');
882
+ textEl.textContent = 'Copied!';
883
+
884
+ // Reset after delay
885
+ setTimeout(() => {
886
+ button.classList.remove('copied');
887
+ textEl.textContent = 'Copy page';
888
+ }, 2000);
889
+ }).catch(err => {
890
+ console.error('Failed to copy:', err);
891
+ showToast('Failed to copy. Please try again.');
892
+ });
893
+ }
894
+
895
+ // Get the page content as markdown-formatted text for LLMs
896
+ function getPageAsMarkdown() {
897
+ const article = document.querySelector('article.bp-doc');
898
+ if (!article) return '';
899
+
900
+ const title = document.querySelector('h1')?.textContent || document.title;
901
+ const url = window.location.href;
902
+
903
+ // Clone the article to avoid modifying the original
904
+ const clone = article.cloneNode(true);
905
+
906
+ // Remove copy buttons and other UI elements
907
+ clone.querySelectorAll('.copy-code-button, .copy-page-dropdown').forEach(el => el.remove());
908
+
909
+ // Convert HTML back to a readable markdown-like format
910
+ let content = '';
911
+
912
+ function processNode(node, depth = 0) {
913
+ if (node.nodeType === Node.TEXT_NODE) {
914
+ return node.textContent;
915
+ }
916
+
917
+ if (node.nodeType !== Node.ELEMENT_NODE) return '';
918
+
919
+ const tag = node.tagName.toLowerCase();
920
+ let text = '';
921
+
922
+ switch(tag) {
923
+ case 'h1':
924
+ text = \`# \${node.textContent}\\n\\n\`;
925
+ break;
926
+ case 'h2':
927
+ text = \`## \${node.textContent}\\n\\n\`;
928
+ break;
929
+ case 'h3':
930
+ text = \`### \${node.textContent}\\n\\n\`;
931
+ break;
932
+ case 'h4':
933
+ text = \`#### \${node.textContent}\\n\\n\`;
934
+ break;
935
+ case 'h5':
936
+ text = \`##### \${node.textContent}\\n\\n\`;
937
+ break;
938
+ case 'h6':
939
+ text = \`###### \${node.textContent}\\n\\n\`;
940
+ break;
941
+ case 'p':
942
+ text = Array.from(node.childNodes).map(n => processNode(n, depth)).join('') + '\\n\\n';
943
+ break;
944
+ case 'pre':
945
+ const code = node.querySelector('code');
946
+ const lang = code?.className?.match(/language-(\\w+)/)?.[1] || '';
947
+ text = '\`\`\`' + lang + '\\n' + (code?.textContent || node.textContent) + '\\n\`\`\`\\n\\n';
948
+ break;
949
+ case 'code':
950
+ if (node.parentElement?.tagName.toLowerCase() !== 'pre') {
951
+ text = '\`' + node.textContent + '\`';
952
+ }
953
+ break;
954
+ case 'strong':
955
+ case 'b':
956
+ text = \`**\${node.textContent}**\`;
957
+ break;
958
+ case 'em':
959
+ case 'i':
960
+ text = \`*\${node.textContent}*\`;
961
+ break;
962
+ case 'a':
963
+ const href = node.getAttribute('href');
964
+ text = \`[\${node.textContent}](\${href?.startsWith('/') ? window.location.origin + href : href})\`;
965
+ break;
966
+ case 'ul':
967
+ text = \`\${Array.from(node.children).map(li => \`- \${li.textContent}\`).join('\\n')}\\n\\n\`;
968
+ break;
969
+ case 'ol':
970
+ text = \`\${Array.from(node.children).map((li, i) => \`\${i + 1}. \${li.textContent}\`).join('\\n')}\\n\\n\`;
971
+ break;
972
+ case 'blockquote':
973
+ text = \`\${node.textContent.split('\\n').map(line => \`> \${line}\`).join('\\n')}\\n\\n\`;
974
+ break;
975
+ case 'hr':
976
+ text = '---\\n\\n';
977
+ break;
978
+ case 'br':
979
+ text = '\\n';
980
+ break;
981
+ case 'table':
982
+ // Simple table handling
983
+ const rows = node.querySelectorAll('tr');
984
+ rows.forEach((row, i) => {
985
+ const cells = row.querySelectorAll('th, td');
986
+ text += \`| \${Array.from(cells).map(c => c.textContent.trim()).join(' | ')} |\\n\`;
987
+ if (i === 0) {
988
+ text += \`| \${Array.from(cells).map(() => '---').join(' | ')} |\\n\`;
989
+ }
990
+ });
991
+ text += '\\n';
992
+ break;
993
+ default:
994
+ // For other elements, just process children
995
+ text = Array.from(node.childNodes).map(n => processNode(n, depth)).join('');
996
+ }
997
+
998
+ return text;
999
+ }
1000
+
1001
+ content = Array.from(clone.childNodes).map(n => processNode(n)).join('');
1002
+
1003
+ // Clean up extra newlines
1004
+ content = content.replace(/\\n{3,}/g, '\\n\\n').trim();
1005
+
1006
+ return \`# \${title}\\n\\nSource: \${url}\\n\\n\${content}\`;
1007
+ }
1008
+
1009
+ // Show toast notification
1010
+ function showToast(message, duration = 3000) {
1011
+ // Remove existing toast
1012
+ const existingToast = document.querySelector('.bp-toast');
1013
+ if (existingToast) {
1014
+ existingToast.remove();
1015
+ }
1016
+
1017
+ const toast = document.createElement('div');
1018
+ toast.className = 'bp-toast';
1019
+ toast.innerHTML = \`
1020
+ <svg fill="none" stroke="currentColor" viewBox="0 0 24 24" style="width: 20px; height: 20px; color: #10b981;">
1021
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
1022
+ </svg>
1023
+ <span>\${message}</span>
1024
+ \`;
1025
+ document.body.appendChild(toast);
1026
+
1027
+ // Trigger animation
1028
+ requestAnimationFrame(() => {
1029
+ toast.classList.add('show');
1030
+ });
1031
+
1032
+ setTimeout(() => {
1033
+ toast.classList.remove('show');
1034
+ setTimeout(() => toast.remove(), 300);
1035
+ }, duration);
1036
+ }
1037
+
1038
+ function copyPageAsMarkdown(event) {
1039
+ event.preventDefault();
1040
+ event.stopPropagation();
1041
+
1042
+ const markdown = getPageAsMarkdown();
1043
+
1044
+ copyToClipboard(markdown).then(() => {
1045
+ // Update button to show copied state
1046
+ const menuItem = event.currentTarget;
1047
+ const iconEl = menuItem.querySelector('.icon svg');
1048
+ const titleEl = menuItem.querySelector('.title');
1049
+ const originalIcon = iconEl.outerHTML;
1050
+ const originalTitle = titleEl.textContent;
1051
+
1052
+ // Show checkmark icon
1053
+ 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>';
1054
+ titleEl.textContent = 'Copied to clipboard!';
1055
+ menuItem.classList.add('copied');
1056
+
1057
+ // Show toast
1058
+ showToast('Page copied as Markdown');
1059
+
1060
+ setTimeout(() => {
1061
+ menuItem.querySelector('.icon').innerHTML = originalIcon;
1062
+ titleEl.textContent = originalTitle;
1063
+ menuItem.classList.remove('copied');
1064
+ closeCopyPageDropdown();
1065
+ }, 1500);
1066
+ }).catch(err => {
1067
+ console.error('Failed to copy:', err);
1068
+ showToast('Failed to copy. Please try again.');
1069
+ });
1070
+ }
1071
+
1072
+ function viewAsMarkdown(event) {
1073
+ event.preventDefault();
1074
+ const markdown = getPageAsMarkdown();
1075
+ const blob = new Blob([markdown], { type: 'text/plain' });
1076
+ const url = URL.createObjectURL(blob);
1077
+ window.open(url, '_blank');
1078
+ closeCopyPageDropdown();
1079
+ }
1080
+
1081
+ function openInChatGPT(event) {
1082
+ event.preventDefault();
1083
+ event.stopPropagation();
1084
+
1085
+ const title = document.querySelector('h1')?.textContent || document.title;
1086
+ const pageUrl = window.location.href;
1087
+ const markdown = getPageAsMarkdown();
1088
+
1089
+ const prompt = \`Please help me understand this documentation page:
1090
+
1091
+ Title: \${title}
1092
+ URL: \${pageUrl}
1093
+
1094
+ ---
1095
+
1096
+ \${markdown}\`;
1097
+
1098
+ copyToClipboard(prompt).then(() => {
1099
+ showToast('Content copied! Paste it in ChatGPT');
1100
+ closeCopyPageDropdown();
1101
+ setTimeout(() => {
1102
+ window.open('https://chat.openai.com/', '_blank');
1103
+ }, 500);
1104
+ }).catch(err => {
1105
+ console.error('Failed to copy:', err);
1106
+ showToast('Failed to copy. Please try again.');
1107
+ });
1108
+ }
1109
+
1110
+ function openInClaude(event) {
1111
+ event.preventDefault();
1112
+ event.stopPropagation();
1113
+
1114
+ const title = document.querySelector('h1')?.textContent || document.title;
1115
+ const pageUrl = window.location.href;
1116
+ const markdown = getPageAsMarkdown();
1117
+
1118
+ const prompt = \`Please help me understand this documentation page:
1119
+
1120
+ Title: \${title}
1121
+ URL: \${pageUrl}
1122
+
1123
+ ---
1124
+
1125
+ \${markdown}\`;
1126
+
1127
+ copyToClipboard(prompt).then(() => {
1128
+ showToast('Content copied! Paste it in Claude');
1129
+ closeCopyPageDropdown();
1130
+ setTimeout(() => {
1131
+ window.open('https://claude.ai/new', '_blank');
1132
+ }, 500);
1133
+ }).catch(err => {
1134
+ console.error('Failed to copy:', err);
1135
+ showToast('Failed to copy. Please try again.');
1136
+ });
1137
+ }
1138
+
1139
+ function openInPerplexity(event) {
1140
+ event.preventDefault();
1141
+ event.stopPropagation();
1142
+
1143
+ const title = document.querySelector('h1')?.textContent || document.title;
1144
+ const pageUrl = window.location.href;
1145
+
1146
+ // Perplexity supports URL-based search
1147
+ const query = encodeURIComponent(\`Explain this documentation: "\${title}" \${pageUrl}\`);
1148
+ closeCopyPageDropdown();
1149
+ window.open(\`https://www.perplexity.ai/search?q=\${query}\`, '_blank');
1150
+ }
1151
+
1152
+ // Close dropdown when clicking outside
1153
+ if (typeof document !== 'undefined') {
1154
+ document.addEventListener('click', (event) => {
1155
+ const dropdown = document.querySelector('.copy-page-dropdown');
1156
+ if (dropdown && !dropdown.contains(event.target)) {
1157
+ closeCopyPageDropdown();
1158
+ }
1159
+ });
1160
+
1161
+ // Close dropdown on escape key
1162
+ document.addEventListener('keydown', (event) => {
1163
+ if (event.key === 'Escape') {
1164
+ closeCopyPageDropdown();
1165
+ }
1166
+ });
1167
+ }
1168
+ `],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}
1169
+ export{j as P,q as Q,x as R};