How to use the sitemap.createSitemapIndex function in sitemap

To help you get started, we’ve selected a few sitemap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gatsbyjs / gatsby / packages / gatsby-plugin-sitemap / src / gatsby-node.js View on Github external
// sitemap-index.xml is default file name. (https://git.io/fhNgG)
    const indexFilePath = path.join(
      publicPath,
      `${rest.sitemapName || `sitemap`}-index.xml`
    )
    const sitemapIndexOptions = {
      ...rest,
      hostname: hostname || withoutTrailingSlash(siteUrl),
      targetFolder: publicPath,
      urls,
      callback: error => {
        if (error) throw new Error(error)
        renameFile(indexFilePath, saved).then(resolve)
      },
    }
    sitemap.createSitemapIndex(sitemapIndexOptions)
  })
}