# `stratic-truncate-indexes`
Gulp plugin to truncate Stratic indexes to a specific number of posts
This is particularly useful in combination with stratic-indexes-to-rss
.
npm install stratic-truncate-indexes
All you need to do is pipe Stratic indexes to this module and BAM! It'll truncate them to a certain number of posts - 15 by default.
You may also pass a number to the module to override the number of posts to truncate to. The complete example below shows this.
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 straticTruncateIndexes = require('stratic-truncate-indexes');
gulp.task('rss', function() {
gulp.src('*.md')
.pipe(frontmatter())
.pipe(straticDateInPath())
.pipe(addsrc('src/blog/index.jade'))
.pipe(straticPostsToIndex('index.jade'))
.pipe(straticTruncateIndexes());
});
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 straticTruncateIndexes = require('stratic-truncate-indexes');
var straticIndexesToRss = require('stratic-indexes-to-rss');
var rename = require('gulp-rename');
gulp.task('rss', function() {
gulp.src('*.md')
.pipe(frontmatter())
.pipe(remark().use(remarkHtml))
.pipe(straticDateInPath())
.pipe(addsrc('src/blog/index.jade'))
.pipe(straticPostsToIndex('index.jade'))
.pipe(straticTruncateIndexes(10)) // Override the default number of posts to truncate to
.pipe(straticIndexesToRss({title: 'Blag!'}, 'https://example.com/blog/'))
.pipe(rename({ extname: '.rss' }))
.pipe(gulp.dest('dist/blog'));
});
LGPL 3.0+
AJ Jordan [email protected]