Markdown2html
Render Markdown files into a static HTML site with an index page, without requiring Python or special content markers. WHAT IT DOES
Scan a directory of Markdown files, parse optional YAML frontmatter, render
titles/dates/excerpts/body as HTML with marked, apply an optional template,
write one HTML file per post, create index.html, and create rss.xml.
Prefer it over
copy-pasting Markdown or hand-writing HTML when the source notes already
contain the content you want published.
Optional YAML frontmatter is parsed only if the file begins with ---
and ends with ---. Supported fields are title, date, slug,
and excerpt. Title also falls back to the first H1, then the file
name. Date falls back to an empty string. Slug falls back to the file
name without its extension. Excerpt falls back to the first paragraph.
Pages are sorted newest date first (empty dates sort last), then title, and
the generated index.html links to every page.
INSTALL
swamp extension pull @svendowideit/markdown2htmlDEPENDENCIES
marked, js-yaml, and the swamp CLI only. Everything is bundled into the
extension, so no separate runtime is needed.
RUN
# Render /home/me/notes into a static site.
swamp workflow run @svendowideit/markdown2html-render \
--input sourceDir=/home/me/notes \
--input outputDir=/home/me/site
# Validate a direct model run first.
swamp model method run pages generate \
--input sourceDir=/home/me/notes \
--input outputDir=/home/me/siteCONFIGURE
Global/module inputs: sourceDir Directory containing Markdown files outputDir Directory where the site is written siteTitle Site title (default Notes) indexTitle Title for index.html and rss.xml (defaults to siteTitle) templatePath Optional HTML template; supported tokens are {{title}}, {{body}}, {{date}}, {{slug}}, {{excerpt}}, {{siteTitle}}, {{recent_posts}}, and {{archives}} recursive Scan subdirectories (default true)
WHAT IT INSTALLS
Nothing on the host. It writes HTML, index.html, and swamp data only.
Upgrade with swamp extension update.
Global Arguments
| Argument | Type | Description |
|---|---|---|
| sourceDir | string | Directory containing Markdown files |
| outputDir | string | Directory where the site is written |
| siteTitle? | string | Site title |
| indexTitle? | string | Title used for index.html and rss.xml; defaults to siteTitle |
| templatePath? | string | Optional HTML template using {{title}}, {{body}}, {{date}}, {{slug}}, and {{excerpt}} |
| recursive? | boolean | Scan subdirectories |
| Argument | Type | Description |
|---|---|---|
| sourceDir? | string | Override source directory |
| outputDir? | string | Override output directory |
| siteTitle? | string | Override site title |
| indexTitle? | string | Override index/feed title |
| templatePath? | string | Override template path |
| recursive? | boolean | Override recursive scan |
Resources
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive1/1earned
- Most symbols documented0/1missing
- No slow types (deprecated)1/1earned
- Dependencies pass trust audit1/2partial
- marked--npm:marked@14 is a range; audited 14.1.4, the version the registry resolved
1 dependency found
- npm:marked@14 -- audited 14.1.4
- Docs keep secrets in a vault1/1earned
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License2/2earned
- Verified public repository2/2earned