https://github.com/straticjs/stratic-truncate-indexes
Truncate indexes to a specific number of posts
https://github.com/straticjs/stratic-truncate-indexes
gulp gulp-plugin hacktoberfest javascript vinyl
Last synced: 4 months ago
JSON representation
Truncate indexes to a specific number of posts
- Host: GitHub
- URL: https://github.com/straticjs/stratic-truncate-indexes
- Owner: straticjs
- License: lgpl-3.0
- Created: 2017-10-19T16:51:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-12-17T06:25:26.000Z (over 7 years ago)
- Last Synced: 2025-03-02T04:04:50.168Z (over 1 year ago)
- Topics: gulp, gulp-plugin, hacktoberfest, javascript, vinyl
- Language: JavaScript
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: COPYING
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# `stratic-truncate-indexes`
[Gulp][1] plugin to truncate [Stratic][2] indexes to a specific number of posts
This is particularly useful in combination with [`stratic-indexes-to-rss`][].
## Installation
npm install stratic-truncate-indexes
## Usage
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.
## Examples
Minimal `gulpfile.js` for this module to work:
```js
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`:
```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'));
});
```
## License
LGPL 3.0+
## Author
AJ Jordan
[1]: http://gulpjs.com/
[2]: https://github.com/straticjs/generator-stratic
[`stratic-indexes-to-rss`]: https://github.com/straticjs/stratic-indexes-to-rss