mirror of
https://github.com/vale981/metalsmith-layouts
synced 2025-03-04 17:21:37 -05:00
No description
lib | ||
test | ||
.gitignore | ||
History.md | ||
Makefile | ||
package.json | ||
Readme.md |
metalsmith-layouts
A metalsmith plugin for layouts
This plugin renders your source files in a layout. You can use any templating engine supported by consolidate.js. Pass options to it with the Javascript API or CLI. The options are:
engine
: templating engine (required)default
: default template (optional)directory
: directory for the layouts,layouts
by default (optional)pattern
: only files that match this pattern will be processed (optional)
Installation
$ npm install git://github.com/ismay/metalsmith-layouts.git
Example
Configuration in metalsmith.json
:
{
"plugins": {
"metalsmith-layouts": {
"engine": "handlebars"
}
}
}
Source file src/index.html
:
---
layout: layout.html
title: The title
---
<p>The contents</p>
Layout layouts/layout.html
:
<!doctype html>
<html>
<head>
<title>{{title}}</title>
</head>
<body>
{{{contents}}}
</body>
</html>
Results in dist/index.html
:
<!doctype html>
<html>
<head>
<title>The title</title>
</head>
<body>
<p>The contents</p>
</body>
</html>
Origins
This plugin originated in metalsmith-templates issue #35. Splitting up metalsmith-templates
into two plugins was suggested by Ian Storm Taylor. The results are:
- metalsmith-in-place:
metalsmith-templates
withinPlace: true
- metalsmith-layouts:
metalsmith-templates
withinPlace: false
Both plugins have been optimised for each use case. For metalsmith-layouts
the differences with metalsmith-templates are:
- The
inPlace
option has been removed - Use
layout
instead oftemplate
in the front-matter to specify a layout - The default folder for layouts is
layouts
instead oftemplates
For further documentation see the original metalsmith-templates, but keep these differences in mind.
License
MIT