{"id":13991662,"url":"https://github.com/ericgj/metalsmith-branch","last_synced_at":"2025-04-13T06:16:12.927Z","repository":{"id":15742177,"uuid":"18480782","full_name":"ericgj/metalsmith-branch","owner":"ericgj","description":"A metalsmith plugin to run separate middleware pipelines on selected files.","archived":false,"fork":false,"pushed_at":"2016-12-13T16:57:06.000Z","size":13,"stargazers_count":20,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T06:15:55.354Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericgj.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-06T01:44:39.000Z","updated_at":"2021-11-24T19:04:34.000Z","dependencies_parsed_at":"2022-09-19T04:23:00.076Z","dependency_job_id":null,"html_url":"https://github.com/ericgj/metalsmith-branch","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Fmetalsmith-branch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Fmetalsmith-branch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Fmetalsmith-branch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericgj%2Fmetalsmith-branch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericgj","download_url":"https://codeload.github.com/ericgj/metalsmith-branch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670438,"owners_count":21142905,"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":[],"created_at":"2024-08-09T14:01:30.996Z","updated_at":"2025-04-13T06:16:12.908Z","avatar_url":"https://github.com/ericgj.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\n# metalsmith-branch\n\n  A [metalsmith][metalsmith] plugin to run separate middleware pipelines on \n  selected files.\n\n  Facilitates 'declarative' pipelines by file pattern or filter, since it means\n  each plugin doesn't have to implement its own filtering.  See examples below.\n\n  *April 2014: Please bear in mind that this is 0.0.x software and use with\n  caution, especially since metalsmith itself is likely to change.*\n\n\n## Installation\n\n    $ npm install metalsmith-branch\n\n\n## Usage\n\n  In your build file:\n  \n  ```js\n  var branch = require('metalsmith-branch')\n\n  metalsmith\n    .use( branch()\n            .pattern('*.md')        // for only md source files,\n            .use( templates({       // run through swig template engine\n                    engine: \"swig\",\n                    inPlace: true\n                  })\n            )\n            .use( markdown() )      // and generate html\n        )\n\n  // you can also specify the pattern directly in constructor\n\n  metalsmith\n    .use( branch('images/*') \n            .use( imageVariants() )\n        )\n\n  // or select files by function of their name, properties, and order:\n\n  var lastweek = function(filename,props,i){\n    var dt = new Date()\n      , last = new Date( dt.getFullYear(), dt.getMonth(), dt.getDate());\n    last.setDate( last.getDate() - 6 )\n    return ( props.published \u003e= last );\n  }\n\n  metalsmith\n    .use( branch( lastweek )\n            .use( tagLatest() )\n        )\n  ```\n\n  Note that nested branches are possible too.\n\n  ```js\n  // to post-process only markdown-sourced files in a 'special' dir:\n\n  metalsmith\n    .use( branch('*.md')\n            .use( markdown() )\n            .use( branch('special/*.html')\n                    .use( postProcess() )\n                )\n        )\n  ```\n  \n  It's also possible to specify an array of patterns:\n  \n  ```js\n  // to select all markdown files in the \"posts\" and \"projects\" directories:\n\n  metalsmith\n    .use( branch()\n            .pattern([\"projects/*/*.md\", \"posts/**/*.md\"])\n            .use( markdown() )\n        )\n  ```\n  \n  See [multimatch][multimatch] for all pattern options.\n  \n## License\n\n  MIT\n\n\n[metalsmith]: https://github.com/segmentio/metalsmith\n[multimatch]: https://www.npmjs.com/package/multimatch\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericgj%2Fmetalsmith-branch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericgj%2Fmetalsmith-branch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericgj%2Fmetalsmith-branch/lists"}