在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):paulwib/gulp-ssg开源软件地址(OpenSource Url):https://github.com/paulwib/gulp-ssg开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-ssgA gulp plugin to help generate a static website from a bunch of files. Installation$ npm install gulp-ssg Usagevar ssg = require('gulp-ssg');
gulp.task('html', function() {
return gulp.src('content/**/*.html')
.pipe(ssg())
.pipe(gulp.dest('public/'));
}); This will add properties to each file's
To explain these a bit more:
This plug-in follows the gulp-data convention of using ExampleSo how can this be used? It gets more interesting when combined with other pipes. For example: var gulp = require('gulp');
var ssg = require('gulp-ssg');
var rename = require('gulp-rename');
var data = require('gulp-data');
var matter = require('gray-matter');
var markdown = require('gulp-markdown');
var wrap = require('gulp-wrap');
var del = require('del');
gulp.task('default', function() {
return gulp.src('src/content/*.md')
// Extract YAML front-matter and assign with gulp-data
.pipe(data(function(file) {
var m = matter(String(file.contents));
file.contents = new Buffer(m.content);
return m.data;
}))
// markdown -> HTML
.pipe(markdown())
// Rename to .html
.pipe(rename({ extname: '.html' }))
// Run through gulp-ssg
.pipe(ssg())
// Wrap file in template
.pipe(wrap(
{ src: 'src/templates/template.html' },
{ siteTitle: 'Example Website'},
{ engine: 'hogan' }
))
// Output to build directory
.pipe(gulp.dest('public/'));
}); There are complete examples with templates in the git repo. Options
baseUrl |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论