awesome-docker/build.js

48 lines
1.2 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';
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,
splitAdjacentBlockquotes: true
});
// converter.setFlavor('github');
console.log('Loading files...');
2018-03-18 11:59:03 +00:00
const index = fs.readFileSync('website/index.tmpl', 'utf8');
2018-03-17 15:27:41 +00:00
const readme = fs.readFileSync('README.md', 'utf8');
console.log('Merging files...');
const $ = cheerio.load(index);
$('#md').append(converter.makeHtml(readme));
2018-03-18 11:59:03 +00:00
console.log('Writing index.html');
fs.writeFileSync('website/index.html', $.html(), 'utf8');
2018-03-17 15:27:41 +00:00
console.log('Bundling with Parcel.js');
console.log('');
2018-03-18 11:59:03 +00:00
new Parcel('website/index.html', {
2018-03-17 15:27:41 +00:00
name: 'build',
2018-03-17 15:35:03 +00:00
// publicURL: '/awesome-docker'
publicURL: '/'
2018-03-17 15:27:41 +00:00
}).bundle();