Merge branch 'master' into master
This commit is contained in:
@ -1,14 +1,27 @@
|
||||
/*
|
||||
This is the builder script that generates the index.html file.
|
||||
This is the web builder script that generates the README file.
|
||||
Run using `npm run webber`.
|
||||
*/
|
||||
// Load modules
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const chalk = require('chalk');
|
||||
const md = require('markdown-it')();
|
||||
const minify = require('html-minifier').minify;
|
||||
|
||||
const fs = require('fs-extra'), path = require('path'), chalk = require('chalk'),
|
||||
md = require('markdown-it')(), minify = require('html-minifier').minify;
|
||||
// Compile the mini.css framework and custom CSS styles, using `node-sass`.
|
||||
const sass = require('node-sass');
|
||||
sass.render({
|
||||
file: path.join('docs','mini','flavor.scss'),
|
||||
outFile: path.join('docs','mini.css'),
|
||||
outputStyle: 'compressed'
|
||||
}, function(err, result) {
|
||||
if(!err){
|
||||
fs.writeFile(path.join('docs','mini.css'), result.css, function(err2){
|
||||
if(!err2) console.log(`${chalk.green('SUCCESS!')} mini.css file generated!`);
|
||||
else console.log(`${chalk.red('ERROR!')} During mini.css file generation: ${err}`);
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.log(`${chalk.red('ERROR!')} During mini.css file generation: ${err}`);
|
||||
}
|
||||
});
|
||||
// Set variables for paths
|
||||
const snippetsPath = './snippets', staticPartsPath = './static-parts', docsPath = './docs';
|
||||
// Set variables for script
|
||||
@ -63,7 +76,7 @@ try {
|
||||
output += md.render(`[${taggedSnippet[0]}](#${taggedSnippet[0].toLowerCase()})\n`).replace(/<p>/g,'').replace(/<\/p>/g,'').replace(/<a/g,'<a class="sublink-1"');
|
||||
output += '\n';
|
||||
}
|
||||
output += `</nav><main class="col-sm-12 col-md-8 col-lg-9" style="height: 100%;overflow-y: auto; background: #eee;">`;
|
||||
output += `</nav><main class="col-sm-12 col-md-8 col-lg-9" style="height: 100%;overflow-y: auto; background: #eceef2;">`;
|
||||
output += `<a id="top"> </a>`;
|
||||
// Loop over tags and snippets to create the list of snippets
|
||||
for(let tag of [...new Set(Object.entries(tagDbData).map(t => t[1]))].filter(v => v).sort((a,b) => a.localeCompare(b))){
|
||||
@ -73,8 +86,7 @@ try {
|
||||
}
|
||||
// Add the ending static part
|
||||
output += `\n${endPart+'\n'}`;
|
||||
// Write to the index.html file
|
||||
|
||||
// Minify output
|
||||
output = minify(output, {
|
||||
collapseBooleanAttributes: true,
|
||||
collapseWhitespace: true,
|
||||
@ -92,7 +104,7 @@ try {
|
||||
trimCustomFragments: true,
|
||||
useShortDoctype: true,
|
||||
});
|
||||
|
||||
// Write to the index.html file
|
||||
fs.writeFileSync(path.join(docsPath,'index.html'), output);
|
||||
}
|
||||
catch (err){ // Handle errors (hopefully not!)
|
||||
|
||||
Reference in New Issue
Block a user