gulp-mass-production
v2.2.1
Published
gulp mass-production plugin.
Downloads
8
Readme
gulp-mass-production
gulp plugin for generating multiple articles.
Install
from npm
npm install -D gulp-mass-production
or
yarn add gulp-mass-production
Usage
You can choose format from json (as postParams) or markdown.
Using Json
gulp.task('html', () => {
const params = {
hoge: {
title: 'hoge title',
tags: ['a', 'b'],
body: 'body body body body...'
},
moge: {
title: 'moge title',
tags: [],
body: 'body body body body...'
}
};
gulp.src('pug/*.pug')
.pipe(massProduction({
postParams: params,
template: 'pug/post.pug'
}))
.pipe(pug())
.pipe(gulp.dest('htdocs'));
});
Running this task, and generating htdocs/hoge/index.html
and htdocs/moge/index.html
.
Using Markdown
gulp.task('html', () => {
gulp.src('pug/*.pug')
.pipe(massProduction({
markdown: "posts/*.md"
template: 'pug/post.pug'
}))
.pipe(pug())
.pipe(gulp.dest('htdocs'));
});
Write markdown article by Frontmatter format.
---
title: hoge title
tags:
- a
- b
---
body body body body...
Pug template & Output
- meta = massProduction.meta
h1= meta.title
p= meta.body
<h1>hoge title</h1>
<p>body body body body...</p>
Options
| Variable | Type | Default | Description |
|----------|------|---------|-------------|
| hrefRule | Function | function (slug, meta) { return slug; };
| Customize html output format ( By default create the directory unless '.html')|
| locals | Object | null | Locals to compile template with |
| markdown | String | null | Markdown file that is used on template file |
| markedOpts | Object | { breaks: true } | Read here |
| namespace | String | 'massProduction' | Object name that is used on template file |
| postParams | Object | null | Data that is used on template file |