@mgks/docmd 0.2.4 → 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 +4 -2
- package/assets/css/welcome.css +1 -1
- package/bin/docmd.js +47 -8
- package/config.js +3 -0
- package/docs/cli-commands.md +22 -13
- package/docs/configuration.md +4 -5
- package/docs/content/frontmatter.md +8 -0
- package/docs/content/index.md +1 -0
- package/docs/content/mermaid.md +723 -0
- package/docs/deployment.md +5 -5
- package/docs/getting-started/basic-usage.md +7 -7
- package/docs/overview.md +2 -2
- package/docs/plugins/analytics.md +1 -2
- package/docs/plugins/index.md +2 -3
- package/docs/plugins/seo.md +2 -3
- package/docs/plugins/sitemap.md +2 -3
- package/docs/theming/assets-management.md +2 -2
- package/docs/theming/available-themes.md +2 -3
- package/docs/theming/custom-css-js.md +3 -5
- package/docs/theming/icons.md +1 -2
- package/docs/theming/light-dark-mode.md +1 -3
- package/package.json +1 -1
- package/src/assets/css/docmd-main.css +4 -1
- package/src/assets/css/docmd-theme-sky.css +1 -1
- package/src/assets/js/docmd-mermaid.js +203 -0
- package/src/commands/dev.js +3 -3
- package/src/commands/init.js +12 -8
- package/src/core/config-loader.js +2 -1
- package/src/core/file-processor.js +18 -0
- package/src/core/html-generator.js +1 -1
- package/src/templates/layout.ejs +5 -1
- package/src/templates/toc.ejs +1 -1
package/src/commands/init.js
CHANGED
|
@@ -4,7 +4,7 @@ const fs = require('fs-extra');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const readline = require('readline');
|
|
6
6
|
|
|
7
|
-
const defaultConfigContent = `// config.js: basic config for docmd
|
|
7
|
+
const defaultConfigContent = `// docmd.config.js: basic config for docmd
|
|
8
8
|
module.exports = {
|
|
9
9
|
// Core Site Metadata
|
|
10
10
|
siteTitle: 'docmd',
|
|
@@ -108,6 +108,8 @@ module.exports = {
|
|
|
108
108
|
{ title: 'GitHub', path: 'https://github.com/mgks/docmd', icon: 'github', external: true },
|
|
109
109
|
{ title: 'Support the Project', path: 'https://github.com/sponsors/mgks', icon: 'heart', external: true },
|
|
110
110
|
],
|
|
111
|
+
|
|
112
|
+
pageNavigation: true, // Enable previous / next page navigation at the bottom of each page
|
|
111
113
|
|
|
112
114
|
// Sponsor Ribbon Configuration
|
|
113
115
|
Sponsor: {
|
|
@@ -139,7 +141,7 @@ Start writing your Markdown content here.
|
|
|
139
141
|
async function initProject() {
|
|
140
142
|
const baseDir = process.cwd();
|
|
141
143
|
const docsDir = path.join(baseDir, 'docs');
|
|
142
|
-
const configFile = path.join(baseDir, 'config.js');
|
|
144
|
+
const configFile = path.join(baseDir, 'docmd.config.js');
|
|
143
145
|
const indexMdFile = path.join(docsDir, 'index.md');
|
|
144
146
|
const assetsDir = path.join(baseDir, 'assets');
|
|
145
147
|
const assetsCssDir = path.join(assetsDir, 'css');
|
|
@@ -154,6 +156,11 @@ async function initProject() {
|
|
|
154
156
|
|
|
155
157
|
// Check each file individually
|
|
156
158
|
if (await fs.pathExists(configFile)) {
|
|
159
|
+
existingFiles.push('docmd.config.js');
|
|
160
|
+
}
|
|
161
|
+
// Check for the config.js as well to warn the user
|
|
162
|
+
const oldConfigFile = path.join(baseDir, 'config.js');
|
|
163
|
+
if (await fs.pathExists(oldConfigFile)) {
|
|
157
164
|
existingFiles.push('config.js');
|
|
158
165
|
}
|
|
159
166
|
|
|
@@ -230,14 +237,11 @@ async function initProject() {
|
|
|
230
237
|
}
|
|
231
238
|
|
|
232
239
|
// Write config file if it doesn't exist or user confirmed override
|
|
233
|
-
if (!await fs.pathExists(configFile)) {
|
|
234
|
-
await fs.writeFile(configFile, defaultConfigContent, 'utf8');
|
|
235
|
-
console.log('📄 Created `config.js`');
|
|
236
|
-
} else if (shouldOverride) {
|
|
240
|
+
if (!await fs.pathExists(configFile) || shouldOverride) {
|
|
237
241
|
await fs.writeFile(configFile, defaultConfigContent, 'utf8');
|
|
238
|
-
console.log('
|
|
242
|
+
console.log(`📄 ${shouldOverride ? 'Updated' : 'Created'} \`docmd.config.js\``);
|
|
239
243
|
} else {
|
|
240
|
-
console.log('⏭️ Skipped existing `config.js`');
|
|
244
|
+
console.log('⏭️ Skipped existing `docmd.config.js`');
|
|
241
245
|
}
|
|
242
246
|
|
|
243
247
|
// Write index.md file if it doesn't exist or user confirmed override
|
|
@@ -14,12 +14,13 @@ async function loadConfig(configPath) {
|
|
|
14
14
|
const config = require(absoluteConfigPath);
|
|
15
15
|
|
|
16
16
|
// Basic validation and defaults
|
|
17
|
-
if (!config.siteTitle) throw new Error('`siteTitle` is missing in config
|
|
17
|
+
if (!config.siteTitle) throw new Error('`siteTitle` is missing in config file');
|
|
18
18
|
config.srcDir = config.srcDir || 'docs';
|
|
19
19
|
config.outputDir = config.outputDir || 'site';
|
|
20
20
|
config.theme = config.theme || {};
|
|
21
21
|
config.theme.defaultMode = config.theme.defaultMode || 'light';
|
|
22
22
|
config.navigation = config.navigation || [{ title: 'Home', path: '/' }];
|
|
23
|
+
config.pageNavigation = config.pageNavigation ?? true;
|
|
23
24
|
|
|
24
25
|
return config;
|
|
25
26
|
} catch (e) {
|
|
@@ -34,6 +34,11 @@ function createMarkdownItInstance(config) {
|
|
|
34
34
|
// Conditionally enable highlighting
|
|
35
35
|
if (config.theme?.codeHighlight !== false) {
|
|
36
36
|
mdOptions.highlight = function (str, lang) {
|
|
37
|
+
// Handle mermaid diagrams
|
|
38
|
+
if (lang === 'mermaid') {
|
|
39
|
+
return `<pre class="mermaid">${new MarkdownIt().utils.escapeHtml(str)}</pre>`;
|
|
40
|
+
}
|
|
41
|
+
|
|
37
42
|
if (lang && hljs.getLanguage(lang)) {
|
|
38
43
|
try {
|
|
39
44
|
return `<pre class="hljs"><code>${hljs.highlight(str, { language: lang, ignoreIllegals: true }).value}</code></pre>`;
|
|
@@ -41,6 +46,14 @@ function createMarkdownItInstance(config) {
|
|
|
41
46
|
}
|
|
42
47
|
return `<pre class="hljs"><code>${new MarkdownIt().utils.escapeHtml(str)}</code></pre>`;
|
|
43
48
|
};
|
|
49
|
+
} else {
|
|
50
|
+
// Even if highlighting is disabled, we need to handle mermaid
|
|
51
|
+
mdOptions.highlight = function (str, lang) {
|
|
52
|
+
if (lang === 'mermaid') {
|
|
53
|
+
return `<pre class="mermaid">${new MarkdownIt().utils.escapeHtml(str)}</pre>`;
|
|
54
|
+
}
|
|
55
|
+
return `<pre><code>${new MarkdownIt().utils.escapeHtml(str)}</code></pre>`;
|
|
56
|
+
};
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
const md = new MarkdownIt(mdOptions);
|
|
@@ -464,6 +477,11 @@ function enhancedTabsRule(state, startLine, endLine, silent) {
|
|
|
464
477
|
typographer: true,
|
|
465
478
|
breaks: true,
|
|
466
479
|
highlight: function (str, lang) {
|
|
480
|
+
// Handle mermaid diagrams in tabs
|
|
481
|
+
if (lang === 'mermaid') {
|
|
482
|
+
return '<pre class="mermaid">' + MarkdownIt.utils.escapeHtml(str) + '</pre>';
|
|
483
|
+
}
|
|
484
|
+
|
|
467
485
|
if (lang && hljs.getLanguage(lang)) {
|
|
468
486
|
try {
|
|
469
487
|
return '<pre class="hljs"><code>' +
|
package/src/templates/layout.ejs
CHANGED
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
<div class="main-content">
|
|
80
80
|
<%- content %>
|
|
81
81
|
|
|
82
|
-
<% if (prevPage || nextPage) { %>
|
|
82
|
+
<% if (config.pageNavigation && (prevPage || nextPage)) { %>
|
|
83
83
|
<div class="page-navigation">
|
|
84
84
|
<% if (prevPage) { %>
|
|
85
85
|
<a href="<%= prevPage.url %>" class="prev-page">
|
|
@@ -129,6 +129,10 @@
|
|
|
129
129
|
</div>
|
|
130
130
|
|
|
131
131
|
<script src="<%= relativePathToRoot %>assets/js/docmd-main.js"></script>
|
|
132
|
+
|
|
133
|
+
<!-- Mermaid.js for diagram rendering -->
|
|
134
|
+
<script src="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js"></script>
|
|
135
|
+
<script src="<%= relativePathToRoot %>assets/js/docmd-mermaid.js"></script>
|
|
132
136
|
|
|
133
137
|
<% (customJsFiles || []).forEach(jsFile => { %>
|
|
134
138
|
<script src="<%= relativePathToRoot %><%- jsFile.startsWith('/') ? jsFile.substring(1) : jsFile %>"></script>
|
package/src/templates/toc.ejs
CHANGED
|
@@ -15,7 +15,7 @@ function decodeHtmlEntities(html) {
|
|
|
15
15
|
const shouldShowToc = typeof isActivePage !== 'undefined' ? isActivePage :
|
|
16
16
|
(typeof navigationHtml !== 'undefined' && navigationHtml && navigationHtml.includes('class="active"'));
|
|
17
17
|
|
|
18
|
-
if (shouldShowToc) {
|
|
18
|
+
if (shouldShowToc && !frontmatter?.toc || frontmatter?.toc !== 'false') {
|
|
19
19
|
// If direct headings aren't available, we'll try to extract them from the content
|
|
20
20
|
let tocHeadings = [];
|
|
21
21
|
if (headings && headings.length > 0) {
|