awesome-docker/build.js

73 lines
1.7 KiB
Markdown
Raw Normal View History

2018-03-17 15:27:41 +00:00
const fs = require('fs');
const showdown = require('showdown');
const cheerio = require('cheerio');
const Parcel = require('parcel-bundler');
process.env.NODE_ENV = 'production';
2018-04-07 12:38:24 +00:00
process.on('unhandledRejection', error => {
console.log('unhandledRejection', error.message);
});
const readme = 'README.md';
const template = 'website/index.tmpl.html';
const merged = 'website/index.html';
const destination = 'website/index.html';
const includeReadme = ({
md = readme,
templateHTML = template,
dest = merged,
}) => {
2018-03-18 13:37:19 +00:00
const converter = new showdown.Converter({
omitExtraWLInCodeBlocks: true,
simplifiedAutoLink: true,
excludeTrailingPunctuationFromURLs: true,
literalMidWordUnderscores: true,
strikethrough: true,
tables: true,
tablesHeaderId: true,
ghCodeBlocks: true,
tasklists: true,
disableForced4SpacesIndentedSublists: true,
simpleLineBreaks: true,
requireSpaceBeforeHeadingText: true,
ghCompatibleHeaderId: true,
ghMentions: true,
backslashEscapesHTMLTags: true,
emoji: true,
2018-04-07 12:38:24 +00:00
splitAdjacentBlockquotes: true,
2018-03-18 13:37:19 +00:00
});
// converter.setFlavor('github');
console.log('Loading files...');
2018-04-07 12:38:24 +00:00
const indexTemplate = fs.readFileSync(templateHTML, 'utf8');
const markdown = fs.readFileSync(md, 'utf8');
2018-03-18 13:37:19 +00:00
console.log('Merging files...');
2018-04-07 12:38:24 +00:00
const $ = cheerio.load(indexTemplate);
$('#md').append(converter.makeHtml(markdown));
2018-03-18 13:37:19 +00:00
console.log('Writing index.html');
2018-04-07 12:38:24 +00:00
fs.writeFileSync(dest, $.html(), 'utf8');
console.log('DONE 👍');
2018-03-18 14:01:47 +00:00
};
2018-03-18 13:37:19 +00:00
2018-04-07 12:38:24 +00:00
const bundle = (dest = destination) => {
2018-03-18 14:01:47 +00:00
console.log('');
console.log('Bundling with Parcel.js');
console.log('');
2018-04-07 12:38:24 +00:00
new Parcel(dest, {
2018-03-18 14:01:47 +00:00
name: 'build',
2018-04-07 12:38:24 +00:00
publicURL: '/',
2018-03-18 14:01:47 +00:00
}).bundle();
};
2018-03-18 13:37:19 +00:00
2018-04-07 12:38:24 +00:00
const main = () => {
includeReadme({});
2018-03-18 14:01:47 +00:00
bundle();
2018-03-18 13:37:19 +00:00
};
main();