@choonkeat/md-serve 0.4.0 → 0.6.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 +28 -4
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -4,6 +4,17 @@ Tiny static file server that renders Markdown (`.md`, `.markdown`) as
|
|
|
4
4
|
GitHub-styled HTML. Single Go binary, distributed via npm with native
|
|
5
5
|
binaries for Linux / macOS / Windows on x64 and arm64.
|
|
6
6
|
|
|
7
|
+
## Protip: query strings
|
|
8
|
+
|
|
9
|
+
A few query strings change how a URL is served — handy when the default
|
|
10
|
+
rendering isn't what you want:
|
|
11
|
+
|
|
12
|
+
| Append to a URL | What you get |
|
|
13
|
+
| --- | --- |
|
|
14
|
+
| `?listing=1` | The bare file listing for a directory — even when an `index.html` or `README.md` would otherwise take over. This is what the **Home** breadcrumb links to. |
|
|
15
|
+
| `?pretty=0` | The **raw source** of a file that normally renders — e.g. `README.md?pretty=0` or `index.html?pretty=0` returns the bytes as `text/plain` instead of the rendered page. |
|
|
16
|
+
| `?pretty=1` | A **syntax-highlighted** view of a source file, with linkable line numbers (e.g. `main.go?pretty=1#L42`). |
|
|
17
|
+
|
|
7
18
|
## Install
|
|
8
19
|
|
|
9
20
|
```sh
|
|
@@ -23,6 +34,8 @@ md-serve # serve $PWD on :$PORT (or :8080), live-reload on
|
|
|
23
34
|
md-serve -dir ./docs # serve a specific directory
|
|
24
35
|
md-serve -addr :3000 # bind to a specific address
|
|
25
36
|
md-serve -no-live # disable the live-reload poller
|
|
37
|
+
md-serve -hide-dotfiles # hide dotfiles (omit from listings, 404 direct requests)
|
|
38
|
+
md-serve -theme-cookie swe-swe-theme # pin light/dark from a request cookie
|
|
26
39
|
md-serve -version
|
|
27
40
|
```
|
|
28
41
|
|
|
@@ -36,9 +49,12 @@ md-serve -version
|
|
|
36
49
|
- Directories: if `index.html` is present it's served raw (matches
|
|
37
50
|
nginx / Apache / Caddy / GitHub Pages, so md-serve can host real
|
|
38
51
|
static apps). Otherwise, if `index.md` / `README.md` / `readme.md` /
|
|
39
|
-
`index.markdown` is present,
|
|
40
|
-
|
|
41
|
-
|
|
52
|
+
`index.markdown` is present, it's rendered GitHub-style under a
|
|
53
|
+
`Home / <file>` breadcrumb — the **Home** crumb (a link to
|
|
54
|
+
`?listing=1`) drops you to the bare file listing. Otherwise a plain
|
|
55
|
+
generated listing with **Name / Size / Modified** columns. Appending
|
|
56
|
+
`?listing=1` to any directory URL forces that listing, bypassing
|
|
57
|
+
`index.html` too.
|
|
42
58
|
- Everything else is served byte-for-byte. That means `.js`, `.css`,
|
|
43
59
|
`.wasm`, `.json`, images, fonts, and the rest all reach the browser
|
|
44
60
|
with their normal MIME types — ES module scripts load, fetch() works,
|
|
@@ -57,7 +73,15 @@ md-serve -version
|
|
|
57
73
|
bytes regardless of `?pretty=1` or the extension's default. So an
|
|
58
74
|
API consumer asking for `/README.md` with `Accept: application/json`
|
|
59
75
|
gets the source, not an HTML wrapper.
|
|
60
|
-
-
|
|
76
|
+
- Theme follows the browser's `prefers-color-scheme` (GitHub light /
|
|
77
|
+
dark) out of the box. Pass `-theme-cookie NAME` to instead pin the
|
|
78
|
+
theme from a request cookie whose value is `light` or `dark` — e.g.
|
|
79
|
+
`-theme-cookie swe-swe-theme` so md-serve matches a host UI that
|
|
80
|
+
already sets that cookie. No cookie (or an unrecognized value) falls
|
|
81
|
+
back to following the browser.
|
|
82
|
+
- Dotfiles are served and shown in listings by default. Pass
|
|
83
|
+
`-hide-dotfiles` to omit them from listings and return `404` for
|
|
84
|
+
direct requests to any dotfile (or path under a dotfile directory).
|
|
61
85
|
- Path traversal is blocked: requests are rejected if they resolve
|
|
62
86
|
outside the served root.
|
|
63
87
|
- Live-reload is on by default: rendered pages poll a tiny endpoint
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@choonkeat/md-serve",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Tiny static file server that renders Markdown as GitHub-styled HTML",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"optionalDependencies": {
|
|
22
|
-
"@choonkeat/md-serve-darwin-arm64": "0.
|
|
23
|
-
"@choonkeat/md-serve-darwin-x64": "0.
|
|
24
|
-
"@choonkeat/md-serve-linux-arm64": "0.
|
|
25
|
-
"@choonkeat/md-serve-linux-x64": "0.
|
|
26
|
-
"@choonkeat/md-serve-win32-arm64": "0.
|
|
27
|
-
"@choonkeat/md-serve-win32-x64": "0.
|
|
22
|
+
"@choonkeat/md-serve-darwin-arm64": "0.6.0",
|
|
23
|
+
"@choonkeat/md-serve-darwin-x64": "0.6.0",
|
|
24
|
+
"@choonkeat/md-serve-linux-arm64": "0.6.0",
|
|
25
|
+
"@choonkeat/md-serve-linux-x64": "0.6.0",
|
|
26
|
+
"@choonkeat/md-serve-win32-arm64": "0.6.0",
|
|
27
|
+
"@choonkeat/md-serve-win32-x64": "0.6.0"
|
|
28
28
|
}
|
|
29
29
|
}
|