diff --git a/build.js b/build.js index ba83930..2b71bff 100644 --- a/build.js +++ b/build.js @@ -2,7 +2,8 @@ const fs = require('fs-extra'); const cheerio = require('cheerio'); const showdown = require('showdown'); const Parcel = require('parcel-bundler'); -const sm = require('sitemap'); +// const sm = require('sitemap'); +const { SitemapStream, streamToPromise } = require('sitemap'); process.env.NODE_ENV = 'production'; @@ -25,20 +26,6 @@ const WEBSITE_FOLDER = 'website'; const indexTemplate = `${WEBSITE_FOLDER}/index.tmpl.html`; const indexDestination = `${WEBSITE_FOLDER}/index.html`; -const sitemapOpts = { - hostname: 'https://awesome-docker.netlify.com/', - cacheTime: 6000000, // 600 sec (10 min) cache purge period - urls: [ - { - url: '/', - changefreq: 'daily', - priority: 0.8, - lastmodrealtime: true, - lastmodfile: 'dist/index.html', - }, - ], -}; - async function processIndex() { const converter = new showdown.Converter({ omitExtraWLInCodeBlocks: true, @@ -88,11 +75,25 @@ const bundle = () => { publicURL: '/', }) .bundle() - .then(() => + .then(() => { + const smStream = new SitemapStream({ hostname: 'https://awesome-docker.netlify.com/' }); + smStream.write({ + url: '/', + changefreq: 'daily', + priority: 0.8, + lastmodrealtime: true, + lastmodfile: 'dist/index.html', + }); + + smStream.end(); + return streamToPromise(smStream); + }) + .then(sm => // Creates a sitemap object given the input configuration with URLs fs.outputFile( 'dist/sitemap.xml', - sm.createSitemap(sitemapOpts).toString(), + // sm.createSitemap(sitemapOpts).toString(), + sm.toString() ), ); }; diff --git a/package.json b/package.json index 290868d..b6f6463 100644 --- a/package.json +++ b/package.json @@ -35,4 +35,4 @@ "eslint-plugin-prettier": "3.1.2", "prettier": "1.19.1" } -} \ No newline at end of file +}