docbrown/app/views/api/v0/articles/_article.json.jbuilder
Daniel Uber 2f1dad4e37
Add reading_time to articles api responses (#13446)
* Add reading_time to articles api responses

Fixes #13436

* Update api docs to match changes to the articles response

* Follow up docs updates

- increment api docs version
- add reading_time to articles/me responses
- add reading time to the show response example format

* Change reading_time attribute to reading_time_minutes

Update the article builder to use `article.reading_time` and present
it as `"reading_time_minutes"`.

Update the api spec to expect the new property name instead of the attribute.

* Update api documentation to reflect the new name

- Change reading_time -> reading_time_minutes.
- I decided to keep the (possibly redundant) description text here.
2021-04-19 17:11:55 -05:00

27 lines
804 B
Ruby

json.type_of "article"
json.extract!(
article,
:id,
:title,
:description,
:readable_publish_date,
:slug,
:path,
:url,
:comments_count,
:public_reactions_count,
:collection_id,
:published_timestamp,
)
json.positive_reactions_count article.public_reactions_count
json.cover_image cloud_cover_url(article.main_image)
json.social_image article_social_image_url(article)
json.canonical_url article.processed_canonical_url
json.created_at utc_iso_timestamp(article.created_at)
json.edited_at utc_iso_timestamp(article.edited_at)
json.crossposted_at utc_iso_timestamp(article.crossposted_at)
json.published_at utc_iso_timestamp(article.published_at)
json.last_comment_at utc_iso_timestamp(article.last_comment_at)
json.reading_time_minutes article.reading_time