├── test ├── actual │ ├── 404.html │ ├── foo.html │ ├── index.html │ └── articles │ │ ├── index.html │ │ └── arctic-ice-is-really-cold.html └── fixtures │ ├── pages │ ├── 404.hbs │ ├── foo.hbs │ ├── index.hbs │ └── articles │ │ ├── index.hbs │ │ └── arctic-ice-is-really-cold.hbs │ └── default.hbs ├── .gitignore ├── docs ├── options.md ├── examples.md └── quickstart.md ├── .gitattributes ├── .verb.md ├── LICENSE-MIT ├── index.js ├── Gruntfile.js ├── package.json └── README.md /test/actual/404.html: -------------------------------------------------------------------------------- 1 | 2 |
This is the home page!
4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | 4 | tmp 5 | temp 6 | TODO.md 7 | 8 | *.sublime-* 9 | -------------------------------------------------------------------------------- /test/fixtures/pages/404.hbs: -------------------------------------------------------------------------------- 1 | --- 2 | title: 404 3 | slug: custom/path 4 | --- 5 |Index page nested in a directory.
4 | -------------------------------------------------------------------------------- /docs/options.md: -------------------------------------------------------------------------------- 1 | ## dest 2 | Type: `String` 3 | Default: `assemble.dest + /tmp` 4 | 5 | Destination of JSON context. 6 | -------------------------------------------------------------------------------- /test/fixtures/pages/foo.hbs: -------------------------------------------------------------------------------- 1 | --- 2 | title: foo 3 | slug: custom/path 4 | date: 2013-10-03 5 | --- 6 |{{{description}}}
9 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behaviour, in case users don't have core.autocrlf set. 2 | * text=lf 3 | * text eol=lf 4 | *.* eol=lf 5 | 6 | *.jpg binary 7 | *.gif binary 8 | *.png binary 9 | *.jpeg binary -------------------------------------------------------------------------------- /docs/examples.md: -------------------------------------------------------------------------------- 1 | ```js 2 | assemble: { 3 | options: { 4 | plugins: ['{%= name %}', 'other/plugins/*.js'], 5 | {%= shortname(name) %}: { 6 | dest: 'tmp/' 7 | } 8 | } 9 | } 10 | ``` -------------------------------------------------------------------------------- /test/actual/articles/arctic-ice-is-really-cold.html: -------------------------------------------------------------------------------- 1 | 2 |Suprising discovery! Contrary to popular belief, ice in the arctic tundra was found to be below freezing temperatures.
4 | -------------------------------------------------------------------------------- /test/fixtures/pages/articles/index.hbs: -------------------------------------------------------------------------------- 1 | --- 2 | title: Some Category 3 | description: Index page nested in a directory. 4 | slug: category-page 5 | date: 2013-10-02 6 | --- 7 |{{{description}}}
9 | -------------------------------------------------------------------------------- /test/fixtures/default.hbs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |{{{description}}}
11 | -------------------------------------------------------------------------------- /.verb.md: -------------------------------------------------------------------------------- 1 | # {%= name %} {%= badge("fury") %} 2 | 3 | > {%= description %} 4 | 5 | ## Getting Started 6 | {%= docs("quickstart") %} 7 | 8 | ## Options 9 | {%= docs("options") %} 10 | 11 | ## Other grunt-assemble plugins 12 | {%= related(verb.related.list, {remove: name}) %} 13 | 14 | ## Contributing 15 | {%= include("contributing") %} 16 | 17 | ## Authors 18 | {%= include("authors") %} 19 | 20 | ## License 21 | {%= copyright() %} 22 | {%= license() %} 23 | 24 | *** 25 | 26 | {%= include("footer") %} 27 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Jon Schlinkert 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Grunt Assemble Plugin: Contextual 3 | * https://github.com/assemble/grunt-assemble-contextual 4 | * 5 | * Copyright (c) 2014-2015 Jon Schlinkert, contributors. 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | var path = require('path'); 10 | var sort = require('sort-object'); 11 | 12 | /** 13 | * @param {Object} params 14 | * @param {Function} callback 15 | * @return {String} The permalink string 16 | */ 17 | module.exports = function(params, callback) { 18 | 19 | 'use strict'; 20 | 21 | var options = params.context; 22 | var grunt = params.grunt; 23 | 24 | var contextual = options.contextual || {}; 25 | var pages = options.pages; 26 | var page = options.page; 27 | 28 | var async = grunt.util.async; 29 | 30 | contextual.dest = contextual.dest || page.filePair.orig.dest + '/tmp'; 31 | 32 | async.forEachSeries(pages, function(file, next) { 33 | 34 | if (page.src !== file.src) {next(); return;} 35 | var outputDir = path.join(contextual.dest, path.dirname(file.src), file.basename); 36 | grunt.file.write(outputDir + '.json', JSON.stringify(sort(options), null, 2)); 37 | 38 | grunt.verbose.ok('Generating context for: '.yellow + file.dest); 39 | next(); 40 | }, function (err) { 41 | callback(); 42 | }); 43 | }; 44 | -------------------------------------------------------------------------------- /docs/quickstart.md: -------------------------------------------------------------------------------- 1 | In the command line, run: 2 | 3 | ```bash 4 | npm install {%= name %} --save 5 | ``` 6 | 7 | Next, to register the plugin with Assemble in your project's Gruntfile you can either specify the direct path to the plugin(s) (e.g. `./path/to/plugins/*.js`), or if installed via npm, make sure the plugin is in the `devDependencies` of your project.js package.json, and simply add the module's name to the `plugins` option: 8 | 9 | ```js 10 | module.exports = function(grunt) { 11 | 12 | // Project configuration. 13 | grunt.initConfig({ 14 | assemble: { 15 | options: { 16 | plugins: ['{%= name %}', 'other/plugins/*.js'], 17 | contextual: { 18 | dest: 'tmp/' 19 | } 20 | }, 21 | files: { 22 | 'dist/': ['templates/*.hbs'] 23 | } 24 | } 25 | }); 26 | grunt.loadNpmTasks('assemble'); 27 | grunt.registerTask('default', ['assemble']); 28 | }; 29 | ``` 30 | If everything was installed and configured correctly, after running `grunt assemble` you should see a JSON file for each page in the `dest` directory defined in the plugin's options. The basename of each page will be used as the name of each file. 31 | 32 | _This plugin will make the build run slower!_ To disable it simple remove it from the options or remove the `dest` property. 33 | 34 | 35 | Visit the [plugins docs](http://assemble.io/plugins/) for more info or for help getting started. 36 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /* 2 | * assemble-contrib-contextual 3 | * https://github.com/assemble/assemble-contrib-contextual 4 | * 5 | * Copyright (c) 2013 Jon Schlinkert, contributors 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = function(grunt) { 12 | 13 | // Project configuration. 14 | grunt.initConfig({ 15 | jshint: { 16 | options: { 17 | curly: true, 18 | eqeqeq: true, 19 | immed: true, 20 | latedef: true, 21 | newcap: true, 22 | noarg: true, 23 | sub: true, 24 | undef: true, 25 | boss: true, 26 | eqnull: true, 27 | node: true 28 | }, 29 | all: ['Gruntfile.js', 'index.js'] 30 | }, 31 | 32 | assemble: { 33 | options: { 34 | plugins: ['./index.js'] 35 | }, 36 | contextual: { 37 | options: { 38 | contextual: { 39 | dest: 'test/tmp' 40 | } 41 | }, 42 | files: [ 43 | { 44 | expand: true, 45 | cwd: 'test/fixtures/pages', 46 | src: ['**/*.hbs'], 47 | dest: 'test/actual' 48 | } 49 | ] 50 | } 51 | }, 52 | 53 | // Before generating new files, remove any files from previous build. 54 | clean: { 55 | actual: ['test/{actual,tmp}/**'], 56 | } 57 | }); 58 | 59 | // These plugins provide necessary tasks. 60 | grunt.loadNpmTasks('grunt-assemble'); 61 | grunt.loadNpmTasks('grunt-contrib-clean'); 62 | grunt.loadNpmTasks('grunt-contrib-jshint'); 63 | 64 | // By default, lint and generate readme. 65 | grunt.registerTask('default', ['jshint', 'clean', 'assemble']); 66 | }; 67 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grunt-assemble-contextual", 3 | "description": "Generates a JSON file with the context of each page. Basic plugin to help see what's happening in the build.", 4 | "version": "0.1.0", 5 | "homepage": "https://github.com/assemble/grunt-assemble-contextual", 6 | "author": { 7 | "name": "Jon Schlinkert", 8 | "url": "https://github.com/jonschlinkert" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git://github.com/assemble/grunt-assemble-contextual.git" 13 | }, 14 | "bugs": { 15 | "url": "git://github.com/assemble/grunt-assemble-contextual/issues" 16 | }, 17 | "licenses": [ 18 | { 19 | "type": "MIT", 20 | "url": "https://github.com/assemble/grunt-assemble-contextual/blob/master/LICENSE-MIT" 21 | } 22 | ], 23 | "main": "index.js", 24 | "engines": { 25 | "node": ">= 0.8.0" 26 | }, 27 | "dependencies": { 28 | "sort-object": "0.0.6", 29 | "lodash": "^2.4.1", 30 | "fs-utils": "^0.4.1" 31 | }, 32 | "devDependencies": { 33 | "grunt": "~0.4.4", 34 | "grunt-contrib-clean": "~0.5.0", 35 | "grunt-contrib-jshint": "~0.10.0", 36 | "grunt-assemble": "^0.4.0" 37 | }, 38 | "keywords": [ 39 | "assemble", 40 | "assembleplugin", 41 | "plugin" 42 | ], 43 | "verb": { 44 | "related": { 45 | "list": [ 46 | "grunt-assemble", 47 | "grunt-assemble-anchors", 48 | "grunt-assemble-contextual", 49 | "grunt-assemble-decompress", 50 | "grunt-assemble-download", 51 | "grunt-assemble-i18n", 52 | "grunt-assemble-lunr", 53 | "grunt-assemble-navigation", 54 | "grunt-assemble-permalinks", 55 | "grunt-assemble-sitemap", 56 | "grunt-assemble-toc", 57 | "grunt-assemble-wordcount" 58 | ] 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # grunt-assemble-contextual [](http://badge.fury.io/js/grunt-assemble-contextual) 2 | 3 | > Generates a JSON file with the context of each page. Basic plugin to help see what's happening in the build. 4 | 5 | ## Getting Started 6 | 7 | In the command line, run: 8 | 9 | ```bash 10 | npm install grunt-assemble-contextual --save 11 | ``` 12 | 13 | Next, to register the plugin with Assemble in your project's Gruntfile you can either specify the direct path to the plugin(s) (e.g. `./path/to/plugins/*.js`), or if installed via npm, make sure the plugin is in the `devDependencies` of your project.js package.json, and simply add the module's name to the `plugins` option: 14 | 15 | ```js 16 | module.exports = function(grunt) { 17 | 18 | // Project configuration. 19 | grunt.initConfig({ 20 | assemble: { 21 | options: { 22 | plugins: ['grunt-assemble-contextual', 'other/plugins/*.js'], 23 | contextual: { 24 | dest: 'tmp/' 25 | } 26 | }, 27 | files: { 28 | 'dist/': ['templates/*.hbs'] 29 | } 30 | } 31 | }); 32 | grunt.loadNpmTasks('assemble'); 33 | grunt.registerTask('default', ['assemble']); 34 | }; 35 | ``` 36 | 37 | If everything was installed and configured correctly, after running `grunt assemble` you should see a JSON file for each page in the `dest` directory defined in the plugin's options. The basename of each page will be used as the name of each file. 38 | 39 | _This plugin will make the build run slower!_ To disable it simple remove it from the options or remove the `dest` property. 40 | 41 | Visit the [plugins docs](http://assemble.io/plugins/) for more info or for help getting started. 42 | 43 | ## Options 44 | 45 | ## dest 46 | 47 | Type: `String` 48 | 49 | Default: `assemble.dest + /tmp` 50 | 51 | Destination of JSON context. 52 | 53 | ## Other grunt-assemble plugins 54 | * [grunt-assemble](https://www.npmjs.com/package/grunt-assemble): Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… [more](https://www.npmjs.com/package/grunt-assemble) | [homepage](http://assemble.io) 55 | * [grunt-assemble-anchors](https://www.npmjs.com/package/grunt-assemble-anchors): Assemble plugin for creating anchor tags from headings in generated html using Cheerio.js. | [homepage](https://github.com/assemble/grunt-assemble-anchors) 56 | * [grunt-assemble-decompress](https://www.npmjs.com/package/grunt-assemble-decompress): Assemble plugin for extracting zip, tar and tar.gz archives. | [homepage](https://github.com/assemble/grunt-assemble-decompress) 57 | * [grunt-assemble-download](https://www.npmjs.com/package/grunt-assemble-download): Assemble plugin for downloading files from GitHub. | [homepage](https://github.com/assemble/grunt-assemble-download) 58 | * [grunt-assemble-i18n](https://www.npmjs.com/package/grunt-assemble-i18n): Plugin for adding i18n support to Assemble projects. | [homepage](https://github.com/assemble/grunt-assemble-i18n) 59 | * [grunt-assemble-lunr](https://www.npmjs.com/package/grunt-assemble-lunr): Assemble plugin for adding search capabilities to your static site, with lunr.js. | [homepage](http://assemble.io) 60 | * [grunt-assemble-navigation](https://www.npmjs.com/package/grunt-assemble-navigation): Assemble navigation plugin. Automatically generate Bootstrap-style, multi-level side nav. See the sidenav on assemble.io for… [more](https://www.npmjs.com/package/grunt-assemble-navigation) | [homepage](https://github.com/assemble/grunt-assemble-navigation) 61 | * [grunt-assemble-permalinks](https://www.npmjs.com/package/grunt-assemble-permalinks): Permalinks plugin for Assemble, the static site generator for Grunt.js, Yeoman and Node.js. This plugin… [more](https://www.npmjs.com/package/grunt-assemble-permalinks) | [homepage](https://github.com/assemble/grunt-assemble-permalinks) 62 | * [grunt-assemble-sitemap](https://www.npmjs.com/package/grunt-assemble-sitemap): Sitemap plugin for Assemble | [homepage](http://assemble.io/plugins) 63 | * [grunt-assemble-toc](https://www.npmjs.com/package/grunt-assemble-toc): Assemble middleware for adding a Table of Contents (TOC) to any HTML page. | [homepage](http://assemble.io) 64 | * [grunt-assemble-wordcount](https://www.npmjs.com/package/grunt-assemble-wordcount): Assemble plugin for displaying wordcount and average reading time to blog posts or pages. | [homepage](https://github.com/assemble/grunt-assemble-wordcount) 65 | 66 | ## Contributing 67 | 68 | Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](git://github.com/assemble/grunt-assemble-contextual/issues/new). 69 | 70 | ## Authors 71 | 72 | **Jon Schlinkert** 73 | 74 | + [github/jonschlinkert](https://github.com/jonschlinkert) 75 | + [twitter/jonschlinkert](http://twitter.com/jonschlinkert) 76 | 77 | ## License 78 | 79 | Copyright © 2015 Jon Schlinkert 80 | Released under the MIT license. 81 | 82 | *** 83 | 84 | _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 25, 2015._ --------------------------------------------------------------------------------