Skip to content

Commit 0707793

Browse files
Kai WagnerKai Wagner
authored andcommitted
Added Open Graph and Twitter card meta tags to the main layout
Signed-off-by: Kai Wagner <kaiwagner@MacBook-Pro-von-Kai.local>
1 parent fa7628a commit 0707793

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

app/helpers/application_helper.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
11
module ApplicationHelper
2+
def meta_title
3+
return content_for(:meta_title) if content_for?(:meta_title)
4+
return "#{content_for(:title)} - Hackorum" if content_for?(:title)
5+
6+
"Hackorum"
7+
end
8+
9+
def meta_description
10+
"PostgreSQL Hackers Archive"
11+
end
12+
13+
def meta_image_url
14+
"https://hackorum.dev/icon.png"
15+
end
16+
17+
def meta_url
18+
"https://hackorum.dev"
19+
end
20+
21+
def meta_type
22+
"website"
23+
end
24+
25+
def twitter_card
26+
"summary"
27+
end
28+
229
# Smart time display: relative for recent, absolute for old
330
def smart_time_display(time)
431
return "" if time.nil?

app/views/layouts/application.html.slim

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
doctype html
22
html data-theme="light"
33
head
4-
title
5-
- if content_for?(:title)
6-
= "#{content_for(:title)} - Hackorum"
7-
- else
8-
= "Hackorum"
4+
title = meta_title
5+
meta[name="description" content=meta_description]
6+
meta[property="og:site_name" content="Hackorum"]
7+
meta[property="og:title" content=meta_title]
8+
meta[property="og:description" content=meta_description]
9+
meta[property="og:url" content=meta_url]
10+
meta[property="og:image" content=meta_image_url]
11+
meta[property="og:image:alt" content=meta_title]
12+
meta[property="og:type" content=meta_type]
13+
meta[name="twitter:card" content=twitter_card]
14+
meta[name="twitter:title" content=meta_title]
15+
meta[name="twitter:description" content=meta_description]
16+
meta[name="twitter:image" content=meta_image_url]
917
meta[name="viewport" content="width=device-width,initial-scale=1"]
1018
meta[name="apple-mobile-web-app-capable" content="yes"]
1119
meta[name="mobile-web-app-capable" content="yes"]

0 commit comments

Comments
 (0)