Created
November 4, 2015 17:59
-
-
Save sakadon/1ffe84c6baa3ca7cf5ac to your computer and use it in GitHub Desktop.
gulp.js環境で、jadeの中でjsonから定型文を呼び出す、2ヶ国語(ja/en)バージョン ref: http://qiita.com/sakadon/items/692ecb29b24b8db20ef3
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
var gulp = require('gulp'); | |
var plumber = require('gulp-plumber'); | |
var jade = require('gulp-jade'); | |
var data = require('gulp-data'); | |
// Jade compile to html | |
gulp.task( 'jade', function() { | |
gulp.src( './src/jade/*.jade' ) | |
.pipe( data( function (file) { | |
return { 'meta': require('./src/jade/meta.json')}; | |
}) ) | |
.pipe( plumber() ) | |
.pipe( jade({ | |
pretty: true | |
}) ) | |
.pipe( gulp.dest('./public_html') ) | |
.pipe( browserSync.reload({ | |
stream: true | |
}) ); | |
}); |
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
doctype html | |
html | |
head | |
meta(charset="utf-8") | |
block title | |
title #{meta.en.title} | |
meta(name="description", content=meta.en.description) | |
meta(name="keywords", content=meta.en.keywords) | |
meta(property="og:title", content=meta.en.title) | |
meta(property="og:type", content="website") | |
meta(property="og:url", content=meta.en.url) | |
meta(property="og:image", content=meta.en.image) | |
meta(property="og:site_name", content=meta.en.site_name) | |
meta(property="og:description", content=meta.en.description) | |
link(rel="stylesheet", href="style.css") | |
script(src="/js/modernizr.js") | |
script(src="/js/jquery.min.js") | |
body | |
... |
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
doctype html | |
html | |
head | |
meta(charset="utf-8") | |
block title | |
title #{meta.ja.title} | |
meta(name="description", content=meta.ja.description) | |
meta(name="keywords", content=meta.ja.keywords) | |
meta(property="og:title", content=meta.ja.title) | |
meta(property="og:type", content="website") | |
meta(property="og:url", content=meta.ja.url) | |
meta(property="og:image", content=meta.ja.image) | |
meta(property="og:site_name", content=meta.ja.site_name) | |
meta(property="og:description", content=meta.ja.description) | |
link(rel="stylesheet", href="style.css") | |
script(src="/js/modernizr.js") | |
script(src="/js/jquery.min.js") | |
body | |
... |
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
{ | |
"ja": { | |
"title": "日本語タイトル", | |
"description": "詳細", | |
"keywords": "ほげ,ふが", | |
"url": "http://", | |
"image": "http://", | |
"site_name": "日本語サイトネーム" | |
}, | |
"en": { | |
"title": "EnglishTitle", | |
"description": "Description", | |
"keywords": "Hoge,Fuga", | |
"url": "http://", | |
"image": "http://", | |
"site_name": "EnglishSitename" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment