Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including sitemap2 with all npm packages installed. Try it out:

var sitemap2 = require("sitemap2")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

sitemap2 v1.0.1

Sitemap-generating framework

Build Status Coverage Status npm version

sitemap2

sitemap2 is a high-level sitemap-generating framework that makes creating sitemap XML files easy.

Installation

$ npm install sitemap2 --save

Usage

It will produce 3 files: sitemap.xml (index xml file), sitemap-0.xml(movies links) sitemap-1.xml(books links)

var fs = require('fs');
var Sitemap = require('sitemap2');

var host = 'http://vk.com';

var sm = new Sitemap({hostName: host});

var movies = new Sitemap({hostName: host});
movies.addUrl('http://vk.com/movies/video-1');
movies.addUrl('http://vk.com/movies/video-n');

var books = new Sitemap({hostName: host});
books.addUrl('http://vk.com/books/book-1');
books.addUrl('http://vk.com/books/book-n');

sm.addSitemap(movies);
sm.addSitemap(books);

var files = sm.toXML();

files.forEach(function saveFileToDisk(file) {
    fs.writeFileSync(file.fileName, file.xml);
});

License

MIT

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free