sitemap
Version:
Sitemap-generating lib/cli
31 lines (30 loc) • 1.33 kB
TypeScript
import { Transform, type TransformOptions, type TransformCallback } from 'node:stream';
import { type SitemapItem, ErrorLevel } from './types.js';
/**
* Serializes one normalized sitemap item to its `<url>` element. Throws if
* the item can't be written, such as a video attribute that isn't a string.
* Drops an alternate link with no `lang` or `hreflang`.
*
* @param item - A normalized item, as `normalizeURL` returns
* @returns The `<url>…</url>` XML for the item
*/
export declare function sitemapItemToXML(item: SitemapItem): string;
export interface SitemapItemStreamOptions extends TransformOptions {
level?: ErrorLevel;
}
/**
* Takes a stream of SitemapItemOptions and spits out xml for each
* @example
* // writes <url><loc>https://example.com</loc><url><url><loc>https://example.com/2</loc><url>
* 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()
* @param level - Error level
*/
export declare class SitemapItemStream extends Transform {
level: ErrorLevel;
constructor(opts?: SitemapItemStreamOptions);
_transform(item: SitemapItem, encoding: string, callback: TransformCallback): void;
}