Updated web script to generate landing page

Prioritized webber over builder to make sure it never times out. Prioritized the index page over the rest of the pages as it takes long due to api calls.
This commit is contained in:
Angelos Chalaris
2018-04-07 17:40:44 +03:00
parent de79e12c5f
commit b8b99bc399
10 changed files with 364 additions and 2096 deletions

View File

@ -62,6 +62,15 @@ const optimizeNodes = (data, regexp, replacer) => {
} while (count > 0);
return output;
};
// Randomizes the order of the values of an array, returning a new array.
const shuffle = ([...arr]) => {
let m = arr.length;
while (m) {
const i = Math.floor(Math.random() * m--);
[arr[m], arr[i]] = [arr[i], arr[m]];
}
return arr;
};
// Capitalizes the first letter of a string
const capitalize = (str, lowerRest = false) =>
str.slice(0, 1).toUpperCase() + (lowerRest ? str.slice(1).toLowerCase() : str.slice(1));
@ -69,4 +78,4 @@ const capitalize = (str, lowerRest = false) =>
const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env;
// Creates a hash for a value using the SHA-256 algorithm.
const hashData = val => crypto.createHash('sha256').update(val).digest('hex');
module.exports = {readSnippets, readTags, optimizeNodes, capitalize, objectFromPairs, isTravisCI, hashData};
module.exports = {readSnippets, readTags, optimizeNodes, capitalize, objectFromPairs, isTravisCI, hashData, shuffle};