Skip to main content
Version: 3.x

createSitemapFetcher

A higher-order function designed for the creation of a sitemap fetcher.

Usage

📖 see guide for more details

import {
createSitemapFetcher,
type SitemapFetcherContext,
} from "@front-commerce/core";

const fetcher = (context: SitemapFetcherContext) => {
// logic to fetch sitemap entries
};

export default createSitemapFetcher(fetcher);

Parameters

SitemapFetcher

The fetcher parameter is a function that conforms to the SitemapFetcher type. It must accept a single argument of type SitemapFetcherContext and return either a Promise that resolves to an array of SitemapEntry items or an array of SitemapEntry items directly.

SitemapFetcherContext

The context provided to the fetcher function contains the following properties:

PropertyTypeDescription
requestRequestThe Fetch Request instance. You can read the MDN docs to see all of its properties.
appFrontCommerceAppThe FrontCommerceApp instance
unsafe_cachemakeCacheFromRequestAn experimental API that provides cache functionality, returned by the makeCacheFromRequest function. This API is subject to change in the future.
warning

The unsafe_cache property is marked as experimental and may change in future versions. Developers should use it with caution.

We are still working on the cache invalidation for common strategies.