@mgks/docmd 0.1.4 → 0.2.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.
Files changed (43) hide show
  1. package/README.md +2 -4
  2. package/assets/css/welcome.css +62 -374
  3. package/assets/images/preview-dark-1.webp +0 -0
  4. package/assets/images/preview-dark-2.webp +0 -0
  5. package/assets/images/preview-dark-3.webp +0 -0
  6. package/assets/images/preview-light-1.webp +0 -0
  7. package/assets/images/preview-light-2.webp +0 -0
  8. package/assets/images/preview-light-3.webp +0 -0
  9. package/config.js +31 -2
  10. package/docs/configuration.md +72 -3
  11. package/docs/content/containers/buttons.md +88 -0
  12. package/docs/content/containers/callouts.md +154 -0
  13. package/docs/content/containers/cards.md +93 -0
  14. package/docs/content/containers/index.md +35 -0
  15. package/docs/content/containers/nested-containers.md +329 -0
  16. package/docs/content/containers/steps.md +175 -0
  17. package/docs/content/containers/tabs.md +228 -0
  18. package/docs/content/frontmatter.md +2 -2
  19. package/docs/index.md +6 -9
  20. package/docs/plugins/seo.md +2 -0
  21. package/docs/theming/available-themes.md +17 -2
  22. package/docs/theming/light-dark-mode.md +12 -3
  23. package/package.json +9 -3
  24. package/src/assets/css/docmd-main.css +934 -573
  25. package/src/assets/css/docmd-theme-retro.css +812 -0
  26. package/src/assets/css/docmd-theme-ruby.css +26 -13
  27. package/src/assets/css/docmd-theme-sky.css +606 -605
  28. package/src/assets/js/docmd-image-lightbox.js +1 -3
  29. package/src/assets/js/docmd-main.js +97 -0
  30. package/src/commands/build.js +1 -1
  31. package/src/commands/init.js +19 -1
  32. package/src/core/file-processor.js +626 -363
  33. package/src/core/html-generator.js +20 -30
  34. package/src/plugins/seo.js +4 -0
  35. package/src/templates/layout.ejs +33 -7
  36. package/assets/images/preview-dark-1.png +0 -0
  37. package/assets/images/preview-dark-2.png +0 -0
  38. package/assets/images/preview-dark-3.png +0 -0
  39. package/assets/images/preview-light-1.png +0 -0
  40. package/assets/images/preview-light-2.png +0 -0
  41. package/assets/images/preview-light-3.png +0 -0
  42. package/docs/content/custom-containers.md +0 -129
  43. package/src/assets/js/docmd-theme-toggle.js +0 -59
@@ -1,6 +1,4 @@
1
- /**
2
- * docmd-image-lightbox.js - Simple lightbox implementation for docmd images
3
- */
1
+ // docmd-image-lightbox.js - Simple lightbox implementation for docmd images
4
2
 
