Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-assemble-sitemap

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-assemble-sitemap - npm Package Compare versions

Comparing version 0.2.6 to 0.2.7

68

index.js

@@ -8,17 +8,16 @@ /*!

var xml = require('jstoxml');
var async = require('async');
var _ = require('lodash');
var union = require('arr-union');
var xml = require('jstoxml');
var path = require('path');
module.exports = function (params, callback) {
var assemble = params.assemble;
var grunt = params.grunt;
var pages = assemble.options.pages;
var options = assemble.options.sitemap || {};
var sitemap = [];
var robots = [];
module.exports = function(params, cb) {
var assemble = params.assemble;
var grunt = params.grunt;
var pages = assemble.options.pages;
var len = pages.length;
var options = assemble.options.sitemap || {};
var sitemap = [];
var robots = [];
var exclusion = ['404'];
var pkg = grunt.file.readJSON('package.json');
var pkg = grunt.file.readJSON('package.json');

@@ -30,6 +29,11 @@ options.homepage = options.homepage || pkg.homepage;

options.dest = options.dest || path.dirname(pages[0].dest);
options.pretty = options.pretty || false;
options.basename = options.basename || 'sitemap.xml';
if (typeof options.exclude !== 'undefined') {
exclusion = union([], exclusion, options.exclude || []);
}
// Only write if it actually changed.
var write = function (file, content) {
var write = function(file, content) {
var msg;

@@ -48,7 +52,12 @@ var old = grunt.file.exists(file) ? grunt.file.read(file) : '';

// Return the relative destination if the option is enabled
var getExternalFilePath = function (relativedest, file) {
if(relativedest === true) {
var getExternalFilePath = function(relativedest, file) {
var finalFilename = file.dest;
if (relativedest === true) {
relativedest = options.dest;
}
return (relativedest ? file.dest.replace(relativedest + "/", "") : file.dest );
if (options.pretty === true) {
finalFilename = file.dest.replace('index.html', '');
}
return (relativedest ? finalFilename.replace(relativedest + '/', '') : finalFilename);
};

@@ -59,8 +68,4 @@

async.forEach(pages, function (file, next) {
if (!_.isUndefined(options.exclude)) {
exclusion = _.union([], exclusion, options.exclude || []);
}
for (var i = 0; i < len; i++) {
var file = pages[i];
var date = file.data.updated || file.data.date || new Date();

@@ -73,3 +78,3 @@ var changefreq = file.data.changefreq || options.changefreq;

robots.push('Disallow: /' + getExternalFilePath(relativedest, file));
return;
continue;
}

@@ -85,6 +90,4 @@

});
}
next();
}, callback());
var result = xml.toXML({

@@ -98,15 +101,13 @@ _name: 'urlset',

var sitemapDest = options.dest + '/sitemap.xml';
var sitemapDest = options.dest + '/' + options.basename;
write(sitemapDest, result);
if (options.robot) {
var sitemapFile = {dest: url+"/"+sitemapDest};
var robot = "User-agent: *\n";
var sitemapFile = {dest: url + '/' + sitemapDest};
var robot = 'User-agent: *\n';
robot += robots.join('\n') + '\n\n';
robot += "Sitemap: " + getExternalFilePath(relativedest, sitemapFile);
robot += "\n";
robot += 'Sitemap: ' + getExternalFilePath(relativedest, sitemapFile);
robot += '\n';

@@ -117,2 +118,3 @@ var robotpDest = options.dest + '/robots.txt';

cb();
};

@@ -119,0 +121,0 @@

{
"name": "grunt-assemble-sitemap",
"description": "Sitemap plugin for Assemble",
"version": "0.2.6",
"version": "0.2.7",
"homepage": "http://assemble.io/plugins",
"author": "Hariadi Hinta (https://github.com/hariadi)",
"repository": {
"type": "git",
"url": "https://github.com/assemble/grunt-assemble-sitemap.git"
},
"contributors": [
"Brian Woodward <brian.woodward@gmail.com> (https://twitter.com/doowb)",
"Chris Smith <quartzmo@gmail.com> (www.angularjsbook.com)",
"Daniel Rauber (https://danielrauber.de)",
"Hariadi Hinta (http://www.hariadi.org)",
"Heinrich Goebl <hgoebl@goebl.com> (http://www.goebl.com)",
"Jarrod Connolly (https://github.com/jarrodconnolly)",
"Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)",
"Marie Hogebrandt <webmistress@melindrea.net> (http://mariehogebrandt.se)",
"Oleg Smetanin (https://oleg.smetan.in)"
],
"repository": "assemble/grunt-assemble-sitemap",
"bugs": {
"url": "https://github.com/assemble/grunt-assemble-sitemap/issues"
},
"license": {
"type": "MIT",
"url": "https://github.com/assemble/grunt-assemble-sitemap/blob/master/LICENSE"
},
"license": "MIT",
"files": [

@@ -23,17 +28,22 @@ "index.js"

"engines": {
"node": ">= 0.8.0"
"node": ">= 0.10.0"
},
"scripts": {
"test": "grunt"
"test": "grunt test"
},
"dependencies": {
"async": "^0.8.0",
"jstoxml": "^0.2.2",
"lodash": "^2.4.1"
"arr-union": "^3.1.0",
"jstoxml": "^0.2.2"
},
"devDependencies": {
"dateformat": "^2.0.0",
"fs-exists-sync": "^0.1.0",
"grunt": "^0.4.5",
"grunt-assemble": "~0.4.0",
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.5.0",
"grunt-contrib-jshint": "^0.10.0"
"gruntify-eslint": "^3.1.0",
"gulp-format-md": "^0.1.11",
"is-valid-app": "^0.2.1",
"js-yaml": "^3.8.2",
"verb-generate-readme": "^0.4.3"
},

@@ -60,10 +70,23 @@ "keywords": [

"grunt-assemble-download",
"grunt-assemble-i18n",
"grunt-assemble-lunr",
"grunt-assemble-navigation",
"grunt-assemble-permalinks",
"grunt-assemble-i18n",
"grunt-assemble-navigation",
"grunt-assemble-sitemap",
"grunt-assemble-toc",
"grunt-assemble-wordcount"
]
},
"toc": true,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"lint": {
"reflinks": true
}
}
}

@@ -1,2 +0,2 @@

# grunt-assemble-sitemap [![NPM version](https://badge.fury.io/js/grunt-assemble-sitemap.svg)](http://badge.fury.io/js/grunt-assemble-sitemap) [![Build Status](https://travis-ci.org/assemble/grunt-assemble-sitemap.svg)](https://travis-ci.org/assemble/grunt-assemble-sitemap)
# grunt-assemble-sitemap [![NPM version](https://img.shields.io/npm/v/grunt-assemble-sitemap.svg?style=flat)](https://www.npmjs.com/package/grunt-assemble-sitemap) [![NPM monthly downloads](https://img.shields.io/npm/dm/grunt-assemble-sitemap.svg?style=flat)](https://npmjs.org/package/grunt-assemble-sitemap) [![NPM total downloads](https://img.shields.io/npm/dt/grunt-assemble-sitemap.svg?style=flat)](https://npmjs.org/package/grunt-assemble-sitemap) [![Linux Build Status](https://img.shields.io/travis/assemble/grunt-assemble-sitemap.svg?style=flat&label=Travis)](https://travis-ci.org/assemble/grunt-assemble-sitemap) [![Windows Build Status](https://img.shields.io/appveyor/ci/assemble/grunt-assemble-sitemap.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/assemble/grunt-assemble-sitemap)

@@ -7,22 +7,20 @@ > Sitemap plugin for Assemble

<!-- toc -->
- [Install](#install)
- [Usage](#usage)
- [Options](#options)
- [Examples](#examples)
- [About](#about)
* [Options](#options)
* [Usage Examples](#usage-examples)
* [Contributing](#contributing)
* [Other grunt-assemble plugins](#other-grunt-assemble-plugins)
* [Author](#author)
* [License](#license)
* [Changes](#changes)
## Install
_(Table of contents generated by [verb])_
Install with [npm](https://www.npmjs.com/):
<!-- tocstop -->
```sh
$ npm i grunt-assemble-sitemap --save
$ npm install --save grunt-assemble-sitemap
```
Next, register the plugin with Assemble:
## Usage
Register the plugin in your assemble config:
```js

@@ -44,3 +42,3 @@ assemble: {

Type: `String`
Type: `String`

@@ -53,3 +51,3 @@ Default: `undefined`

Type: `String`
Type: `String`

@@ -62,3 +60,3 @@ Default: `homepage` (from package.json)

Type: `String`
Type: `String`

@@ -79,3 +77,3 @@ Default: `weekly`

Type: `Float`
Type: `Float`

@@ -86,5 +84,5 @@ Default: `0.5`

## exclusions
## exclude
Type: `Array`
Type: `Array`

@@ -98,3 +96,3 @@ Default: `['404']`

sitemap: {
exclusions: ["foo", "bar"],
exclude: ["foo", "bar"],
},

@@ -109,3 +107,3 @@ files: {

Type: `String` / `Boolean`
Type: `String` / `Boolean`

@@ -116,5 +114,12 @@ Default: `false`

## basename
Type: `String`
Default: `sitemap.xml`
If you have a master sitemap that references sub-sitemaps, use this feature. For example `static-sitemap.xml`
## robot
Type: `Boolean`
Type: `Boolean`

@@ -125,4 +130,9 @@ Default: `true`

## Usage Examples
## pretty
Type: `Boolean`
Default: `false`
When generating a sitemap with directory indexes, use pretty urls by removing `index` path segments from `http://www.example.com/directory/index.html` to to create `http://www.example.com/directory/`
## Simple

@@ -143,2 +153,3 @@

}
```

@@ -181,67 +192,153 @@

## Contributing
## About
We welcome all kinds of contributions! The most basic way to show your support is to star the project, and if you'd like to get involved please see the [Contributing to grunt-assemble-sitemap](http://assemble.io/contributing/) guide for information on contributing to this project.
### Related projects
***
* [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#readme "Assemble plugin for creating anchor tags from headings in generated html using Cheerio.js.")
* [grunt-assemble-contextual](https://www.npmjs.com/package/grunt-assemble-contextual): Generates a JSON file with the context of each page. Basic plugin to help see… [more](https://github.com/assemble/grunt-assemble-contextual) | [homepage](https://github.com/assemble/grunt-assemble-contextual "Generates a JSON file with the context of each page. Basic plugin to help see what's happening in the build.")
* [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 "Assemble plugin for extracting zip, tar and tar.gz archives.")
* [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 "Assemble plugin for downloading files from GitHub.")
* [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 "Plugin for adding i18n support to Assemble projects.")
* [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 "Assemble plugin for adding search capabilities to your static site, with lunr.js.")
* [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://github.com/assemble/grunt-assemble-navigation) | [homepage](https://github.com/assemble/grunt-assemble-navigation "Assemble navigation plugin. Automatically generate Bootstrap-style, multi-level side nav. See the sidenav on assemble.io for a demonstration.")
* [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://github.com/assemble/grunt-assemble-permalinks) | [homepage](https://github.com/assemble/grunt-assemble-permalinks "Permalinks plugin for Assemble, the static site generator for Grunt.js, Yeoman and Node.js. This plugin enables powerful and configurable URI patterns, [Moment.js](http://momentjs.com/) for parsing dates, much more.")
* [grunt-assemble-sitemap](https://www.npmjs.com/package/grunt-assemble-sitemap): Sitemap plugin for Assemble | [homepage](http://assemble.io/plugins "Sitemap plugin for Assemble")
* [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 "Assemble middleware for adding a Table of Contents (TOC) to any HTML page.")
* [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 "Assemble plugin for displaying wordcount and average reading time to blog posts or pages.")
* [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](http://assemble.io) | [homepage](http://assemble.io "Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt, Less.js / lesscss.org, Topcoat, Web Experience Toolkit, and hundreds of other projects to build sites, themes, components, documentation, blogs and gh")
## Other grunt-assemble plugins
### Contributing
* [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)
* [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)
* [grunt-assemble-contextual](https://www.npmjs.com/package/grunt-assemble-contextual): Generates a JSON file with the context of each page. Basic plugin to help see… [more](https://www.npmjs.com/package/grunt-assemble-contextual) | [homepage](https://github.com/assemble/grunt-assemble-contextual)
* [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)
* [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)
* [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)
* [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)
* [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)
* [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)
* [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)
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
***
### Contributors
## Author
| **Commits** | **Contributor** |
| --- | --- |
| 64 | [hariadi](https://github.com/hariadi) |
| 11 | [doowb](https://github.com/doowb) |
| 7 | [rauberdaniel](https://github.com/rauberdaniel) |
| 7 | [hgoebl](https://github.com/hgoebl) |
| 2 | [jonschlinkert](https://github.com/jonschlinkert) |
| 1 | [quartzmo](https://github.com/quartzmo) |
| 1 | [jarrodconnolly](https://github.com/jarrodconnolly) |
| 1 | [Melindrea](https://github.com/Melindrea) |
| 1 | [olegsmetanin](https://github.com/olegsmetanin) |
**Hariadi Hinta**
### Release history
+ [github/hariadi](https://github.com/hariadi)
+ [twitter/hariadi](http://twitter.com/hariadi)
2017-03-16 **v0.2.6**
## License
* Add `option.basename` to specify the basename of the output file. Defaults to `sitemap.xml`.
* Add `option.pretty` to remove `index.html` from paths.
* Repo code clean up.
Copyright © 2015 Hariadi Hinta
Released under the MIT license.
2014-05-31 **v0.2.5**
***
* fix sitemap and robots not generated
* relativedest can be a path now
## Changes
2014-05-31 **v0.2.4**
**DATE** **VERSION** **CHANGES**
* added sitemap URL to robots.txt
* added relativedest to options
* 2015-09-25 v0.2.6 Rename to `grunt-assemble-sitemap`
* 2014-06-01 v0.2.5 fix sitemap and robots not generated,relativedest can be a path now
* 2014-06-01 v0.2.4 added sitemap URL to robots.txt,added relativedest to options
* 2014-05-03 v0.2.3 fixes toc,Change docs to use verb
* 2014-03-26 v0.2.2 Change from plugin to middleware
* 2014-02-21 v0.2.1 fix option.robot was ignored and always true 0159123,(feat) add option.dest
and use as output path,fix option.robot was ignored and always true,(feat)
add option to overwrite changefreq per file,cosmetical changes (code
formatting, naming, simplify),(wip) enable globbing patterns for
option.exclude
* 2014-02-05 v0.2.0 Generation of robots.txt will now respect the relativedest option.
* 2014-02-02 v0.1.9 Fix sitemap destination
* 2014-01-28 v0.1.8 Use external library,Get pages from assemble object
* 2014-01-03 v0.1.7 Add relativedest option
* 2013-12-12 v0.1.6 Fix plugin name in Usage Examples,Update deps
* 2013-11-28 v0.1.4 Updates dependencies to work with Grunt 0.4.2,[object Object],Add TOC to
docs
* 2013-10-20 v0.1.3 Fix sitemap and robots.txt generated on every folder,Update docs
options:exclusions
* 2013-10-18 v0.1.2 Fix homepage
* 2013-10-17 v0.1.1 Add option to generate robots.txt,Change name to
assemble-contrib.sitemap,Move to Assemble main repo
* 2013-10-01 v0.1.0 First commmit.,Add option to exclude
2014-05-02 **v0.2.3**
* fixes toc
* Change docs to use verb
2014-03-25 **v0.2.2**
* Change from plugin to middleware
2014-02-20 **v0.2.1**
* fix option.robot was ignored and always true 0159123
* (feat) add option.dest and use as output path
* fix option.robot was ignored and always true
* (feat) add option to overwrite changefreq per file
* cosmetical changes (code formatting, naming, simplify)
* (wip) enable globbing patterns for option.exclude
2014-02-04 **v0.2.0**
* Generation of robots.txt will now respect the relativedest option.
2014-02-01 **v0.1.9**
* Fix sitemap destination
2014-01-27 **v0.1.8**
* Use external library
* Get pages from assemble object
2014-01-02 **v0.1.7**
* Add relativedest option
2013-12-11 **v0.1.6**
* Fix plugin name in Usage Examples
* Update deps
2013-11-27 **v0.1.4**
* Updates dependencies to work with Grunt 0.4.2
* [object Object]
* Add TOC to docs
2013-10-19 **v0.1.3**
* Fix sitemap and robots.txt generated on every folder
* Update docs options:exclusions
2013-10-17 **v0.1.2**
* Fix homepage
2013-10-16 **v0.1.1**
* Add option to generate robots.txt
* Change name to assemble-contrib.sitemap
* Move to Assemble main repo
2013-09-30 **v0.1.0**
* First commmit.
* Add option to exclude
### Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
### Author
**Hariadi Hinta**
* [github/hariadi](https://github.com/hariadi)
* [twitter/hariadi](https://twitter.com/hariadi)
### License
Copyright © 2017, [Hariadi Hinta](https://github.com/hariadi).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 25, 2015._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on March 17, 2017._

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc