├── .gitignore ├── test ├── fixture │ ├── src │ │ ├── live.md │ │ └── draft.md │ └── build │ │ ├── live.md │ │ └── draft.md └── index.js ├── Makefile ├── History.md ├── package.json ├── lib └── index.js └── Readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /test/fixture/src/live.md: -------------------------------------------------------------------------------- 1 | live -------------------------------------------------------------------------------- /test/fixture/build/live.md: -------------------------------------------------------------------------------- 1 | live -------------------------------------------------------------------------------- /test/fixture/build/draft.md: -------------------------------------------------------------------------------- 1 | 2 | draft -------------------------------------------------------------------------------- /test/fixture/src/draft.md: -------------------------------------------------------------------------------- 1 | --- 2 | draft: true 3 | --- 4 | 5 | draft -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | node_modules: package.json 3 | @npm install 4 | 5 | test: node_modules 6 | @./node_modules/.bin/mocha --reporter spec 7 | 8 | .PHONY: test -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | 2 | 0.1.0 - March 7, 2013 3 | --------------------- 4 | * update for Metalsmith `0.2.0` 5 | 6 | 0.0.1 - February 7, 2013 7 | ------------------------ 8 | :sparkles: -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "metalsmith-build-date", 3 | "description": "A Metalsmith plugin that adds a build date to the metadata.", 4 | "repository": "git://github.com/segmentio/metalsmith-build-date.git", 5 | "version": "0.2.0", 6 | "license": "MIT", 7 | "main": "lib/index.js", 8 | "devDependencies": { 9 | "mocha": "1.x", 10 | "metalsmith": "0.x" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Expose `plugin`. 3 | */ 4 | 5 | module.exports = plugin; 6 | 7 | /** 8 | * A Metalsmith plugin that adds a build date to the metadata. 9 | * 10 | * @return {Function} 11 | */ 12 | 13 | function plugin(options) { 14 | 15 | options = options || { 16 | key: 'date' 17 | }; 18 | 19 | return function(files, metalsmith, done){ 20 | var data = metalsmith.metadata(); 21 | data[options.key] = new Date(); 22 | done(); 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | 2 | var assert = require('assert'); 3 | var Metalsmith = require('metalsmith'); 4 | var date = require('..'); 5 | 6 | describe('metalsmith-build-date', function(){ 7 | it('should add a build date', function(done){ 8 | var m = Metalsmith('test/fixture'); 9 | m 10 | .use(date()) 11 | .build(function(err){ 12 | if (err) return done(err); 13 | assert(m.metadata().date instanceof Date); 14 | done(); 15 | }); 16 | }); 17 | 18 | it('should add a build date with the key dateBuilt', function(done){ 19 | var m = Metalsmith('test/fixture'); 20 | m 21 | .use(date({ key: 'dateBuilt' })) 22 | .build(function(err){ 23 | if (err) return done(err); 24 | assert(m.metadata().dateBuilt instanceof Date); 25 | done(); 26 | }); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # This metalsmith plugin has been retired. 2 | Functionality it provides is trivial to add yourself through `metalsmith.metadata({ date: new Date() })` 3 | 4 | --- 5 | 6 | # metalsmith-build-date 7 | 8 | A Metalsmith plugin that adds a build date to the metadata. Useful for `atom.xml` or other feeds. 9 | 10 | ## Installation 11 | 12 | $ npm install metalsmith-build-date 13 | 14 | ## Usage 15 | 16 | ```js 17 | var date = require('metalsmith-build-date'); 18 | 19 | metalsmith.use(date()); 20 | ``` 21 | 22 | That will add a global `date` property to your metadata, so you can use it in a template like: 23 | 24 | ```handlebars 25 | 26 | 27 | {{ date }} 28 | ``` 29 | 30 | ## Options 31 | 32 | ### key 33 | 34 | Change the key from the default value of 'date' to whatever you want. 35 | Useful if you already have a date in your frontmatter for the file, or if 36 | you want to be more specific about what the date represents. 37 | 38 | Example: 39 | 40 | ```js 41 | metalsmith.use(date({ key: 'dateBuilt' )); 42 | ``` 43 | 44 | ## CLI Usage 45 | 46 | Install via npm and then add the `metalsmith-build-date` key to your `metalsmith.json`: 47 | 48 | ```json 49 | { 50 | "plugins": { 51 | "metalsmith-build-date": true 52 | } 53 | } 54 | ``` 55 | 56 | ## License 57 | 58 | MIT 59 | --------------------------------------------------------------------------------