// Get random colors (from a predefined set) for bottom-wave in blog cardseleventyConfig.addFilter("getRandomColor", function (name, _postIdx, idx) { // Get the same number for each name -> colors are fixed for each name function getHash(input, numColors) { var hash = 0, len = input.length; for (var i = 0; i < len; i++) { hash = (hash << 5) - hash + input.charCodeAt(i); hash |= 0; // to 32bit integer } return Math.abs(hash) % numColors; } const color = waveColors[getHash(name, waveColors.length)]; // Based on index -> new posts make old posts' colors change // function getHash(input, numColors) { // return input % numColors; // } // const color = waveColors[getHash(_postIdx, waveColors.length)]; switch (idx) { case 0: return `rgba(${color}, 0.1)`; case 1: return `rgba(${color}, 0.05)`; case 2: return `rgba(${color}, 0.01)`; case 3: return `rgba(${color}, 0.005)`; }});