hongbo-miao/hongbomiao.com

View on GitHub
web/scripts/generateSitemap.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { SitemapItemLoose, SitemapStream, SitemapStreamOptions, streamToPromise } from 'sitemap';

const generateSitemap = async (
  options: SitemapStreamOptions,
  links: ReadonlyArray<SitemapItemLoose>,
): Promise<string> => {
  const stream = new SitemapStream(options);
  links.forEach((link) => stream.write(link));
  stream.end();
  return streamToPromise(stream).then((data) => String(data));
};

export default generateSitemap;