Comparing version 4.0.2 to 4.1.1
@@ -0,3 +1,19 @@ | ||
# master | ||
Nothing yet | ||
# 4.1.1 | ||
Add a pretty print option to `toString(false)` | ||
pass true pretty print | ||
Add an xmlparser that will output a config that would generate that same file | ||
cli: | ||
use --parser to output the complete config --line-separated to print out line | ||
separated config compatible with the --json input option for cli | ||
lib: import parseSitemap and pass it a stream | ||
# 4.0.2 | ||
Fix npx script error - needs the shebang | ||
# 4.0.1 | ||
@@ -4,0 +20,0 @@ Validation functions which depend on xmllint will now warn if you do not have xmllint installed. |
@@ -17,3 +17,4 @@ #!/usr/bin/env node | ||
const errors_1 = require("./lib/errors"); | ||
console.warn('CLI is in new and likely to change quite a bit. Please send feature/bug requests to https://github.com/ekalinin/sitemap.js/issues'); | ||
const sitemap_parser_1 = require("./lib/sitemap-parser"); | ||
console.warn('CLI is new and likely to change quite a bit. Please send feature/bug requests to https://github.com/ekalinin/sitemap.js/issues'); | ||
/* eslint-disable-next-line @typescript-eslint/no-var-requires */ | ||
@@ -52,5 +53,16 @@ const arg = require('arg'); | ||
'--json': Boolean, | ||
'--validate': Boolean | ||
'--validate': Boolean, | ||
'--parse': Boolean, | ||
'--line-separated': Boolean | ||
}; | ||
const argv = arg(argSpec); | ||
function getStream() { | ||
if (argv._ && argv._.length) { | ||
return fs_1.createReadStream(argv._[0]); | ||
} | ||
else { | ||
console.warn('Reading from stdin. If you are not piping anything in, this command is not doing anything'); | ||
return process.stdin; | ||
} | ||
} | ||
if (argv['--version']) { | ||
@@ -62,16 +74,30 @@ /* eslint-disable-next-line @typescript-eslint/no-var-requires */ | ||
else if (argv['--help']) { | ||
// TODO stream a full JSON configuration in | ||
// TODO allow user to append entry to existing xml | ||
console.log(` | ||
Turn a list of urls into a sitemap xml. | ||
Options: | ||
--help Print this text | ||
--version Print the version | ||
--json Parse each line as json and feed to Sitemap | ||
--help Print this text | ||
--version Print the version | ||
--json Parse each line as json and feed to Sitemap | ||
--parse Parse fed xml and spit out config | ||
--line-separated When used with parse, it spits out each entry as json rather | ||
than the whole json. This can be then consumed with --json by | ||
the cli | ||
`); | ||
} | ||
else if (argv['--parse']) { | ||
sitemap_parser_1.parseSitemap(getStream()).then((items) => { | ||
if (argv['--line-separated'] && items.urls) { | ||
items.urls.forEach((url) => { | ||
console.log(JSON.stringify(url)); | ||
}); | ||
} | ||
else { | ||
console.log(JSON.stringify(items)); | ||
} | ||
}); | ||
} | ||
else if (argv['--validate']) { | ||
let xml = process.stdin; | ||
if (argv._ && argv._.length) { | ||
xml = argv._[0]; | ||
} | ||
xmllint_1.xmlLint(xml) | ||
xmllint_1.xmlLint(getStream()) | ||
.then(() => console.log('valid')) | ||
@@ -78,0 +104,0 @@ .catch(([error, stderr]) => { |
@@ -13,2 +13,3 @@ /*! | ||
export { xmlLint } from './lib/xmllint'; | ||
export { parseSitemap } from './lib/sitemap-parser'; | ||
export default createSitemap; |
@@ -19,3 +19,5 @@ "use strict"; | ||
exports.xmlLint = xmllint_1.xmlLint; | ||
var sitemap_parser_1 = require("./lib/sitemap-parser"); | ||
exports.parseSitemap = sitemap_parser_1.parseSitemap; | ||
exports.default = sitemap_1.createSitemap; | ||
//# sourceMappingURL=index.js.map |
import { ICallback, ISitemapIndexItemOptions, SitemapItemOptions } from './types'; | ||
/** | ||
* Shortcut for `new SitemapIndex (...)`. | ||
* Create several sitemaps and an index automatically from a list of urls | ||
* | ||
@@ -5,0 +6,0 @@ * @param {Object} conf |
@@ -10,2 +10,3 @@ "use strict"; | ||
* Shortcut for `new SitemapIndex (...)`. | ||
* Create several sitemaps and an index automatically from a list of urls | ||
* | ||
@@ -12,0 +13,0 @@ * @param {Object} conf |
@@ -23,2 +23,8 @@ import { XMLElement } from 'xmlbuilder'; | ||
constructor(conf: SitemapItemOptions, root?: XMLElement, level?: ErrorLevel); | ||
/** | ||
* For creating standalone sitemap entries | ||
* @param {SitemapItemOptions} conf sitemap entry options | ||
* @param {ErrorLevel} [level=ErrorLevel.WARN] How to handle errors in data passed in | ||
* @return {string} the entry | ||
*/ | ||
static justItem(conf: SitemapItemOptions, level?: ErrorLevel): string; | ||
@@ -30,9 +36,17 @@ /** | ||
toXML(): string; | ||
/** | ||
* Builds just video element | ||
* @param {IVideoItem} video sitemap video configuration | ||
*/ | ||
buildVideoElement(video: IVideoItem): void; | ||
/** | ||
* given the passed in sitemap item options builds an internal xml structure | ||
* @returns the XMLElement built | ||
*/ | ||
buildXML(): XMLElement; | ||
/** | ||
* Alias for toXML() | ||
* @return {String} | ||
* Builds and stringifies the xml as configured by constructor | ||
* @return {String} the item converted to a string of xml | ||
*/ | ||
toString(): string; | ||
} |
@@ -54,2 +54,8 @@ "use strict"; | ||
} | ||
/** | ||
* For creating standalone sitemap entries | ||
* @param {SitemapItemOptions} conf sitemap entry options | ||
* @param {ErrorLevel} [level=ErrorLevel.WARN] How to handle errors in data passed in | ||
* @return {string} the entry | ||
*/ | ||
static justItem(conf, level) { | ||
@@ -66,2 +72,6 @@ const smi = new SitemapItem(conf, undefined, level); | ||
} | ||
/** | ||
* Builds just video element | ||
* @param {IVideoItem} video sitemap video configuration | ||
*/ | ||
buildVideoElement(video) { | ||
@@ -127,2 +137,6 @@ const videoxml = this.url.element('video:video'); | ||
} | ||
/** | ||
* given the passed in sitemap item options builds an internal xml structure | ||
* @returns the XMLElement built | ||
*/ | ||
buildXML() { | ||
@@ -242,4 +256,4 @@ this.url.children = []; | ||
/** | ||
* Alias for toXML() | ||
* @return {String} | ||
* Builds and stringifies the xml as configured by constructor | ||
* @return {String} the item converted to a string of xml | ||
*/ | ||
@@ -246,0 +260,0 @@ toString() { |
@@ -10,2 +10,10 @@ /// <reference types="node" /> | ||
import { CompressCallback } from 'zlib'; | ||
export interface ISitemapOptions { | ||
urls?: (ISitemapItemOptionsLoose | string)[]; | ||
hostname?: string; | ||
cacheTime?: number; | ||
xslUrl?: string; | ||
xmlNs?: string; | ||
level?: ErrorLevel; | ||
} | ||
/** | ||
@@ -20,12 +28,6 @@ * Shortcut for `new Sitemap (...)`. | ||
* @param {String} conf.xmlNs | ||
* @param {ErrorLevel} [level=ErrorLevel.WARN] level optional | ||
* @return {Sitemap} | ||
*/ | ||
export declare function createSitemap({ urls, hostname, cacheTime, xslUrl, xmlNs, level }: { | ||
urls?: (ISitemapItemOptionsLoose | string)[]; | ||
hostname?: string; | ||
cacheTime?: number; | ||
xslUrl?: string; | ||
xmlNs?: string; | ||
level?: ErrorLevel; | ||
}): Sitemap; | ||
export declare function createSitemap({ urls, hostname, cacheTime, xslUrl, xmlNs, level }: ISitemapOptions): Sitemap; | ||
export declare class Sitemap { | ||
@@ -45,24 +47,22 @@ limit: number; | ||
* @param {String} hostname optional | ||
* @param {Number} cacheTime optional in milliseconds; 0 - cache disabled | ||
* @param {String} xslUrl optional | ||
* @param {String} xmlNs optional | ||
* @param {Number} [cacheTime=0] cacheTime optional in milliseconds; 0 - cache disabled | ||
* @param {String=} xslUrl optional | ||
* @param {String=} xmlNs optional | ||
* @param {ErrorLevel} [level=ErrorLevel.WARN] level optional | ||
*/ | ||
constructor({ urls, hostname, cacheTime, xslUrl, xmlNs, level }?: { | ||
urls?: (ISitemapItemOptionsLoose | string)[]; | ||
hostname?: string; | ||
cacheTime?: number; | ||
xslUrl?: string; | ||
xmlNs?: string; | ||
level?: ErrorLevel; | ||
}); | ||
constructor({ urls, hostname, cacheTime, xslUrl, xmlNs, level }?: ISitemapOptions); | ||
/** | ||
* Clear sitemap cache | ||
* Empty cache and bipass it until set again | ||
*/ | ||
clearCache(): void; | ||
/** | ||
* Can cache be used | ||
* has it been less than cacheTime since cache was set | ||
* @returns true if it has been less than cacheTime ms since cache was set | ||
*/ | ||
isCacheValid(): boolean; | ||
/** | ||
* Fill cache | ||
* stores the passed in string on the instance to be used when toString is | ||
* called within the configured cacheTime | ||
* @param {string} newCache what you want cached | ||
* @returns the passed in string unaltered | ||
*/ | ||
@@ -73,5 +73,11 @@ setCache(newCache: string): string; | ||
* Add url to sitemap | ||
* @param {String} url | ||
* @param {String | ISitemapItemOptionsLoose} url | ||
* @param {ErrorLevel} [level=ErrorLevel.WARN] level | ||
*/ | ||
add(url: string | ISitemapItemOptionsLoose, level?: ErrorLevel): number; | ||
/** | ||
* For checking whether the url has been added or not | ||
* @param {string | ISitemapItemOptionsLoose} url The url you wish to check | ||
* @returns true if the sitemap has the passed in url | ||
*/ | ||
contains(url: string | ISitemapItemOptionsLoose): boolean; | ||
@@ -86,13 +92,37 @@ /** | ||
* Alias for toString | ||
* @param {boolean} [pretty=false] whether xml should include whitespace | ||
*/ | ||
toXML(): string; | ||
toXML(pretty?: boolean): string; | ||
/** | ||
* Converts the passed in sitemap entry into one capable of being consumed by SitemapItem | ||
* @param {string | ISitemapItemOptionsLoose} elem the string or object to be converted | ||
* @param {XMLElement=} root xmlbuilder root object. Pass undefined here | ||
* @param {string} hostname | ||
* @returns SitemapItemOptions a strict sitemap item option | ||
*/ | ||
static normalizeURL(elem: string | ISitemapItemOptionsLoose, root?: XMLElement, hostname?: string): SitemapItemOptions; | ||
/** | ||
* Normalize multiple urls | ||
* @param {(string | ISitemapItemOptionsLoose)[]} urls array of urls to be normalized | ||
* @param {XMLElement=} root xmlbuilder root object. Pass undefined here | ||
* @param {string=} hostname | ||
* @returns a Map of url to SitemapItemOption | ||
*/ | ||
static normalizeURLs(urls: (string | ISitemapItemOptionsLoose)[], root?: XMLElement, hostname?: string): Map<string, SitemapItemOptions>; | ||
/** | ||
* Synchronous alias for toXML() | ||
* Converts the urls stored in an instance of Sitemap to a valid sitemap xml document | ||
* as a string. Accepts a boolean as its first argument to designate on whether to | ||
* pretty print. Defaults to false. | ||
* @return {String} | ||
*/ | ||
toString(): string; | ||
toString(pretty?: boolean): string; | ||
/** | ||
* like toString, it builds the xmlDocument, then it runs gzip on the | ||
* resulting string and returns it as a Buffer via callback or direct | ||
* invokation | ||
* @param {CompressCallback=} callback executes callback on completion with a buffer parameter | ||
* @returns a Buffer if no callback is provided | ||
*/ | ||
toGzip(callback: CompressCallback): void; | ||
toGzip(): Buffer; | ||
} |
@@ -34,2 +34,3 @@ "use strict"; | ||
* @param {String} conf.xmlNs | ||
* @param {ErrorLevel} [level=ErrorLevel.WARN] level optional | ||
* @return {Sitemap} | ||
@@ -55,5 +56,6 @@ */ | ||
* @param {String} hostname optional | ||
* @param {Number} cacheTime optional in milliseconds; 0 - cache disabled | ||
* @param {String} xslUrl optional | ||
* @param {String} xmlNs optional | ||
* @param {Number} [cacheTime=0] cacheTime optional in milliseconds; 0 - cache disabled | ||
* @param {String=} xslUrl optional | ||
* @param {String=} xmlNs optional | ||
* @param {ErrorLevel} [level=ErrorLevel.WARN] level optional | ||
*/ | ||
@@ -88,3 +90,3 @@ constructor({ urls = [], hostname, cacheTime = 0, xslUrl, xmlNs, level = types_1.ErrorLevel.WARN } = {}) { | ||
/** | ||
* Clear sitemap cache | ||
* Empty cache and bipass it until set again | ||
*/ | ||
@@ -95,3 +97,4 @@ clearCache() { | ||
/** | ||
* Can cache be used | ||
* has it been less than cacheTime since cache was set | ||
* @returns true if it has been less than cacheTime ms since cache was set | ||
*/ | ||
@@ -104,3 +107,6 @@ isCacheValid() { | ||
/** | ||
* Fill cache | ||
* stores the passed in string on the instance to be used when toString is | ||
* called within the configured cacheTime | ||
* @param {string} newCache what you want cached | ||
* @returns the passed in string unaltered | ||
*/ | ||
@@ -117,3 +123,4 @@ setCache(newCache) { | ||
* Add url to sitemap | ||
* @param {String} url | ||
* @param {String | ISitemapItemOptionsLoose} url | ||
* @param {ErrorLevel} [level=ErrorLevel.WARN] level | ||
*/ | ||
@@ -125,2 +132,7 @@ add(url, level) { | ||
} | ||
/** | ||
* For checking whether the url has been added or not | ||
* @param {string | ISitemapItemOptionsLoose} url The url you wish to check | ||
* @returns true if the sitemap has the passed in url | ||
*/ | ||
contains(url) { | ||
@@ -139,6 +151,14 @@ return this.urls.has(this._normalizeURL(url).url); | ||
* Alias for toString | ||
* @param {boolean} [pretty=false] whether xml should include whitespace | ||
*/ | ||
toXML() { | ||
return this.toString(); | ||
toXML(pretty) { | ||
return this.toString(pretty); | ||
} | ||
/** | ||
* Converts the passed in sitemap entry into one capable of being consumed by SitemapItem | ||
* @param {string | ISitemapItemOptionsLoose} elem the string or object to be converted | ||
* @param {XMLElement=} root xmlbuilder root object. Pass undefined here | ||
* @param {string} hostname | ||
* @returns SitemapItemOptions a strict sitemap item option | ||
*/ | ||
static normalizeURL(elem, root, hostname) { | ||
@@ -205,2 +225,6 @@ // SitemapItem | ||
} | ||
if (video.view_count !== undefined) { | ||
/* eslint-disable-next-line @typescript-eslint/camelcase */ | ||
nv.view_count = '' + video.view_count; | ||
} | ||
return nv; | ||
@@ -224,2 +248,9 @@ }); | ||
} | ||
/** | ||
* Normalize multiple urls | ||
* @param {(string | ISitemapItemOptionsLoose)[]} urls array of urls to be normalized | ||
* @param {XMLElement=} root xmlbuilder root object. Pass undefined here | ||
* @param {string=} hostname | ||
* @returns a Map of url to SitemapItemOption | ||
*/ | ||
static normalizeURLs(urls, root, hostname) { | ||
@@ -234,6 +265,8 @@ const urlMap = new Map(); | ||
/** | ||
* Synchronous alias for toXML() | ||
* Converts the urls stored in an instance of Sitemap to a valid sitemap xml document | ||
* as a string. Accepts a boolean as its first argument to designate on whether to | ||
* pretty print. Defaults to false. | ||
* @return {String} | ||
*/ | ||
toString() { | ||
toString(pretty = false) { | ||
if (this.root.children.length) { | ||
@@ -260,3 +293,7 @@ this.root.children = []; | ||
} | ||
return this.setCache(this.root.end()); | ||
let opts; | ||
if (pretty) { | ||
opts = { pretty }; | ||
} | ||
return this.setCache(this.root.end(opts)); | ||
} | ||
@@ -263,0 +300,0 @@ toGzip(callback) { |
@@ -106,2 +106,5 @@ /// <reference types="node" /> | ||
} | ||
/** | ||
* Strict options for individual sitemap entries | ||
*/ | ||
export interface SitemapItemOptions extends ISitemapItemOptionsBase { | ||
@@ -112,2 +115,5 @@ img: ISitemapImg[]; | ||
} | ||
/** | ||
* Options for individual sitemap entries prior to normalization | ||
*/ | ||
export interface ISitemapItemOptionsLoose extends ISitemapItemOptionsBase { | ||
@@ -121,2 +127,5 @@ video?: IVideoItemLoose | IVideoItemLoose[]; | ||
} | ||
/** | ||
* How to handle errors in passed in urls | ||
*/ | ||
export declare enum ErrorLevel { | ||
@@ -123,0 +132,0 @@ SILENT = "silent", |
@@ -38,2 +38,5 @@ "use strict"; | ||
})(EnumAllowDeny = exports.EnumAllowDeny || (exports.EnumAllowDeny = {})); | ||
/** | ||
* How to handle errors in passed in urls | ||
*/ | ||
var ErrorLevel; | ||
@@ -40,0 +43,0 @@ (function (ErrorLevel) { |
/// <reference types="node" /> | ||
import { Readable } from 'stream'; | ||
/** | ||
* Verify the passed in xml is valid | ||
* @param xml what you want validated | ||
* @return {Promise<null>} resolves on valid rejects [error stderr] | ||
*/ | ||
export declare function xmlLint(xml: string | Readable): Promise<null>; |
@@ -5,2 +5,7 @@ "use strict"; | ||
const errors_1 = require("./errors"); | ||
/** | ||
* Verify the passed in xml is valid | ||
* @param xml what you want validated | ||
* @return {Promise<null>} resolves on valid rejects [error stderr] | ||
*/ | ||
function xmlLint(xml) { | ||
@@ -7,0 +12,0 @@ let args = ['--schema', './schema/all.xsd', '--noout', '-']; |
{ | ||
"name": "sitemap", | ||
"version": "4.0.2", | ||
"description": "Sitemap-generating framework", | ||
"version": "4.1.1", | ||
"description": "Sitemap-generating lib/cli", | ||
"keywords": [ | ||
@@ -27,2 +27,3 @@ "sitemap", | ||
"scripts": { | ||
"build": "tsc", | ||
"prepublishOnly": "sort-package-json && npm run test", | ||
@@ -102,3 +103,5 @@ "test": "eslint lib/* ./cli.ts && tsc && jest && npm run test:xmllint", | ||
"@types/node": "^12.0.2", | ||
"@types/sax": "^1.2.0", | ||
"arg": "^4.1.1", | ||
"sax": "^1.2.4", | ||
"xmlbuilder": "^13.0.0" | ||
@@ -105,0 +108,0 @@ }, |
130
README.md
sitemap.js [![Build Status](https://travis-ci.org/ekalinin/sitemap.js.svg?branch=master)](https://travis-ci.org/ekalinin/sitemap.js) | ||
========== | ||
**sitemap.js** is a high-level sitemap-generating framework that | ||
**sitemap.js** is a high-level sitemap-generating library/cli that | ||
makes creating [sitemap XML](http://www.sitemaps.org/) files easy. | ||
@@ -19,3 +19,3 @@ | ||
* [Usage](#usage) | ||
* [CLI](#CLI) | ||
* [CLI](#cli) | ||
* [Example of using sitemap.js with <a href="https://expressjs.com/">express</a>:](#example-of-using-sitemapjs-with-express) | ||
@@ -26,3 +26,3 @@ * [Example of dynamic page manipulations into sitemap:](#example-of-dynamic-page-manipulations-into-sitemap) | ||
* [Auto creating sitemap and index files from one large list](#auto-creating-sitemap-and-index-files-from-one-large-list) | ||
* [API](#API) | ||
* [API](#api) | ||
* [Create Sitemap](#create-sitemap) | ||
@@ -32,7 +32,9 @@ * [Sitemap](#sitemap) | ||
* [createSitemapIndex](#createsitemapindex) | ||
* [xmlLint](#xmllint) | ||
* [parseSitemap](#parsesitemap) | ||
* [Sitemap Item Options](#sitemap-item-options) | ||
* [ISitemapImage](#ISitemapImage) | ||
* [IVideoItem](#IVideoItem) | ||
* [ILinkItem](#ILinkItem) | ||
* [INewsItem](#INewsItem) | ||
* [ISitemapImage](#isitemapimage) | ||
* [IVideoItem](#ivideoitem) | ||
* [ILinkItem](#ilinkitem) | ||
* [INewsItem](#inewsitem) | ||
* [License](#license) | ||
@@ -64,4 +66,2 @@ | ||
The main functions you want to use in the sitemap module are | ||
```javascript | ||
@@ -229,7 +229,7 @@ const { createSitemap } = require('sitemap') | ||
## Sitemap | ||
### Sitemap | ||
``` | ||
const { Sitemap } = require('sitemap') | ||
const sm = new Sitemap({ | ||
const smi = new Sitemap({ | ||
urls: [{url: '/path'}], | ||
@@ -242,4 +242,71 @@ hostname: 'http://example.com', | ||
``` | ||
__toString__ | ||
``` | ||
smi.toString(true) | ||
``` | ||
Converts the urls stored in an instance of Sitemap to a valid sitemap xml document as a string. Accepts a boolean as its first argument to designate on whether to pretty print. Defaults to false. | ||
__toXML__ | ||
alias for toString | ||
## buildSitemapIndex | ||
__toGzip__ | ||
``` | ||
smi.toGzip ((xmlGzippedBuffer) => console.log(xmlGzippedBuffer)); | ||
smi.toGzip(); | ||
``` | ||
like toString, it builds the xmlDocument, then it runs gzip on the resulting string and returns it as a Buffer via callback or direct invokation | ||
__clearCache__ | ||
``` | ||
smi.clearCache() | ||
``` | ||
cache will be emptied and will be bipassed until set again | ||
__isCacheValid__ | ||
``` | ||
smi.isCacheValid() | ||
``` | ||
returns true if it has been less than cacheTimeout ms since cache was set | ||
__setCache__ | ||
``` | ||
smi.setCache('...xmlDoc') | ||
``` | ||
stores the passed in string on the instance to be used when toString is called within the configured cacheTimeout | ||
returns the passed in string unaltered | ||
__add__ | ||
``` | ||
smi.add('/path', 'warn') | ||
``` | ||
adds the provided url to the sitemap instance | ||
takes an optional parameter level for whether to print a console warning in the event of bad data 'warn' (default), throw an exception 'throw', or quietly ignore bad data 'silent' | ||
returns the number of locations currently in the sitemap instance | ||
__contains__ | ||
``` | ||
smi.contains('/path') | ||
``` | ||
Returns true if path is already a part of the sitemap instance, false otherwise. | ||
__del__ | ||
``` | ||
smi.del('/path') | ||
``` | ||
removes the provided url or url option from the sitemap instance | ||
__normalizeURL__ | ||
``` | ||
Sitemap.normalizeURL('/', undefined, 'http://example.com') | ||
``` | ||
static function that returns the stricter form of a options passed to SitemapItem | ||
__normalizeURLs__ | ||
``` | ||
Sitemap.normalizeURLs(['http://example.com', {url: 'http://example.com'}]) | ||
``` | ||
static function that takes an array of urls and returns a Map of their resolved url to the strict form of SitemapItemOptions | ||
### buildSitemapIndex | ||
Build a sitemap index file | ||
@@ -254,3 +321,3 @@ ``` | ||
## createSitemapIndex | ||
### createSitemapIndex | ||
Create several sitemaps and an index automatically from a list of urls | ||
@@ -272,4 +339,31 @@ ``` | ||
## Sitemap Item Options | ||
### xmlLint | ||
Resolve or reject depending on whether the passed in xml is a valid sitemap. | ||
This is just a wrapper around the xmllint command line tool and thus requires | ||
xmllint. | ||
``` | ||
const { createReadStream } = require('fs') | ||
const { xmlLint } = require('sitemap') | ||
xmlLint(createReadStream('./example.xml')).then( | ||
() => console.log('xml is valid'), | ||
([err, stderr]) => console.error('xml is invalid', stderr) | ||
) | ||
``` | ||
### parseSitemap | ||
Read xml and resolve with the configuration that would produce it or reject with | ||
an error | ||
``` | ||
const { createReadStream } = require('fs') | ||
const { parseSitemap, createSitemap } = require('sitemap') | ||
parseSitemap(createReadStream('./example.xml')).then( | ||
// produces the same xml | ||
// you can, of course, more practically modify it or store it | ||
(xmlConfig) => console.log(createSitemap(xmlConfig).toString()), | ||
(err) => console.log(err) | ||
) | ||
``` | ||
### Sitemap Item Options | ||
|Option|Type|eg|Description| | ||
@@ -289,3 +383,3 @@ |------|----|--|-----------| | ||
## ISitemapImage | ||
### ISitemapImage | ||
@@ -303,3 +397,3 @@ Sitemap image | ||
## IVideoItem | ||
### IVideoItem | ||
@@ -339,3 +433,3 @@ Sitemap video. https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190 | ||
## ILinkItem | ||
### ILinkItem | ||
@@ -349,3 +443,3 @@ https://support.google.com/webmasters/answer/189077 | ||
## INewsItem | ||
### INewsItem | ||
@@ -352,0 +446,0 @@ https://support.google.com/webmasters/answer/74288?hl=en&ref_topic=4581190 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2165
453
152874
5
40
+ Added@types/sax@^1.2.0
+ Addedsax@^1.2.4
+ Added@types/sax@1.2.7(transitive)
+ Addedsax@1.4.1(transitive)