@mgks/docmd 0.2.3 → 0.2.5

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/README.md CHANGED
@@ -17,6 +17,8 @@
17
17
 
18
18
  Docmd (`docmd`) is a Node.js command-line tool dedicated to generating beautiful, lightweight static documentation sites from standard Markdown files. It champions the philosophy of "zero clutter, just content," prioritizing ease of use for documentation authors and a clean, performant experience for readers.
19
19
 
20
+ #### 🟢 [Live Preview](https://docmd.mgks.dev): Documentation site powered entirely by *Docmd*, serving as both the official docs and a live demo.
21
+
20
22
  ## Features
21
23
 
22
24
  - 📝 **Markdown First** - Standard Markdown with YAML frontmatter
@@ -27,7 +29,7 @@ Docmd (`docmd`) is a Node.js command-line tool dedicated to generating beautiful
27
29
  - 🎭 **No-Style Pages** - Create custom standalone pages with complete HTML control
28
30
  - 🖌️ **Custom Styling** - Add custom CSS/JS and HTML directly in frontmatter
29
31
  - 💻 **Simple CLI** - Easy `init`, `dev`, and `build` commands
30
- - 🌐 **Deploy Anywhere** - Deploy the generated sites anywhere (GitHub Pages, Netlify, Vercel, etc.).
32
+ - 🌐 **Deploy Anywhere** - Deploy the generated sites anywhere (GitHub Pages, Netlify, Vercel, etc.)
31
33
 
32
34
  ## Installation
33
35
 
@@ -80,4 +82,4 @@ If you find `docmd` useful, please consider:
80
82
  - Sharing it with others who might benefit
81
83
  - Reporting issues or submitting pull requests
82
84
 
