Skip to content

Add comments to entity #18

@luisherranz

Description

@luisherranz

Comments appear in the replies array of the _embed property:

screen shot 2018-07-05 at 11 44 49

We should return an array of comments:

connection.entity('post', 60).comments // => array of comments

We need a new Comment model. Comments in the REST API have the following schema:

{
  "id": 49719,
  "post": 117741,
  "parent": 49714,
  "author": 0,
  "author_name": "M.A.",
  "author_url": "",
  "date": "2018-08-13T23:09:00",
  "date_gmt": "2018-08-13T21:09:00",
  "content": {
    "rendered": "<p>Toda la razón.<br />\nPero si el tiempo ha demostrado algo es que por mucho que cambies, unos están arriba y otros abajo. Y casi siempre son los mismos&#8230;.</p>\n"
  },
  "link": "https://www.diariomotor.com/competicion/noticia/zak-brown-no-es-ideal-tener-a-dos-pilotos-jovenes-en-mclaren/#comment-49719",
  "status": "approved",
  "type": "comment",
  "author_avatar_urls": {
    "24": "https://secure.gravatar.com/avatar/09371c7b05ce82b1f692a19cd164a60e?s=24&d=mm&r=g",
    "48": "https://secure.gravatar.com/avatar/09371c7b05ce82b1f692a19cd164a60e?s=48&d=mm&r=g",
    "96": "https://secure.gravatar.com/avatar/09371c7b05ce82b1f692a19cd164a60e?s=96&d=mm&r=g"
  },
  "meta": [],
  "_links": {
    "self": [
      {
        "href": "https://www.diariomotor.com/competicion/wp-json/wp/v2/comments/49719"
      }
    ],
    "collection": [
      {
        "href": "https://www.diariomotor.com/competicion/wp-json/wp/v2/comments"
      }
    ],
    "up": [
      {
        "embeddable": true,
        "post_type": "noticia",
        "href": "https://www.diariomotor.com/competicion/wp-json/wp/v2/noticias/117741"
      }
    ],
    "in-reply-to": [
      {
        "embeddable": true,
        "href": "https://www.diariomotor.com/competicion/wp-json/wp/v2/comments/49714"
      }
    ]
  }
}

We need to decide what fields to expose directly (the other ones can be got from .raw)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions