1 # frozen_string_literal: true
4 require "addressable/uri"
6 def opengraph_tags(title, properties)
8 "og:site_name" => t("layouts.project_name.title"),
9 "og:title" => properties["og:title"] || title || t("layouts.project_name.title"),
10 "og:type" => "website",
11 "og:url" => url_for(:only_path => false),
12 "og:description" => properties["og:description"] || t("layouts.intro_text")
14 opengraph_image_properties(properties)
16 properties.slice("article:published_time")
19 safe_join(tags.map do |property, content|
20 tag.meta(:property => property, :content => content)
26 def opengraph_image_properties(properties)
28 if properties["og:image"]
30 image_properties["og:image"] = Addressable::URI.join(root_url, properties["og:image"]).normalize
31 image_properties["og:image:alt"] = properties["og:image:alt"] if properties["og:image:alt"]
32 return image_properties
34 rescue Addressable::URI::InvalidURIError
35 # return default image
38 "og:image" => image_url("osm_logo_256.png"),
39 "og:image:alt" => t("layouts.logo.alt_text")