seo: add json-ld structured data for videos.

Makes video posts eligible for rich results in Google, which means they
can include a thumbnail.

Ref: https://developers.google.com/search/docs/data-types/video
This commit is contained in:
evazion
2020-07-08 15:16:58 -05:00
parent df32e0da72
commit fc331f2079
2 changed files with 17 additions and 0 deletions

View File

@@ -12,6 +12,19 @@ module SeoHelper
"#{Danbooru.config.canonical_app_name} is the original anime image booru. Search millions of anime pictures categorized by thousands of tags."
end
# https://developers.google.com/search/docs/data-types/video#video-object
def json_ld_video_data(post)
json_ld_tag({
"@context": "https://schema.org",
"@type": "VideoObject",
"name": page_title,
"description": meta_description,
"uploadDate": post.created_at.iso8601,
"thumbnailUrl": post.preview_file_url,
"contentUrl": post.file_url,
})
end
def json_ld_website_data
urls = [
Danbooru.config.twitter_url,

View File

@@ -147,6 +147,10 @@
<% if policy(@post).visible? %>
<%= tag.meta property: "og:image", content: @post.open_graph_image_url %>
<% if @post.is_video? %>
<%= json_ld_video_data(@post) %>
<% end %>
<% end %>
<% if @post.twitter_card_supported? %>