Browse Source

Fix type error in laura scraping source

Tati 7 years ago
parent
commit
b4d84f1318

+ 0 - 4
ktchn/src/recipes/scrape/index.ts

@@ -5,10 +5,6 @@ import { ScrapingSource } from './sources/index';
 import { Ingredient } from '../model';
 import { parse as parseIngredient } from 'recipe-ingredient-parser';
 
-function selectSource(url: string): ScrapingSource|void {
-  return ;
-}
-
 function selectSourceAsync(url: string): Promise<ScrapingSource> {
   const foundSource = Sources.find((source) => {
     return url.search(source.domain) > 0;

+ 2 - 2
ktchn/src/recipes/scrape/sources/laura-in-the-kitchen.ts

@@ -38,11 +38,11 @@ function getIngredients($: CheerioSelector): ComposedIngredients[] {
   const ingredientsScrape = $(SELECTORS.INGREDIENTS).children();
   const isNewIngredientList = (tagName: string): boolean => tagName === 'span';
   
-  let ingredients: ComposedIngredients[] = [];
-
+  let ingredients: ComposedIngredients[] = [{name: '', ingredients: []}];
   return ingredientsScrape.toArray().reduce((list, rawIngredient)=>{
     let last = list.length - 1;
     let text = $(rawIngredient).text();
+
     if (isNewIngredientList(rawIngredient.tagName)) {
       return list.concat([{name: text, ingredients: []}]);
     } else {