83
- **[GitHub Sponsors](https://github.com/sponsors/mgks): Become a monthly or one-time GitHub sponsor to support docmd & other projects developed by [me](https://mgks.dev).**
85
+ **[GitHub Sponsors](https://github.com/sponsors/mgks): Become a monthly or one-time GitHub sponsor to support docmd & other projects developed by [@mgks](https://mgks.dev).**
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Source file from the docmd project — https://github.com/mgks/docmd
3
- * Configuration for the docmd project's own documentation
3
+ * Welcome page stylesheet for the docmd project's own documentation
4
4
  */
5
5
 
6
6
  :root,html[data-theme=light]{--primary-color:#047bf1;--primary-hover:#026ed9;--text-color:#333;--text-light:#666;--bg-color:#fff;--bg-secondary:#f8f9fa;--border-color:#eaeaea}.theme-toggle,body{color:var(--text-color);display:flex}.logo-text,h1{font-weight:700}.install-code pre,.logo-text{font-family:'PT Mono',monospace}:root{--shadow-color:#00000014;--container-padding:5rem}@media (prefers-color-scheme:dark){:root{--primary-color:#047bf1;--primary-hover:#026ed9;--text-color:#e0e0e0;--text-light:#aaa;--bg-color:#121212;--bg-secondary:#1e1e1e;--border-color:#333;--shadow-color:#0000004d}}[data-theme=light]{--shadow-color:#00000059}[data-theme=dark]{--primary-color:#1955b6;--primary-hover:#084dbd;--text-color:#e0e0e0;--text-light:#aaa;--bg-color:#121212;--bg-secondary:#1e1e1e;--border-color:#333;--shadow-color:#000000de}*{margin:0;padding:0;box-sizing:border-box}body{font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif;line-height:1.5;background-color:var(--bg-color);height:100vh;overflow:hidden}.landing-container{display:flex;width:100%;height:100%;padding:0 var(--container-padding);max-width:1600px;margin:0 auto}.content-side{flex:1;padding:3rem 2rem 3rem 0;display:flex;flex-direction:column;justify-content:center}.preview-side{flex:1;display:flex;align-items:center;justify-content:flex-start;position:relative;overflow:visible}.header-top{position:absolute;top:2rem;right:3rem;z-index:100}.theme-toggle{background:var(--bg-secondary);border:1px solid var(--border-color);width:40px;height:40px;border-radius:50%;align-items:center;justify-content:center;cursor:pointer;transition:.2s}.theme-toggle:hover{background:var(--border-color)}.logo{margin-bottom:1.5rem;display:flex;align-items:center}.buttons,.features,.install-section,.tagline{margin-bottom:2rem}.logo svg{height:48px;width:auto}.logo-text{font-size:2em;margin-left:.25em}h1{font-size:3rem;margin-bottom:1rem;letter-spacing:-.02em}.tagline{font-size:1.25rem;color:var(--text-light);font-weight:400}.btn-primary,.feature-icon{background-color:var(--primary-color);color:#fff}.features{display:grid;grid-template-columns:repeat(2,1fr);gap:1.5rem}.feature{display:flex;align-items:flex-start;gap:.75rem}.feature-icon{width:32px;height:32px;border-radius:6px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.feature-text{font-size:.9rem}.feature-text strong{display:block;margin-bottom:.25rem}.buttons{display:flex;gap:1rem}.btn{display:inline-flex;align-items:center;gap:.5rem;padding:.75rem 1.5rem;border-radius:8px;font-weight:600;font-size:1rem;text-decoration:none;transition:.2s}.btn-primary{border:none}.btn-secondary,.install-code pre{background-color:var(--bg-secondary);border:1px solid var(--border-color)}.btn-primary:hover{background-color:var(--primary-hover)}.btn-secondary{color:var(--text-color)}.btn-secondary:hover{background-color:var(--border-color)}.social-links{display:flex;gap:1rem;padding:0 .25em}.social-link{color:var(--text-light);transition:color .2s}.social-link:hover{color:var(--primary-color)}.preview-stack{position:relative;width:100%;height:400px;transform:translateX(15%);perspective:1000px}.preview-image{position:absolute;width:100%;max-width:700px;height:400px;border-radius:20px;box-shadow:0 25px 50px -12px var(--shadow-color);transition:.3s;overflow:hidden}.preview-image img{width:100%;height:100%;object-fit:cover;object-position:left top;border-radius:8px;pointer-events:none}.preview-image.top{z-index:3;transform:rotate(3deg) translateY(-10%) translateX(7%)}.preview-image.middle{z-index:2;transform:rotate(-3deg) translateY(1%) translateX(-2%)}.preview-image.bottom{z-index:1;transform:rotate(-8deg) translateY(10%) translateX(-10%)}[data-theme=dark] .preview-image .dark-img,[data-theme=light] .preview-image .light-img{display:block}[data-theme=dark] .preview-image .light-img,[data-theme=light] .preview-image .dark-img{display:none}@media (max-width:1400px){:root{--container-padding:3rem}.preview-stack{transform:translateX(15%)}}@media (max-width:1200px){:root{--container-padding:2rem}.preview-side{display:none}.content-side{max-width:100%;padding:3rem 0}.header-top{right:2rem}}@media (max-width:768px){:root{--container-padding:1.5rem}body{overflow:auto}.content-side{padding:2rem 0}.features{grid-template-columns:1fr}.buttons{flex-direction:column}.header-top{padding:1rem 0;text-align:center;right:1rem}h1{font-size:2.5rem}.tagline{font-size:1em;font-weight:500}.landing-container{padding:1rem;flex-direction:column}}.social-links .lucide-heart-handshake{color:#cd2727}.install-code{position:relative;display:inline-block}.install-code pre{border-radius:8px;padding:1rem 3.5rem 1rem 1rem;margin:0;font-size:.9rem;color:var(--text-color)}.install-code code{background:0 0;padding:0;color:inherit}.copy-button{position:absolute;top:.5rem;right:.5rem;background:var(--bg-color);border:1px solid var(--border-color);border-radius:4px;padding:.5rem;cursor:pointer;transition:.2s;color:var(--text-light)}.copy-button:hover{background:var(--border-color);color:var(--text-color)}
package/bin/docmd.js CHANGED
@@ -1,11 +1,28 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const { Command } = require('commander');
4
+ const fs = require('fs-extra');
5
+ const path = require('path');
4
6
  const { version } = require('../package.json');
5
7
  const { initProject } = require('../src/commands/init');
6
8
  const { buildSite } = require('../src/commands/build');
7
9
  const { startDevServer } = require('../src/commands/dev');
8
10
 
11
+ // Helper function to find the config file
12
+ const findConfigFile = () => {
13
+ const newConfigPath = 'docmd.config.js';
14
+ const oldConfigPath = 'config.js';
15
+
16
+ if (fs.existsSync(path.resolve(process.cwd(), newConfigPath))) {
17
+ return newConfigPath;
18
+ }
19
+ if (fs.existsSync(path.resolve(process.cwd(), oldConfigPath))) {
20
+ return oldConfigPath;
21
+ }
22
+
23
+ throw new Error('Configuration file not found. Please create a docmd.config.js file or run "docmd init".');
24
+ };
25
+
9
26
  const program = new Command();
10
27
 
11
28
  program
@@ -15,7 +32,7 @@ program
15
32
 
16
33
  program
17
34
  .command('init')
18
- .description('Initialize a new docmd project (creates docs/ and config.js)')
35
+ .description('Initialize a new docmd project (creates docs/ and config file)')
19
36
  .action(async () => {
20
37
  try {
21
38
  await initProject();
@@ -28,17 +45,27 @@ program
28
45
 
29
46
  program
30
47
  .command('build')
31
- .description('Build the static site from Markdown files and config.js')
32
- .option('-c, --config <path>', 'Path to config.js file', 'config.js')
48
+ .description('Build the static site from Markdown files and config')
49
+ .option('-c, --config <path>', 'Path to config file')
33
50
  .option('-p, --preserve', 'Preserve existing asset files instead of updating them')
34
51
  .option('--no-preserve', 'Force update all asset files, overwriting existing ones')
52
+ .option('--silent', 'Suppress log output')
35
53
  .action(async (options) => {
36
54
  try {
37
- console.log('🚀 Starting build process...');
38
- await buildSite(options.config, {
55
+ const originalLog = console.log;
56
+ if (options.silent) { console.log = () => {}; }
57
+
58
+ const configPath = options.config || findConfigFile();
59
+ console.log(`🚀 Starting build process using ${configPath}...`);
60
+ await buildSite(configPath, {
39
61
  preserve: options.preserve
40
62
  });
41
- console.log('✅ Build complete! Site generated in `site/` directory.');
63
+
64
+ console.log = originalLog;
65
+ if (!options.silent) {
66
+ console.log('✅ Build complete! Site generated in `site/` directory.');
67
+ }
68
+
42
69
  } catch (error) {
43
70
  console.error('❌ Build failed:', error.message);
44
71
  console.error(error.stack);
@@ -49,12 +76,24 @@ program
49
76
  program
50
77
  .command('dev')
51
78
  .description('Start a live preview development server')
52
- .option('-c, --config <path>', 'Path to config.js file', 'config.js')
79
+ .option('-c, --config <path>', 'Path to config file')
80
+ .option('--port <number>', 'Specify a port for the dev server')
53
81
  .option('-p, --preserve', 'Preserve existing asset files instead of updating them')
54
82
  .option('--no-preserve', 'Force update all asset files, overwriting existing ones')
83
+ .option('--silent', 'Suppress log output')
55
84
  .action(async (options) => {
56
85
  try {
57
- await startDevServer(options.config, { preserve: options.preserve });
86
+ if (options.silent) {
87
+ const originalLog = console.log;
88
+ console.log = (message) => {
89
+ if (message && message.includes('Dev server started at')) {
90
+ originalLog(message);
91
+ }
92
+ };
93
+ }
94
+ const configPath = options.config || findConfigFile();
95
+ await startDevServer(configPath, { preserve: options.preserve, port: options.port });
96
+
58
97
  } catch (error) {
59
98
  console.error('❌ Dev server failed:', error.message);
60
99
  console.error(error.stack);
package/config.js CHANGED
@@ -112,6 +112,7 @@ module.exports = {
112
112
  { title: 'Frontmatter', path: '/content/frontmatter', icon: 'file-text' },
113
113
  { title: 'Markdown Syntax', path: '/content/markdown-syntax', icon: 'code-2' },
114
114
  { title: 'Images', path: '/content/images', icon: 'image' },
115
+ { title: 'Mermaid Diagrams', path: '/content/mermaid', icon: 'network' },
115
116
  {
116
117
  title: 'Custom Containers',
117
118
  path: '/content/containers/',
@@ -163,6 +164,8 @@ module.exports = {
163
164
  { title: 'Issues', path: 'https://github.com/mgks/docmd/issues', icon: 'badge-alert', external: true }
164
165
  ],
165
166
 
167
+ pageNavigation: true, // Enable previous / next page navigation at the bottom of each page
168
+
166
169
  // Sponsor Ribbon Configuration
167
170
  sponsor: {
168
171
  enabled: true, // Enable/disable the sponsor ribbon
@@ -20,9 +20,9 @@ docmd init
20
20
  This command creates the basic file and directory structure required for a `docmd` project:
21
21
  * `docs/`: A directory to store your Markdown source files.
22
22
  * `docs/index.md`: A sample Markdown file.
23
- * `config.js`: The main configuration file for your site, pre-filled with default settings.
23
+ * `docmd.config.js`: The main configuration file for your site, pre-filled with default settings.
24
24
 
25
- If a `docs/` directory or `config.js` file already exists, `docmd init` will typically warn you and avoid overwriting them to prevent accidental data loss.
25
+ If a `docs/` directory or `docmd.config.js` file already exists, `docmd init` will typically warn you and avoid overwriting them to prevent accidental data loss.
26
26
 
27
27
  **Options:**
28
28
  This command currently does not take any options.
@@ -37,7 +37,7 @@ docmd build [options]
37
37
  ```
38
38
 
39
39
  **Description:**
40
- The `build` command reads your Markdown files from the source directory (specified by `srcDir` in `config.js`, defaults to `docs/`), processes them along with your `config.js`, and generates a complete static website in the output directory (specified by `outputDir` in `config.js`, defaults to `site/`).
40
+ The `build` command reads your Markdown files from the source directory (specified by `srcDir` in `docmd.config.js`, defaults to `docs/`), processes them along with your `docmd.config.js`, and generates a complete static website in the output directory (specified by `outputDir` in `docmd.config.js`, defaults to `site/`).
41
41
 
42
42
  The output `site/` directory contains all the HTML, CSS, JavaScript, and other assets needed to deploy your documentation.
43
43
 
@@ -46,14 +46,16 @@ By default, the build process will update all assets to ensure you have the late
46
46
  **Options:**
47
47
 
48
48
  * `-c, --config <path>`
49
- * **Default:** `config.js`
50
- * **Description:** Specifies the path to the configuration file. Useful if your config file is not named `config.js` or is not in the project root.
51
- * **Example:** `docmd build --config my.docmd.config.js`
49
+ * **Default:** `docmd.config.js` or `config.js`
50
+ * **Description:** Specifies the path to the configuration file.
52
51
 
53
52
  * `-p, --preserve`
54
53
  * **Default:** `false`
55
- * **Description:** Preserves existing asset files instead of updating them. Use this flag if you've customized any of the default assets and want to keep your modifications.
56
- * **Example:** `docmd build --preserve`
54
+ * **Description:** Preserves existing asset files instead of updating them.
55
+
56
+ * `--silent`
57
+ * **Default:** `false`
58
+ * **Description:** Suppresses most log output in the console. Useful for running in automated environments.
57
59
 
58
60
  ## `docmd dev`
59
61
 
@@ -68,7 +70,7 @@ docmd dev [options]
68
70
  The `dev` command is essential for writing and previewing your documentation. It:
69
71
  1. Performs an initial build of your site.
70
72
  2. Starts a local web server (usually on `http://localhost:3000`).
71
- 3. Watches your source files (`docs/` directory, `config.js`, and internal `docmd` theme assets) for changes.
73
+ 3. Watches your source files (`docs/` directory, `docmd.config.js`, and internal `docmd` theme assets) for changes.
72
74
  4. When a change is detected, it automatically rebuilds the necessary parts of your site and triggers a live reload in your browser.
73
75
 
74
76
  This provides a fast feedback loop, allowing you to see your changes almost instantly.
@@ -76,14 +78,21 @@ This provides a fast feedback loop, allowing you to see your changes almost inst
76
78
  **Options:**
77
79
 
78
80
  * `-c, --config <path>`
79
- * **Default:** `config.js`
81
+ * **Default:** `docmd.config.js` or `config.js`
80
82
  * **Description:** Specifies the path to the configuration file.
81
- * **Example:** `docmd dev --config my.docmd.config.js`
83
+
84
+ * `--port <number>`
85
+ * **Default:** `3000`
86
+ * **Description:** Specifies the port for the development server. If the port is in use, docmd will automatically try the next available one.
87
+ * **Example:** `docmd dev --port 8080`
82
88
 
83
89
  * `-p, --preserve`
84
90
  * **Default:** `false`
85
- * **Description:** Preserves existing asset files instead of updating them. Use this flag if you've customized any of the default assets and want to keep your modifications.
86
- * **Example:** `docmd dev --preserve`
91
+ * **Description:** Preserves existing asset files instead of updating them.
92
+
93
+ * `--silent`
94
+ * **Default:** `false`
95
+ * **Description:** Suppresses most log output in the console. Useful for running in automated environments.
87
96
 
88
97
  **Note:** The development server starts on port 3000 by default. If port 3000 is already in use, the server will automatically try the next available port (3001, 3002, etc.) until it finds an open port.
89
98
 
@@ -1,16 +1,15 @@
1
1
  ---
2
2
  title: "Configuration"
3
- description: "Detailed explanation of all options available in the docmd config.js file, including logo, theming, plugins, and more."
3
+ description: "Detailed explanation of all options available in the docmd config file, including logo, theming, plugins, and more."
4
4
  ---
5
5
 
6
- # Configuration (`config.js`)
6
+ # Configuration (`docmd.config.js`)
7
7
 
8
- `docmd` uses a `config.js` file in the root of your documentation project to control various aspects of your site. This file should export a JavaScript object containing your configuration options.
8
+ `docmd` uses a `docmd.config.js` file in the root of your project... For backward compatibility, it will fall back to using `config.js` if `docmd.config.js` is not found.
9
9
 
10
- ## Example `config.js` Structure:
10
+ ## Example `docmd.config.js` Structure:
11
11
 
12
12
  ```javascript
13
- // config.js
14
13
  module.exports = {
15
14
  siteTitle: 'My Awesome Project Docs',
16
15
  logo: {
@@ -16,9 +16,9 @@ The button container is a self-contained component. You provide its text, URL, a
16
16
  :::
17
17
 
18
18
  **Syntax:**
19
- ```markdown
20
- ::: button Button_Text /path/to/link [color:#hexcode]
21
- ::: button Button_Text external:/external-url [color:#hexcode]
19
+ ```bash
20
+ ::: button Button_Text /path/to/link color:#hexcode
21
+ ::: button Button_Text external:/external-url color:#hexcode
22
22
  ```
23
23
 
24
24
  - **`Button_Text`**: The text to display on the button. Use underscores (`_`) for spaces.
@@ -35,7 +35,7 @@ The button container is a self-contained component. You provide its text, URL, a
35
35
  This button will use the default theme color and link to a section on the current page.
36
36
 
37
37
  **Code:**
38
- ```markdown
38
+ ```bash
39
39
  ::: button View_Examples #examples
40
40
  ```
41
41
 
@@ -47,7 +47,7 @@ This button will use the default theme color and link to a section on the curren
47
47
  External links open in a new tab for better user experience.
48
48
 
49
49
  **Code:**
50
- ```markdown
50
+ ```bash
51
51
  ::: button GitHub_Repository external:https://github.com/mgks/docmd
52
52
  ```
53
53
 
@@ -59,7 +59,7 @@ External links open in a new tab for better user experience.
59
59
  You can easily override the color for emphasis.
60
60
 
61
61
  **Code:**
62
- ```markdown
62
+ ```bash
63
63
  ::: button Getting_Started #getting-started color:#28a745
64
64
  ```
65
65
 
@@ -72,7 +72,7 @@ Buttons are flexible and can be placed inside other containers, like cards or ca
72
72
 
73
73
  **Code:**
74
74
 
75
- ```markdown
75
+ ```bash
76
76
  ::: card Feature Announcement
77
77
  Our latest feature is now available! Read the full documentation to learn more about how it works.
78
78
  ::: button Read_More /path/to/feature/docs/
@@ -52,6 +52,14 @@ Examples of custom fields you *might* add (these are not built-in features):
52
52
  * `tags`: ["tag1", "tag2"]
53
53
  * `permalink`: "https://example.com/your-canonical-url/" (Sets the canonical URL for SEO purposes)
54
54
 
55
+ ## Page-Specific Behavior Fields
56
+
57
+ * **`toc`** (Boolean, Optional)
58
+ * **Purpose:** Controls the visibility of the "On This Page" table of contents sidebar.
59
+ * **Default:** `true` (TOC is visible if the page has headings).
60
+ * **Usage:** Set to `false` to completely hide the TOC sidebar for a specific page. This is useful for landing pages or pages with minimal content.
61
+ * **Example:** `toc: false`
62
+
55
63
  ## Example Usage
56
64
 
57
65
  Consider a file named `docs/guides/installation.md`:
@@ -12,6 +12,7 @@ docmd uses Markdown files to create beautiful documentation. This section covers
12
12
  - [**Frontmatter**](/content/frontmatter/) - Learn how to add metadata to your pages
13
13
  - [**Markdown Syntax**](/content/markdown-syntax/) - Basic and advanced Markdown features
14
14
  - [**Images**](/content/images/) - How to add and style images in your documentation
15
+ - [**Mermaid Diagrams**](/content/mermaid/) - Create beautiful diagrams and flowcharts with Mermaid
15
16
  - [**Custom Containers**](/content/custom-containers/) - Special content blocks like callouts and cards
16
17
  - [**noStyle Pages**](/content/no-style-pages/) - Create custom standalone pages with complete HTML control
17
18