An opinionated approach to generating static HTML using gulp and Nunjucks templates.
APACHE-2.0 License
An opinionated approach to generating static HTML using gulp and Nunjucks (as of v0.1.0) templates.
The plugin is a simple static site generator that:
gulpfile.js
gulp.task('html', () => {
return gulp.src('html/**/*.html')
.pipe(gulpNucleus())
.pipe(gulp.dest('dist'));
});
html/index.html
---
title: hello
---
<!doctype html>
<html>
<head><title>
{{ title }} <!-- rendered using Nunjucks -->
</title></head>
<body>
Hello world!
</body>
</html>
gulpfile.js:
gulp.task('html', () => {
return gulp.src('html/**/*.html')
.pipe(gulpNucleus({
dataPath: 'data'
}))
.pipe(gulp.dest('dist'));
});
data/apikeys.yaml:
fooApi: 2346b3166bdb60a0506d
html/index.html:
...
<script src="foo.js?key={{apikeys.fooApi}}"></script>
HTML pages that start with a $
are considered generator pages. For example:
gulpfile.js:
gulp.task('html', () => {
return gulp.src('html/**/*.html')
.pipe(gulpNucleus({
dataPath: 'data'
}))
.pipe(gulp.dest('dist'));
});
data/people.yaml:
- id: jane
name: Jane
- id: john
name: John
html/$person.html:
---
generate:
collection: people
variable: person
filename: '{{person.id}}.html'
---
Hi, my name is {{person.name}}