2.1.1 • Published 1 year ago

mini-md v2.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.11

1 year ago

2.0.7

1 year ago

2.0.12

1 year ago

2.0.6

1 year ago

2.0.9

1 year ago

2.0.10

1 year ago

2.0.8

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago