1 Star 0 Fork 0

白一梓 / grunt-pages

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
package.json 20.43 KB
一键复制 编辑 原始数据 按行查看 历史
{
"name": "grunt-pages",
"version": "0.11.0",
"description": "Grunt task to create pages using markdown and templates",
"main": "Gruntfile.js",
"dependencies": {
"jade": "~0.35.0",
"ejs": "~0.8.4",
"colors": "~0.6.0-1",
"pygmentize-bundled": "~2.1.0",
"marked": "git://github.com/ChrisWren/marked.git#listener",
"rss": "~0.2.0",
"lodash": "~2.4.1",
"sitemap":"~0.8.1",
"node-fs": "~0.1.7"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-simple-mocha": "~0.4.0",
"grunt-contrib-jshint": "~0.4.3",
"grunt-contrib-connect": "~0.3.0",
"grunt-contrib-watch": "~0.4.4",
"grunt-concurrent": "~0.3.1",
"matchdep": "~0.1.2",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-clean": "~0.4.1",
"should": "~1.2.2",
"sinon": "~1.7.3",
"grunt-release": "~0.4.0",
"grunt-mdlint": "0.0.0",
"grunt-node-inspector": "~0.1.0",
"grunt-shell": "~0.4.0"
},
"peerDependencies": {
"grunt": "~0.4.1"
},
"scripts": {
"test": "grunt test"
},
"repository": {
"type": "git",
"url": "https://github.com/CabinJS/grunt-pages.git"
},
"keywords": [
"grunt",
"gruntplugin",
"static site generator",
"workflow",
"jekyll",
"blog"
],
"contributors": [
{
"name": "Larry Davis",
"email": "lazd@lazd.net"
},
{
"name": "Colin Wren",
"email": "colin@cawren.com"
},
{
"name": "Justin Helmer",
"email": "jhelmer25@gmail.com"
}
],
"author": {
"name": "ChrisWren"
},
"license": "MIT",
"readme": "# grunt-pages\n> Grunt task to create pages using markdown and templates\n\n[![NPM version](https://badge.fury.io/js/grunt-pages.png)](http://badge.fury.io/js/grunt-pages)\n[![Dependency Status](https://gemnasium.com/CabinJS/grunt-pages.png)](https://gemnasium.com/CabinJS/grunt-pages)\n[![Travis Status](https://travis-ci.org/CabinJS/grunt-pages.png?branch=master)](https://travis-ci.org/CabinJS/grunt-pages)\n\n## Prerequisites\nThis Grunt task uses [pygments](http://pygments.org/) which requires [Python](http://www.python.org/getit/) to be installed.\n\n## Getting Started\nIf you haven't used Grunt before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, install this plugin with this command:\n```shell\nnpm install grunt-pages --save-dev\n```\n\nThen add this line to your project's `Gruntfile.js` Gruntfile:\n\n```javascript\ngrunt.loadNpmTasks('grunt-pages');\n```\n\n## Documentation\n\n### Sample config\nHere is a sample config to create a blog using grunt-pages:\n```js\npages: {\n options: {\n pageSrc: 'src/pages'\n },\n posts: {\n src: 'posts',\n dest: 'dev',\n layout: 'src/layouts/post.jade',\n url: 'posts/:title/'\n }\n}\n```\n\n### Authoring posts\n\n#### Post Format\nPosts are written in markdown and include a metadata section at the top to provide information about the post. The metadata format is a JavaScript Object, and here is an example:\n\n```js\n{\n title: \"Art Ballin': Explorations in New-Weird-American Expressionism\",\n date: \"2013-2-22\",\n author: \"Highroller, Jody\"\n}\n```\n\nThe only property that is not interpreted literally is the `date`. If it is specified, it is used as a `dateString` when constructing a [Date object](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date) in JavaScript, and must be in a [parseable format](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/parse). If unspecified, the post's date will be the result of constructing a Date object using the post's last modified time.\n\n#### Syntax Highlighting\nFor adding code to your posts, grunt-pages has [GitHub flavoured markdown](https://help.github.com/articles/github-flavored-markdown) and syntax highlighting using [pygments](http://pygments.org/).\n\n#### Draft Posts\nTo make a post a draft when deploying your site, simply prefix its filename with a `_`. These posts will not be rendered or available in list pages.\n\n### Styling Headers\n\nBy default, grunt-pages generates header tags that include nested anchor tags with span's to allow for header section linking. Here is an example of the HTML that the above header would generate:\n```html\n<h3>\n <a name=\"styling-headers\" class=\"anchor\" href=\"#styling-headers\">\n <span class=\"header-link\"></span>\n </a>\n \"Styling Headers\"\n</h3>\n```\nThe generated markup follows the same format as GitHub README's and it is recommended to reference [Cabin theme](http://www.cabinjs.com/#themes)'s styling when trying to create header linking. \n\n### Required properties\n\n#### src\nType: `String`\n\nThe directory where the source posts are located.\n\n#### dest\nType: `String`\n\nThe directory where pages are generated.\n\n#### layout\nType: `String`\n\nThe [jade](https://github.com/visionmedia/jade) or [EJS](https://github.com/visionmedia/ejs) layout template used for each post. The post metadata will be stored in a `post` object to be rendered in the layout template. Posts also have access to other posts via the `posts` array, and know about their `currentIndex` within the array so that they can optionally create navigation to nearby posts. [Here](https://github.com/CabinJS/grunt-pages/blob/master/test/fixtures/integration/input/target2/layouts/post.jade) is an example post layout template.\n\n**Note: you can run grunt-pages with the `--debug` flag set to see all the data passed to templates for rendering**.\n\n#### url\nType: `String || Function`\n\nThe 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.\n\nYou 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).\n\nHere is an example config which demonstrates how to implement the `url` as a function:\n\n```js\npages: {\n customURL: {\n src: 'posts',\n dest: 'dist',\n url: function (post, options) {\n // use post source path and apply default post url formatting\n return options.formatPostUrl(post.sourcePath.replace('.md', '/'));\n }\n }\n}\n```\n\nParsed posts are cached in the `.grunt/grunt-pages` folder based on the `lastModified` time to improve the task run time.\n\n### Options\n\n#### pageSrc\nType: `String`\n\nThe folder where the ejs or jade source pages of your website are located. These pages have access to each post's `content` and metadata properties via a `posts` array. Additionally, pages have access to their own filename(without extension) via the `currentPage` variable to optionally display it differently when linking to pages. All of the files in this folder are generated in the `dest` folder maintaining the same relative path from `options.pageSrc`.\n\n#### data\nType: `Object || String`\n\nA JavaScript object or the location of a JSON file which is passed as data to templates. This option is primarily used to specify config that is shared across all pages. It is available in page and post templates via the `data` object.\n\n#### sortFunction\nType: `Function`\n\nDefault: Sort by `date` descending\n\n```js\nfunction (a, b) {\n return b.date - a.date;\n}\n```\n\nA compare function used by [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) to sort posts.\n\n#### formatPostUrl\nType: `Function`\n\nDefault:\n```js\nfunction (url) {\n return url\n .toLowerCase() // change everything to lowercase\n .replace(/^\\s+|\\s+$/g, '') // trim leading and trailing spaces\n .replace(/[_|\\s|\\.]+/g, '-') // change all spaces, periods and underscores to a hyphen\n .replace(/[^a-z\\u0400-\\u04FF0-9-]+/g, '') // remove all non-cyrillic, non-numeric characters except the hyphen\n .replace(/[-]+/g, '-') // replace multiple instances of the hyphen with a single instance\n .replace(/^-+|-+$/g, ''); // trim leading and trailing hyphens\n}\n```\n\nA function that takes a `url` as a parameter and returns a formatted URL string. This is primarily used to remove special characters and replace whitespace.\n\n#### rss\nType: `Object`\n\nAn object containing config for RSS feed generation.\n\nAll [options accepted by dylang/node-rss](https://github.com/dylang/node-rss#feed-options) are supported, with notable options listed below.\n\nHere is a sample config to create a blog with an RSS feed using grunt-pages:\n```js\npages: {\n options: {\n pageSrc: 'src/pages',\n rss: {\n author: 'Chris Wren',\n title: 'Chris Wren\\'s Blog',\n description: 'A blog about code.',\n url: 'http://chrisawren.com'\n }\n },\n posts: {\n src: 'posts',\n dest: 'dev',\n layout: 'src/layouts/post.jade',\n url: 'posts/:title/'\n }\n}\n```\n\n##### rss.url\nType: `String`\n\nThe URL of your site.\n\n##### rss.author\nType: `String`\n\nThe feed owner. Also used as `managingEditor` and `webMaster` if those options are not specified.\n\n##### rss.title\nType: `String`\n\nThe title of the feed.\n\n##### rss.numPosts\nType: `Number` Default: `10`\n\nNumber of posts to output in the RSS feed. This is used to avoid hitting a max file size limit.\n\n##### rss.description\nType: `String`\n\nOptional. Short description of the feed.\n\n##### rss.path\nType: `String`\n\nOptional. The path of the file to store the RSS XML in. This is specific to grunt-pages and is not part of dylang/node-rss.\n\n#### pagination\nType: `Object || Array`\n\nObject or an array of objects containing config for pagination. This option generates paginated list pages which each contain a specified group of posts.\n\n### Config using the default pagination scheme\n\n```js\npages: {\n options: {\n pagination: {\n postsPerPage: 3,\n listPage: 'src/layouts/listPage.jade'\n }\n },\n posts: {\n src: 'posts',\n dest: 'dev',\n layout: 'src/layouts/post.jade',\n url: 'posts/:title/'\n }\n}\n```\n\nThis config will generate paginated list pages by grouping the specified number of posts per page and using the default url scheme specified in the [pagination.url](#paginationurl) parameter.\n\n##### pagination.postsPerPage\nType: `Number`\n\nThe number of posts each list page will contain.\n\n##### pagination.listPage\nType: `String`\n\nThe location of the layout template which is used for each list page. This page will not be rendered as a regular page if `options.pageSrc` is specified. Instead it will be rendered as the root paginated list page with the first post group instead of all the posts. [Here](https://github.com/CabinJS/grunt-pages/blob/master/test/fixtures/integration/input/target2/pages/blog/index.jade) is a sample `options.pagination.listPage` template. This template has access to the following variables:\n\n###### posts\nType: `Array` of `Object`s\n\nAn array of post objects assigned to this page which each contain the post `content` and other metadata properties of the post.\n\n###### pages\nType: `Array` of `Object`s\n\nAn array of page objects which each contain a `url` and `id` property.\n\n###### currentIndex\nType: `Number`\n\nA reference to the index of the list page currently being rendered. This can be used to display the current page differently than the rest of the pages in a list, or to display links to the surrounding pages based on their position relative to the `currentIndex`.\n\n##### pagination.url\nType: `String` Default: `pages/:id/`\n\nThe location of the generated list pages relative to the `options.pagination.listPage`. You can override this property to have a custom url scheme for list pages. You **must** have a `:id` variable in your url scheme which will be replaced by the page's id.\n\n### Config using a custom pagination scheme\n\nTo paginate in a custom manor, you can use the following parameter:\n\n##### pagination.getPostGroups\nType: `Function`\n\nDefault: `Group by options.pagination.postsPerPage`\n\n```js\nfunction (postCollection, pagination) {\nvar postsPerPage = pagination.postsPerPage;\n var postGroups = [];\n var postGroup;\n var i = 0;\n\n while ((postGroup = postCollection.slice(i * postsPerPage, (i + 1) * postsPerPage)).length) {\n postGroups.push({\n posts: postGroup,\n id: i\n });\n i++;\n }\n return postGroups;\n}\n```\n\nThis function returns an array of post groups to be rendered as list pages. It takes the `posts` array and `options.pagination` config object as parameters and is expected to return an array of postGroup objects which each contain the `id` of the group(to be used in the url) and the array of `posts` in the following format:\n\n```js\n[{\n id: 'javascript',\n posts: [{\n title: 'Front end web development',\n tags: ['javascript', 'css'],\n content: '...'\n }, {\n title: 'Backbone.js',\n tags: ['javascript'],\n content: '...'\n }]\n}, {\n id: 'css',\n posts: [{\n title: 'Style and Sass',\n tags: ['css'],\n content: '...'\n },{\n title: 'Front end web development',\n tags: ['javascript', 'css'],\n content: '...'\n }]\n}];\n```\n\nHere is a sample pagination config which paginates using the `tags` property of each post:\n\n```js\npages: {\n options: {\n pagination: {\n listPage: 'src/layouts/tagListPage.jade',\n getPostGroups: function (posts) {\n var postGroups = {};\n\n posts.forEach(function (post) {\n post.tags.forEach(function (tag) {\n tag = tag.toLowerCase();\n if (postGroups[tag]) {\n postGroups[tag].posts.push(post);\n } else {\n postGroups[tag] = {\n posts: [post]\n };\n }\n });\n });\n\n return grunt.util._.map(postGroups, function (postGroup, id) {\n return {\n id: id,\n posts: postGroup.posts\n };\n });\n }\n }\n },\n posts: {\n src: 'src/posts',\n dest: 'dev',\n layout: 'src/layouts/post.jade',\n url: 'posts/:title'\n }\n}\n```\n\n#### templateEngine\nType: `String`\n\nThe file extension of the template engine to be used. This option filters template files in the `options.pageSrc` folder when developing a grunt-pages configuration for multiple template engines.\n\n# Changelog\n\n**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.\n\n**Breaking changes:**\n\n- 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.\n- Header links now use the same URL formatting function as post URLs.\n\n**0.9.1** - Fixed bug where the `options.pagination.listPage` wasn't properly ignored for certain filenames.\n\n**0.9.0** - Posts now have access to their `currentIndex` within the `posts` array for navigating between nearby posts. Parsed posts are now cached in the `.grunt/grunt-pages` folder instead of `node_modules/grunt-pages` to provide more visibility and follow Grunt conventions. Header anchor tags now have correct attribute spacing thanks to [@gmarty](https://github.com/gmarty). Improved template debugging by printing data passed to template when an error is encountered. Reduced `--debug` output for post content to allow for easier debugging. \n\n**Breaking changes:**\n\n- Parsed posts are now cached in the `.grunt/grunt-pages` folder instead of `node_modules/grunt-pages`.\n- Jade template output is no longer pretty printed unless `--debug` is specified.\n- Posts no longer have access to the post `dest` property which was mistakenly leaked to the template.\n\n**0.8.3** - Posts without the `date` specified now default to using the post's last modified time as the date thanks to [@danburzo](https://github.com/danburzo). Fixed bug where draft posts in nested folders weren't ignored properly.\n\n**0.8.2** - Temporarily reverted bug fix as caching issues resulted from code change.\n\n**0.8.1** - Fixed bug where draft posts in nested folders weren't ignored properly. \n\n**0.8.0** - Header tags are now rendered with a child span and anchor tag for linking into post sections. Removed support for YAML metadata. Added more robust metadata extraction for JavaScript object metadata. Added `--debug` flag to debug template data rendering. Standardized error logging to use the same format. \n\n**Breaking changes:**\n\n- Header tags are now rendered with a nested span and anchor tag for linking into post sections instead of being wrapped with anchor tags.\n- No more YAML metadata in posts.\n\n**0.7.2** - Added support for Python 3 due to updating of [node-pygmentize-bundled](https://github.com/rvagg/node-pygmentize-bundled/) dependency. \n\n**0.7.1** - Wrong node_modules were pushed to npm. Pushed correct dependencies listed in package.json to fix bug. \n\n**0.7.0** - See breaking changes below. \n\n**Breaking changes:**\n\n- Pagination urls now have trailing `index.html` sections removed by default. The pagination url for a root list page is now `''` instead of `/` to allow for [base](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) tags. Updated default [pagination.url](#paginationurl) to `pages/:id/` following new scheme that doesn't use `index.html`'s.\n\n**0.6.1** - Removed accidental logging pushed to npm.\n\n**0.6.0** - Updated pagination urls to not have a leading `/`.\n\n**Breaking changes:**\n\n- Pagination urls will no longer have a leading `/` by default. This is a bug fix and the implementation now matches what is documented in the [pagination.url](#paginationurl) API.\n\n**0.5.0** - Updated default post url regex to capture more cases thanks to [@justinhelmer](https://github.com/justinhelmer). Fixed bugs regarding normalizing the post dest and ignoring draft posts thanks to [@justinhelmer](https://github.com/justinhelmer).\n\n**Breaking changes:**\n\n- Post urls will potentially be altered because of the new regex. To update, you will have to provide redirects to altered post urls if you need to maintain them i.e. social media share buttons.\n\n**0.4.1** - `.html` excluded from post url :variable replacement.\n\n**0.4.0** - Altered post url to *not* automatically add `.html` to urls.\n\n**Breaking changes:**\n\n- Post urls will now require .html to be listed explicitly to be in the url. The recommended convention is to put each post in its own folder, like `posts/:title/` so that a post with the title `hello` would be generated at posts/hello/index.html.\n\n**0.3.3** - Added lodash as a hard dependency.\n\n**0.3.2** - Added post caching for unmodified posts to speed up task.\n\n**0.3.1** - Added [rss option](#rss) to generates feeds thanks to [@lazd](https://github.com/lazd).\n\n**0.3.0** - Altered pagination API to allow for custom pagination schemes.\n\n**Breaking changes:**\n\n- Paginated pages no longer have a `currentPage` as a property of the current page in the `pages` array, rather it is exposed as a global variable called `currentIndex` for easier accessibility.\n\n**0.2.5** - Fixed metadata parsing bug, added `formatPostUrl` option & added `pagination.url` option.\n\n**0.2.4** - Added `sortFunction` option & allowed for `data` option to take an object as a parameter.\n\n**0.2.3** - Ignored dotfiles, added error reporting for incorrect data JSON files, and added new header anchor link format.\n\n**0.2.2** - Used forked version of marked to enable header anchor links.\n\n**0.2.1** - Added support for `_` prefixed draft posts and pages now receive their filename as a `currentPage` variable.\n\n**0.2.0** - Fixed `templateEngine` bug, changed `pagination` and `data` api.\n\n**0.1.0** - Added `data` option, added `templateEngine` option, added `pagination` option, and changed post data format to be a `post` object rather than global variables for each post property.\n\n**0.0.0** - Initial release.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/CabinJS/grunt-pages/issues"
},
"_id": "grunt-pages@0.10.1",
"dist": {
"shasum": "ae2dd9a7d7a6b2d23e214823196dc4a6710698bb"
},
"_from": "grunt-pages@~0.10.0",
"_resolved": "https://registry.npmjs.org/grunt-pages/-/grunt-pages-0.10.1.tgz"
}
JavaScript
1
https://gitee.com/yunnysunny/grunt-pages.git
git@gitee.com:yunnysunny/grunt-pages.git
yunnysunny
grunt-pages
grunt-pages
master

搜索帮助