sitemap
- Version 9.0.0
- Published
- 468 kB
- 4 dependencies
- MIT license
Install
npm i sitemapyarn add sitemappnpm add sitemapOverview
Sitemap-generating lib/cli
Index
Variables
Functions
- isAllowDeny()
- isPriceType()
- isResolution()
- isValidChangeFreq()
- isValidYesNo()
- lineSeparatedURLsToSitemapOptions()
- mergeStreams()
- normalizeURL()
- parseSitemap()
- parseSitemapIndex()
- simpleSitemapAndIndex()
- streamToPromise()
- validateLimit()
- validatePath()
- validatePublicBasePath()
- validateSMIOptions()
- validateURL()
- validateXSLUrl()
- xmlLint()
Classes
Interfaces
Enums
TagNames
- 'expires'
- 'image:caption'
- 'image:geo_location'
- 'image:image'
- 'image:license'
- 'image:loc'
- 'image:title'
- 'mobile:mobile'
- 'news:access'
- 'news:genres'
- 'news:keywords'
- 'news:language'
- 'news:name'
- 'news:news'
- 'news:publication_date'
- 'news:publication'
- 'news:stock_tickers'
- 'news:title'
- 'video:category'
- 'video:content_loc'
- 'video:description'
- 'video:duration'
- 'video:expiration_date'
- 'video:family_friendly'
- 'video:gallery_loc'
- 'video:id'
- 'video:live'
- 'video:platform'
- 'video:player_loc'
- 'video:price'
- 'video:publication_date'
- 'video:rating'
- 'video:requires_subscription'
- 'video:restriction'
- 'video:tag'
- 'video:thumbnail_loc'
- 'video:title'
- 'video:uploader'
- 'video:video'
- 'video:view_count'
- 'xhtml:link'
- changefreq
- lastmod
- loc
- priority
- url
- urlset
Type Aliases
Variables
variable DEFAULT_SITEMAP_ITEM_LIMIT
const DEFAULT_SITEMAP_ITEM_LIMIT: number;Default maximum number of items in each sitemap XML file Set below the max to leave room for URLs added during processing
See Also
https://www.sitemaps.org/protocol.html#index
variable LIMITS
const LIMITS: { readonly MAX_URL_LENGTH: 2048; readonly URL_PROTOCOL_REGEX: RegExp; readonly MIN_SITEMAP_ITEM_LIMIT: 1; readonly MAX_SITEMAP_ITEM_LIMIT: 50000; readonly MAX_VIDEO_TITLE_LENGTH: 100; readonly MAX_VIDEO_DESCRIPTION_LENGTH: 2048; readonly MAX_VIDEO_CATEGORY_LENGTH: 256; readonly MAX_TAGS_PER_VIDEO: 32; readonly MAX_NEWS_TITLE_LENGTH: 200; readonly MAX_NEWS_NAME_LENGTH: 256; readonly MAX_IMAGE_CAPTION_LENGTH: 512; readonly MAX_IMAGE_TITLE_LENGTH: 512; readonly MAX_IMAGES_PER_URL: 1000; readonly MAX_VIDEOS_PER_URL: 100; readonly MAX_LINKS_PER_URL: 100; readonly MAX_URL_ENTRIES: 50000; readonly ISO_DATE_REGEX: RegExp; readonly MAX_CUSTOM_NAMESPACES: 20; readonly MAX_NAMESPACE_LENGTH: 512;};Security limits for sitemap generation and parsing
These limits are based on: - sitemaps.org protocol specification - Security best practices to prevent DoS and injection attacks - Google's sitemap extension specifications
See Also
https://www.sitemaps.org/protocol.html
https://developers.google.com/search/docs/advanced/sitemaps/build-sitemap
variable validators
const validators: { [index: string]: RegExp };Functions
function isAllowDeny
isAllowDeny: (ad: string) => ad is EnumAllowDeny;Type guard to check if a string is a valid allow/deny value
function isPriceType
isPriceType: (pt: string | PriceType) => pt is PriceType;Type guard to check if a string is a valid price type
function isResolution
isResolution: (res: string) => res is Resolution;Type guard to check if a string is a valid resolution
function isValidChangeFreq
isValidChangeFreq: (freq: string) => freq is EnumChangefreq;function isValidYesNo
isValidYesNo: (yn: string) => yn is EnumYesNo;Type guard to check if a string is a valid yes/no value
function lineSeparatedURLsToSitemapOptions
lineSeparatedURLsToSitemapOptions: ( stream: Readable, { isJSON }?: { isJSON?: boolean }) => Readable;Takes a stream likely from fs.createReadStream('./path') and returns a stream of sitemap items
Parameter stream
a stream of line separated urls.
Parameter
opts.isJSON is the stream line separated JSON. leave undefined to guess
function mergeStreams
mergeStreams: (streams: Readable[], options?: TransformOptions) => Readable;Combines multiple streams into one
Parameter streams
the streams to combine
function normalizeURL
normalizeURL: ( elem: string | SitemapItemLoose, hostname?: string, lastmodDateOnly?: boolean) => SitemapItem;Converts the passed in sitemap entry into one capable of being consumed by SitemapItem
Parameter elem
the string or object to be converted
Parameter hostname
Returns
SitemapItemOptions a strict sitemap item option
function parseSitemap
parseSitemap: (xml: Readable) => Promise<SitemapItem[]>;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) ) ```
Parameter xml
what to parse {Promise<SitemapItem[]>} resolves with list of sitemap items that can be fed into a SitemapStream. Rejects with an Error object.
function parseSitemapIndex
parseSitemapIndex: (xml: Readable, maxEntries?: number) => Promise<IndexItem[]>;Read xml and resolve with the configuration that would produce it or reject with an error ``` const { createReadStream } = require('fs') const { parseSitemapIndex, createSitemap } = require('sitemap') parseSitemapIndex(createReadStream('./example-index.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) ) ```
Parameter xml
what to parse
Parameter maxEntries
Maximum number of sitemap entries to parse (default: 50,000 per sitemaps.org spec) {Promise<IndexItem[]>} resolves with list of index items that can be fed into a SitemapIndexStream. Rejects with an Error object.
function simpleSitemapAndIndex
simpleSitemapAndIndex: ({ hostname, sitemapHostname, sourceData, destinationDir, limit, gzip, publicBasePath, xslUrl,}: SimpleSitemapAndIndexOptions) => Promise<void>;A simpler interface for creating sitemaps and indexes. Automatically handles splitting large datasets into multiple sitemap files.
Parameter options
Configuration options
Returns
A promise that resolves when all sitemaps and the index are written
Throws
{InvalidHostnameError} If hostname or sitemapHostname is invalid
Throws
{InvalidPathError} If destinationDir contains path traversal
Throws
{InvalidPublicBasePathError} If publicBasePath is invalid
Throws
{InvalidLimitError} If limit is out of range
Throws
{InvalidXSLUrlError} If xslUrl is invalid
Throws
{Error} If sourceData type is not supported
function streamToPromise
streamToPromise: (stream: Readable) => Promise<Buffer>;Converts a readable stream into a promise that resolves with the concatenated data from the stream.
The function listens for 'data' events from the stream, and when the stream ends, it resolves the promise with the concatenated data. If an error occurs while reading from the stream, the promise is rejected with the error.
⚠️ CAUTION: This function should not generally be used in production / when writing to files as it holds a copy of the entire file contents in memory until finished.
Parameter stream
The readable stream to convert to a promise.
Returns
{Promise} A promise that resolves with the concatenated data from the stream as a Buffer, or rejects with an error if one occurred while reading from the stream. If the stream is empty, the promise is rejected with an EmptyStream error.
Throws
{EmptyStream} If the stream is empty.
function validateLimit
validateLimit: (limit: number) => void;Validates that a limit is within acceptable range per sitemaps.org spec
Security: This function enforces sitemap size limits (1-50,000 URLs per sitemap) as specified by sitemaps.org. This prevents resource exhaustion attacks and ensures compliance with search engine requirements.
Parameter limit
The limit to validate
Throws
{InvalidLimitError} If the limit is out of range
function validatePath
validatePath: (path: string, paramName: string) => void;Validates that a path doesn't contain path traversal sequences
Security: This function prevents path traversal attacks by detecting any occurrence of '..' in the path, whether it appears as '../', '/..', or standalone. This prevents attackers from accessing files outside the intended directory structure.
Parameter path
The path to validate
Parameter paramName
The parameter name for error messages
Throws
{InvalidPathError} If the path contains traversal sequences
function validatePublicBasePath
validatePublicBasePath: (publicBasePath: string) => void;Validates that a public base path is safe for URL construction
Security: This function prevents path traversal attacks and validates that the path is safe for use in URL construction within sitemap indexes. It checks for '..' sequences, null bytes, and invalid whitespace that could be used to manipulate URL structure or inject malicious content.
Parameter publicBasePath
The public base path to validate
Throws
{InvalidPublicBasePathError} If the path is invalid
function validateSMIOptions
validateSMIOptions: ( conf: SitemapItem, level?: ErrorLevel, errorHandler?: ErrorHandler) => SitemapItem;Verifies all data passed in will comply with sitemap spec.
Parameter conf
Options to validate
Parameter level
logging level
Parameter errorHandler
error handling func
function validateURL
validateURL: (url: string, paramName: string) => void;Validates that a URL is well-formed and meets security requirements
Security: This function enforces that URLs use safe protocols (http/https), are within reasonable length limits (2048 chars per sitemaps.org spec), and can be properly parsed. This prevents protocol injection attacks and ensures compliance with sitemap specifications.
Parameter url
The URL to validate
Parameter paramName
The parameter name for error messages
Throws
{InvalidHostnameError} If the URL is invalid
function validateXSLUrl
validateXSLUrl: (xslUrl: string) => void;Validates that an XSL URL is safe and well-formed
Security: This function validates XSL stylesheet URLs to prevent injection attacks. It blocks dangerous protocols and content patterns that could be used for XSS or other attacks. The validation uses case-insensitive matching to catch obfuscated attacks.
Parameter xslUrl
The XSL URL to validate
Throws
{InvalidXSLUrlError} If the URL is invalid
function xmlLint
xmlLint: (xml: string | Readable) => Promise<void>;Verify the passed in xml is valid. Requires xmllib be installed
Security: This function always pipes XML content via stdin to prevent command injection vulnerabilities. Never pass user-controlled strings as file path arguments to xmllint.
Parameter xml
what you want validated (string or Readable stream) {Promise} resolves on valid rejects [error stderr]
Classes
class ChangeFreqInvalidError
class ChangeFreqInvalidError extends Error {}changefreq property in sitemap is invalid
constructor
constructor(url: string, changefreq: any);class EmptySitemap
class EmptySitemap extends Error {}constructor
constructor();class EmptyStream
class EmptyStream extends Error {}constructor
constructor();class IndexObjectStreamToJSON
class IndexObjectStreamToJSON extends Transform {}A Transform that converts a stream of objects into a JSON Array or a line separated stringified JSON
Parameter lineSeparated
whether to separate entries by a new line or comma
constructor
constructor(opts?: IndexObjectStreamToJSONOptions);property firstWritten
firstWritten: boolean;property lineSeparated
lineSeparated: boolean;class InvalidAttr
class InvalidAttr extends Error {}constructor
constructor(key: string);class InvalidAttrValue
class InvalidAttrValue extends Error {}constructor
constructor(key: string, val: any, validator: RegExp);class InvalidHostnameError
class InvalidHostnameError extends Error {}constructor
constructor(hostname: string, reason: string);class InvalidLimitError
class InvalidLimitError extends Error {}constructor
constructor(limit: any);class InvalidNewsAccessValue
class InvalidNewsAccessValue extends Error {}constructor
constructor(url: string, access: any);class InvalidNewsFormat
class InvalidNewsFormat extends Error {}constructor
constructor(url: string);class InvalidPathError
class InvalidPathError extends Error {}constructor
constructor(path: string, reason: string);class InvalidPublicBasePathError
class InvalidPublicBasePathError extends Error {}constructor
constructor(publicBasePath: string, reason: string);class InvalidVideoCategory
class InvalidVideoCategory extends Error {}constructor
constructor(url: string, count: number);class InvalidVideoDescription
class InvalidVideoDescription extends Error {}constructor
constructor(url: string, length: number);class InvalidVideoDuration
class InvalidVideoDuration extends Error {}constructor
constructor(url: string, duration: any);class InvalidVideoFamilyFriendly
class InvalidVideoFamilyFriendly extends Error {}constructor
constructor(url: string, fam: string);class InvalidVideoFormat
class InvalidVideoFormat extends Error {}constructor
constructor(url: string);class InvalidVideoPriceCurrency
class InvalidVideoPriceCurrency extends Error {}constructor
constructor(url: string, currency: string);class InvalidVideoPriceType
class InvalidVideoPriceType extends Error {}constructor
constructor(url: string, priceType?: string, price?: string);class InvalidVideoRating
class InvalidVideoRating extends Error {}constructor
constructor(url: string, title: any, rating: any);class InvalidVideoResolution
class InvalidVideoResolution extends Error {}constructor
constructor(url: string, resolution: string);class InvalidVideoRestriction
class InvalidVideoRestriction extends Error {}constructor
constructor(url: string, code: string);class InvalidVideoRestrictionRelationship
class InvalidVideoRestrictionRelationship extends Error {}constructor
constructor(url: string, val?: string);class InvalidVideoTagCount
class InvalidVideoTagCount extends Error {}constructor
constructor(url: string, count: number);class InvalidVideoTitle
class InvalidVideoTitle extends Error {}constructor
constructor(url: string, length: number);class InvalidVideoViewCount
class InvalidVideoViewCount extends Error {}constructor
constructor(url: string, count: number);class InvalidXMLAttributeNameError
class InvalidXMLAttributeNameError extends Error {}constructor
constructor(attributeName: string);class InvalidXSLUrlError
class InvalidXSLUrlError extends Error {}constructor
constructor(xslUrl: string, reason: string);class NoConfigError
class NoConfigError extends Error {}Config was not passed to SitemapItem constructor
constructor
constructor(message?: string);class NoURLError
class NoURLError extends Error {}URL in SitemapItem does not exist
constructor
constructor(message?: string);class ObjectStreamToJSON
class ObjectStreamToJSON extends Transform {}A Transform that converts a stream of objects into a JSON Array or a line separated stringified JSON
Parameter lineSeparated
whether to separate entries by a new line or comma
constructor
constructor(opts?: ObjectStreamToJSONOptions);property firstWritten
firstWritten: boolean;property lineSeparated
lineSeparated: boolean;class PriorityInvalidError
class PriorityInvalidError extends Error {}priority property in sitemap is invalid
constructor
constructor(url: string, priority: any);class ReadlineStream
class ReadlineStream extends Readable {}Wraps node's ReadLine in a stream
constructor
constructor(options: ReadlineStreamOptions);class SitemapAndIndexStream
class SitemapAndIndexStream extends SitemapIndexStream {}SitemapAndIndexStreamis a Transform stream that takes in sitemap items, writes them to sitemap files, adds the sitemap files to a sitemap index, and creates new sitemap files when the count limit is reached.It waits for the target stream of the current sitemap file to finish before moving on to the next if the target stream is returned by the
getSitemapStreamcallback in the 3rd position of the tuple.⚠️ CAUTION: This object is
readableand must be read (e.g. piped to a file or to /dev/null) beforefinishwill be emitted. Failure to read the stream will result in hangs.{SitemapIndexStream}
constructor
constructor(opts: SitemapAndIndexStreamOptions);SitemapAndIndexStreamis a Transform stream that takes in sitemap items, writes them to sitemap files, adds the sitemap files to a sitemap index, and creates new sitemap files when the count limit is reached.It waits for the target stream of the current sitemap file to finish before moving on to the next if the target stream is returned by the
getSitemapStreamcallback in the 3rd position of the tuple.⚠️ CAUTION: This object is
readableand must be read (e.g. piped to a file or to /dev/null) beforefinishwill be emitted. Failure to read the stream will result in hangs.Parameter opts
Stream options.
class SitemapIndexStream
class SitemapIndexStream extends Transform {}SitemapIndexStreamis a Transform stream that takesIndexItems or sitemap URL strings and outputs a stream of sitemap index XML.It automatically handles the XML declaration and the opening and closing tags for the sitemap index.
⚠️ CAUTION: This object is
readableand must be read (e.g. piped to a file or to /dev/null) beforefinishwill be emitted. Failure to read the stream will result in hangs.{Transform}
constructor
constructor(opts?: SitemapIndexStreamOptions);SitemapIndexStreamis a Transform stream that takesIndexItems or sitemap URL strings and outputs a stream of sitemap index XML.It automatically handles the XML declaration and the opening and closing tags for the sitemap index.
⚠️ CAUTION: This object is
readableand must be read (e.g. piped to a file or to /dev/null) beforefinishwill be emitted. Failure to read the stream will result in hangs.Parameter opts
Stream options.
property lastmodDateOnly
lastmodDateOnly: boolean;property level
level: ErrorLevel;property xslUrl
xslUrl?: string;class SitemapItemStream
class SitemapItemStream extends Transform {}Takes a stream of SitemapItemOptions and spits out xml for each
Parameter level
Error level
Example 1
// writes https://example.comhttps://example.com/2 const smis = new SitemapItemStream({level: 'warn'}) smis.pipe(writestream) smis.write({url: 'https://example.com', img: [], video: [], links: []}) smis.write({url: 'https://example.com/2', img: [], video: [], links: []}) smis.end()
constructor
constructor(opts?: SitemapItemStreamOptions);property level
level: ErrorLevel;class SitemapStream
class SitemapStream extends Transform {}A [Transform](https://nodejs.org/api/stream.html#stream_implementing_a_transform_stream) for turning a [Readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) of either [SitemapItemOptions](#sitemap-item-options) or url strings into a Sitemap. The readable stream it transforms **must** be in object mode.
Parameter opts
Configuration options
Parameter
{string} [opts.hostname] - Base URL for relative paths. Must use http:// or https:// protocol
Parameter
{ErrorLevel} [opts.level=ErrorLevel.WARN] - Error handling level (SILENT, WARN, or THROW)
Parameter
{boolean} [opts.lastmodDateOnly=false] - Format lastmod as date only (YYYY-MM-DD)
Parameter
{NSArgs} [opts.xmlns] - Control which XML namespaces to include in output
Parameter
{string} [opts.xslUrl] - URL to XSL stylesheet for sitemap display. Must use http:// or https://
Parameter
{ErrorHandler} [opts.errorHandler] - Custom error handler function
Throws
{InvalidHostnameError} If hostname is provided but invalid (non-http(s), malformed, or >2048 chars)
Throws
{InvalidXSLUrlError} If xslUrl is provided but invalid (non-http(s), malformed, >2048 chars, or contains malicious content)
Throws
{Error} If xmlns.custom contains invalid namespace declarations
Example 1
const stream = new SitemapStream({hostname: 'https://example.com',level: ErrorLevel.THROW});stream.write({ url: '/page', changefreq: 'daily' });stream.end();- Hostname and xslUrl are validated to prevent URL injection attacks - Custom namespaces are validated to prevent XML injection - All URLs are normalized and validated before output - XML content is properly escaped to prevent injection
constructor
constructor(opts?: SitemapStreamOptions);property errorHandler
errorHandler?: ErrorHandler;property hasHeadOutput
hasHeadOutput: boolean;property hostname
hostname?: string;property lastmodDateOnly
lastmodDateOnly: boolean;property level
level: ErrorLevel;property xmlNS
xmlNS: NSArgs;property xslUrl
xslUrl?: string;class UndefinedTargetFolder
class UndefinedTargetFolder extends Error {}SitemapIndex target Folder does not exists
constructor
constructor(message?: string);class XMLLintUnavailable
class XMLLintUnavailable extends Error {}constructor
constructor(message?: string);class XMLToSitemapIndexStream
class XMLToSitemapIndexStream extends Transform {}Takes a stream of xml and transforms it into a stream of IndexItems Use this to parse existing sitemap indices into config options compatible with this library
constructor
constructor(opts?: XMLToSitemapIndexItemStreamOptions);property error
error: Error;property level
level: ErrorLevel;property logger
logger: Logger;property saxStream
saxStream: SAXStream;class XMLToSitemapItemStream
class XMLToSitemapItemStream extends Transform {}Takes a stream of xml and transforms it into a stream of SitemapItems Use this to parse existing sitemaps into config options compatible with this library
constructor
constructor(opts?: XMLToSitemapItemStreamOptions);property errors
errors: Error[];All errors encountered during parsing. Each validation failure is captured here for comprehensive error reporting.
property level
level: ErrorLevel;property logger
logger: Logger;property saxStream
saxStream: SAXStream;property urlCount
urlCount: number;Interfaces
interface Img
interface Img {}Sitemap Image https://support.google.com/webmasters/answer/178636?hl=en&ref_topic=4581190
property caption
caption?: string;The caption of the image
Example 1
'Thanksgiving dinner'
property geoLocation
geoLocation?: string;The geographic location of the image.
Example 1
'Limerick, Ireland'
property license
license?: string;A URL to the license of the image.
Example 1
'https://example.com/license.txt'
property title
title?: string;The title of the image
Example 1
'Star Wars EP IV'
property url
url: string;The URL of the image
Example 1
'https://example.com/image.jpg'
interface IndexObjectStreamToJSONOptions
interface IndexObjectStreamToJSONOptions extends TransformOptions {}property lineSeparated
lineSeparated: boolean;interface LinkItem
interface LinkItem {}https://support.google.com/webmasters/answer/189077
interface NewsItem
interface NewsItem {}https://support.google.com/webmasters/answer/74288?hl=en&ref_topic=4581190
property access
access?: 'Registration' | 'Subscription';property genres
genres?: string;Example 1
'PressRelease, Blog'
property keywords
keywords?: string;Example 1
'business, merger, acquisition'
property publication
publication: { name: string; /** * The `<language>` is the language of your publication. Use an ISO 639 * language code (2 or 3 letters). */ language: string;};property publication_date
publication_date: string;Article publication date in W3C format, using either the "complete date" (YYYY-MM-DD) format or the "complete date plus hours, minutes, and seconds"
property stock_tickers
stock_tickers?: string;Example 1
'NASDAQ:A, NASDAQ:B'
property title
title: string;The title of the news article
Example 1
'Companies A, B in Merger Talks'
interface ObjectStreamToJSONOptions
interface ObjectStreamToJSONOptions extends TransformOptions {}property lineSeparated
lineSeparated: boolean;interface ReadlineStreamOptions
interface ReadlineStreamOptions extends ReadableOptions {}property input
input: Readable;interface SimpleSitemapAndIndexOptions
interface SimpleSitemapAndIndexOptions {}Options for the simpleSitemapAndIndex function
property destinationDir
destinationDir: string;Where to write the sitemaps and index Must be a relative path without path traversal sequences
property gzip
gzip?: boolean;Whether to compress the written files true
property hostname
hostname: string;The hostname for all URLs Must be a valid http:// or https:// URL
property limit
limit?: number;How many URLs to write before switching to a new file Must be between 1 and 50,000 per sitemaps.org spec 50000
property publicBasePath
publicBasePath?: string;Where the sitemaps are relative to the hostname. Defaults to root. Must not contain path traversal sequences
property sitemapHostname
sitemapHostname?: string;The hostname for the sitemaps if different than hostname Must be a valid http:// or https:// URL
property sourceData
sourceData: SitemapItemLoose[] | string | Readable | string[];The urls you want to make a sitemap out of. Can be an array of items, a file path string, a Readable stream, or an array of strings
property xslUrl
xslUrl?: string;Optional URL to an XSL stylesheet Must be a valid http:// or https:// URL
interface SitemapAndIndexStreamOptions
interface SitemapAndIndexStreamOptions extends SitemapIndexStreamOptions {}Options for the SitemapAndIndexStream
{SitemapIndexStreamOptions}
property getSitemapStream
getSitemapStream: getSitemapStreamFunc;Callback for SitemapIndexAndStream that creates a new sitemap stream for a given sitemap index.
Called when a new sitemap file is needed.
The write stream is the destination where the sitemap was piped. SitemapAndIndexStream will wait for the
finishevent on each sitemap's write stream before moving on to the next sitemap. This ensures that the contents of the write stream will be fully written before being used by any following operations (e.g. uploading, reading contents for unit tests).Parameter i
The index of the sitemap file
Returns
A tuple containing the index item to be written into the sitemap index, the sitemap stream, and the write stream for the sitemap pipe destination
property limit
limit?: number;Max number of items in each sitemap XML file.
When the limit is reached the current sitemap file will be closed, a wait for
finishon the target write stream will happen, and a new sitemap file will be created.Range: 1 - 50,000
45000
interface SitemapIndexStreamOptions
interface SitemapIndexStreamOptions extends TransformOptions {}Options for the SitemapIndexStream
property lastmodDateOnly
lastmodDateOnly?: boolean;Whether to output the lastmod date only (no time)
false
property level
level?: ErrorLevel;How to handle errors in passed in urls
ErrorLevel.WARN
property xslUrl
xslUrl?: string;URL to an XSL stylesheet to include in the XML
interface SitemapItem
interface SitemapItem extends SitemapItemBase {}Strict options for individual sitemap entries
interface SitemapItemLoose
interface SitemapItemLoose extends SitemapItemBase {}Options for individual sitemap entries prior to normalization
property img
img?: string | Img | (string | Img)[];property lastmodfile
lastmodfile?: string | Buffer | URL;property lastmodISO
lastmodISO?: string;property lastmodrealtime
lastmodrealtime?: boolean;property links
links?: LinkItem[];property video
video?: VideoItemLoose | VideoItemLoose[];interface SitemapItemStreamOptions
interface SitemapItemStreamOptions extends TransformOptions {}property level
level?: ErrorLevel;interface SitemapStreamOptions
interface SitemapStreamOptions extends TransformOptions {}property errorHandler
errorHandler?: ErrorHandler;property hostname
hostname?: string;property lastmodDateOnly
lastmodDateOnly?: boolean;property level
level?: ErrorLevel;property xmlns
xmlns?: NSArgs;property xslUrl
xslUrl?: string;interface StringObj
interface StringObj {}Generic object with string keys and any values Used for XML attribute building and other flexible data structures
index signature
[index: string]: any;interface VideoItem
interface VideoItem extends VideoItemBase {}Sitemap video. <https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190>
property family_friendly
family_friendly?: EnumYesNo;property live
live?: EnumYesNo;Indicates whether the video is a live stream. Supported values are yes or no.
property rating
rating?: number;The rating of the video. Supported values are float numbers.
Example 1
2.5
property requires_subscription
requires_subscription?: EnumYesNo;Indicates whether a subscription (either paid or free) is required to view the video. Allowed values are yes or no.
property tag
tag: string[];An arbitrary string tag describing the video. Tags are generally very short descriptions of key concepts associated with a video or piece of content.
Example 1
['Baking']
interface VideoItemLoose
interface VideoItemLoose extends VideoItemBase {}Sitemap video. <https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190>
property family_friendly
family_friendly?: EnumYesNo | boolean;property live
live?: EnumYesNo | boolean;Indicates whether the video is a live stream. Supported values are yes or no.
property rating
rating?: string | number;The rating of the video. Supported values are float numbers.
Example 1
2.5
property requires_subscription
requires_subscription?: EnumYesNo | boolean;property tag
tag?: string | string[];An arbitrary string tag describing the video. Tags are generally very short descriptions of key concepts associated with a video or piece of content.
Example 1
['Baking']
interface XMLToSitemapIndexItemStreamOptions
interface XMLToSitemapIndexItemStreamOptions extends TransformOptions {}interface XMLToSitemapItemStreamOptions
interface XMLToSitemapItemStreamOptions extends TransformOptions {}Enums
enum EnumAllowDeny
enum EnumAllowDeny { ALLOW = 'allow', DENY = 'deny',}enum EnumChangefreq
enum EnumChangefreq { DAILY = 'daily', MONTHLY = 'monthly', ALWAYS = 'always', HOURLY = 'hourly', WEEKLY = 'weekly', YEARLY = 'yearly', NEVER = 'never',}How frequently the page is likely to change. This value provides general information to search engines and may not correlate exactly to how often they crawl the page. Please note that the value of this tag is considered a hint and not a command. See <https://www.sitemaps.org/protocol.html#xmlTagDefinitions> for the acceptable values
enum EnumYesNo
enum EnumYesNo { YES = 'YES', NO = 'NO', Yes = 'Yes', No = 'No', yes = 'yes', no = 'no',}enum ErrorLevel
enum ErrorLevel { SILENT = 'silent', WARN = 'warn', THROW = 'throw',}How to handle errors in passed in urls
enum IndexTagNames
enum IndexTagNames { sitemap = 'sitemap', sitemapindex = 'sitemapindex', loc = 'loc', lastmod = 'lastmod',}member lastmod
lastmod = 'lastmod'member loc
loc = 'loc'member sitemap
sitemap = 'sitemap'member sitemapindex
sitemapindex = 'sitemapindex'enum TagNames
enum TagNames { url = 'url', loc = 'loc', urlset = 'urlset', lastmod = 'lastmod', changefreq = 'changefreq', priority = 'priority', 'video:thumbnail_loc' = 'video:thumbnail_loc', 'video:video' = 'video:video', 'video:title' = 'video:title', 'video:description' = 'video:description', 'video:tag' = 'video:tag', 'video:duration' = 'video:duration', 'video:player_loc' = 'video:player_loc', 'video:content_loc' = 'video:content_loc', 'image:image' = 'image:image', 'image:loc' = 'image:loc', 'image:geo_location' = 'image:geo_location', 'image:license' = 'image:license', 'image:title' = 'image:title', 'image:caption' = 'image:caption', 'video:requires_subscription' = 'video:requires_subscription', 'video:publication_date' = 'video:publication_date', 'video:id' = 'video:id', 'video:restriction' = 'video:restriction', 'video:family_friendly' = 'video:family_friendly', 'video:view_count' = 'video:view_count', 'video:uploader' = 'video:uploader', 'video:expiration_date' = 'video:expiration_date', 'video:platform' = 'video:platform', 'video:price' = 'video:price', 'video:rating' = 'video:rating', 'video:category' = 'video:category', 'video:live' = 'video:live', 'video:gallery_loc' = 'video:gallery_loc', 'news:news' = 'news:news', 'news:publication' = 'news:publication', 'news:name' = 'news:name', 'news:access' = 'news:access', 'news:genres' = 'news:genres', 'news:publication_date' = 'news:publication_date', 'news:title' = 'news:title', 'news:keywords' = 'news:keywords', 'news:stock_tickers' = 'news:stock_tickers', 'news:language' = 'news:language', 'mobile:mobile' = 'mobile:mobile', 'xhtml:link' = 'xhtml:link', 'expires' = 'expires',}member 'expires'
'expires' = 'expires'member 'image:caption'
'image:caption' = 'image:caption'member 'image:geo_location'
'image:geo_location' = 'image:geo_location'member 'image:image'
'image:image' = 'image:image'member 'image:license'
'image:license' = 'image:license'member 'image:loc'
'image:loc' = 'image:loc'member 'image:title'
'image:title' = 'image:title'member 'mobile:mobile'
'mobile:mobile' = 'mobile:mobile'member 'news:access'
'news:access' = 'news:access'member 'news:genres'
'news:genres' = 'news:genres'member 'news:keywords'
'news:keywords' = 'news:keywords'member 'news:language'
'news:language' = 'news:language'member 'news:name'
'news:name' = 'news:name'member 'news:news'
'news:news' = 'news:news'member 'news:publication_date'
'news:publication_date' = 'news:publication_date'member 'news:publication'
'news:publication' = 'news:publication'member 'news:stock_tickers'
'news:stock_tickers' = 'news:stock_tickers'member 'news:title'
'news:title' = 'news:title'member 'video:category'
'video:category' = 'video:category'member 'video:content_loc'
'video:content_loc' = 'video:content_loc'member 'video:description'
'video:description' = 'video:description'member 'video:duration'
'video:duration' = 'video:duration'member 'video:expiration_date'
'video:expiration_date' = 'video:expiration_date'member 'video:family_friendly'
'video:family_friendly' = 'video:family_friendly'member 'video:gallery_loc'
'video:gallery_loc' = 'video:gallery_loc'member 'video:id'
'video:id' = 'video:id'member 'video:live'
'video:live' = 'video:live'member 'video:platform'
'video:platform' = 'video:platform'member 'video:player_loc'
'video:player_loc' = 'video:player_loc'member 'video:price'
'video:price' = 'video:price'member 'video:publication_date'
'video:publication_date' = 'video:publication_date'member 'video:rating'
'video:rating' = 'video:rating'member 'video:requires_subscription'
'video:requires_subscription' = 'video:requires_subscription'member 'video:restriction'
'video:restriction' = 'video:restriction'member 'video:tag'
'video:tag' = 'video:tag'member 'video:thumbnail_loc'
'video:thumbnail_loc' = 'video:thumbnail_loc'member 'video:title'
'video:title' = 'video:title'member 'video:uploader'
'video:uploader' = 'video:uploader'member 'video:video'
'video:video' = 'video:video'member 'video:view_count'
'video:view_count' = 'video:view_count'member 'xhtml:link'
'xhtml:link' = 'xhtml:link'member changefreq
changefreq = 'changefreq'member lastmod
lastmod = 'lastmod'member loc
loc = 'loc'member priority
priority = 'priority'member url
url = 'url'member urlset
urlset = 'urlset'Type Aliases
type ErrorHandler
type ErrorHandler = (error: Error, level: ErrorLevel) => void;type PriceType
type PriceType = 'rent' | 'purchase' | 'RENT' | 'PURCHASE';Video price type - supports both lowercase and uppercase variants as allowed by the Google Video Sitemap specification
See Also
https://developers.google.com/search/docs/advanced/sitemaps/video-sitemaps
type Resolution
type Resolution = 'HD' | 'hd' | 'sd' | 'SD';Video resolution - supports both lowercase and uppercase variants as allowed by the Google Video Sitemap specification
See Also
https://developers.google.com/search/docs/advanced/sitemaps/video-sitemaps
Package Files (13)
- dist/esm/index.d.ts
- dist/esm/lib/constants.d.ts
- dist/esm/lib/errors.d.ts
- dist/esm/lib/sitemap-index-parser.d.ts
- dist/esm/lib/sitemap-index-stream.d.ts
- dist/esm/lib/sitemap-item-stream.d.ts
- dist/esm/lib/sitemap-parser.d.ts
- dist/esm/lib/sitemap-simple.d.ts
- dist/esm/lib/sitemap-stream.d.ts
- dist/esm/lib/types.d.ts
- dist/esm/lib/utils.d.ts
- dist/esm/lib/validation.d.ts
- dist/esm/lib/xmllint.d.ts
Dependencies (4)
Dev Dependencies (24)
- @babel/core
- @eslint/eslintrc
- @eslint/js
- @types/jest
- @types/memorystream
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- eslint
- eslint-config-prettier
- eslint-plugin-jest
- eslint-plugin-prettier
- express
- globals
- husky
- jest
- lint-staged
- memorystream
- prettier
- sort-package-json
- stats-lite
- stream-json
- through2-map
- ts-jest
- typescript
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/sitemap.
- Markdown[](https://www.jsdocs.io/package/sitemap)
- HTML<a href="https://www.jsdocs.io/package/sitemap"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 6081 ms. - Missing or incorrect documentation? Open an issue for this package.
