Skip to content

Commit

Permalink
Correct CreativeWork implementation
Browse files Browse the repository at this point in the history
We're had feedback to say that we should use name and text instead of
headLine and description generally for CreativeWork.

Articles still use headLine / description in the [Google docs](https://developers.google.com/search/docs/data-types/article)
so we duplicate these here.
  • Loading branch information
sihugh committed Apr 3, 2020
1 parent e7aba40 commit c85c8fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
useful summary for people upgrading their application, not a replication
of the commit log.

## Unreleased

* Correct CreativeWork to use name and text fields instead of headLine and description ([PR #1423](https://github.com/alphagov/govuk_publishing_components/pull/1423))

## 21.38.0

* Expand video player to support youtube livestream URLs ([PR #1418](https://github.com/alphagov/govuk_publishing_components/pull/1418))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def initialize(page)
def structured_data
# http://schema.org/Article
data = CreativeWorkSchema.new(@page).structured_data
.merge(head_line)
.merge(body)
.merge(search_action)
data["@type"] = "Article"
Expand All @@ -18,6 +19,13 @@ def structured_data

private

def head_line
{
"headLine" => page.title,
"description" => page.description,
}
end

# Not all formats have a `body` - some have their content split over
# multiple fields. In this case we'll skip the `articleBody` field
def body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def structured_data
"@type" => "WebPage",
"@id" => page.canonical_url,
},
"headline" => page.title,
"name" => page.title,
"datePublished" => page.content_item["first_published_at"],
"dateModified" => page.content_item["public_updated_at"],
"description" => page.description,
"text" => page.description,
"publisher" => {
"@type" => "Organization",
"name" => "GOV.UK",
Expand Down

0 comments on commit c85c8fb

Please sign in to comment.