2.1.1 • Published 23 days ago

mini-md v2.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
23 days ago

mini-md

A view engine / template engine for express that can serve your markdown files as HTML.

Installation

yarn add mini-md

Syntax

Templates

You can reference other markdown files in your markdown files by using the following syntax:

[](md:path/to/file.md)

You can also use template bindings in your markdown files by using the following syntax:

[](md:path/to/file.md, key=value, key2=value2)

The key=value pairs are passed to the template engine and can be used in the referenced file:

Key has value: {key}
Key2 has value: {key2}

Note that this means you need to escape opening curly braces in your markdown files:

This is an opening curly: {curly-open}

You can also provide a bindings object to the render function:

app.get("/", (req, res) => {
  res.render("index.md", { bindings: { key: "value", key2: "value2" } });
});

Modifying the document

You can add \ tags straight to your markdown if you supply html: true into mdOptions:

app.engine("md", miniMd({ mdOptions: { html: true } }));

You can also add attributes to your body and html tags by adding the respective tags in your markdown files with the attributes you want:

<html lang="en" />
<body class="body" />

Usage

In your typescript:

import express from "express";
import path from "path";
import { miniMd } from "mini-md";

const app = express();
app.engine("md", miniMd());
app.set("views", "views");

app.get("/", (req, res) => {
  res.render("index.md");
});

In ./md/fragments/header.md:

# So long

In ./md/index.md:

[](md:fragments/header.md)

and thanks for all the fish!

Or even something like this:

header:

# So long {msg}

index:

[](md:fragments/header.md, msg=and thanks for all the fish!)

See the examples if you want to see it in action.

Todos

  • Test more extensively
  • Simplify the code
  • Make a prettier plugin for the md syntax + html
2.1.1

23 days ago

2.0.3

25 days ago

2.0.2

25 days ago

2.0.5

25 days ago

2.0.4

25 days ago

2.0.11

24 days ago

2.0.7

24 days ago

2.0.12

24 days ago

2.0.6

25 days ago

2.0.9

24 days ago

2.0.10

24 days ago

2.0.8

24 days ago

2.0.1

25 days ago

2.0.0

25 days ago

1.0.19

7 months ago

1.0.18

7 months ago

1.0.17

7 months ago

1.0.16

7 months ago

1.0.15

7 months ago

1.0.13

7 months ago

1.0.12

7 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago