grunt-pages
Advanced tools
Comparing version
{ | ||
"name": "grunt-pages", | ||
"version": "0.10.0", | ||
"version": "0.10.1", | ||
"description": "Grunt task to create pages using markdown and templates", | ||
@@ -13,3 +13,3 @@ "main": "Gruntfile.js", | ||
"rss": "~0.2.0", | ||
"lodash": "~2.2.0", | ||
"lodash": "~2.4.1", | ||
"node-fs": "~0.1.7" | ||
@@ -16,0 +16,0 @@ }, |
@@ -95,6 +95,25 @@ # grunt-pages | ||
#### url | ||
Type: `String` | ||
Type: `String || Function` | ||
The URL of each post. The URL string takes variables as parameters using the `:variable` syntax. Variables specified in the URL are required in each post's metadata. URLs ending with a trailing `/` will generate posts as index.html files inside of the URL's folder. Parsed posts are cached in the `.grunt/grunt-pages` folder to improve build time. | ||
The URL format of each post. When specified as a string, the `url` takes variables as parameters using the `:variable` syntax. Variables specified in the `url` are required in each post's metadata. URLs with a trailing `/` will generate posts as index.html files inside of the URL's folder. | ||
You can also specify the `url` as a function which receives a post's metadata and grunt options object and returns the post's url. Note that the post metadata also includes the `sourcePath` of the post and `lastModified` time. This is used to maintain legacy post urls when migrating from another static site tool and to account for post titles that have all special characters(foreign languages). | ||
Here is an example config which demonstrates how to implement the `url` as a function: | ||
```js | ||
pages: { | ||
customURL: { | ||
src: 'posts', | ||
dest: 'dist', | ||
url: function (post, options) { | ||
// use post source path and apply default post url formatting | ||
return options.formatPostUrl(post.sourcePath.replace('.md', '/')); | ||
} | ||
} | ||
} | ||
``` | ||
Parsed posts are cached in the `.grunt/grunt-pages` folder based on the `lastModified` time to improve the task run time. | ||
### Options | ||
@@ -360,2 +379,9 @@ | ||
**0.10.0** - Added [`options.rss.numPosts`](#rssnumposts) option to determine the number of posts included in the RSS feed, defaulting to 10. Header links now use the same URL formatting function as post URLs. | ||
**Breaking changes:** | ||
- The generated RSS feed now uses the first 10 posts(after sorting) instead of all of them to prevent a max file size error in RSS readers. | ||
- Header links now use the same URL formatting function as post URLs. | ||
**0.9.1** - Fixed bug where the `options.pagination.listPage` wasn't properly ignored for certain filenames. | ||
@@ -362,0 +388,0 @@ |
@@ -406,2 +406,6 @@ /* | ||
if (typeof _this.data.url === 'function') { | ||
return _this.data.url(post, options); | ||
} | ||
var url = _this.data.url; | ||
@@ -408,0 +412,0 @@ |
49007
2.88%664
0.45%467
5.9%- Removed
Updated