Sitemap
@warlock.js/sitemap builds sitemaps.org
documents. You add entries and it returns a valid XML document. It has zero
runtime dependencies and knows nothing about Warlock. It has no connector,
no config module, no lifecycle, and no page registry. It only generates
sitemaps; it cannot parse one.
import { Sitemap } from "@warlock.js/sitemap";
const sitemap = new Sitemap({ baseUrl: "https://example.com", changefreq: "weekly" });
sitemap.add({ path: "/" });sitemap.add({ path: "/posts/hello-world", lastmod: new Date(), priority: 0.8 });
await sitemap.saveTo("public/sitemap.xml");Those lines work the same way in an Express handler, a cron script, a
node build-sitemap.mjs, or a Warlock controller.
Two classes, split at the protocol ceiling
Section titled “Two classes, split at the protocol ceiling”The protocol limits one file to 50,000 URLs or 50MB uncompressed.
Sitemapkeeps every entry in memory. That makesentries(), the diagnostics, and a repeatabletoXML()possible. Use it for any site under the ceiling. → Build a sitemapSitemapIndexstreams from source factories. It writes size-capped shards and a master index, then publishes the whole set atomically. It keeps only the current shard in memory. → Large sites
In a Warlock web app
Section titled “In a Warlock web app”You don’t call either class yourself. @warlock.js/web finds your pages,
expands locales, chooses Sitemap or SitemapIndex, generates the file at
warlock build and at boot, and serves /sitemap.xml and /robots.txt. You
configure all of it under web.sitemap in src/config/web.ts:
warlock add sitemap→ In a Warlock app and the full Sitemap and robots.txt guide.
Read by intent
Section titled “Read by intent”- Building one yourself → Build a sitemap
- Past 50,000 URLs, or one file per locale → Large sites
- Warlock web pages,
robots.txt, locales → Sitemap and robots.txt - Method-by-method lookup → API reference