elcontraption / metalsmith-layouts-by-name

A Metalsmith plugin to enable setting layouts without extension, and layouts as `[layoutName]/index.html`.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Metalsmith Layouts by Name

A Metalsmith plugin to enable setting layouts without extension, and layouts as [layoutName]/index.html.

Installation

$ npm install metalsmith-layouts-by-name

Usage

var layouts = require('metalsmith-layouts');
var layoutsByName = require('metalsmith-layouts-by-name');
var metalsmith = require('Metalsmith');

// Make sure you add this plugin before metalsmith-layouts:
metalsmith
    .use(layoutsByName({
        // Optional: path to your layouts directory, `layouts` by default
        directory: 'path/to/layouts'
    }))
    .use(layouts());

Now, if your layout is set like this:

---
layout: my-layout
---

Metalsmith will first check for my-layout.html. If that file does not exist, my-layout/index.html will be checked.

About

A Metalsmith plugin to enable setting layouts without extension, and layouts as `[layoutName]/index.html`.


Languages

Language:JavaScript 100.0%