Skip to content

Commit

Permalink
move the meta tags into a helper
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Jan 11, 2022
1 parent 691a7f2 commit f5e42db
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
25 changes: 25 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
module ApplicationHelper
def sharing_meta_tags(title: "Feed Your Email")
description = "Generate an email address you can use for any newsletter, and a corresponding feed you can use to read those emails."
image = root_url + "card.jpg"

[
# OpenGraph
tag.meta(property: "og:title", content: title),
tag.meta(property: "og:description", content: description),
tag.meta(property: "og:url", content: root_url),
tag.meta(property: "og:image", content: image),
tag.meta(property: "og:site_name", content: title),
tag.meta(property: "og:locale", content: "en_US"),
tag.meta(property: "og:type", content: "website"),
# Twitter
tag.meta(property: "twitter:card", content: "summary_large_image"),
tag.meta(property: "twitter:title", content: title),
tag.meta(property: "twitter:description", content: description),
tag.meta(property: "twitter:image", content: image),
tag.meta(property: "twitter:site", content: root_url),
tag.meta(property: "twitter:creator", content: "@indirect"),
# Icons
tag.link(rel: "icon", type: "image/svg+xml", href: "/favicon.svg"),
tag.link(rel: "alternate icon", href: "/favicon.ico"),
].join("\n").html_safe
end
end
13 changes: 1 addition & 12 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>

<%= tag.meta property: "og:title", content: "Feed Your Email" %>
<%= tag.meta property: "og:image", content: "https://feedyouremail.arko.me/card.jpg" %>
<%= tag.meta property: "og:description", content: "Generate an email address you can use for any newsletter, and a corresponding feed you can use to read those emails." %>

<%= tag.meta property: "twitter:card", content: "summary_large_image" %>
<%= tag.meta property: "twitter:title", content: "Feed Your Email" %>
<%= tag.meta property: "twitter:image", content: "https://feedyouremail.arko.me/card.jpg" %>
<%= tag.meta property: "twitter:description", content: "Generate an email address you can use for any newsletter, and a corresponding feed you can use to read those emails." %>

<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="alternate icon" href="/favicon.ico">
<%= sharing_meta_tags %>

<%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %>
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
Expand Down

0 comments on commit f5e42db

Please sign in to comment.