@mgks/docmd 0.1.0 → 0.1.2
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/.github/workflows/publish.yml +1 -1
- package/README.md +2 -2
- package/bin/docmd.js +8 -2
- package/config.js +31 -31
- package/docs/cli-commands.md +13 -0
- package/docs/content/images.md +205 -0
- package/docs/content/index.md +17 -0
- package/docs/theming/assets-management.md +126 -0
- package/docs/theming/custom-css-js.md +3 -6
- package/package.json +2 -1
- package/src/assets/css/{main.css → docmd-main.css} +255 -10
- package/src/assets/css/{theme-sky.css → docmd-theme-sky.css} +153 -1
- package/src/assets/js/docmd-image-lightbox.js +72 -0
- package/src/assets/js/{theme-toggle.js → docmd-theme-toggle.js} +4 -4
- package/src/commands/build.js +151 -9
- package/src/commands/dev.js +103 -17
- package/src/commands/init.js +198 -17
- package/src/core/file-processor.js +40 -0
- package/src/core/html-generator.js +7 -3
- package/src/plugins/sitemap.js +10 -3
- package/src/templates/layout.ejs +5 -63
- package/src/templates/toc.ejs +53 -20
- package/docs/writing-content/index.md +0 -17
- package/src/assets/css/toc.css +0 -76
- /package/docs/{writing-content → content}/custom-containers.md +0 -0
- /package/docs/{writing-content → content}/frontmatter.md +0 -0
- /package/docs/{writing-content → content}/markdown-syntax.md +0 -0
- /package/src/assets/css/{highlight-dark.css → docmd-highlight-dark.css} +0 -0
- /package/src/assets/css/{highlight-light.css → docmd-highlight-light.css} +0 -0
- /package/src/assets/images/{logo-dark.png → docmd-logo-dark.png} +0 -0
- /package/src/assets/images/{logo-light.png → docmd-logo-light.png} +0 -0
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/* src/assets/css/main.css */
|
|
2
|
-
@import url('./toc.css'); /* Import the TOC styles */
|
|
3
|
-
|
|
1
|
+
/* src/assets/css/docmd-main.css */
|
|
4
2
|
:root {
|
|
5
3
|
--font-family-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
6
4
|
--font-family-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
|
@@ -18,6 +16,14 @@
|
|
|
18
16
|
--code-text: #333;
|
|
19
17
|
--header-bg: #ffffff; /* Added for header */
|
|
20
18
|
--header-border: #e0e0e0; /* Added for header border */
|
|
19
|
+
|
|
20
|
+
/* Image styling variables */
|
|
21
|
+
--image-border-color: #e0e0e0;
|
|
22
|
+
--image-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
23
|
+
--image-caption-bg: #f8f8f8;
|
|
24
|
+
--image-caption-text: #666;
|
|
25
|
+
--lightbox-bg: rgba(0, 0, 0, 0.9);
|
|
26
|
+
--lightbox-text: #fff;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
body[data-theme="dark"] {
|
|
@@ -33,6 +39,14 @@
|
|
|
33
39
|
--code-text: #abb2bf;
|
|
34
40
|
--header-bg: #1a1a1a; /* Added for header */
|
|
35
41
|
--header-border: #444444; /* Added for header border */
|
|
42
|
+
|
|
43
|
+
/* Image styling variables for dark mode */
|
|
44
|
+
--image-border-color: #444444;
|
|
45
|
+
--image-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
|
46
|
+
--image-caption-bg: #2c2c2c;
|
|
47
|
+
--image-caption-text: #bdc3c7;
|
|
48
|
+
--lightbox-bg: rgba(0, 0, 0, 0.95);
|
|
49
|
+
--lightbox-text: #fff;
|
|
36
50
|
}
|
|
37
51
|
|
|
38
52
|
body {
|
|
@@ -275,11 +289,6 @@
|
|
|
275
289
|
.callout .callout-content > :first-child { margin-top: 0; }
|
|
276
290
|
.callout .callout-content > :last-child { margin-bottom: 0; }
|
|
277
291
|
|
|
278
|
-
|
|
279
|
-
/* Cards */
|
|
280
|
-
.card {
|
|
281
|
-
/* background-color: var(--code-bg); /* Already set by .docmd-container */
|
|
282
|
-
}
|
|
283
292
|
.card .card-title {
|
|
284
293
|
font-weight: bold;
|
|
285
294
|
font-size: 1.1em;
|
|
@@ -497,8 +506,10 @@
|
|
|
497
506
|
text-align: right;
|
|
498
507
|
opacity: 0.9;
|
|
499
508
|
font-weight: 500;
|
|
500
|
-
|
|
501
509
|
}
|
|
510
|
+
.branding-footer svg {
|
|
511
|
+
color: rgb(251, 58, 58);
|
|
512
|
+
}
|
|
502
513
|
|
|
503
514
|
.page-footer a {
|
|
504
515
|
color: var(--link-color);
|
|
@@ -559,4 +570,238 @@
|
|
|
559
570
|
display: flex;
|
|
560
571
|
flex-direction: column-reverse;
|
|
561
572
|
}
|
|
562
|
-
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/* TOC Styles - Simplified Hyperlink Style */
|
|
576
|
+
.toc-container {
|
|
577
|
+
margin: 0;
|
|
578
|
+
padding: 0;
|
|
579
|
+
border: none;
|
|
580
|
+
background-color: transparent;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
.toc-title {
|
|
584
|
+
margin-top: 0;
|
|
585
|
+
margin-bottom: 0.5rem;
|
|
586
|
+
font-size: 1rem;
|
|
587
|
+
font-weight: bold;
|
|
588
|
+
color: var(--text-muted);
|
|
589
|
+
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
.toc-list {
|
|
593
|
+
list-style: none;
|
|
594
|
+
padding-left: 0;
|
|
595
|
+
margin: 0;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
.toc-item {
|
|
599
|
+
margin-bottom: 0.25rem;
|
|
600
|
+
line-height: 1.4;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
.toc-link {
|
|
604
|
+
text-decoration: none;
|
|
605
|
+
color: var(--link-color);
|
|
606
|
+
display: inline-block;
|
|
607
|
+
padding: 0.1rem 0;
|
|
608
|
+
font-size: 0.9rem;
|
|
609
|
+
font-weight: 500;
|
|
610
|
+
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
.toc-link:hover {
|
|
614
|
+
text-decoration: underline;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/* Indentation for different heading levels */
|
|
618
|
+
.toc-level-2 {
|
|
619
|
+
margin-left: 0;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
.toc-level-3 {
|
|
623
|
+
margin-left: 0.75rem;
|
|
624
|
+
font-size: 0.85rem;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
.toc-level-4 {
|
|
628
|
+
margin-left: 1.5rem;
|
|
629
|
+
font-size: 0.8rem;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/* TOC sidebar should only display on active pages */
|
|
633
|
+
.toc-sidebar {
|
|
634
|
+
width: 180px;
|
|
635
|
+
position: sticky;
|
|
636
|
+
top: 2rem;
|
|
637
|
+
max-height: calc(100vh - 4rem);
|
|
638
|
+
overflow-y: auto;
|
|
639
|
+
align-self: flex-start;
|
|
640
|
+
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/* Hide TOC on mobile */
|
|
644
|
+
@media (max-width: 1024px) {
|
|
645
|
+
.toc-sidebar {
|
|
646
|
+
width: 100%;
|
|
647
|
+
position: static;
|
|
648
|
+
margin-bottom: 1rem;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/* Basic image styling */
|
|
653
|
+
img {
|
|
654
|
+
max-width: 100%;
|
|
655
|
+
height: auto;
|
|
656
|
+
display: block;
|
|
657
|
+
margin: 1.5rem 0;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/* Image alignment classes */
|
|
661
|
+
img.align-left {
|
|
662
|
+
float: left;
|
|
663
|
+
margin-right: 1.5rem;
|
|
664
|
+
margin-bottom: 1rem;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
img.align-center {
|
|
668
|
+
margin-left: auto;
|
|
669
|
+
margin-right: auto;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
img.align-right {
|
|
673
|
+
float: right;
|
|
674
|
+
margin-left: 1.5rem;
|
|
675
|
+
margin-bottom: 1rem;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/* Image size classes */
|
|
679
|
+
img.size-small {
|
|
680
|
+
max-width: 300px;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
img.size-medium {
|
|
684
|
+
max-width: 500px;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
img.size-large {
|
|
688
|
+
max-width: 800px;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/* Image borders and shadows */
|
|
692
|
+
img.with-border {
|
|
693
|
+
border: 1px solid var(--image-border-color);
|
|
694
|
+
padding: 4px;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
img.with-shadow {
|
|
698
|
+
box-shadow: var(--image-shadow);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/* Figure and caption styling */
|
|
702
|
+
.docmd-container figure {
|
|
703
|
+
margin: 2rem 0;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
.docmd-container figure img {
|
|
707
|
+
margin-bottom: 0.5rem;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
.docmd-container figcaption {
|
|
711
|
+
font-size: 0.9rem;
|
|
712
|
+
color: var(--image-caption-text);
|
|
713
|
+
text-align: center;
|
|
714
|
+
padding: 0.5rem;
|
|
715
|
+
background-color: var(--image-caption-bg);
|
|
716
|
+
border-radius: 0 0 4px 4px;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/* Image gallery */
|
|
720
|
+
.docmd-container .image-gallery {
|
|
721
|
+
display: grid;
|
|
722
|
+
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
|
723
|
+
gap: 1rem;
|
|
724
|
+
margin: 2rem 0;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
.docmd-container .image-gallery figure {
|
|
728
|
+
margin: 0;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/* Clear floats after aligned images */
|
|
732
|
+
.docmd-container .clear-float::after {
|
|
733
|
+
content: "";
|
|
734
|
+
display: table;
|
|
735
|
+
clear: both;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/* Lightbox styling */
|
|
739
|
+
.docmd-lightbox {
|
|
740
|
+
display: none;
|
|
741
|
+
position: fixed;
|
|
742
|
+
top: 0;
|
|
743
|
+
left: 0;
|
|
744
|
+
width: 100%;
|
|
745
|
+
height: 100%;
|
|
746
|
+
background-color: var(--lightbox-bg);
|
|
747
|
+
z-index: 9999;
|
|
748
|
+
justify-content: center;
|
|
749
|
+
align-items: center;
|
|
750
|
+
flex-direction: column;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
.docmd-lightbox-content {
|
|
754
|
+
position: relative;
|
|
755
|
+
max-width: 90%;
|
|
756
|
+
max-height: 90%;
|
|
757
|
+
text-align: center;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
.docmd-lightbox-content img {
|
|
761
|
+
max-width: 100%;
|
|
762
|
+
max-height: 80vh;
|
|
763
|
+
object-fit: contain;
|
|
764
|
+
margin: 0 auto;
|
|
765
|
+
box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
.docmd-lightbox-caption {
|
|
769
|
+
color: var(--lightbox-text);
|
|
770
|
+
padding: 1rem;
|
|
771
|
+
font-size: 1rem;
|
|
772
|
+
max-width: 100%;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
.docmd-lightbox-close {
|
|
776
|
+
position: absolute;
|
|
777
|
+
top: 20px;
|
|
778
|
+
right: 30px;
|
|
779
|
+
color: var(--lightbox-text);
|
|
780
|
+
font-size: 2.5rem;
|
|
781
|
+
cursor: pointer;
|
|
782
|
+
z-index: 10000;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.docmd-lightbox-close:hover {
|
|
786
|
+
color: #ddd;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/* Cursor for lightbox images */
|
|
790
|
+
img.lightbox,
|
|
791
|
+
.docmd-container .image-gallery img {
|
|
792
|
+
cursor: zoom-in;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/* Responsive image handling */
|
|
796
|
+
@media (max-width: 768px) {
|
|
797
|
+
img.align-left,
|
|
798
|
+
img.align-right {
|
|
799
|
+
float: none;
|
|
800
|
+
margin-left: auto;
|
|
801
|
+
margin-right: auto;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
.docmd-container .image-gallery {
|
|
805
|
+
grid-template-columns: 1fr;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* theme-sky.css - Sky theme for docmd
|
|
1
|
+
/* theme-sky.css - Sky theme for docmd */
|
|
2
2
|
|
|
3
3
|
:root [data-theme="light"] {
|
|
4
4
|
/* Font family */
|
|
@@ -35,6 +35,16 @@
|
|
|
35
35
|
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
36
36
|
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
|
37
37
|
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
|
38
|
+
|
|
39
|
+
/* Image styling variables */
|
|
40
|
+
--image-border-color: var(--sky-border);
|
|
41
|
+
--image-shadow: var(--shadow-md);
|
|
42
|
+
--image-caption-bg: var(--sky-background-alt);
|
|
43
|
+
--image-caption-text: var(--sky-text-light);
|
|
44
|
+
--image-hover-transform: translateY(-2px);
|
|
45
|
+
--image-hover-shadow: var(--shadow-lg);
|
|
46
|
+
--image-border-radius: 8px;
|
|
47
|
+
--image-transition: all 0.3s ease;
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
/* Dark mode */
|
|
@@ -69,6 +79,16 @@
|
|
|
69
79
|
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
|
|
70
80
|
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
|
|
71
81
|
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
|
|
82
|
+
|
|
83
|
+
/* Image styling variables for dark mode */
|
|
84
|
+
--image-border-color: var(--sky-border);
|
|
85
|
+
--image-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
|
|
86
|
+
--image-caption-bg: var(--sky-background-alt);
|
|
87
|
+
--image-caption-text: var(--sky-text-light);
|
|
88
|
+
--image-hover-transform: translateY(-2px);
|
|
89
|
+
--image-hover-shadow: 0 6px 12px rgba(0, 0, 0, 0.7);
|
|
90
|
+
--image-border-radius: 8px;
|
|
91
|
+
--image-transition: all 0.3s ease;
|
|
72
92
|
}
|
|
73
93
|
|
|
74
94
|
/* Apply theme styles */
|
|
@@ -496,4 +516,136 @@
|
|
|
496
516
|
h3 {
|
|
497
517
|
font-size: 1.25rem;
|
|
498
518
|
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/* Enhanced image styling for Sky theme */
|
|
522
|
+
img {
|
|
523
|
+
border-radius: var(--image-border-radius);
|
|
524
|
+
transition: var(--image-transition);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/* Enhanced borders and shadows */
|
|
528
|
+
img.with-border {
|
|
529
|
+
border: 1px solid var(--image-border-color);
|
|
530
|
+
padding: 8px;
|
|
531
|
+
background-color: var(--bg-color);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
img.with-shadow {
|
|
535
|
+
box-shadow: var(--image-shadow);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
img.with-shadow:hover {
|
|
539
|
+
box-shadow: var(--image-hover-shadow);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/* Beautiful figure styling */
|
|
543
|
+
figure {
|
|
544
|
+
border-radius: var(--image-border-radius);
|
|
545
|
+
overflow: hidden;
|
|
546
|
+
transition: var(--image-transition);
|
|
547
|
+
box-shadow: var(--shadow-sm);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
figure:hover {
|
|
551
|
+
box-shadow: var(--shadow-md);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
figure img {
|
|
555
|
+
margin-bottom: 0;
|
|
556
|
+
border-radius: var(--image-border-radius) var(--image-border-radius) 0 0;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
figcaption {
|
|
560
|
+
background-color: var(--image-caption-bg);
|
|
561
|
+
color: var(--image-caption-text);
|
|
562
|
+
padding: 0.75rem 1rem;
|
|
563
|
+
font-size: 0.9rem;
|
|
564
|
+
font-weight: 500;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/* Advanced image gallery */
|
|
568
|
+
.image-gallery {
|
|
569
|
+
display: grid;
|
|
570
|
+
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
571
|
+
gap: 1.5rem;
|
|
572
|
+
margin: 2rem 0;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
.image-gallery figure {
|
|
576
|
+
height: 100%;
|
|
577
|
+
display: flex;
|
|
578
|
+
flex-direction: column;
|
|
579
|
+
margin: 0;
|
|
580
|
+
transition: var(--image-transition);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
.image-gallery figure:hover {
|
|
584
|
+
transform: var(--image-hover-transform);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
.image-gallery img {
|
|
588
|
+
height: 200px;
|
|
589
|
+
width: 100%;
|
|
590
|
+
object-fit: cover;
|
|
591
|
+
margin: 0;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
.image-gallery figcaption {
|
|
595
|
+
flex: 1;
|
|
596
|
+
display: flex;
|
|
597
|
+
align-items: center;
|
|
598
|
+
justify-content: center;
|
|
599
|
+
text-align: center;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/* Zoom effect on gallery images */
|
|
603
|
+
.image-gallery.zoom img {
|
|
604
|
+
transition: transform 0.5s ease;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.image-gallery.zoom figure:hover img {
|
|
608
|
+
transform: scale(1.05);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/* Lightbox effect - requires JavaScript implementation */
|
|
612
|
+
img.lightbox {
|
|
613
|
+
cursor: zoom-in;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/* Image with frames */
|
|
617
|
+
img.framed {
|
|
618
|
+
border: 8px solid white;
|
|
619
|
+
box-shadow: 0 0 0 1px var(--image-border-color), var(--image-shadow);
|
|
620
|
+
box-sizing: border-box;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/* Polaroid style */
|
|
624
|
+
figure.polaroid {
|
|
625
|
+
background: white;
|
|
626
|
+
padding: 10px 10px 30px 10px;
|
|
627
|
+
box-shadow: var(--shadow-md);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
figure.polaroid img {
|
|
631
|
+
border-radius: 0;
|
|
632
|
+
box-shadow: none;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
figure.polaroid figcaption {
|
|
636
|
+
background: white;
|
|
637
|
+
color: var(--sky-text);
|
|
638
|
+
font-family: 'Caveat', cursive, var(--font-family-sans);
|
|
639
|
+
font-size: 1.1rem;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/* Responsive adjustments */
|
|
643
|
+
@media (max-width: 768px) {
|
|
644
|
+
.image-gallery {
|
|
645
|
+
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
.image-gallery img {
|
|
649
|
+
height: 150px;
|
|
650
|
+
}
|
|
499
651
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* docmd-image-lightbox.js - Simple lightbox implementation for docmd images
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
6
|
+
// Create lightbox elements
|
|
7
|
+
const lightbox = document.createElement('div');
|
|
8
|
+
lightbox.className = 'docmd-lightbox';
|
|
9
|
+
lightbox.innerHTML = `
|
|
10
|
+
<div class="docmd-lightbox-content">
|
|
11
|
+
<img src="" alt="">
|
|
12
|
+
<div class="docmd-lightbox-caption"></div>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="docmd-lightbox-close">×</div>
|
|
15
|
+
`;
|
|
16
|
+
document.body.appendChild(lightbox);
|
|
17
|
+
|
|
18
|
+
const lightboxImg = lightbox.querySelector('img');
|
|
19
|
+
const lightboxCaption = lightbox.querySelector('.docmd-lightbox-caption');
|
|
20
|
+
const lightboxClose = lightbox.querySelector('.docmd-lightbox-close');
|
|
21
|
+
|
|
22
|
+
// Find all images with lightbox class or in image galleries
|
|
23
|
+
const lightboxImages = document.querySelectorAll('img.lightbox, .image-gallery img');
|
|
24
|
+
|
|
25
|
+
// Add click event to each image
|
|
26
|
+
lightboxImages.forEach(function(img) {
|
|
27
|
+
img.style.cursor = 'zoom-in';
|
|
28
|
+
|
|
29
|
+
img.addEventListener('click', function() {
|
|
30
|
+
// Get the image source and caption
|
|
31
|
+
const src = this.getAttribute('src');
|
|
32
|
+
let caption = this.getAttribute('alt') || '';
|
|
33
|
+
|
|
34
|
+
// If image is inside a figure with figcaption, use that caption
|
|
35
|
+
const figure = this.closest('figure');
|
|
36
|
+
if (figure) {
|
|
37
|
+
const figcaption = figure.querySelector('figcaption');
|
|
38
|
+
if (figcaption) {
|
|
39
|
+
caption = figcaption.textContent;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Set the lightbox content
|
|
44
|
+
lightboxImg.setAttribute('src', src);
|
|
45
|
+
lightboxCaption.textContent = caption;
|
|
46
|
+
|
|
47
|
+
// Show the lightbox
|
|
48
|
+
lightbox.style.display = 'flex';
|
|
49
|
+
document.body.style.overflow = 'hidden'; // Prevent scrolling
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Close lightbox when clicking the close button or outside the image
|
|
54
|
+
lightboxClose.addEventListener('click', closeLightbox);
|
|
55
|
+
lightbox.addEventListener('click', function(e) {
|
|
56
|
+
if (e.target === lightbox) {
|
|
57
|
+
closeLightbox();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Close lightbox when pressing Escape key
|
|
62
|
+
document.addEventListener('keydown', function(e) {
|
|
63
|
+
if (e.key === 'Escape' && lightbox.style.display === 'flex') {
|
|
64
|
+
closeLightbox();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
function closeLightbox() {
|
|
69
|
+
lightbox.style.display = 'none';
|
|
70
|
+
document.body.style.overflow = ''; // Restore scrolling
|
|
71
|
+
}
|
|
72
|
+
});
|
|
@@ -12,10 +12,10 @@ function applyTheme(theme, isInitialLoad = false) {
|
|
|
12
12
|
const isLight = theme.includes('light');
|
|
13
13
|
const currentHref = highlightThemeLink.href;
|
|
14
14
|
|
|
15
|
-
if (isDark && currentHref.includes('highlight-light.css')) {
|
|
16
|
-
highlightThemeLink.href = currentHref.replace('highlight-light.css', 'highlight-dark.css');
|
|
17
|
-
} else if (isLight && currentHref.includes('highlight-dark.css')) {
|
|
18
|
-
highlightThemeLink.href = currentHref.replace('highlight-dark.css', 'highlight-light.css');
|
|
15
|
+
if (isDark && currentHref.includes('docmd-highlight-light.css')) {
|
|
16
|
+
highlightThemeLink.href = currentHref.replace('docmd-highlight-light.css', 'docmd-highlight-dark.css');
|
|
17
|
+
} else if (isLight && currentHref.includes('docmd-highlight-dark.css')) {
|
|
18
|
+
highlightThemeLink.href = currentHref.replace('docmd-highlight-dark.css', 'docmd-highlight-light.css');
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|