← @mortar-kit/core

sitemapfunction

import { sitemap } from '@mortar-kit/core'

function sitemap(content: ContentSource, collections: readonly AnyCollection[], options: SitemapOptions): Promise<string>

A sitemap (sitemaps.org XML) of every document whose collection has a url, read through content. Serve it at /sitemap.xml.

Parameters

content: ContentSource
collections: readonly AnyCollection[]

Returns

Promise<string>

Example

if (path === '/sitemap.xml') return new Response(await sitemap(content, collections, { origin }), { headers: { 'content-type': 'application/xml' } });