Skip to content

Basic example with markdown

Kevin Van Lierde edited this page Dec 3, 2022 · 3 revisions

You can use @metalsmith/in-place with metalsmith's Javascript API or the CLI. For this example we'll use the CLI:

Install metalsmith and @metalsmith/in-place:

npm install metalsmith @metalsmith/in-place

Install appropriate jstransformers

In this case we'll use markdown, so we'll also need to install jstransformer-markdown:

npm install jstransformer-markdown

Configure metalsmith

We'll create a metalsmith.json configuration file and a file for @metalsmith/in-place to process:

./metalsmith.json

{
  "source": "src",
  "destination": "build",
  "plugins": [
    { "@metalsmith/in-place": { }}
  ]
}

./src/index.md

## A title
A paragraph of text here, with a [link](http://www.page.com).

Build

To build just run the metalsmith CLI (note that you'll need [email protected] or higher to use npx):

$ npx metalsmith

Which will output the following file:

./build/index.html

<h2>A title</h2>
<p>A paragraph of text here, with a <a href="http://www.page.com">link</a>.</p>