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:
@@ -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."
|
"#{Danbooru.config.canonical_app_name} is the original anime image booru. Search millions of anime pictures categorized by thousands of tags."
|
||||||
end
|
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
|
def json_ld_website_data
|
||||||
urls = [
|
urls = [
|
||||||
Danbooru.config.twitter_url,
|
Danbooru.config.twitter_url,
|
||||||
|
|||||||
@@ -147,6 +147,10 @@
|
|||||||
|
|
||||||
<% if policy(@post).visible? %>
|
<% if policy(@post).visible? %>
|
||||||
<%= tag.meta property: "og:image", content: @post.open_graph_image_url %>
|
<%= tag.meta property: "og:image", content: @post.open_graph_image_url %>
|
||||||
|
|
||||||
|
<% if @post.is_video? %>
|
||||||
|
<%= json_ld_video_data(@post) %>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @post.twitter_card_supported? %>
|
<% if @post.twitter_card_supported? %>
|
||||||
|
|||||||
Reference in New Issue
Block a user