{"name":"sitemap","version":"3.2.2","description":"Sitemap-generating framework","keywords":["sitemap","sitemap.xml"],"homepage":"https://github.com/ekalinin/sitemap.js#readme","bugs":{"url":"https://github.com/ekalinin/sitemap.js/issues"},"repository":{"type":"git","url":"git://github.com/ekalinin/sitemap.js.git"},"license":"MIT","author":{"name":"Eugene Kalinin","email":"e.v.kalinin@gmail.com"},"main":"dist/index.js","types":"dist/index.d.ts","directories":{"lib":"lib","test":"tests"},"scripts":{"prepublishOnly":"sort-package-json && npm run test","test":"tsc && jest","test-perf":"node ./tests/perf.js","test:typecheck":"tsc"},"husky":{"hooks":{"pre-commit":"sort-package-json","pre-push":"npm test"}},"eslintConfig":{"env":{"es6":true,"jasmine":true,"jest":true,"node":true},"extends":["eslint:recommended","plugin:@typescript-eslint/recommended"],"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":6,"sourceType":"module"},"rules":{"no-case-declarations":0,"no-console":0,"no-unused-vars":0,"react/prop-types":0,"indent":"off","no-dupe-class-members":"off","@typescript-eslint/indent":["error",2],"@typescript-eslint/no-parameter-properties":"off","@typescript-eslint/no-unused-vars":["error",{"args":"none"}],"@typescript-eslint/explicit-member-accessibility":"off","@typescript-eslint/interface-name-prefix":"always"}},"jest":{"collectCoverage":true,"collectCoverageFrom":["lib/**/*.ts","!lib/**/*.d.ts","!node_modules/"],"coverageThreshold":{"global":{"branches":80,"functions":90,"lines":90,"statements":90}}},"dependencies":{"lodash.chunk":"^4.2.0","lodash.padstart":"^4.6.1","whatwg-url":"^7.0.0","xmlbuilder":"^13.0.0"},"devDependencies":{"@babel/core":"^7.4.4","@babel/plugin-proposal-class-properties":"^7.4.4","@babel/plugin-transform-typescript":"^7.4.5","@babel/preset-env":"^7.4.4","@babel/preset-typescript":"^7.3.3","@types/jest":"^24.0.12","@types/lodash.chunk":"^4.2.6","@types/lodash.padstart":"^4.6.6","@types/node":"^12.0.2","@types/url-join":"^4.0.0","@types/whatwg-url":"^6.4.0","@typescript-eslint/eslint-plugin":"^1.9.0","@typescript-eslint/parser":"^1.9.0","babel-eslint":"^10.0.1","babel-polyfill":"^6.26.0","babel-preset-minify":"^0.5.0","eslint":"^5.0.0","husky":"^3.0.0","jasmine":"^3.4.0","jest":"^24.8.0","sort-package-json":"^1.22.1","source-map":"~0.7.3","stats-lite":"^2.2.0","typescript":"^3.4.5"},"engines":{"node":">=6.0.0","npm":">=4.0.0"},"License":"MIT","gitHead":"3ffb9ba03d15695e2940587bb214c0e267878bc1","_id":"sitemap@3.2.2","_nodeVersion":"12.6.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-TModL/WU4m2q/mQcrDgNANn0P4LwprM9MMvG4hu5zP4c6IIKs2YLTu6nXXnNr8ODW/WFtxKggiJ1EGn2W0GNmg==","shasum":"3f77c358fa97b555c879e457098e39910095c62b","tarball":"http://registry-npm.ywwl.com/sitemap/download/sitemap-3.2.2.tgz","fileCount":30,"unpackedSize":88473,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdJZV6CRA9TVsSAnZWagAAK9UP/3u7KEfqv55pTGsbIjai\nJqWo6FKS4zUH2JHdeFQDnJFwaidXK1LGj0ezHgme/y2Ak3PDbhamXrO7SLBc\n3Jd3mo6CFajfQiETe5aKlTlOZmsaFmDdAQAcaKtaT+9Gx07guHjyy+Rx2Td/\nfwu3vlJ02c39Ui4qsXnflr3bhCxBnyHE7IhcgchyImVeWfU0AAGGFJS4RpKD\n3RPFV7qvOD3QorAnwNBRU9qq403uP1SuBTEqD5i3JOLdQmdh1twHddh6pZFb\ngSp7BIlyL/tV6VGToF057sW2Z+b3EqbkwugOhrzrkrFVc6VfYU6id+GBIF4a\nIuuN9j2qtlaSy48zqAagQGkFC+8Y002odiKxrvkrFGh18Opaaekq9Q2CP4q0\nFh+qhPzAWAQNpvnBQCB5mUDEttH2dz2HYGyZHq4+b3ekprx4augHP2kmF4tD\nu92zwYDolbheskASwO5KQoSLllOaok8WcwTqVwi+6/a3u8+asAw5AC9BK1eY\nG3YII46v0tScZklYEHBNRx2sXWAUxOB9i+/6YDivfWuNxdDOUQqPJblTIe83\nNQiTCRn/kXdP1c6iJ7JagJSHD2OYMB6zuhD8DQnD/BEk4t5RH9UKjsdmWDPN\nJ62wRYGIBL6uAtXC5fTyEmzH4DelqVRpCwGeNN0yGXAiYU36WEIyvKEY+fyl\n6fC1\r\n=+twI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEnkGhL5A4Z36amiHU2pInVPPZFQO3MT86e2rf8dK540AiAhTZ8NBkuAtvTDvdw53i0fvpwRssSrCjb9t6PqNJO+ig=="}],"size":21709,"noattachment":false,"key":"/sitemap/-/sitemap-3.2.2.tgz"},"maintainers":[{"name":"ekalinin","email":"e.v.kalinin@gmail.com"}],"_npmUser":{"name":"ekalinin","email":"e.v.kalinin@gmail.com"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sitemap_3.2.2_1562744185577_0.8200933558819647"},"_hasShrinkwrap":false,"readme":"# sitemap ![MIT License](https://img.shields.io/npm/l/sitemap)[![Build Status](https://travis-ci.org/ekalinin/sitemap.js.svg?branch=master)](https://travis-ci.org/ekalinin/sitemap.js)![Monthly Downloads](https://img.shields.io/npm/dm/sitemap)\n\n**sitemap** is a high-level streaming sitemap-generating library/CLI that\nmakes creating [sitemap XML](http://www.sitemaps.org/) files easy. [What is a sitemap?](https://support.google.com/webmasters/answer/156184?hl=en&ref_topic=4581190)\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Generate a one time sitemap from a list of urls](#generate-a-one-time-sitemap-from-a-list-of-urls)\n- [Example of using sitemap.js with](#serve-a-sitemap-from-a-server-and-periodically-update-it) [express](https://expressjs.com/)\n- [Generating more than one sitemap](#create-sitemap-and-index-files-from-one-large-list)\n- [Options you can pass](#options-you-can-pass)\n- [Examples](#examples)\n- [API](#api)\n- [Maintainers](#maintainers)\n- [License](#license)\n\n## Installation\n\n```sh\nnpm install --save sitemap\n```\n\n## Generate a one time sitemap from a list of urls\n\nIf you are just looking to take a giant list of URLs and turn it into some sitemaps, try out our CLI. The cli can also parse, update and validate existing sitemaps.\n\n```sh\nnpx sitemap < listofurls.txt # `npx sitemap -h` for more examples and a list of options.\n```\n\nFor programmatic one time generation of a sitemap try:\n\n```js\n  const { SitemapStream, streamToPromise } = require( 'sitemap' )\n  const { Readable } = require( 'stream' )\n\n  // An array with your links\n  const links = [{ url: '/page-1/',  changefreq: 'daily', priority: 0.3  }]\n\n  // Create a stream to write to\n  const stream = new SitemapStream( { hostname: 'https://...' } )\n\n  // Return a promise that resolves with your XML string\n  return streamToPromise(Readable.from(links).pipe(stream)).then((data) =>\n    data.toString()\n  )\n```\n\n## Serve a sitemap from a server and periodically update it\n\nUse this if you have less than 50 thousand urls. See SitemapAndIndexStream for if you have more.\n\n```js\nconst express = require('express')\nconst { SitemapStream, streamToPromise } = require('sitemap')\nconst { createGzip } = require('zlib')\nconst { Readable } = require('stream')\n\nconst app = express()\nlet sitemap\n\napp.get('/sitemap.xml', function(req, res) {\n  res.header('Content-Type', 'application/xml');\n  res.header('Content-Encoding', 'gzip');\n  // if we have a cached entry send it\n  if (sitemap) {\n    res.send(sitemap)\n    return\n  }\n\n  try {\n    const smStream = new SitemapStream({ hostname: 'https://example.com/' })\n    const pipeline = smStream.pipe(createGzip())\n\n    // pipe your entries or directly write them.\n    smStream.write({ url: '/page-1/',  changefreq: 'daily', priority: 0.3 })\n    smStream.write({ url: '/page-2/',  changefreq: 'monthly',  priority: 0.7 })\n    smStream.write({ url: '/page-3/'})    // changefreq: 'weekly',  priority: 0.5\n    smStream.write({ url: '/page-4/',   img: \"http://urlTest.com\" })\n    /* or use\n    Readable.from([{url: '/page-1'}...]).pipe(smStream)\n    if you are looking to avoid writing your own loop.\n    */\n\n    // cache the response\n    streamToPromise(pipeline).then(sm => sitemap = sm)\n    // make sure to attach a write stream such as streamToPromise before ending\n    smStream.end()\n    // stream write the response\n    pipeline.pipe(res).on('error', (e) => {throw e})\n  } catch (e) {\n    console.error(e)\n    res.status(500).end()\n  }\n})\n\napp.listen(3000, () => {\n  console.log('listening')\n});\n```\n\n## Create sitemap and index files from one large list\n\nIf you know you are definitely going to have more than 50,000 urls in your sitemap, you can use this slightly more complex interface to create a new sitemap every 45,000 entries and add that file to a sitemap index.\n\n```js\nconst { createReadStream, createWriteStream } = require('fs');\nconst { resolve } = require('path');\nconst { createGzip } = require('zlib')\nconst {\n  simpleSitemapAndIndex,\n  lineSeparatedURLsToSitemapOptions\n} = require('sitemap')\n\n// writes sitemaps and index out to the destination you provide.\nsimpleSitemapAndIndex({\n  hostname: 'https://example.com',\n  destinationDir: './',\n  sourceData: lineSeparatedURLsToSitemapOptions(\n    createReadStream('./your-data.json.txt')\n  ),\n  // or (only works with node 10.17 and up)\n  sourceData: [{ url: '/page-1/', changefreq: 'daily'}, ...],\n  // or\n  sourceData: './your-data.json.txt',\n}).then(() => {\n  // Do follow up actions\n})\n```\n\nWant to customize that?\n\n```js\nconst { createReadStream, createWriteStream } = require('fs');\nconst { resolve } = require('path');\nconst { createGzip } = require('zlib')\nconst { Readable } = require('stream')\nconst {\n  SitemapAndIndexStream,\n  SitemapStream,\n  lineSeparatedURLsToSitemapOptions\n} = require('sitemap')\n\nconst sms = new SitemapAndIndexStream({\n  limit: 50000, // defaults to 45k\n  lastmodDateOnly: false, // print date not time\n  // SitemapAndIndexStream will call this user provided function every time\n  // it needs to create a new sitemap file. You merely need to return a stream\n  // for it to write the sitemap urls to and the expected url where that sitemap will be hosted\n  getSitemapStream: (i) => {\n    const sitemapStream = new SitemapStream({ hostname: 'https://example.com' });\n    // if your server automatically serves sitemap.xml.gz when requesting sitemap.xml leave this line be\n    // otherwise you will need to add .gz here and remove it a couple lines below so that both the index \n    // and the actual file have a .gz extension\n    const path = `./sitemap-${i}.xml`; \n\n    const ws = sitemapStream\n      .pipe(createGzip()) // compress the output of the sitemap\n      .pipe(createWriteStream(resolve(path + '.gz'))); // write it to sitemap-NUMBER.xml\n\n    return [new URL(path, 'https://example.com/subdir/').toString(), sitemapStream, ws];\n  },\n});\n\n// when reading from a file\nlineSeparatedURLsToSitemapOptions(\n  createReadStream('./your-data.json.txt')\n)\n.pipe(sms)\n.pipe(createGzip())\n.pipe(createWriteStream(resolve('./sitemap-index.xml.gz')));\n\n// or reading straight from an in-memory array\nsms\n.pipe(createGzip())\n.pipe(createWriteStream(resolve('./sitemap-index.xml.gz')));\n\nconst arrayOfSitemapItems = [{ url: '/page-1/', changefreq: 'daily'}, ...]\nReadable.from(arrayOfSitemapItems).pipe(sms) // available as of node 10.17.0\n// or\narrayOfSitemapItems.forEach(item => sms.write(item))\nsms.end() // necessary to let it know you've got nothing else to write\n```\n\n### Options you can pass\n\n```js\nconst { SitemapStream, streamToPromise } = require('sitemap');\nconst smStream = new SitemapStream({\n  hostname: 'http://www.mywebsite.com',\n  xslUrl: \"https://example.com/style.xsl\",\n  lastmodDateOnly: false, // print date not time\n  xmlns: { // trim the xml namespace\n    news: true, // flip to false to omit the xml namespace for news\n    xhtml: true,\n    image: true,\n    video: true,\n    custom: [\n      'xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\"',\n      'xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"',\n    ],\n  }\n })\n// coalesce stream to value\n// alternatively you can pipe to another stream\nstreamToPromise(smStream).then(console.log)\n\nsmStream.write({\n  url: '/page1',\n  changefreq: 'weekly',\n  priority: 0.8, // A hint to the crawler that it should prioritize this over items less than 0.8\n})\n\n// each sitemap entry supports many options\n// See [Sitemap Item Options](./api.md#sitemap-item-options) below for details\nsmStream.write({\n  url: 'http://test.com/page-1/',\n  img: [\n    {\n      url: 'http://test.com/img1.jpg',\n      caption: 'An image',\n      title: 'The Title of Image One',\n      geoLocation: 'London, United Kingdom',\n      license: 'https://creativecommons.org/licenses/by/4.0/'\n    },\n    {\n      url: 'http://test.com/img2.jpg',\n      caption: 'Another image',\n      title: 'The Title of Image Two',\n      geoLocation: 'London, United Kingdom',\n      license: 'https://creativecommons.org/licenses/by/4.0/'\n    }\n  ],\n  video: [\n    {\n      thumbnail_loc: 'http://test.com/tmbn1.jpg',\n      title: 'A video title',\n      description: 'This is a video'\n    },\n    {\n      thumbnail_loc: 'http://test.com/tmbn2.jpg',\n      title: 'A video with an attribute',\n      description: 'This is another video',\n      'player_loc': 'http://www.example.com/videoplayer.mp4?video=123',\n      'player_loc:autoplay': 'ap=1',\n      'player_loc:allow_embed': 'yes'\n    }\n  ],\n  links: [\n    { lang: 'en', url: 'http://test.com/page-1/' },\n    { lang: 'ja', url: 'http://test.com/page-1/ja/' }\n  ],\n  androidLink: 'android-app://com.company.test/page-1/',\n  news: {\n    publication: {\n      name: 'The Example Times',\n      language: 'en'\n    },\n    genres: 'PressRelease, Blog',\n    publication_date: '2008-12-23',\n    title: 'Companies A, B in Merger Talks',\n    keywords: 'business, merger, acquisition, A, B',\n    stock_tickers: 'NASDAQ:A, NASDAQ:B'\n  }\n})\n// indicate there is nothing left to write\nsmStream.end()\n```\n\n## Examples\n\nFor more examples see the [examples directory](./examples/)\n\n## API\n\nFull API docs can be found [here](./api.md)\n\n## Maintainers\n\n- [@ekalinin](https://github.com/ekalinin)\n- [@derduher](https://github.com/derduher)\n\n## License\n\nSee [LICENSE](https://github.com/ekalinin/sitemap.js/blob/master/LICENSE) file.\n","publish_time":1562744185718,"_cnpm_publish_time":1562744185718,"dist-tags":{"latest":"10.0.0","legacy":"7.1.3","v8-latest":"8.0.3"}}