From 3c7207a984b4385fcb9ef58d388429a120165723 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sat, 9 Feb 2019 11:28:29 +0200 Subject: [PATCH] Add recommended resources --- scripts/web.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/web.js b/scripts/web.js index 5c439397c..bdba8762c 100644 --- a/scripts/web.js +++ b/scripts/web.js @@ -77,6 +77,13 @@ ${ '
+${['adapter','array','function','object'].includes(tag) ? +'

Recommended Resource - ES6: The Right Parts

Learn new ES6 JavaScript language features like arrow function, destructuring, generators & more to write cleaner and more productive, readable programs.

' +: ['browser', 'node', 'date'].includes(tag) ? +'

Recommended Resource - JavaScript: The Hard Parts

Take your JavaScript to the next level. Gain an understanding of callbacks, higher order functions, closure, asynchronous and object-oriented JavaScript!

' +: '

Recommended Resource - JavaScript: From Fundamentals to Functional JS

Learn higher-order functions, closures, scope, master key functional methods like map, reduce and filter and promises and ES6+ asynchronous JavaScript.

' +}
`; const filterSnippets = (snippetList, excludedFiles) => Object.keys(snippetList) .filter(key => !excludedFiles.includes(key)) @@ -190,6 +197,7 @@ try {


`; // Loop over tags and snippets to create the list of snippets for (let tag of taggedData) { + let notEmbedded = true; let localOutput = output .replace(/\$tag/g, util.capitalize(tag)) .replace(new RegExp(`./${tag}#`, 'g'), '#'); @@ -197,8 +205,13 @@ try { localOutput += md .render(`## ${util.capitalize(tag, true)}\n`) .replace(/

/g, '

'); - for (let taggedSnippet of Object.entries(tagDbData).filter(v => v[1][0] === tag)) + for (let taggedSnippet of Object.entries(tagDbData).filter(v => v[1][0] === tag)) { localOutput += generateSnippetCard(snippets, taggedSnippet, true); + if (Object.entries(tagDbData).filter(v => v[1][0] === tag).findIndex(v => v[0] === taggedSnippet[0]) >= Object.entries(tagDbData).filter(v => v[1][0] === tag).length * 0.5 && notEmbedded) { + notEmbedded = !notEmbedded; + localOutput += embedCard(tag); + } + } // Add the ending static part localOutput += `\n${endPart + '\n'}`; // Optimize punctuation nodes