2016-09-25 2 views
1

Как установить один или несколько рецептов в NewsArticle или BlogPosting.Несколько объектов в schema.org

Я пробовал, но Google's Structured Data Testing Tool throws Ошибка при работе с recipe1 ключа. Я не уверен, что изменить recipe1 ключ:

<script type="application/ld+json"> 
{ 
"@context" : "http://schema.org", 
    "@type" : "NewsArticle", 
    "author" : { "@type" : "Person", 
     "name" : "hgezim" 
    }, 
    "dateModified" : "2016-09-21T06:25:35+00:00", 
    "datePublished" : "2016-09-21T06:25:35+00:00", 
    "headline" : "Chicken Papriak", 
    "mainEntityOfPage" : "http://localhost:8080/2016/09/21/chicken-papriak/", 
    "publisher" : { "@type" : "Organization", 
     "name" : "Dev Blog" 
    }, 
    "recipe1": { 
    "@context": "http://schema.org", 
    "@type": "Recipe", 
    "author": "John Smith", 
    "cookTime": "PT1H", 
    "datePublished": "2009-05-08", 
    "description": "This classic banana bread recipe comes from my mom -- the walnuts add a nice texture and flavor to the banana bread.", 
    "image": "bananabread.jpg", 
    "recipeIngredient": [ 
     "3 or 4 ripe bananas, smashed", 
     "1 egg", 
     "3/4 cup of sugar" 
    ], 
    "interactionStatistic": { 
     "@type": "InteractionCounter", 
     "interactionType": "http://schema.org/Comment", 
     "userInteractionCount": "140" 
    }, 
    "name": "Mom's World Famous Banana Bread", 
    "nutrition": { 
     "@type": "NutritionInformation", 
     "calories": "240 calories", 
     "fatContent": "9 grams fat" 
    }, 
    "prepTime": "PT15M", 
    "recipeInstructions": "Preheat the oven to 350 degrees. Mix in the ingredients in a bowl. Add the flour last. Pour the mixture into a loaf pan and bake for one hour.", 
    "recipeYield": "1 loaf", 
    "suitableForDiet": "http://schema.org/LowFatDiet" 
    } 
} 
    </script> 
+0

Что вы хотите передать? Какова была бы цель «BlogPosting» внутри «NewsArticle»? Для цитирования? И какова будет цель 'Рецепт' внутри' NewsArticle'? Это основное содержание статьи? Но в этом случае, действительно ли это «NewsArticle»? – unor

+0

Предположим, я хочу «Рецепт» (или больше) внутри «BlogPosting». – Gezim

ответ

1

Это зависит от того, как объекты связаны друг с другом. Вы должны использовать свойство, которое определено для передачи этого отношения.

Для поиска подходящего жилья, проверить BlogPosting для свойств, которые имеют Recipe или один из его родительских типов (CreativeWork, Thing) как ожидаемое значение.

Например:

  • about может быть использован, если пост блога об этом конкретном рецепте (например, вы описали, как вам понравилось)
  • hasPart может быть использован, если рецепт является частью блог размещать
  • mentions может быть использована, если вы просто ссылаться на этот рецепт в блоге
  • ...
0

Спасибо @unor. Я использовал hasPart следующим образом:

<script type="application/ld+json"> 
{ "@context" : "http://schema.org", 
    "@type" : "NewsArticle", 
    "author" : { "@type" : "Person", 
     "name" : "hgezim" 
    }, 
    "dateModified" : "2016-09-21T06:25:35+00:00", 
    "datePublished" : "2016-09-21T06:25:35+00:00", 
    "hasPart" : { "@context" : "http://schema.org", 
     "@type" : "Recipe", 
     "author" : "John Smith", 
     "cookTime" : "PT1H", 
     "datePublished" : "2009-05-08", 
     "description" : "This classic banana bread recipe comes from my mom -- the walnuts add a nice texture and flavor to the banana bread.", 
     "image" : "bananabread.jpg", 
     "interactionStatistic" : { "@type" : "InteractionCounter", 
      "interactionType" : "http://schema.org/Comment", 
      "userInteractionCount" : "140" 
     }, 
     "name" : "Mom's World Famous Banana Bread", 
     "nutrition" : { "@type" : "NutritionInformation", 
      "calories" : "240 calories", 
      "fatContent" : "9 grams fat" 
     }, 
     "prepTime" : "PT15M", 
     "recipeIngredient" : [ "3 or 4 ripe bananas, smashed", 
      "1 egg", 
      "3/4 cup of sugar" 
     ], 
     "recipeInstructions" : "Preheat the oven to 350 degrees. Mix in the ingredients in a bowl. Add the flour last. Pour the mixture into a loaf pan and bake for one hour.", 
     "recipeYield" : "1 loaf", 
     "suitableForDiet" : "http://schema.org/LowFatDiet" 
    }, 
    "headline" : "Chicken Papriak", 
    "mainEntityOfPage" : "http://localhost:8080/2016/09/21/chicken-papriak/", 
    "publisher" : { "@type" : "Organization", 
     "name" : "Dev Blog" 
    } 
} 
</script> 

Он проверяет, как validates JSON-LD.