mirror of
https://github.com/veggiemonk/awesome-docker.git
synced 2025-01-10 06:49:44 -05:00
73 lines
1.7 KiB
Markdown
73 lines
1.7 KiB
Markdown
const fs = require('fs');
|
|
const showdown = require('showdown');
|
|
const cheerio = require('cheerio');
|
|
const Parcel = require('parcel-bundler');
|
|
|
|
process.env.NODE_ENV = 'production';
|
|
|
|
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,
|
|
}) => {
|
|
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...');
|
|
const indexTemplate = fs.readFileSync(templateHTML, 'utf8');
|
|
const markdown = fs.readFileSync(md, 'utf8');
|
|
|
|
console.log('Merging files...');
|
|
const $ = cheerio.load(indexTemplate);
|
|
$('#md').append(converter.makeHtml(markdown));
|
|
|
|
console.log('Writing index.html');
|
|
fs.writeFileSync(dest, $.html(), 'utf8');
|
|
console.log('DONE 👍');
|
|
};
|
|
|
|
const bundle = (dest = destination) => {
|
|
console.log('');
|
|
console.log('Bundling with Parcel.js');
|
|
console.log('');
|
|
|
|
new Parcel(dest, {
|
|
name: 'build',
|
|
publicURL: '/',
|
|
}).bundle();
|
|
};
|
|
|
|
const main = () => {
|
|
includeReadme({});
|
|
bundle();
|
|
};
|
|
|
|
main();
|