How to use the sitemap.xml 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 phenomic / phenomic / src / loader-sitemap-webpack-plugin / __tests__ / index.js View on Github external
)
      .toBeFalsy()
      if (stats.hasErrors()) {
        console.error(stats.compilation.errors)
      }

      // doesn't give any warning
      expect(
        stats.hasWarnings()
      )
      .toBeFalsy()
      if (stats.hasWarnings()) {
        console.log(stats.compilation.warnings)
      }

      const sitemap = stats.compilation.assets["sitemap.xml"]
      if (!sitemap) {
        console.log(stats.compilation.assets)
      }

      // should create a xml for the sitemap
      expect(
        sitemap && sitemap._value,
      )
      .toBeTruthy()

      // should contain a filtred entry (urlset)
      expect(
        sitemap._value.includes("
github phenomic / phenomic / src / loader-sitemap-webpack-plugin / index.js View on Github external
const collection = minify(PhenomicLoaderWebpackPlugin.collection)
      const { site_url, collectionOptions } = this.options || {}

      if (!site_url) {
        throw new Error(
          "Missing `site_url` option in sitemap configuration. "
        )
      }

      const sitemap = sm.createSitemap ({
        hostname: site_url,
        urls: enhanceCollection(collection, collectionOptions)
          .map(item => ({ url: item.__url })),
      })

      compilation.assets["sitemap.xml"] = new RawSource(sitemap.toString())

      callback()
    })
  })