Ghost icon indicating copy to clipboard operation
Ghost copied to clipboard

Add the @id for json-ld

Open Wardormeur opened this issue 2 years ago • 0 comments

Hello, This introduces the json-ld @id. The goal is to allow for extension of the schema through a different script but on the same model. To do so, we need to be able to merge them by adding the same @id into both scripts as a point of reference. This is useful if you want to add other fields, through the "ghost_header", like so Example usage using the ghost_header, assuming the Article had the @id field populated :

<script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@id": "myarticle.com/42",
      "@type": "Article",
      "isAccessibleForFree": "False",
      "hasPart":
        {
        "@type": "WebPageElement",
        "isAccessibleForFree": "False",
        "cssSelector" : ".paywall"
        }
     }
</script>

I've validated this method against a modified sample on https://validator.schema.org/

  • [x] There's a clear use-case for this code change, explained below
  • [ ] Commit message has a short title & references relevant issues
  • [] The build will pass (run yarn test:all and yarn lint)

Wardormeur avatar Feb 14 '24 15:02 Wardormeur