mirror of
https://github.com/vale981/metalsmith-layouts
synced 2025-03-04 17:21:37 -05:00
Add example
This commit is contained in:
parent
0b0cf959b9
commit
74cd4253ce
1 changed files with 63 additions and 2 deletions
65
Readme.md
65
Readme.md
|
@ -6,11 +6,72 @@ This originated in [https://github.com/segmentio/metalsmith-templates/issues/35]
|
|||
|
||||
## Installation
|
||||
|
||||
```
|
||||
```bash
|
||||
$ npm install git://github.com/ismay/metalsmith-layouts.git
|
||||
```
|
||||
|
||||
## Changes
|
||||
## Usage
|
||||
|
||||
All `metalsmith-layouts` does is apply layouts to your source files. Pass options to `metalsmith-layouts` with the [Javascript API](https://github.com/segmentio/metalsmith#api) or [CLI](https://github.com/segmentio/metalsmith#cli). The options are:
|
||||
|
||||
* `engine`: templating engine
|
||||
* `default`: default template (optional)
|
||||
* `directory`: directory for the layouts, `layouts` by default (optional)
|
||||
* `pattern`: only files that match this pattern will be processed (optional)
|
||||
|
||||
## Example
|
||||
|
||||
Configuration in `metalsmith.json`:
|
||||
|
||||
```
|
||||
{
|
||||
"plugins": {
|
||||
"metalsmith-layouts": {
|
||||
"engine": "handlebars"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Source file `src/index.html`:
|
||||
|
||||
```html
|
||||
---
|
||||
layout: layout.html
|
||||
title: The title
|
||||
---
|
||||
<p>The contents</p>
|
||||
```
|
||||
|
||||
Layout `layouts/layout.html`:
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{title}}</title>
|
||||
</head>
|
||||
<body>
|
||||
{{{contents}}}
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
Results in `dist/index.html`:
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The title</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>The contents</p>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## Differences with segmentio/metalsmith-templates
|
||||
|
||||
* The `inPlace` option has been removed
|
||||
* Use `layout` instead of `template` in the front-matter to specify a layout
|
||||
|
|
Loading…
Add table
Reference in a new issue