{ "name": "docpad-plugin-paged", "version": "2.1.4", "description": "DocPad plugin which adds the ability to render a document out to multiple pages", "homepage": "https://github.com/docpad/docpad-plugin-paged", "keywords": [ "docpad", "docpad-plugin", "paging", "pagination", "paged" ], "author": { "name": "Ben Delarre", "email": "ben@delarre.net", "url": "http://www.delarre.net" }, "maintainers": [ { "name": "Ben Delarre", "email": "ben@delarre.net", "url": "https://github.com/benjamind" }, { "name": "Benjamin Lupton", "email": "b@lupton.cc", "url": "https://github.com/balupton" } ], "contributors": [ { "name": "Ben Delarre", "email": "ben@delarre.net", "url": "https://github.com/benjamind" }, { "name": "Benjamin Lupton", "email": "b@lupton.cc", "url": "https://github.com/balupton" } ], "bugs": { "url": "https://github.com/docpad/docpad-plugin-paged/issues" }, "repository": { "type": "git", "url": "http://github.com/docpad/docpad-plugin-paged.git" }, "engines": { "node": ">=0.4", "docpad": "6.x" }, "dependencies": { "taskgroup": "~3.1.1" }, "devDependencies": { "coffee-script": "~1.6.2" }, "main": "./out/paged.plugin.js", "scripts": { "test": "node ./out/paged.test.js" }, "readme": "# Paged Plugin for DocPad\r\nThis plugin provides [DocPad](https://docpad.org) with Paging. Documents can declare a number of pages that should be rendered for the document, or a collection over which the document should be rendered repeatedly.\r\n\r\n\r\n## Install\r\n\r\n```\r\nnpm install --save docpad-plugin-paged\r\n```\r\n\r\n\r\n## Usage\r\n\r\n### Setup\r\n\r\nTo use, simply add `isPaged: true` to the meta data for any document that you want to be rendered with paging. You can then use `pageSize` or `pagedCollection` to instruct the plugin how many pages to generate from this document.\r\n\r\nIn documents that have paging enabled we can use the `@document.page` object to retrieve information about the current and total pages. The `page` object is of the form:\r\n\r\n```\r\n{\r\n\tnumber: 0,\t\t// current page number\r\n\tcount: 10,\t\t// total number of pages\r\n\tsize: 5,\t\t// expected number of documents per page\r\n\tstartIdx: 0,\t// document index for first document in this page\r\n\tendIdx: 5\t\t// document index for last document in this page\r\n}\r\n```\r\n\r\n### Paging Collections\r\n\r\nYou can generate pages over a collection by using the `pagedCollection` meta property. Simply specify the name of a collection and the plugin will use this collections length to calculate how many pages to generate from this document. So if your `posts` collection contains 5 documents, and you have specified a `pageSize` of 3 then the paging plugin will render 2 pages, the first with documents 0-2 and the second with the remaining 2 documents.\r\n\r\n### Example\r\n\r\nFor instance we could create the file `src/documents/index.html.eco` which contains something similar to the followìng:\r\n\r\n```\r\n---\r\ntitle: 'Home'\r\nlayout: 'default'\r\ntags: ['page']\r\nisPaged: true\r\npageOrder: 0\r\npagedCollection: 'posts'\r\npageSize: 3\r\n---\r\n<% posts = @getCollection('posts') %>\r\n<% for i in [@document.page.startIdx...@document.page.endIdx]: %>\r\n\t<% document = posts.at(i).toJSON() %>\r\n\t
\r\n\t\t

<%= document.title %>

\r\n\t\t
<%= document.date.toLocaleDateString() %>
\r\n\t\t
\r\n\t\t\t<%- document.contentRenderedWithoutLayouts %>\r\n\t\t
\r\n\t
\r\n<% end %>\r\n\r\n
\r\n\t\r\n
\r\n```\r\n\r\nThis will render out documents from the `posts` collection in groups of 3. The first 3 documents in the collection will be rendered into a file called `index.html` as normal, then the remaining documents from the collection will be rendered into subsequent files `index.1.html`, `index.2.html`, `index.3.html` etc.\r\n\r\nIn this example we can also see the use of the new helper methods `hasPrevPage()`, `hasNextPage()`, `getPrevPage()`, `getNextPage()` and `getPagedUrl(n)`. Hopefully these methods are pretty self explanatory, with the get methods returning the urls for the relevant pages. In this example we use these methods to create the standard Twitter Bootstrap pagination HTML.\r\n\r\n## History\r\nYou can discover the history inside the `History.md` file\r\n\r\n## License\r\nLicensed under the incredibly [permissive](http://en.wikipedia.org/wiki/Permissive_free_software_licence) [MIT License](http://creativecommons.org/licenses/MIT/)\r\n
Copyright © 2012 [Ben Delarre](http://delarre.net)", "readmeFilename": "README.md", "_id": "docpad-plugin-paged@2.1.4", "dist": { "shasum": "92275d0282e35a1ca2199171ff416cef28b0f05b" }, "_from": "docpad-plugin-paged@~2.1.4", "_resolved": "https://registry.npmjs.org/docpad-plugin-paged/-/docpad-plugin-paged-2.1.4.tgz" }