@choonkeat/md-serve 0.5.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.
Files changed (2) hide show
  1. package/README.md +24 -3
  2. 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
@@ -24,6 +35,7 @@ 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
26
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
27
39
  md-serve -version
28
40
  ```
29
41
 
@@ -37,9 +49,12 @@ md-serve -version
37
49
  - Directories: if `index.html` is present it's served raw (matches
38
50
  nginx / Apache / Caddy / GitHub Pages, so md-serve can host real
39
51
  static apps). Otherwise, if `index.md` / `README.md` / `readme.md` /
40
- `index.markdown` is present, a combined page renders the directory
41
- listing on top and the rendered README below GitHub-style. Otherwise
42
- a plain generated listing with **Name / Size / Modified** columns.
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.
43
58
  - Everything else is served byte-for-byte. That means `.js`, `.css`,
44
59
  `.wasm`, `.json`, images, fonts, and the rest all reach the browser
45
60
  with their normal MIME types — ES module scripts load, fetch() works,
@@ -58,6 +73,12 @@ md-serve -version
58
73
  bytes regardless of `?pretty=1` or the extension's default. So an
59
74
  API consumer asking for `/README.md` with `Accept: application/json`
60
75
  gets the source, not an HTML wrapper.
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.
61
82
  - Dotfiles are served and shown in listings by default. Pass
62
83
  `-hide-dotfiles` to omit them from listings and return `404` for
63
84
  direct requests to any dotfile (or path under a dotfile directory).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choonkeat/md-serve",
3
- "version": "0.5.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.5.0",
23
- "@choonkeat/md-serve-darwin-x64": "0.5.0",
24
- "@choonkeat/md-serve-linux-arm64": "0.5.0",
25
- "@choonkeat/md-serve-linux-x64": "0.5.0",
26
- "@choonkeat/md-serve-win32-arm64": "0.5.0",
27
- "@choonkeat/md-serve-win32-x64": "0.5.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
  }