mirror of
https://github.com/veggiemonk/awesome-docker.git
synced 2024-12-22 22:19:30 -05:00
fix sitemap build step
This commit is contained in:
parent
2f47b5dbe4
commit
2917fe08a7
35
build.js
35
build.js
@ -2,7 +2,8 @@ const fs = require('fs-extra');
|
|||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
const showdown = require('showdown');
|
const showdown = require('showdown');
|
||||||
const Parcel = require('parcel-bundler');
|
const Parcel = require('parcel-bundler');
|
||||||
const sm = require('sitemap');
|
// const sm = require('sitemap');
|
||||||
|
const { SitemapStream, streamToPromise } = require('sitemap');
|
||||||
|
|
||||||
process.env.NODE_ENV = 'production';
|
process.env.NODE_ENV = 'production';
|
||||||
|
|
||||||
@ -25,20 +26,6 @@ const WEBSITE_FOLDER = 'website';
|
|||||||
const indexTemplate = `${WEBSITE_FOLDER}/index.tmpl.html`;
|
const indexTemplate = `${WEBSITE_FOLDER}/index.tmpl.html`;
|
||||||
const indexDestination = `${WEBSITE_FOLDER}/index.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() {
|
async function processIndex() {
|
||||||
const converter = new showdown.Converter({
|
const converter = new showdown.Converter({
|
||||||
omitExtraWLInCodeBlocks: true,
|
omitExtraWLInCodeBlocks: true,
|
||||||
@ -88,11 +75,25 @@ const bundle = () => {
|
|||||||
publicURL: '/',
|
publicURL: '/',
|
||||||
})
|
})
|
||||||
.bundle()
|
.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
|
// Creates a sitemap object given the input configuration with URLs
|
||||||
fs.outputFile(
|
fs.outputFile(
|
||||||
'dist/sitemap.xml',
|
'dist/sitemap.xml',
|
||||||
sm.createSitemap(sitemapOpts).toString(),
|
// sm.createSitemap(sitemapOpts).toString(),
|
||||||
|
sm.toString()
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user