sitemap.xml JavaScript API

Everything the sitemap.xml extension adds to pb_hooks and page code, generated from the TypeScript declarations it ships (your app's types.d.ts has the same, so your editor knows them). For how to use it, see its docs; for Go, the Go API.

$sitemapXml

The app's /sitemap.xml (ext/sitemap-xml). Private paths (robots.txt) are left out of whatever you add.

$sitemapXml.add()

$sitemapXml.add(entries: sitemapXml.Entry | sitemapXml.Entry[] | ((req: sitemapXml.Request) => sitemapXml.Entry[] | Promise<sitemapXml.Entry[]>)): void

Adds URLs: an entry, an array of entries, or a function returning them, run when the sitemap is built (it may query $app). A function that throws is left out and logged.

Parameter Type
entries sitemapXml.Entry | sitemapXml.Entry[] | ((req: sitemapXml.Request) => sitemapXml.Entry[] | Promise<sitemapXml.Entry[]>)

Types

sitemapXml.Entry

A URL: a path on this app ("/blog/hello") or a full URL, with when it last changed if you know.

type sitemapXml.Entry = string | { path: string; lastmod?: string | Date };

sitemapXml.Request

What a source function receives.

Member Type
origin string scheme://host the request reached the app at, e.g. "https://example.com".