mdts 0.2.0 → 0.3.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/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  - **File Tree Navigation**: Provides a hierarchical view of your Markdown files for easy browsing.
10
10
  - **Markdown Rendering**: Renders Markdown files in a clean, readable format.
11
- - [WIP] **Live Reload**:
11
+ - **Live Reload**: Automatically reloads the page in the browser when Markdown files are changed on disk.
12
12
 
13
13
  ![screenshot](docs/screenshot.png)
14
14
 
@@ -24,10 +24,6 @@ By default, `mdts` will serve files from the current directory (`.`) on port `85
24
24
 
25
25
  You can specify a different directory and port:
26
26
 
27
- ```bash
28
- npx mdts [directory] --port 8000
29
- ```
30
-
31
27
  - `-p, --port <port>`: Specify the port to serve on (default: `8521`)
32
28
  - `[directory]`: Specify the directory to serve (default: current directory `.`)
33
29
 
@@ -39,6 +35,40 @@ To serve Markdown files from the `docs` directory on port `3000`:
39
35
  npx mdts docs -p 3000
40
36
  ```
41
37
 
38
+ ### Advanced Usage Examples
39
+ Here are some practical scenarios where `mdts` can be useful:
40
+
41
+ - **AI-powered documentation workflow:**
42
+ Leverage AI tools to generate or refine your documentation. As the AI produces content, use `mdts` to instantly preview the generated Markdown files locally. This allows for a rapid feedback loop, enabling you to review, edit, and iterate on AI-generated documentation in real-time within your browser, ensuring accuracy and adherence to your project's style before committing changes.
43
+ ```bash
44
+ # Assuming your AI-generated docs are in a 'docs-ai' directory
45
+ npx mdts docs-ai
46
+ ```
47
+ This setup provides a seamless way to integrate AI into your documentation pipeline, making the process of creating and maintaining comprehensive project documentation more efficient.
48
+
49
+ - **Exploring a new project's documentation:**
50
+ When joining a new project, you often need to quickly understand its structure and documentation. Running `mdts` at the project root can give you an immediate overview of all Markdown-based documentation (e.g., `README.md`, `CONTRIBUTING.md`, `docs/`).
51
+ ```bash
52
+ # Navigate to your new project's root directory
53
+ cd /path/to/new-project
54
+ npx mdts .
55
+ ```
56
+ This provides a convenient way to browse all project-related Markdown files without opening them individually in a text editor.
57
+
58
+ - **Browsing a collection of Markdown notes/documents:**
59
+ If you have a repository where you collect Markdown files exported from various sources (e.g., Notion, Evernote, Confluence), `mdts` can help you browse them easily.
60
+ ```bash
61
+ npx mdts ~/my-markdown-collection
62
+ ```
63
+ This will serve all Markdown files in `~/my-markdown-collection` and its subdirectories, allowing you to navigate through them in your browser.
64
+
65
+ - **Reviewing `README` files of installed `node_modules`:**
66
+ Sometimes you might want to quickly check the `README.md` of a library installed in your `node_modules` directory to understand its usage or features.
67
+ ```bash
68
+ npx mdts node_modules
69
+ ```
70
+ This will serve the `node_modules` directory, allowing you to browse the `README.md` files of your installed packages directly in your browser.
71
+
42
72
  ## Development
43
73
 
44
74
  To build the project:
package/dist/cli.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { serve } from './server/server.js';
2
2
  import open from 'open';
3
3
  import { Command } from 'commander';
4
+ import { existsSync } from 'fs';
5
+ import path from 'path';
4
6
  const DEFAULT_PORT = 8521;
5
7
  const DEFAULT_DIRECTORY = '.';
6
8
  export const cli = () => {
@@ -11,7 +13,9 @@ export const cli = () => {
11
13
  .action((directory, options) => {
12
14
  const port = parseInt(options.port, 10);
13
15
  serve(directory, port);
14
- open(`http://localhost:${port}`);
16
+ const readmePath = path.join(directory, 'README.md');
17
+ const initialPath = existsSync(readmePath) ? '/README.md' : '';
18
+ open(`http://localhost:${port}${initialPath}`);
15
19
  });
16
20
  program.parse(process.argv);
17
21
  };