How to use the sitemap.buildSitemapIndex 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 HW-Core / universal-pwa / apps / sitemap-gen / express.js View on Github external
}

    Sitemap.sitemaps.map((sitemap, index) => {
        const savePath = fileName.replace('.xml', `-${index}.xml`);

        app.get(basePath + savePath, (req, res) => {
            res.header('Content-Type', 'application/xml');
            res.send(Sitemap.sitemaps[index].toString())
        });

        // push public path for indexing
        sitemapPaths.push(Sitemap.hostname + publicPath + path.basename(savePath));
    });

    // create index string
    const sitemapIndex = sm.buildSitemapIndex({
        urls: sitemapPaths,
        hostname: Sitemap.hostname
    });

    app.get(basePath + fileName, (req, res) => {
        res.header('Content-Type', 'application/xml');
        console.log(sitemapIndex)
        res.send(sitemapIndex)
    });

    return app;
}
github kuflash / react-router-sitemap / lib / index.js View on Github external
return this;
		}

		this.sitemaps.map((sitemap, index) => {
			const savePath = dist.replace('.xml', `-${index}.xml`);

			// write sitemap
			fs.writeFileSync(savePath, sitemap.toString());

			// push public path for indexing
			sitemapPaths.push(this.hostname + publicPath + path.basename(savePath));
		});

		// create index string
		const sitemapIndex = sm.buildSitemapIndex({
			urls: sitemapPaths,
			hostname: this.hostname
		});

		// write sitemap index
		fs.writeFileSync(dist, sitemapIndex);

		return this;
	}
github nuxt-community / sitemap-module / lib / builder.js View on Github external
const hostname = getHostname(options.hostname ? options : { ...options, hostname: defaultHostname }, req, base)
    const url = new URL(path, hostname)
    return url.href
  })

  // Set lastmod for each sitemap
  sitemapIndexConfig.lastmod = options.lastmod

  // Set XML namespaces
  sitemapIndexConfig.xmlNs = options.xmlNs

  // Set XSL url
  sitemapIndexConfig.xslUrl = options.xslUrl

  // Create a sitemapindex
  return sm.buildSitemapIndex(sitemapIndexConfig)
}
github 40818419 / vue-router-sitemap / src / index.js View on Github external
save(dist, publicPath = '/') {
    const sitemapPaths = [];

    this.sitemaps.forEach((sitemap, index) => {
      const savePath = dist.replace('.xml', `-${index}.xml`);
      fs.writeFileSync(savePath, sitemap.toString());
      sitemapPaths.push(this.hostname + publicPath + path.basename(savePath));
    });

    const sitemapIndex = sitemap.buildSitemapIndex({
      urls: sitemapPaths,
      hostname: this.hostname,
    });
    fs.writeFileSync(dist, sitemapIndex);

    return this;
  }
}
github socrata / opendatanetwork.com / scripts / sitemap / sitemap.js View on Github external
return Promise.all(allSitemaps.map(writeSitemap)).then(filenames => {
        const index = sitemap.buildSitemapIndex({
            urls: filenames.map(filename => `${hostname}/sitemap/${filename}`)
        });

        const path = baseDirectory + 'sitemap.xml';
        return fs.writeFile(path, oneLine(index)).then(() => Promise.resolve(path));
    });
}).then(indexPath => {
github mirumee / saleor-storefront / src / sitemap / SitemapGenerator.ts View on Github external
generateSitemapIndex(filename: string) {
    const urls = this.sitemaps.map(filename => `${this.hostname}/${filename}`);
    this.saveToFile(buildSitemapIndex({ urls }).toString(), filename);
  }
github magda-io / magda / magda-web-server / src / buildSitemapRouter.ts View on Github external
.then(async result => {
                    const datasetsPages = result.map(token => {
                        return baseExternalUri
                            .clone()
                            .path(
                                URI.joinPaths(
                                    baseExternalUrl,
                                    "sitemap/dataset/afterToken",
                                    token.toString() + ".xml"
                                ).href()
                            )
                            .href();
                    });

                    const smi = sm.buildSitemapIndex({
                        urls: [
                            baseExternalUri
                                .clone()
                                .path(
                                    URI.joinPaths(
                                        baseExternalUrl,
                                        "sitemap/main.xml"
                                    ).href()
                                )
                                .href()
                        ].concat(datasetsPages)
                    });

                    res.send(smi);
                })
        );