Skip to content

Latest commit

 

History

History
74 lines (56 loc) · 2.13 KB

README.md

File metadata and controls

74 lines (56 loc) · 2.13 KB

stratic-paginate-indexes

Gulp plugin to split Stratic index pages into pages

Installation

npm install stratic-paginate-indexes

Usage

Usage is quite simple. All you need to do is pipe Stratic indexes to this module and presto! You're done.

Minimal gulpfile.js for this module to work:

var gulp = require('gulp');
var frontMatter = require('gulp-gray-matter');
var straticDateInPath = require('stratic-date-in-path');
var addsrc = require('gulp-add-src');
var straticPostsToIndex = require('stratic-posts-to-index');
var straticPaginateIndexes = require('stratic-paginate-indexes');

gulp.task('post-index', function() {
    gulp.src('*.md')
        .pipe(frontMatter())
        .pipe(straticDateInPath())
        .pipe(addsrc('src/blog/index.jade'))
        .pipe(straticPostsToIndex('index.jade'))
        .pipe(straticPaginateIndexes());
});

Complete example gulpfile.js:

var gulp = require('gulp');
var frontMatter = require('gulp-gray-matter');
var remark = require('gulp-remark');
var remarkHtml = require('remark-html');
var straticDateInPath = require('stratic-date-in-path');
var addsrc = require('gulp-add-src');
var straticPostsToIndex = require('stratic-posts-to-index');
var straticPaginateIndexes = require('stratic-paginate-indexes');
var jade = require('gulp-jade');
var rename = require('gulp-rename');

gulp.task('post-index', function() {
    gulp.src('*.md')
        .pipe(frontMatter())
        .pipe(remark().use(remarkHtml))
        .pipe(straticDateInPath())
        .pipe(addsrc('src/blog/index.jade'))
        .pipe(straticPostsToIndex('index.jade'))
        .pipe(straticPaginateIndexes())
        .pipe(jade({pretty: true, basedir: __dirname}))
        .pipe(rename({ extname: '.html' }))
        .pipe(gulp.dest('dist/blog'));
});

Locals

Two additional locals are provided to templates via the file.data attribute. page indicates which page number the file represents. pageCount represents how many total pages there are for that particular index.

License

LGPL 3.0+

Author

AJ Jordan [email protected]