{"id":19574332,"url":"https://github.com/straticjs/stratic-posts-to-index","last_synced_at":"2026-05-19T09:07:35.429Z","repository":{"id":57371924,"uuid":"61002056","full_name":"straticjs/stratic-posts-to-index","owner":"straticjs","description":"Gulp plugin to prepare Vinyl files with indexes of a stream of Stratic posts","archived":false,"fork":false,"pushed_at":"2018-12-17T06:24:37.000Z","size":48,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-03T16:40:49.627Z","etag":null,"topics":["gulp","gulp-plugin","hacktoberfest","javascript","stratic"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/straticjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-13T02:43:10.000Z","updated_at":"2021-10-07T17:00:19.000Z","dependencies_parsed_at":"2022-09-07T18:10:28.073Z","dependency_job_id":null,"html_url":"https://github.com/straticjs/stratic-posts-to-index","commit_stats":null,"previous_names":["strugee/stratic-posts-to-index"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/straticjs/stratic-posts-to-index","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straticjs%2Fstratic-posts-to-index","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straticjs%2Fstratic-posts-to-index/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straticjs%2Fstratic-posts-to-index/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straticjs%2Fstratic-posts-to-index/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/straticjs","download_url":"https://codeload.github.com/straticjs/stratic-posts-to-index/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/straticjs%2Fstratic-posts-to-index/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264787470,"owners_count":23663937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gulp","gulp-plugin","hacktoberfest","javascript","stratic"],"created_at":"2024-11-11T06:39:59.809Z","updated_at":"2026-05-19T09:07:30.408Z","avatar_url":"https://github.com/straticjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `stratic-posts-to-index`\n\n[Gulp][1] plugin to prepare Vinyl files with indexes of a stream of [Stratic][2] posts\n\n## Installation\n\n    npm install stratic-posts-to-index\n\n## Example\n\nMinimal example:\n\n```js\nvar gulp = require('gulp');\nvar frontMatter = require('gulp-gray-matter');\nvar straticPostsToIndex = require('stratic-posts-to-index');\nvar addsrc = require('gulp-add-src');\nvar straticDateInPath = require('stratic-date-in-path');\n\ngulp.task('post-index', function() {\n\treturn gulp.src('*.md')\n\t           .pipe(frontMatter())\n\t           .pipe(straticDateInPath())\n\t           .pipe(addsrc('src/blog/index.jade'))\n\t           .pipe(straticPostsToIndex('index.jade'))\n});\n```\n\nFull example:\n\n```js\nvar gulp = require('gulp');\nvar remark = require('gulp-remark');\nvar remarkHtml = require('remark-html');\nvar frontMatter = require('gulp-gray-matter');\nvar straticPostsToIndex = require('stratic-posts-to-index');\nvar addsrc = require('gulp-add-src');\nvar jade = require('gulp-jade');\nvar straticDateInPath = require('stratic-date-in-path');\nvar rename = require('gulp-rename');\n\ngulp.task('post-index', function() {\n\treturn gulp.src('*.md')\n\t           .pipe(frontMatter())\n\t           .pipe(remark().use(remarkHtml))\n\t           .pipe(straticDateInPath())\n\t           .pipe(addsrc('index.jade'))\n\t           .pipe(straticPostsToIndex('index.jade'))\n\t           .pipe(jade({basedir: __dirname}))\n\t           .pipe(rename({ extname: '.html' }))\n\t           .pipe(gulp.dest('dist'));\n});\n```\n\nWhat's happening here? First we read in the Stratic posts from disk, render them as Markdown, and put the date in their path. Then we add `index.jade` into the stream of files. `index.jade` is what will be used for the template.\n\nWhen we pipe all the files to `postsToIndex`, we pass it the name of the template file. From there, `stratic-posts-to-index` will output copies of this template, one for each index page. See \"Locals\" below for information on the locals that are provided to the template.\n\nThe rest is just standard Gulp: we render the Jade, rename the templates to `.html` files, and write to the `dist` directory.\n\n## Locals\n\nEach template file gets some information as an object in its `data` attribute. Most template system plugins will use this object as locals for the template being rendered.\n\n`posts` (`Array`) - the posts that should be included in that particular index, presorted in reverse-chronological order\n\n`indexType` (`String`) - the type of index this is. The value will be one of `main`, `year`, `month`, or `category`.\n\n`includedYears` (`Array`) - years that the posts included in the index were authored in (set for `main` indexes)\n\n`includedMonths` (`Array`) - months that the posts included in the index were authored in (set for `main` and `year` indexes)\n\n`includedCategories` (`Array`) - categories that the posts included in the index were categorized as (set for `main`, `year` and `month` indexes)\n\n`year` (`Number`) - the year that the index is for (set for `year` and `month` indexes)\n\n`month` (`Number`) - the (zero-based) month that the index is for (set for `month` indexes)\n\n`category` (`String`) - the category that the index is for (set for `category` indexes)\n\n## Code of Conduct\n\nPlease note that StraticJS is developed under the [Contributor Covenant][3] Code of Conduct. Project contributors are expected to respect these terms.\n\nFor the full Code of Conduct, see [CODE_OF_CONDUCT.md][4]. Violations may be reported to \u003calex@strugee.net\u003e.\n\n## License\n\nLGPL 3.0+\n\n## Author\n\nAJ Jordan \u003calex@strugee.net\u003e\n\n [1]: http://gulpjs.com/\n [2]: https://github.com/straticjs/generator-stratic\n [3]: http://contributor-covenant.org/\n [4]: https://github.com/straticjs/stratic-posts-to-index/blob/master/CODE_OF_CONDUCT.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstraticjs%2Fstratic-posts-to-index","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstraticjs%2Fstratic-posts-to-index","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstraticjs%2Fstratic-posts-to-index/lists"}