export type GetApiSitemapLocaleXmlArgs = {locale: 'en' | 'de' | 'fr' | 'es' | 'it' | 'ca' | 'pl' | 'nl' | 'pt-br'}; export type GetApiSitemapLocaleXmlOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Sitemap of all published pages for a locale * * GET /sitemap/{locale}.xml */ export const getApiSitemapLocaleXml = async (args: GetApiSitemapLocaleXmlArgs, options?: GetApiSitemapLocaleXmlOptions) => { const {baseUrl = "https://www.1global.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/xml") const url = `${baseUrl.replace(/\/+$/, '')}/sitemap/${encodeURIComponent(String(args.locale))}.xml${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };