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 = {}; |   let attributes = {}; | ||||||
| 
 | 
 | ||||||
|   Object.keys(obj).forEach(key => attributes[cleanKey(key)] = obj[key]); |   Object.keys(obj).forEach(key => attributes[cleanKey(key)] = obj[key]); | ||||||
|  |   attributes.ingredients = groupByKeyPrefix('ingredient', attributes); | ||||||
| 
 | 
 | ||||||
|   return { |   return { | ||||||
|     data: { |     data: { | ||||||
|  | @ -38,3 +39,13 @@ function cleanKey(key) { | ||||||
|   if (key === 'meal') key = 'name'; |   if (key === 'meal') key = 'name'; | ||||||
|   return key; |   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}} |           {{@meal.name}} | ||||||
|         </div> |         </div> | ||||||
|         <p class="text-gray-700 text-base"> |         <p class="text-gray-700 text-base"> | ||||||
|           Lorem ipsum dolor sit amet, consectetur adipisicing elit. |           {{#each @meal.ingredients as |ingredient|}} | ||||||
|  |             {{ingredient}} | ||||||
|  |           {{/each}} | ||||||
|         </p> |         </p> | ||||||
|       </div> |       </div> | ||||||
|       <div> |       <div> | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ export default class MealModel extends Model { | ||||||
|   @attr area; |   @attr area; | ||||||
|   @attr mealThumb; |   @attr mealThumb; | ||||||
|   @attr instructions; |   @attr instructions; | ||||||
|  |   @attr ingredients; | ||||||
|   @attr tags; |   @attr tags; | ||||||
|   @attr youtube; |   @attr youtube; | ||||||
|   @attr source; |   @attr source; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Ava Gaiety Wroten
						Ava Gaiety Wroten