@mgks/docmd 0.1.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.
- package/.gitattributes +2 -0
- package/.github/FUNDING.yml +15 -0
- package/.github/workflows/deploy-docmd.yml +45 -0
- package/.github/workflows/publish.yml +84 -0
- package/LICENSE +21 -0
- package/README.md +83 -0
- package/bin/docmd.js +63 -0
- package/config.js +137 -0
- package/docs/cli-commands.md +87 -0
- package/docs/configuration.md +166 -0
- package/docs/contributing.md +86 -0
- package/docs/deployment.md +129 -0
- package/docs/getting-started/basic-usage.md +88 -0
- package/docs/getting-started/index.md +21 -0
- package/docs/getting-started/installation.md +75 -0
- package/docs/index.md +56 -0
- package/docs/plugins/analytics.md +76 -0
- package/docs/plugins/index.md +71 -0
- package/docs/plugins/seo.md +79 -0
- package/docs/plugins/sitemap.md +88 -0
- package/docs/theming/available-themes.md +85 -0
- package/docs/theming/custom-css-js.md +84 -0
- package/docs/theming/icons.md +93 -0
- package/docs/theming/index.md +19 -0
- package/docs/theming/light-dark-mode.md +107 -0
- package/docs/writing-content/custom-containers.md +129 -0
- package/docs/writing-content/frontmatter.md +76 -0
- package/docs/writing-content/index.md +17 -0
- package/docs/writing-content/markdown-syntax.md +277 -0
- package/package.json +56 -0
- package/src/assets/css/highlight-dark.css +1 -0
- package/src/assets/css/highlight-light.css +1 -0
- package/src/assets/css/main.css +562 -0
- package/src/assets/css/theme-sky.css +499 -0
- package/src/assets/css/toc.css +76 -0
- package/src/assets/favicon.ico +0 -0
- package/src/assets/images/docmd-logo.png +0 -0
- package/src/assets/images/docmd-preview.png +0 -0
- package/src/assets/images/logo-dark.png +0 -0
- package/src/assets/images/logo-light.png +0 -0
- package/src/assets/js/theme-toggle.js +59 -0
- package/src/commands/build.js +300 -0
- package/src/commands/dev.js +182 -0
- package/src/commands/init.js +51 -0
- package/src/core/config-loader.js +28 -0
- package/src/core/file-processor.js +376 -0
- package/src/core/html-generator.js +139 -0
- package/src/core/icon-renderer.js +105 -0
- package/src/plugins/analytics.js +44 -0
- package/src/plugins/seo.js +65 -0
- package/src/plugins/sitemap.js +100 -0
- package/src/templates/layout.ejs +174 -0
- package/src/templates/navigation.ejs +107 -0
- package/src/templates/toc.ejs +34 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Analytics Integration"
|
|
3
|
+
description: "Integrate web analytics services like Google Analytics into your docmd site to track visitor traffic."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Analytics Integration Plugin
|
|
7
|
+
|
|
8
|
+
`docmd` allows you to easily integrate popular web analytics services into your documentation site using the built-in analytics plugin. This helps you understand your audience, track page views, and gather insights into how your documentation is being used.
|
|
9
|
+
|
|
10
|
+
## Enabling Analytics Plugin
|
|
11
|
+
|
|
12
|
+
You enable analytics by adding the analytics plugin and its configuration to the `plugins` object in your `config.js`.
|
|
13
|
+
|
|
14
|
+
**Example:**
|
|
15
|
+
|
|
16
|
+
```javascript
|
|
17
|
+
// config.js
|
|
18
|
+
module.exports = {
|
|
19
|
+
// ...
|
|
20
|
+
plugins: {
|
|
21
|
+
// Analytics plugin configuration
|
|
22
|
+
analytics: {
|
|
23
|
+
// For Google Analytics 4 (GA4)
|
|
24
|
+
googleV4: {
|
|
25
|
+
measurementId: 'G-XXXXXXXXXX' // Your GA4 Measurement ID
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
// For Google Universal Analytics (Legacy)
|
|
29
|
+
// googleUA: {
|
|
30
|
+
// trackingId: 'UA-XXXXXXXXX-Y' // Your Universal Analytics Tracking ID
|
|
31
|
+
// }
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
// ... other plugins
|
|
35
|
+
},
|
|
36
|
+
// ...
|
|
37
|
+
};
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Choose the analytics service and version you want to use by configuring the appropriate section.
|
|
41
|
+
|
|
42
|
+
## Available Analytics Options
|
|
43
|
+
|
|
44
|
+
### Google Analytics 4 (GA4)
|
|
45
|
+
|
|
46
|
+
* **Configuration Key:** `googleV4`
|
|
47
|
+
* **Description:** Integrates the latest version of Google Analytics, GA4. This is the recommended version for new Google Analytics setups.
|
|
48
|
+
* **Options:**
|
|
49
|
+
* `measurementId` (String, Required): Your Google Analytics 4 Measurement ID, which typically looks like `G-XXXXXXXXXX`.
|
|
50
|
+
* **Action:** Injects the standard Google Analytics 4 `gtag.js` tracking snippet into your pages.
|
|
51
|
+
|
|
52
|
+
### Google Universal Analytics (Legacy)
|
|
53
|
+
|
|
54
|
+
* **Configuration Key:** `googleUA`
|
|
55
|
+
* **Description:** Integrates the older version of Google Analytics, known as Universal Analytics (UA). Note that Google has sunset Universal Analytics as of July 2023.
|
|
56
|
+
* **Options:**
|
|
57
|
+
* `trackingId` (String, Required): Your Google Universal Analytics Tracking ID, which typically looks like `UA-XXXXXXXXX-Y`.
|
|
58
|
+
* **Action:** Injects the standard Google Universal Analytics `analytics.js` tracking snippet into your pages.
|
|
59
|
+
|
|
60
|
+
## Important Considerations
|
|
61
|
+
|
|
62
|
+
* **Choose One Google Analytics Version:** If using Google Analytics, configure *either* `googleUA` *or* `googleV4`, but not both for the same property, to avoid incorrect data collection.
|
|
63
|
+
* **Privacy and Consent:**
|
|
64
|
+
* Be mindful of user privacy when implementing analytics.
|
|
65
|
+
* Clearly disclose your use of analytics (and any cookies set by them) in your site's privacy policy or a cookie consent banner if required by regulations in your target regions (e.g., GDPR, CCPA).
|
|
66
|
+
* Consider features like IP anonymization if your analytics provider offers them and it's appropriate for your privacy stance.
|
|
67
|
+
* **Testing:** After enabling the analytics plugin and deploying your site, verify that data is being collected correctly in your analytics provider's dashboard. Use browser developer tools (Network tab) to check if the tracking script is loading.
|
|
68
|
+
|
|
69
|
+
## Future Analytics Support
|
|
70
|
+
|
|
71
|
+
`docmd` may add support for other privacy-focused or popular analytics providers in the future, such as:
|
|
72
|
+
* Plausible Analytics
|
|
73
|
+
* Fathom Analytics
|
|
74
|
+
* Simple Analytics
|
|
75
|
+
|
|
76
|
+
Check the latest `docmd` documentation or GitHub repository for updates on supported analytics integrations.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Using Plugins with docmd"
|
|
3
|
+
description: "Extend docmd's functionality with built-in plugins."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Extending docmd with Plugins
|
|
7
|
+
|
|
8
|
+
`docmd` supports a plugin system to add extra features and integrations to your documentation site without bloating the core tool. Plugins can modify the build process, inject content into pages, or add site-wide functionalities.
|
|
9
|
+
|
|
10
|
+
## Enabling Plugins
|
|
11
|
+
|
|
12
|
+
You enable and configure plugins in your `config.js` file within the `plugins` object. Each plugin is configured using its key with a corresponding configuration object.
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
// config.js
|
|
16
|
+
module.exports = {
|
|
17
|
+
// ... other config ...
|
|
18
|
+
plugins: {
|
|
19
|
+
// SEO Plugin
|
|
20
|
+
seo: {
|
|
21
|
+
defaultDescription: 'Your site-wide meta description',
|
|
22
|
+
openGraph: {
|
|
23
|
+
defaultImage: '/assets/images/og-preview.png',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
// Analytics Plugin
|
|
27
|
+
analytics: {
|
|
28
|
+
googleV4: {
|
|
29
|
+
measurementId: 'G-XXXXXXXXXX'
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
// Sitemap Plugin
|
|
33
|
+
sitemap: {
|
|
34
|
+
defaultChangefreq: 'weekly',
|
|
35
|
+
defaultPriority: 0.8
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
// ...
|
|
39
|
+
};
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Core Plugins
|
|
43
|
+
|
|
44
|
+
`docmd` ships with several core plugins that you can easily enable:
|
|
45
|
+
|
|
46
|
+
* **[SEO & Meta Tags](/plugins/seo/):** Automatically generates common SEO-related meta tags (description, Open Graph, Twitter Cards).
|
|
47
|
+
* **[Analytics Integration](/plugins/analytics/):** Easily add tracking snippets for popular web analytics services like Google Analytics.
|
|
48
|
+
* **[Sitemap](/plugins/sitemap/):** Generates a sitemap.xml file for search engines to better discover and index your content.
|
|
49
|
+
|
|
50
|
+
Click on the links above or see the sidebar for detailed configuration of each core plugin.
|
|
51
|
+
|
|
52
|
+
## How Plugins Work
|
|
53
|
+
|
|
54
|
+
Plugins in `docmd` hook into various parts of the build process:
|
|
55
|
+
|
|
56
|
+
* They can add meta tags and scripts to the page head
|
|
57
|
+
* They can inject content or scripts at the beginning or end of the page body
|
|
58
|
+
* They can generate additional files in the output directory
|
|
59
|
+
* They can modify the HTML output of pages
|
|
60
|
+
|
|
61
|
+
All plugins are designed to be configurable through your `config.js` file, giving you control over their behavior.
|
|
62
|
+
|
|
63
|
+
## Future Plugin Development
|
|
64
|
+
|
|
65
|
+
The plugin system is designed with future extensibility in mind. As `docmd` evolves, we plan to:
|
|
66
|
+
|
|
67
|
+
* Add more built-in plugins for common documentation needs
|
|
68
|
+
* Create an API for developers to build custom plugins
|
|
69
|
+
* Enable community contribution of third-party plugins
|
|
70
|
+
|
|
71
|
+
For now, focus on utilizing the available core plugins to enhance your site's functionality.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "SEO & Meta Tags Plugin"
|
|
3
|
+
description: "Configure Search Engine Optimization (SEO) meta tags to improve your docmd site's discoverability."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SEO & Meta Tags Plugin (`seo`)
|
|
7
|
+
|
|
8
|
+
The `seo` plugin automatically generates important meta tags in the `<head>` of your HTML pages. This helps search engines and social media platforms understand, index, and display your content more effectively.
|
|
9
|
+
|
|
10
|
+
## Enabling the Plugin
|
|
11
|
+
|
|
12
|
+
Add the `seo` plugin to the `plugins` object in your `config.js`:
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
// config.js
|
|
16
|
+
module.exports = {
|
|
17
|
+
// ...
|
|
18
|
+
plugins: {
|
|
19
|
+
seo: {
|
|
20
|
+
defaultDescription: 'Discover insightful articles and guides on Project X. Your go-to resource for learning and development.',
|
|
21
|
+
openGraph: {
|
|
22
|
+
// siteName: 'Project X Documentation', // Optional, defaults to config.siteTitle
|
|
23
|
+
defaultImage: '/assets/images/default-og-image.png', // Absolute path from site root
|
|
24
|
+
},
|
|
25
|
+
twitter: {
|
|
26
|
+
cardType: 'summary_large_image', // e.g., 'summary', 'summary_large_image'
|
|
27
|
+
// siteUsername: '@ProjectX_Docs', // Your site's Twitter handle
|
|
28
|
+
// creatorUsername: '@YourHandle' // Default author handle (override in frontmatter)
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
// ... other plugins
|
|
32
|
+
},
|
|
33
|
+
// ...
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Configuration Options
|
|
38
|
+
|
|
39
|
+
All options for the `seo` plugin are optional. If an option is not provided, the plugin will attempt to use sensible defaults or derive values from page frontmatter or `config.siteTitle`.
|
|
40
|
+
|
|
41
|
+
* `defaultDescription` (String):
|
|
42
|
+
* A fallback meta description used for pages that do not have a `description` specified in their YAML frontmatter.
|
|
43
|
+
* `openGraph` (Object): Configures [Open Graph](https://ogp.me/) meta tags, primarily used by Facebook, LinkedIn, Pinterest, etc.
|
|
44
|
+
* `siteName` (String): The name of your website (e.g., "My Project Documentation"). If not provided, `config.siteTitle` is used.
|
|
45
|
+
* `defaultImage` (String): Absolute path (from site root) to a default image for `og:image` when a page is shared, if the page itself doesn't specify an image in its frontmatter (e.g., via `image: /path/to/page-image.png` or `ogImage: ...`).
|
|
46
|
+
* Other tags like `og:title`, `og:description`, `og:url`, and `og:type` are automatically generated based on page frontmatter and URL.
|
|
47
|
+
* `twitter` (Object): Configures [Twitter Card](https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/abouts-cards) meta tags.
|
|
48
|
+
* `cardType` (String): The type of Twitter card. Common values: `'summary'`, `'summary_large_image'`. Defaults to `'summary'`.
|
|
49
|
+
* `siteUsername` (String): The Twitter @username of the site/publisher (e.g., `@MyProjectAccount`).
|
|
50
|
+
* `creatorUsername` (String): The default Twitter @username of the content creator. Can be overridden per page via frontmatter (e.g., `twitterCreator: @PageAuthorHandle`).
|
|
51
|
+
* Twitter tags like `twitter:title`, `twitter:description`, and `twitter:image` are also derived from page frontmatter, similar to Open Graph tags.
|
|
52
|
+
|
|
53
|
+
## Frontmatter for SEO
|
|
54
|
+
|
|
55
|
+
For the best SEO results, provide specific metadata in each page's frontmatter. The `seo` plugin will prioritize these values.
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
---
|
|
59
|
+
title: "Advanced Widget Configuration"
|
|
60
|
+
description: "A detailed guide on configuring advanced settings for the Super Widget, including performance tuning and security options."
|
|
61
|
+
image: "/assets/images/widgets/super-widget-social.jpg" # Used for og:image and twitter:image
|
|
62
|
+
ogType: "article" # Specify Open Graph type, e.g., article, website
|
|
63
|
+
twitterCreator: "@widgetMaster"
|
|
64
|
+
keywords: "widget, configuration, advanced, performance, security" # Optional, some argue keywords meta tag is less relevant now
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
# Advanced Widget Configuration
|
|
68
|
+
...
|
|
69
|
+
```
|
|
70
|
+
Supported frontmatter fields that the `seo` plugin may look for:
|
|
71
|
+
* `title` (Used for `og:title`, `twitter:title`)
|
|
72
|
+
* `description` (Used for `<meta name="description">`, `og:description`, `twitter:description`)
|
|
73
|
+
* `image` or `ogImage` (Used for `og:image`, `twitter:image`)
|
|
74
|
+
* `ogType` (Overrides default `og:type`)
|
|
75
|
+
* `twitterCard` (Overrides `config.seo.twitter.cardType` for this page)
|
|
76
|
+
* `twitterCreator` (Overrides `config.seo.twitter.creatorUsername` for this page)
|
|
77
|
+
* `noindex` (Boolean): If `true`, adds `<meta name="robots" content="noindex">` to discourage search engines from indexing this specific page.
|
|
78
|
+
|
|
79
|
+
By configuring the `seo` plugin and utilizing frontmatter effectively, you can significantly improve how your documentation is presented and discovered online.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Sitemap Plugin"
|
|
3
|
+
description: "Automatically generate a sitemap.xml for your docmd site to improve search engine discoverability."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Sitemap Plugin (`sitemap`)
|
|
7
|
+
|
|
8
|
+
The `sitemap` plugin automatically generates a `sitemap.xml` file for your documentation site. This helps search engines discover, crawl, and index your content more effectively, which can improve your site's visibility in search results.
|
|
9
|
+
|
|
10
|
+
## Enabling the Plugin
|
|
11
|
+
|
|
12
|
+
Add the `sitemap` plugin to the `plugins` object in your `config.js`:
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
// config.js
|
|
16
|
+
module.exports = {
|
|
17
|
+
// ...
|
|
18
|
+
plugins: {
|
|
19
|
+
sitemap: {
|
|
20
|
+
defaultChangefreq: 'weekly',
|
|
21
|
+
defaultPriority: 0.8
|
|
22
|
+
},
|
|
23
|
+
// ... other plugins
|
|
24
|
+
},
|
|
25
|
+
// ...
|
|
26
|
+
};
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Configuration Options
|
|
30
|
+
|
|
31
|
+
All options for the `sitemap` plugin are optional. If an option is not provided, the plugin will use sensible defaults.
|
|
32
|
+
|
|
33
|
+
* `defaultChangefreq` (String):
|
|
34
|
+
* Specifies how frequently the content is likely to change
|
|
35
|
+
* Possible values: `'always'`, `'hourly'`, `'daily'`, `'weekly'`, `'monthly'`, `'yearly'`, `'never'`
|
|
36
|
+
* Default: `'weekly'`
|
|
37
|
+
|
|
38
|
+
* `defaultPriority` (Number):
|
|
39
|
+
* Indicates the relative importance of a page in your site
|
|
40
|
+
* Value between 0.0 and 1.0
|
|
41
|
+
* Default: `0.8`
|
|
42
|
+
|
|
43
|
+
## How It Works
|
|
44
|
+
|
|
45
|
+
The sitemap plugin automatically:
|
|
46
|
+
|
|
47
|
+
1. Scans all generated HTML pages during the build process
|
|
48
|
+
2. Creates a `sitemap.xml` file in the root of your site output directory
|
|
49
|
+
3. Includes all pages with their URLs, last modification dates, and configured priorities
|
|
50
|
+
|
|
51
|
+
The plugin uses your `siteUrl` property from the config.js file to create absolute URLs, which is required for a valid sitemap. Make sure you have a `siteUrl` defined:
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
module.exports = {
|
|
55
|
+
siteUrl: 'https://yourdomain.com', // No trailing slash
|
|
56
|
+
// ... other config
|
|
57
|
+
};
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Overriding Per-Page Settings with Frontmatter
|
|
61
|
+
|
|
62
|
+
You can override the default sitemap settings for individual pages by adding specific frontmatter properties:
|
|
63
|
+
|
|
64
|
+
```yaml
|
|
65
|
+
---
|
|
66
|
+
title: "Important Page"
|
|
67
|
+
description: "This is a very important page that changes frequently"
|
|
68
|
+
sitemap:
|
|
69
|
+
changefreq: 'daily'
|
|
70
|
+
priority: 1.0
|
|
71
|
+
---
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Excluding Pages from the Sitemap
|
|
75
|
+
|
|
76
|
+
If you want to exclude specific pages from the sitemap, you can add the following to your frontmatter:
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
---
|
|
80
|
+
title: "Private Page"
|
|
81
|
+
description: "This page should not appear in search engines"
|
|
82
|
+
sitemap: false
|
|
83
|
+
---
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Verifying Your Sitemap
|
|
87
|
+
|
|
88
|
+
After building your site, check the generated sitemap at `your-site/sitemap.xml`. You can also submit the sitemap URL to search engines like Google Search Console or Bing Webmaster Tools to help them discover and index your content more efficiently.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Available Themes"
|
|
3
|
+
description: "An overview of the built-in themes provided by docmd."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Available Themes
|
|
7
|
+
|
|
8
|
+
`docmd` allows you to choose from a selection of built-in themes to quickly change the overall look and feel of your documentation site. You can specify the theme in your `config.js` file using the `theme.name` property.
|
|
9
|
+
|
|
10
|
+
## 1. `default` Theme
|
|
11
|
+
|
|
12
|
+
* **`theme.name: 'default'`** (This is the default if `theme.name` is not specified)
|
|
13
|
+
* **Description:** The standard `docmd` theme. It's designed to be clean, modern, responsive, and highly readable. It features:
|
|
14
|
+
* A collapsible sidebar for navigation.
|
|
15
|
+
* Support for light and dark color modes.
|
|
16
|
+
* Clear typography optimized for documentation.
|
|
17
|
+
* Well-styled custom containers (callouts, cards, steps).
|
|
18
|
+
* Effective syntax highlighting for code blocks.
|
|
19
|
+
* **When to use:** A great general-purpose theme suitable for most documentation projects.
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
// config.js
|
|
23
|
+
module.exports = {
|
|
24
|
+
// ...
|
|
25
|
+
theme: {
|
|
26
|
+
name: 'default',
|
|
27
|
+
defaultMode: 'light',
|
|
28
|
+
// ...
|
|
29
|
+
},
|
|
30
|
+
// ...
|
|
31
|
+
};
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 2. `sky` Theme
|
|
35
|
+
|
|
36
|
+
* **`theme.name: 'sky'`**
|
|
37
|
+
* **Description:** A modern theme inspired by popular documentation platforms, with a fresh and airy design. It features:
|
|
38
|
+
* A clean, minimalist interface with subtle shadows and rounded corners.
|
|
39
|
+
* Custom typography with improved readability.
|
|
40
|
+
* Refined color palette for both light and dark modes.
|
|
41
|
+
* Enhanced callout and container styles.
|
|
42
|
+
* Premium documentation feel with careful attention to spacing and contrast.
|
|
43
|
+
* **When to use:** When you want a premium, polished look for your documentation site.
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
// config.js
|
|
47
|
+
module.exports = {
|
|
48
|
+
// ...
|
|
49
|
+
theme: {
|
|
50
|
+
name: 'sky',
|
|
51
|
+
defaultMode: 'light', // or 'dark'
|
|
52
|
+
// ...
|
|
53
|
+
},
|
|
54
|
+
// ...
|
|
55
|
+
};
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Light and Dark Mode
|
|
59
|
+
|
|
60
|
+
All themes support both light and dark color modes. You can set the default mode using the `theme.defaultMode` property and enable a toggle button with `theme.enableModeToggle`:
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
// config.js
|
|
64
|
+
module.exports = {
|
|
65
|
+
// ...
|
|
66
|
+
theme: {
|
|
67
|
+
name: 'sky', // or 'default'
|
|
68
|
+
defaultMode: 'dark', // Start in dark mode
|
|
69
|
+
enableModeToggle: true, // Show a toggle button in the sidebar
|
|
70
|
+
// ...
|
|
71
|
+
},
|
|
72
|
+
// ...
|
|
73
|
+
};
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Users can switch between modes using the toggle button in the sidebar, and their preference will be saved in localStorage for future visits.
|
|
77
|
+
|
|
78
|
+
## How Themes Work
|
|
79
|
+
|
|
80
|
+
Each theme consists of CSS files located within `docmd`'s internal assets. When you select a theme name, `docmd` links the corresponding stylesheet in your site's HTML:
|
|
81
|
+
|
|
82
|
+
- `default` theme uses the base CSS with no additional theme stylesheet
|
|
83
|
+
- `sky` theme loads `theme-sky.css` with its custom styling
|
|
84
|
+
|
|
85
|
+
You can further customize any chosen theme using the `theme.customCss` option in your `config.js` to add your own overrides or additional styles. See [Custom CSS & JS](/theming/custom-css-js/) for details.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Custom CSS & JS"
|
|
3
|
+
description: "Learn how to add your own custom CSS and JavaScript to your docmd site for advanced customization."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Custom Styles & Scripts
|
|
7
|
+
|
|
8
|
+
While `docmd` themes provide a solid foundation, you can further tailor the appearance and behavior of your site by injecting custom CSS and JavaScript files. This is configured in your `config.js` file.
|
|
9
|
+
|
|
10
|
+
## Custom CSS
|
|
11
|
+
|
|
12
|
+
You can add one or more custom CSS files using the `theme.customCss` array in your `config.js`.
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
// config.js
|
|
16
|
+
module.exports = {
|
|
17
|
+
// ...
|
|
18
|
+
theme: {
|
|
19
|
+
name: 'default',
|
|
20
|
+
// ...
|
|
21
|
+
customCss: [
|
|
22
|
+
'/assets/css/my-branding.css', // Path relative to your site's root
|
|
23
|
+
'/css/another-stylesheet.css'
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
// ...
|
|
27
|
+
};
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**How it works:**
|
|
31
|
+
* Each string in the `customCss` array should be an absolute path from the root of your generated `site/` directory (e.g., if your file is `site/assets/css/my-branding.css`, the path is `/assets/css/my-branding.css`).
|
|
32
|
+
* These `<link rel="stylesheet">` tags will be added to the `<head>` of every page *after* the main theme CSS and `highlight.js` CSS. This allows your custom styles to override the default theme styles.
|
|
33
|
+
* You are responsible for ensuring these CSS files exist at the specified locations in your final `site/` output. Typically, you would:
|
|
34
|
+
1. Create your custom CSS files (e.g., `my-branding.css`).
|
|
35
|
+
2. Place them in a folder within your project (e.g., `my-project/static-assets/css/`).
|
|
36
|
+
3. Ensure that this folder (or its contents) is copied to the correct location in your `site/` directory during `docmd`'s asset copying process. If `docmd` copies a top-level `assets/` folder from your source, place them there.
|
|
37
|
+
|
|
38
|
+
**Use Cases for Custom CSS:**
|
|
39
|
+
* **Overriding CSS Variables:** The `default` theme uses CSS variables extensively. You can redefine these in your custom CSS.
|
|
40
|
+
```css
|
|
41
|
+
/* my-branding.css */
|
|
42
|
+
:root { /* Light mode overrides */
|
|
43
|
+
--primary-color: #D65A31; /* Example: Change primary color */
|
|
44
|
+
--font-family-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
45
|
+
--text-color: #222;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
body[data-theme="dark"] { /* Dark mode overrides */
|
|
49
|
+
--primary-color: #E87A5A;
|
|
50
|
+
--bg-color: #121212;
|
|
51
|
+
--text-color: #ddd;
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
* **Styling Custom Components:** Add styles for specific elements or components unique to your documentation.
|
|
55
|
+
* **Fine-tuning Layout:** Make minor adjustments to spacing, sizing, or layout elements.
|
|
56
|
+
|
|
57
|
+
## Custom JavaScript
|
|
58
|
+
|
|
59
|
+
You can add one or more custom JavaScript files using the top-level `customJs` array in your `config.js`.
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
// config.js
|
|
63
|
+
module.exports = {
|
|
64
|
+
// ...
|
|
65
|
+
customJs: [
|
|
66
|
+
'/assets/js/my-interactive-script.js', // Path relative to your site's root
|
|
67
|
+
'/js/third-party-integration.js'
|
|
68
|
+
],
|
|
69
|
+
// ...
|
|
70
|
+
};
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**How it works:**
|
|
74
|
+
* Each string in the `customJs` array should be an absolute path from the root of your generated `site/` directory.
|
|
75
|
+
* These `<script src="..."></script>` tags will be added just before the closing `</body>` tag on every page. This ensures the DOM is loaded before your scripts run and is generally better for page performance.
|
|
76
|
+
* Similar to custom CSS, you are responsible for ensuring these JavaScript files exist at the specified locations in your final `site/` output.
|
|
77
|
+
|
|
78
|
+
**Use Cases for Custom JS:**
|
|
79
|
+
* Adding interactive elements (e.g., custom modals, tabs not provided by `docmd`).
|
|
80
|
+
* Integrating third-party services or widgets.
|
|
81
|
+
* Performing custom DOM manipulations after the page loads.
|
|
82
|
+
* Adding simple analytics or tracking snippets if not using a built-in plugin.
|
|
83
|
+
|
|
84
|
+
By using `customCss` and `customJs`, you have significant flexibility to extend and personalize your `docmd` site beyond the standard theming options.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Using Icons"
|
|
3
|
+
description: "How to use Lucide icons in your docmd site navigation and content."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Using Icons
|
|
7
|
+
|
|
8
|
+
`docmd` allows you to add visual flair and improve navigation clarity with SVG icons from the [Lucide icon library](https://lucide.dev/).
|
|
9
|
+
|
|
10
|
+
## Icons in Navigation
|
|
11
|
+
|
|
12
|
+
You can specify an icon for each navigation item (including parent categories) in your `config.js` file using the `icon` property:
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
// config.js
|
|
16
|
+
// ...
|
|
17
|
+
navigation: [
|
|
18
|
+
{ title: 'Home', path: '/', icon: 'home' },
|
|
19
|
+
{
|
|
20
|
+
title: 'User Guides',
|
|
21
|
+
icon: 'book-open', // Icon for the category
|
|
22
|
+
children: [
|
|
23
|
+
{ title: 'Installation', path: '/user-guides/installation', icon: 'download' },
|
|
24
|
+
{ title: 'First Steps', path: '/user-guides/first-steps', icon: 'footprints' },
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{ title: 'API Reference', path: '/api-reference', icon: 'code' }
|
|
28
|
+
]
|
|
29
|
+
// ...
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**How it Works:**
|
|
33
|
+
* The `icon` value (e.g., `'home'`, `'book-open'`) uses kebab-case notation that maps to Lucide icon names.
|
|
34
|
+
* During build, `docmd` converts these names to the appropriate Lucide icon SVGs.
|
|
35
|
+
* The navigation template renders these icons inline for optimal performance.
|
|
36
|
+
|
|
37
|
+
## Available Icons
|
|
38
|
+
|
|
39
|
+
`docmd` uses the [Lucide](https://lucide.dev/) icon library, which provides a comprehensive set of beautiful, consistent open-source icons.
|
|
40
|
+
|
|
41
|
+
To see all available icons and their names:
|
|
42
|
+
1. Visit the [Lucide Icons Gallery](https://lucide.dev/icons/)
|
|
43
|
+
2. When you find an icon you want to use, note its name (shown below each icon)
|
|
44
|
+
3. Use the kebab-case version of the name in your config (e.g., `arrow-up-right` instead of `ArrowUpRight`)
|
|
45
|
+
|
|
46
|
+
**Common Icon Examples:**
|
|
47
|
+
* Navigation: `home`, `book-open`, `file-text`, `settings`, `users`
|
|
48
|
+
* Actions: `download`, `upload-cloud`, `play`, `external-link`
|
|
49
|
+
* UI Elements: `sun`, `moon`, `menu`, `x`, `search`
|
|
50
|
+
* Indicators: `alert-circle`, `check-circle`, `info`
|
|
51
|
+
* Directional: `chevron-right`, `chevron-down`, `arrow-left`
|
|
52
|
+
|
|
53
|
+
## Icon Styling
|
|
54
|
+
|
|
55
|
+
Lucide icons in `docmd` are styled using CSS. They are rendered as inline SVGs with appropriate classes for targeting:
|
|
56
|
+
|
|
57
|
+
```css
|
|
58
|
+
/* Example styling for navigation icons */
|
|
59
|
+
.sidebar-nav .lucide-icon {
|
|
60
|
+
width: 1.2em;
|
|
61
|
+
height: 1.2em;
|
|
62
|
+
margin-right: 0.5em;
|
|
63
|
+
vertical-align: middle;
|
|
64
|
+
stroke-width: 2px; /* Adjust line thickness */
|
|
65
|
+
stroke: currentColor; /* Use current text color */
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* Example of targeting a specific icon */
|
|
69
|
+
.sidebar-nav .icon-home {
|
|
70
|
+
color: #3498db; /* Blue color for home icon */
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The icons have the following CSS classes you can target:
|
|
75
|
+
- `.lucide-icon` - Applied to all Lucide icons
|
|
76
|
+
- `.icon-{name}` - Applied to specific icons, e.g., `.icon-home`
|
|
77
|
+
|
|
78
|
+
You can add these styles to your custom CSS file specified in `theme.customCss` in your configuration.
|
|
79
|
+
|
|
80
|
+
## Using Icons in Content
|
|
81
|
+
|
|
82
|
+
To use icons directly in your Markdown content, you'll need to use HTML with inline SVGs. You can copy SVG code directly from the [Lucide website](https://lucide.dev/) and paste it into your Markdown.
|
|
83
|
+
|
|
84
|
+
```html
|
|
85
|
+
<!-- Example of inline SVG in Markdown -->
|
|
86
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-info">
|
|
87
|
+
<circle cx="12" cy="12" r="10"></circle>
|
|
88
|
+
<path d="M12 16v-4"></path>
|
|
89
|
+
<path d="M12 8h.01"></path>
|
|
90
|
+
</svg> This is a note with an info icon.
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
A future version of `docmd` might provide shortcodes or other simplified ways to use icons directly in Markdown content.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Theming Your docmd Site"
|
|
3
|
+
description: "Learn how to customize the appearance of your docmd site, including themes, modes, custom styles, and icons."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Theming Your docmd Site
|
|
7
|
+
|
|
8
|
+
`docmd` allows for extensive customization of your documentation site's appearance, ensuring it aligns with your branding and provides an optimal user experience.
|
|
9
|
+
|
|
10
|
+
## Core Theming Concepts:
|
|
11
|
+
|
|
12
|
+
* **[Available Themes](/theming/available-themes/):** Choose from pre-built themes to quickly change the overall look and feel.
|
|
13
|
+
* **[Light & Dark Mode](/theming/light-dark-mode/):** Understand how to set the default color mode and enable user toggling.
|
|
14
|
+
* **[Custom CSS & JS](/theming/custom-css-js/):** Inject your own CSS and JavaScript files for fine-grained control over styling and functionality.
|
|
15
|
+
* **[Using Icons](/theming/icons/):** Enhance navigation and content with SVG icons.
|
|
16
|
+
* **CSS Variables:** The default theme (`default`) is built using CSS variables, making it easier to tweak common properties like colors and fonts via your custom CSS.
|
|
17
|
+
* **Syntax Highlighting:** Code block themes are provided for both light and dark modes via `highlight.js` stylesheets, adapting to the current color mode.
|
|
18
|
+
|
|
19
|
+
The goal is to provide a good-looking, accessible site out-of-the-box, with straightforward ways to adapt it to your specific needs.
|