Ingredients replacing lorem ipsum
This commit is contained in:
		
							parent
							
								
									a2e45705c1
								
							
						
					
					
						commit
						a03953a0ab
					
				
					 3 changed files with 15 additions and 1 deletions
				
			
		|  | @ -21,6 +21,7 @@ function normalize(obj) { | |||
|   let attributes = {}; | ||||
| 
 | ||||
|   Object.keys(obj).forEach(key => attributes[cleanKey(key)] = obj[key]); | ||||
|   attributes.ingredients = groupByKeyPrefix('ingredient', attributes); | ||||
| 
 | ||||
|   return { | ||||
|     data: { | ||||
|  | @ -38,3 +39,13 @@ function cleanKey(key) { | |||
|   if (key === 'meal') key = 'name'; | ||||
|   return key; | ||||
| } | ||||
| 
 | ||||
| function groupByKeyPrefix(keyPrefix, obj) { | ||||
|   let resultingArray = []; | ||||
|   Object.keys(obj).forEach(key => { | ||||
|     let value = obj[key]; | ||||
|     if (!value) return; | ||||
|     if (key.startsWith(keyPrefix)) resultingArray.push(value); | ||||
|   }); | ||||
|   return resultingArray; | ||||
| } | ||||
|  |  | |||
|  | @ -9,7 +9,9 @@ | |||
|           {{@meal.name}} | ||||
|         </div> | ||||
|         <p class="text-gray-700 text-base"> | ||||
|           Lorem ipsum dolor sit amet, consectetur adipisicing elit. | ||||
|           {{#each @meal.ingredients as |ingredient|}} | ||||
|             {{ingredient}} | ||||
|           {{/each}} | ||||
|         </p> | ||||
|       </div> | ||||
|       <div> | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ export default class MealModel extends Model { | |||
|   @attr area; | ||||
|   @attr mealThumb; | ||||
|   @attr instructions; | ||||
|   @attr ingredients; | ||||
|   @attr tags; | ||||
|   @attr youtube; | ||||
|   @attr source; | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Ava Gaiety Wroten
						Ava Gaiety Wroten