https://github.com/morganconrad/metalsmith-functional
https://github.com/morganconrad/metalsmith-functional
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/morganconrad/metalsmith-functional
- Owner: MorganConrad
- License: mit
- Created: 2017-12-29T00:02:00.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-29T01:48:51.000Z (over 8 years ago)
- Last Synced: 2025-01-11T14:45:45.058Z (over 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](http://travis-ci.org/MorganConrad/metalsmith-functional)
[](https://github.com/MorganConrad/metalsmith-functional)
[](https://www.npmjs.org/package/metalsmith-functional)
[](https://snyk.io/test/github/morganconrad/metalsmith-functional)
[](https://coveralls.io/github/MorganConrad/metalsmith-functional)
# metalsmith-functional
Inspired by [This feature request](https://github.com/segmentio/metalsmith/issues/287)
Most metalsmith plugins directly modify the `files` object. There is a growing trend towards "functional style" or immutable code, which **returns** a new version of the object instead of modifying it. Until metalsmith supports this style, you can try using this plugin.
```
const functional = require('metalsmith-functional');
...
.use(functional(fn [,options]))
```
### fn - your function, of the form `fn(files, metalsmith [,callback(err, results)])`
- return (or callback with) either an Object or an Array (see options.id)
- if there is an err `files` will remain unchanged
### options
- options.retain Do not delete existing key/value pairs in files. (default = false)
- options.id if fn returns an array, which key to use for the filename is files