How to use the sitemap.createSitemap 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 numenta / numenta-web / numenta.org / gatsby-node.js View on Github external
)
        }
      }
      const text = [title, content, details.join(' ')].join(' ')
      return {path, text, title}
    })

  // prep sitemap
  const urls = pages
    .filter((page) => page.path)
    .map(({path}) => ({
      url: path,
      changefreq: 'monthly',  // 'daily' @TODO dynamic per file dates, etc
      priority: 0.5,  // @TODO dynamic per url length (shorter=higher)
    }))
  const sitemap = createSitemap({
    hostname: 'http://numenta.org',  // @TODO stringify hostname in config
    urls,
  })

  console.log('postBuild generate search index')
  fs.writeFileSync('public/_searchIndex.json', JSON.stringify(searches))

  console.log('postBuild generate sitemap')
  fs.writeFileSync('public/sitemap.xml', sitemap.toString())

  console.log('postBuild static asset copy')
  return ncp('static/', 'public/', callback)
}
github surmon-china / nodepress / src / modules / sitemap / sitemap.service.ts View on Github external
private reBuild(): Promise {
    this.sitemap = sitemap.createSitemap({
      cacheTime: 666666,
      urls: [...this.pagesMap],
      // hostname: APP_CONFIG.APP.URL,
    });
    return Promise.all([
      this.addTagsMap(),
      this.addCategoriesMap(),
      this.addArticlesMap(),
    ])
      .then(_ => Promise.resolve(this.sitemap))
      .catch(error => {
        console.warn('生成网站地图前获取数据库发生错误', error);
        return Promise.resolve(this.sitemap);
      });
  }
github nuxt-community / modules / modules / sitemap / index.js View on Github external
function createSitemap (options, routes, req) {
  const sitemapConfig = {}

  // Set sitemap hostname
  sitemapConfig.hostname = options.hostname ||
    (req && `${isHTTPS(req) ? 'https' : 'http'}://${req.headers.host}`) || `http://${hostname()}`

  // Set urls and ensure they are unique
  sitemapConfig.urls = uniq(routes)

  // Set cacheTime
  sitemapConfig.cacheTime = options.cacheTime || 0

  // Create promisified instance and return
  const sitemap = sm.createSitemap(sitemapConfig)
  sitemap.toXML = pify(sitemap.toXML)

  return sitemap
}
github richardzcode / Dochameleon / lib / core / Assets.js View on Github external
urls.push({url, changefreq: 'weekly', priority: 0.5});
      });

    this.site.blog.metadatas
      .forEach(metadata => {
        const url = metadata.permalink();
        urls.push({url, changefreq: 'weekly', priority: 0.3});
      });

    this.site.docs.metadatas
      .forEach(metadata => {
        const url = metadata.permalink();
        urls.push({url, changefreq: 'weekly', priority: 0.3});
      });

    const sitemap = createSitemap({
      hostname: this.site.rootUrl,
      cacheTime: 600 * 1000, // 600 sec - cache purge period
      urls: urls,
    });

    return new Promise((resolve, reject) => {
      sitemap.toXML((err, xml) => {
        if (err) {
          reject('An error has occured.');
        } else {
          resolve(xml);
        }
      });
    });
  }
github ExtraHop / metalsmith-sitemap / lib / index.js View on Github external
return function(files, metalsmith, done) {
    // Create sitemap object
    var sitemap = sm.createSitemap ({
      hostname: hostname
    });

    // Checks whether files should be processed
    function check(file, frontmatter) {
      // Only process files that match the pattern
      if (!match(file, pattern)[0]) {
        return false;
      }

      // Don't process private files
      if (get(frontmatter, privateProperty)) {
        return false;
      }

      return true;
github prisma-archive / prep / src / index.js View on Github external
timeout: 1000,
        dimensions,
        https: false,
        hostname: 'http://localhost',
        useragent: 'Prep',
        minify: false,
        concurrency: 4,
        additionalSitemapUrls: [],
    }, configuration)

    debug('Config prepared', configuration)

    // render sitemap
    const sitemapUrs = configuration.routes.map(route => ({ url: route }))
        .concat(configuration.additionalSitemapUrls.map(route => ({ url: route })))
    const sm = sitemap.createSitemap({
        hostname: configuration.hostname,
        urls: sitemapUrs,
    })
    mkdirp.sync(targetDir)
    fs.writeFileSync(`${targetDir}/sitemap.xml`, sm.toString());

    debug('Sitemap created')

    // start temporary local webserver
    const app = express()
        .use(serveStatic(buildDir))
        .use(fallback('index.html', { root: buildDir }))
    let server
    if (configuration.https) {
        const credentials = {
            key: fs.readFileSync(`${__dirname}/../ssl/key.pem`),
github benmccormick / benmccormickorg / server-src / page-processing.js View on Github external
function generateSiteMap(pages) {
  const sitemap = sm.createSitemap({
    hostname: 'https://benmccormick.org',
    cacheTime: '60000',
    urls: pagesToSitemap(pages),
  });
  console.log('Generating sitemap.xml');
  mkFile('/public/sitemap.xml', sitemap.toString());
}
github socrata / opendatanetwork.com / scripts / sitemap / sitemap.js View on Github external
function createSitemap(urls) {
    return sitemap.createSitemap({
        hostname,
        urls: urls.map(formatSitemapURL)
    });
}
github kuflash / react-router-sitemap / lib / sitemap-builder / index.js View on Github external
export default (hostname = 'http://localhost', paths = []) => {

	return sitemap.createSitemap({
		hostname,
		urls: paths.map(path => ({ url: path })),
	});

};