@arraypress/sitemap
v1.0.0
Published
XML sitemap generation. Simple, fast, zero dependencies.
Maintainers
Readme
@arraypress/sitemap
XML sitemap generation. Simple, fast, zero dependencies.
Installation
npm install @arraypress/sitemapUsage
import { buildSitemap, buildSitemapIndex, sitemapResponse } from '@arraypress/sitemap';
const xml = buildSitemap([
'https://example.com/',
{ url: 'https://example.com/about', lastmod: '2025-01-01', changefreq: 'monthly', priority: 0.8 },
]);
// Serve as a response (works with Cloudflare Workers, Deno, Bun, etc.)
return sitemapResponse(xml);API
buildSitemap(urls)
Build a complete XML sitemap string. Accepts an array of URL strings or objects.
function buildSitemap(urls: (string | SitemapUrl)[]): stringSitemapUrl fields:
| Field | Type | Description |
|-------|------|-------------|
| url | string | Page URL (required) |
| lastmod | string | Last modified date (ISO 8601) |
| changefreq | string | Change frequency (always, hourly, daily, weekly, monthly, yearly, never) |
| priority | number | Priority (0.0 to 1.0) |
buildSitemapIndex(sitemaps)
Build a sitemap index XML string for sites with multiple sitemaps.
function buildSitemapIndex(sitemaps: (string | { url: string; lastmod?: string })[]): stringsitemapResponse(xml)
Create a Response object with Content-Type: application/xml; charset=utf-8.
function sitemapResponse(xml: string): ResponseLicense
MIT
