gulp plugin for generating multiple articles.
npm install -D gulp-mass-production
or
yarn add gulp-mass-production
You can choose format from json (as postParams) or markdown.
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
.
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...
- meta = massProduction.meta
h1= meta.title
p= meta.body
<h1>hoge title</h1>
<p>body body body body...</p>
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 |