Skip to content

lib/dynamic-sitemap

function dynamicSitemap(options: DynamicSitemapOptions): AstroIntegration

Defined in: studiocms/packages/studiocms/src/lib/dynamic-sitemap/index.ts:56

Generates a dynamic sitemap integration for Astro.

DynamicSitemapOptions

Configuration options for the dynamic sitemap.

AstroIntegration

The Astro integration object.

The integration adds virtual imports for sitemaps and injects routes for the sitemap index and individual sitemaps.

The options parameter should include:

  • sitemaps: An array of objects, each containing:
    • pluginName: The name of the plugin.
    • sitemapXMLEndpointPath: The entry point path for the sitemap XML.

The function performs the following steps:

  1. Creates a resolver using the current module URL.
  2. Adds virtual imports for the sitemaps.
  3. Injects a route for the sitemap index.
  4. Iterates over the provided sitemaps and injects routes for each sitemap.

If multiple sitemaps have the same pattern, a unique pattern is generated by appending an index.