This repository has been archived by the owner on Nov 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #276 from iojs/264_build_process_2
#264 build process - adds various i18n helpers, html-based templates
- Loading branch information
Showing
17 changed files
with
438 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var path = require('path'); | ||
var gulp = require('gulp'); | ||
var clone = require('gulp-clone'); | ||
var buffer = require('vinyl-buffer'); | ||
var mergeStream = require('merge-stream'); | ||
var generateContentAndTemplates = require('../util/content').generateContentAndTemplates; | ||
var through = require('through2'); | ||
|
||
gulp.task('content', function() { | ||
var base = path.resolve(__dirname, '..', '..'); | ||
var contentJSON = require('../../source/content.js'); | ||
var languagesJSON = require('../../source/languages.js'); | ||
var matchHTML = /\.html$/; | ||
var templates = {}; | ||
var templateStreams = mergeStream(); | ||
|
||
Object.keys(contentJSON).filter(function(key) { | ||
var article = contentJSON[key]; | ||
if (article.content && matchHTML.test(article.content)) { | ||
var contentTemplate = `source/templates/${article.content}`; | ||
if (templates[contentTemplate] == null) { | ||
templates[contentTemplate] = gulp.src(contentTemplate, {base: 'source/templates'}); | ||
} | ||
languagesJSON.forEach(function(lang) { | ||
var newpath = path.resolve(base, 'content', lang.code, article.url); | ||
var stream = templates[contentTemplate] | ||
.pipe(clone()) | ||
.pipe(through.obj(function(file, _unused_, cb) { | ||
file.base = 'content' | ||
file.path = path.join(base, 'content', lang.code, article.url); | ||
file._article = article; | ||
this.push(file); | ||
cb(); | ||
})); | ||
templateStreams.add(stream); | ||
}); | ||
} | ||
}); | ||
|
||
return templateStreams | ||
.pipe(buffer()) | ||
.pipe(through.obj(generateContentAndTemplates())) | ||
.pipe(gulp.dest('public/')) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.