5
3
  document.addEventListener('DOMContentLoaded', function() {
6
4
  // Create lightbox elements
@@ -0,0 +1,97 @@
1
+ /**
2
+ * docmd-main.js
3
+ * Main client-side script for docmd UI interactions.
4
+ * Handles:
5
+ * 1. Light/Dark theme toggling and persistence.
6
+ * 2. Sidebar expand/collapse functionality and persistence.
7
+ * 3. Tabs container interaction.
8
+ */
9
+
10
+ // --- 1. Theme Toggle Logic ---
11
+ function initializeThemeToggle() {
12
+ const themeToggleButton = document.getElementById('theme-toggle-button');
13
+
14
+ // Function to apply the theme to the body and save preference
15
+ const applyTheme = (theme, isInitial = false) => {
16
+ document.body.setAttribute('data-theme', theme);
17
+ if (!isInitial) {
18
+ localStorage.setItem('docmd-theme', theme);
19
+ }
20
+ };
21
+
22
+ // Set the initial theme on page load
23
+ const storedTheme = localStorage.getItem('docmd-theme');
24
+ const initialTheme = storedTheme || document.body.getAttribute('data-theme') || 'light';
25
+ applyTheme(initialTheme, true);
26
+
27
+ // Add click listener to the toggle button
28
+ if (themeToggleButton) {
29
+ themeToggleButton.addEventListener('click', () => {
30
+ const currentTheme = document.body.getAttribute('data-theme');
31
+ const newTheme = currentTheme.includes('dark')
32
+ ? currentTheme.replace('dark', 'light')
33
+ : currentTheme.replace('light', 'dark');
34
+ applyTheme(newTheme);
35
+ });
36
+ }
37
+ }
38
+
39
+ // --- 2. Sidebar Collapse Logic ---
40
+ function initializeSidebarToggle() {
41
+ const toggleButton = document.getElementById('sidebar-toggle-button');
42
+ const body = document.body;
43
+
44
+ // Only run if the sidebar is configured to be collapsible
45
+ if (!body.classList.contains('sidebar-collapsible') || !toggleButton) {
46
+ return;
47
+ }
48
+
49
+ // Set initial state from localStorage or config default
50
+ const defaultConfigCollapsed = body.dataset.defaultCollapsed === 'true';
51
+ let isCollapsed = localStorage.getItem('docmd-sidebar-collapsed');
52
+
53
+ if (isCollapsed === null) {
54
+ isCollapsed = defaultConfigCollapsed;
55
+ } else {
56
+ isCollapsed = isCollapsed === 'true';
57
+ }
58
+
59
+ if (isCollapsed) {
60
+ body.classList.add('sidebar-collapsed');
61
+ }
62
+
63
+ // Add click listener to the toggle button
64
+ toggleButton.addEventListener('click', () => {
65
+ body.classList.toggle('sidebar-collapsed');
66
+ const currentlyCollapsed = body.classList.contains('sidebar-collapsed');
67
+ localStorage.setItem('docmd-sidebar-collapsed', currentlyCollapsed);
68
+ });
69
+ }
70
+
71
+ // --- 3. Tabs Container Logic ---
72
+ function initializeTabs() {
73
+ document.querySelectorAll('.docmd-tabs').forEach(tabsContainer => {
74
+ const navItems = tabsContainer.querySelectorAll('.docmd-tabs-nav-item');
75
+ const tabPanes = tabsContainer.querySelectorAll('.docmd-tab-pane');
76
+
77
+ navItems.forEach((navItem, index) => {
78
+ navItem.addEventListener('click', () => {
79
+ navItems.forEach(item => item.classList.remove('active'));
80
+ tabPanes.forEach(pane => pane.classList.remove('active'));
81
+
82
+ navItem.classList.add('active');
83
+ if(tabPanes[index]) {
84
+ tabPanes[index].classList.add('active');
85
+ }
86
+ });
87
+ });
88
+ });
89
+ }
90
+
91
+
92
+ // --- Main Execution ---
93
+ document.addEventListener('DOMContentLoaded', () => {
94
+ initializeThemeToggle();
95
+ initializeSidebarToggle();
96
+ initializeTabs();
97
+ });
@@ -211,7 +211,7 @@ async function buildSite(configPath, options = { isDev: false, preserve: false,
211
211
  const depth = outputHtmlPath.split(path.sep).length - 1;
212
212
  const relativePathToRoot = depth > 0 ? '../'.repeat(depth) : './';
213
213
 
214
- const { frontmatter: pageFrontmatter, htmlContent, headings } = await processMarkdownFile(filePath, { isDev: options.isDev });
214
+ const { frontmatter: pageFrontmatter, htmlContent, headings } = await processMarkdownFile(filePath, { isDev: options.isDev }, config);
215
215
 
216
216
  // Special handling for no-style pages
217
217
  let finalHtmlContent = htmlContent;
@@ -22,11 +22,18 @@ module.exports = {
22
22
  srcDir: 'docs', // Source directory for Markdown files
23
23
  outputDir: 'site', // Directory for generated static site
24
24
 
25
+ // Sidebar Configuration
26
+ sidebar: {
27
+ collapsible: true, // or false to disable
28
+ defaultCollapsed: false, // or true to start collapsed
29
+ },
30
+
25
31
  // Theme Configuration
26
32
  theme: {
27
33
  name: 'sky', // Themes: 'default', 'sky'
28
34
  defaultMode: 'light', // Initial color mode: 'light' or 'dark'
29
35
  enableModeToggle: true, // Show UI button to toggle light/dark modes
36
+ positionMode: 'bottom', // 'top' or 'bottom' for the theme toggle
30
37
  customCss: [ // Array of paths to custom CSS files
31
38
  // '/assets/css/custom.css', // Custom TOC styles
32
39
  ]
@@ -38,6 +45,9 @@ module.exports = {
38
45
  '/assets/js/docmd-image-lightbox.js', // Image lightbox functionality
39
46
  ],
40
47
 
48
+ // Content Processing
49
+ autoTitleFromH1: true, // Set to true to automatically use the first H1 as page title
50
+
41
51
  // Plugins Configuration
42
52
  // Plugins are configured here. docmd will look for these keys.
43
53
  plugins: {
@@ -91,7 +101,15 @@ module.exports = {
91
101
  },
92
102
  // External links:
93
103
  { title: 'GitHub', path: 'https://github.com/mgks/docmd', icon: 'github', external: true },
94
- ],
104
+ { title: 'Support the Project', path: 'https://github.com/sponsors/mgks', icon: 'heart', external: true },
105
+ ],
106
+
107
+ // Sponsor Ribbon Configuration
108
+ Sponsor: {
109
+ enabled: false,
110
+ title: 'Support docmd',
111
+ link: 'https://github.com/sponsors/mgks',
112
+ },
95
113
 
96
114
  // Footer Configuration
97
115
  // Markdown is supported here.