@mgks/docmd 0.1.3 → 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 (56) hide show
  1. package/.github/workflows/deploy-docmd.yml +2 -2
  2. package/README.md +2 -4
  3. package/assets/css/welcome.css +62 -358
  4. package/assets/images/preview-dark-1.webp +0 -0
  5. package/assets/images/preview-dark-2.webp +0 -0
  6. package/assets/images/preview-dark-3.webp +0 -0
  7. package/assets/images/preview-light-1.webp +0 -0
  8. package/assets/images/preview-light-2.webp +0 -0
  9. package/assets/images/preview-light-3.webp +0 -0
  10. package/config.js +35 -4
  11. package/docs/cli-commands.md +1 -2
  12. package/docs/configuration.md +104 -23
  13. package/docs/content/containers/buttons.md +88 -0
  14. package/docs/content/containers/callouts.md +154 -0
  15. package/docs/content/containers/cards.md +93 -0
  16. package/docs/content/containers/index.md +35 -0
  17. package/docs/content/containers/nested-containers.md +329 -0
  18. package/docs/content/containers/steps.md +175 -0
  19. package/docs/content/containers/tabs.md +228 -0
  20. package/docs/content/frontmatter.md +4 -4
  21. package/docs/content/index.md +5 -4
  22. package/docs/content/markdown-syntax.md +4 -4
  23. package/docs/content/no-style-example.md +1 -1
  24. package/docs/contributing.md +7 -0
  25. package/docs/deployment.md +22 -31
  26. package/docs/getting-started/basic-usage.md +3 -2
  27. package/docs/getting-started/index.md +3 -3
  28. package/docs/getting-started/installation.md +1 -1
  29. package/docs/index.md +14 -20
  30. package/docs/plugins/seo.md +2 -0
  31. package/docs/plugins/sitemap.md +1 -1
  32. package/docs/theming/assets-management.md +1 -1
  33. package/docs/theming/available-themes.md +45 -52
  34. package/docs/theming/light-dark-mode.md +12 -3
  35. package/package.json +9 -3
  36. package/src/assets/css/docmd-main.css +935 -573
  37. package/src/assets/css/docmd-theme-retro.css +812 -0
  38. package/src/assets/css/docmd-theme-ruby.css +619 -0
  39. package/src/assets/css/docmd-theme-sky.css +606 -605
  40. package/src/assets/js/docmd-image-lightbox.js +1 -3
  41. package/src/assets/js/docmd-main.js +97 -0
  42. package/src/commands/build.js +1 -1
  43. package/src/commands/dev.js +5 -2
  44. package/src/commands/init.js +21 -1
  45. package/src/core/file-processor.js +626 -363
  46. package/src/core/html-generator.js +20 -30
  47. package/src/plugins/seo.js +4 -0
  48. package/src/templates/layout.ejs +34 -8
  49. package/assets/images/preview-dark-1.png +0 -0
  50. package/assets/images/preview-dark-2.png +0 -0
  51. package/assets/images/preview-dark-3.png +0 -0
  52. package/assets/images/preview-light-1.png +0 -0
  53. package/assets/images/preview-light-2.png +0 -0
  54. package/assets/images/preview-light-3.png +0 -0
  55. package/docs/content/custom-containers.md +0 -129
  56. 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;
@@ -44,6 +44,9 @@ async function startDevServer(configPathOption, options = { preserve: false }) {
44
44
  let paths = resolveConfigPaths(config);
45
45
 
46
46
  // docmd's internal templates and assets (for live dev of docmd itself)
47
+ const DOCMD_COMMANDS_DIR = path.resolve(__dirname, '..', 'commands');
48
+ const DOCMD_CORE_DIR = path.resolve(__dirname, '..', 'core');
49
+ const DOCMD_PLUGINS_DIR = path.resolve(__dirname, '..', 'plugins');
47
50
  const DOCMD_TEMPLATES_DIR = path.resolve(__dirname, '..', 'templates');
48
51
  const DOCMD_ASSETS_DIR = path.resolve(__dirname, '..', 'assets');
49
52
 
@@ -199,13 +202,13 @@ async function startDevServer(configPathOption, options = { preserve: false }) {
199
202
  }
200
203
 
201
204
  // Add internal paths for docmd development (not shown to end users)
202
- const internalPaths = [DOCMD_TEMPLATES_DIR, DOCMD_ASSETS_DIR];
205
+ const internalPaths = [DOCMD_TEMPLATES_DIR, DOCMD_ASSETS_DIR, DOCMD_COMMANDS_DIR, DOCMD_CORE_DIR, DOCMD_PLUGINS_DIR];
203
206
 
204
207
  // Only in development environments, we might want to watch internal files too
205
208
  if (process.env.DOCMD_DEV === 'true') {
206
209
  watchedPaths.push(...internalPaths);
207
210
  }
208
-
211
+
209
212
  console.log(`👀 Watching for changes in:`);
210
213
  console.log(` - Source: ${formatPathForDisplay(paths.srcDirToWatch, CWD)}`);
211
214
  console.log(` - Config: ${formatPathForDisplay(paths.configFileToWatch, CWD)}`);
@@ -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
  ]
@@ -35,8 +42,12 @@ module.exports = {
35
42
  // Custom JavaScript Files
36
43
  customJs: [ // Array of paths to custom JS files, loaded at end of body
37
44
  // '/assets/js/custom-script.js', // Paths relative to outputDir root
45
+ '/assets/js/docmd-image-lightbox.js', // Image lightbox functionality
38
46
  ],
39
47
 
48
+ // Content Processing
49
+ autoTitleFromH1: true, // Set to true to automatically use the first H1 as page title
50
+
40
51
  // Plugins Configuration
41
52
  // Plugins are configured here. docmd will look for these keys.
42
53
  plugins: {
@@ -85,11 +96,20 @@ module.exports = {
85
96
  { title: 'Documentation', path: 'https://docmd.mgks.dev', icon: 'scroll', external: true },
86
97
  { title: 'Installation', path: 'https://docmd.mgks.dev/getting-started/installation', icon: 'download', external: true },
87
98
  { title: 'Basic Usage', path: 'https://docmd.mgks.dev/getting-started/basic-usage', icon: 'play', external: true },
99
+ { title: 'Content', path: 'https://docmd.mgks.dev/content', icon: 'layout-template', external: true },
88
100
  ],
89
101
  },
90
102
  // External links:
91
103
  { title: 'GitHub', path: 'https://github.com/mgks/docmd', icon: 'github', external: true },
92
- ],
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
+ },
93
113
 
94
114
  // Footer Configuration
95
115
  // Markdown is supported here.