Metalsmith static site pages missing metadata

I am trying to create a tutorial to set up Metalsmith , and I got to the end of the first part.

I installed node.js and modules. The IDE is Visual Studio 2013 with the node.js tools installed. I placed the main structure and I am trying to get one page to render using a template.

The instructions indicate to insert the following into the file:

---
title: Home
template: home.hbt
---

This is your first page

With a template like:

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>{{ title }} | Metalsmith Page</title>
</head>
<body>
    <div class="main-wrapper">
        {{{ contents }}}
    </div>
</body>
</html>

The tutorial says that it should appear on the html page, but the result that I get looks something like this:

--- title: Home template: home.hbt --- This is your first page

When I use the markup renderer, it gives

<p>---
title: Home</p>
<h2 id="template-home-hbt">template: home.hbt</h2>
<p>This is your first page</p>

, YAML front-matter. , .

+4
1



YAML:

UTF-8

UTF-8, , , , Jekyll. , Jekyll Windows.

, Node.js, utf8.

IDE utf8 , .

, metalmith.

var stripBom = require('strip-bom');
var front = require('front-matter');
var extend = require('extend');

// **snip**

.use(function __utf8BOM_workaround(files, metalsmith, done)
{
    setImmediate(done);
    Object.keys(files).forEach(function (file)
    {
        var data = files[file];
        var parsed = front(stripBom(data.contents.toString()));
        data = extend({}, data, parsed.attributes);
        data.contents = new Buffer(parsed.body);

        files[file] = data;
    });
})
+6

Source: https://habr.com/ru/post/1542450/


All Articles