Skip to content

Commit 04ad7f1

Browse files
committed
Start generating the site
Right now I'm using handlebars templates rendered via gulp. It's all very much a work in progress at this point, but it did successfully generate index.html
1 parent 9f392ea commit 04ad7f1

7 files changed

Lines changed: 61 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/node_modules

_src/app.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var express = require('express');
2+
var app = express();
3+
4+
5+
app.use(express.static('../', {
6+
extensions: ['html', 'ico']
7+
}));
8+
app.listen(8080);

_src/gulpfile.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
var gulp = require('gulp');
2+
var path = require('path');
3+
var through = require('through2');
4+
var rename = require('gulp-rename');
5+
var merge = require('merge-stream');
6+
var Handlebars = require('handlebars');
7+
8+
gulp.task('partials', function () {
9+
return gulp.src('./partials/**/*.hbs')
10+
.pipe(through.obj(function (file, encoding, callback) {
11+
Handlebars.registerPartial(path.basename(file.path, '.hbs'), file.contents.toString());
12+
return callback();
13+
}));
14+
});
15+
16+
gulp.task('templates', ['partials'], function () {
17+
return gulp.src('./templates/**/*.hbs')
18+
.pipe(through.obj(function (file, encoding, callback) {
19+
file.contents = new Buffer(Handlebars.compile(file.contents.toString())());
20+
this.push(file);
21+
return callback();
22+
}))
23+
.pipe(rename({
24+
extname: '.html'
25+
}))
26+
.pipe(gulp.dest('../'));
27+
});
28+
29+
gulp.task('default', ['templates']);

_src/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "mike.fail",
3+
"version": "0.0.1",
4+
"description": "mike.fail blog",
5+
"main": "app.js",
6+
"dependencies": {
7+
"gulp": "^3.8.9",
8+
"gulp-rename": "^1.2.0",
9+
"handlebars": "^2.0.0",
10+
"merge-stream": "^0.1.6",
11+
"through2": "^0.6.3"
12+
},
13+
"devDependencies": {
14+
"express": "^4.10.0"
15+
},
16+
"author": "Michael Groshans",
17+
"license": "GPL3"
18+
}

_src/partials/header.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>mike.fail</h1>

_src/templates/index.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{> header}}
2+
<p>fail</p>

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<h1>Blog</h1>
2-
<p>Awesome content!</p>
1+
<h1>mike.fail</h1>
2+
<p>fail</p>

0 commit comments

Comments
 (0)