| 
									
										
										
										
											2016-10-29 00:46:45 +01:00
										 |  |  | const preFormattedBlockNames = { | 
					
						
							| 
									
										
										
										
											2017-01-19 21:16:48 -06:00
										 |  |  |   'api-projects': 'API Projects', | 
					
						
							|  |  |  |   'basic-css': 'Basic CSS', | 
					
						
							|  |  |  |   'basic-html-and-html5': 'Basic HTML and HTML5', | 
					
						
							|  |  |  |   'css-flexbox': 'CSS Flexbox', | 
					
						
							|  |  |  |   devops: 'DevOps', | 
					
						
							|  |  |  |   es6: 'ES6', | 
					
						
							|  |  |  |   'information-security-with-helmetjs': 'Information Security with HelmetJS', | 
					
						
							| 
									
										
										
										
											2016-10-29 00:46:45 +01:00
										 |  |  |   jquery: 'jQuery', | 
					
						
							|  |  |  |   'json-apis-and-ajax': 'JSON APIs and Ajax', | 
					
						
							| 
									
										
										
										
											2017-01-19 21:16:48 -06:00
										 |  |  |   'mongodb-and-mongoose': 'MongoDB and Mongoose', | 
					
						
							|  |  |  |   'the-dom': 'The DOM' | 
					
						
							| 
									
										
										
										
											2016-10-29 00:46:45 +01:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2017-01-19 21:16:48 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-29 00:46:45 +01:00
										 |  |  | const noFormatting = [ | 
					
						
							|  |  |  |   'and', | 
					
						
							|  |  |  |   'for', | 
					
						
							|  |  |  |   'of', | 
					
						
							|  |  |  |   'the', | 
					
						
							|  |  |  |   'up', | 
					
						
							|  |  |  |   'with' | 
					
						
							|  |  |  | ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default function blockNameify(phrase) { | 
					
						
							|  |  |  |   const preFormatted = preFormattedBlockNames[phrase] || ''; | 
					
						
							|  |  |  |   if (preFormatted) { | 
					
						
							|  |  |  |     return preFormatted; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return phrase.split('-') | 
					
						
							|  |  |  |     .map((word) => { | 
					
						
							|  |  |  |       if (noFormatting.includes(word)) { | 
					
						
							|  |  |  |         return word; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       if (word === 'javascript') { | 
					
						
							|  |  |  |         return 'JavaScript'; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return word.charAt(0).toUpperCase() + word.slice(1); | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .join(' '); | 
					
						
							|  |  |  | } |