| 
									
										
										
										
											2018-04-06 14:51:52 +01:00
										 |  |  | const preFormattedBlockNames = { | 
					
						
							|  |  |  |   'api-projects': 'API Projects', | 
					
						
							|  |  |  |   'basic-css': 'Basic CSS', | 
					
						
							|  |  |  |   'basic-html-and-html5': 'Basic HTML and HTML5', | 
					
						
							|  |  |  |   'css-flexbox': 'CSS Flexbox', | 
					
						
							|  |  |  |   'css-grid': 'CSS Grid', | 
					
						
							|  |  |  |   devops: 'DevOps', | 
					
						
							|  |  |  |   es6: 'ES6', | 
					
						
							|  |  |  |   'information-security-with-helmetjs': 'Information Security with HelmetJS', | 
					
						
							|  |  |  |   jquery: 'jQuery', | 
					
						
							|  |  |  |   'json-apis-and-ajax': 'JSON APIs and Ajax', | 
					
						
							|  |  |  |   'mongodb-and-mongoose': 'MongoDB and Mongoose', | 
					
						
							| 
									
										
										
										
											2018-12-03 01:56:18 -08:00
										 |  |  |   'the-dom': 'The DOM', | 
					
						
							|  |  |  |   'apis-and-microservices': 'APIs and Microservices', | 
					
						
							|  |  |  |   'apis-and-microservices-projects': 'APIs and Microservices Projects' | 
					
						
							| 
									
										
										
										
											2018-04-06 14:51:52 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 15:24:17 +01:00
										 |  |  | const noFormatting = ['and', 'for', 'of', 'the', 'up', 'with']; | 
					
						
							| 
									
										
										
										
											2018-04-06 14:51:52 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | exports.blockNameify = function blockNameify(phrase) { | 
					
						
							|  |  |  |   const preFormatted = preFormattedBlockNames[phrase] || ''; | 
					
						
							|  |  |  |   if (preFormatted) { | 
					
						
							|  |  |  |     return preFormatted; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-04-17 15:24:17 +01:00
										 |  |  |   return phrase | 
					
						
							|  |  |  |     .split('-') | 
					
						
							|  |  |  |     .map(word => { | 
					
						
							| 
									
										
										
										
											2018-04-06 14:51:52 +01:00
										 |  |  |       if (noFormatting.indexOf(word) !== -1) { | 
					
						
							|  |  |  |         return word; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (word === 'javascript') { | 
					
						
							|  |  |  |         return 'JavaScript'; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return word.charAt(0).toUpperCase() + word.slice(1); | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .join(' '); | 
					
						
							|  |  |  | }; |