Skip to content

Commit

Permalink
more og upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
loftwah committed Aug 28, 2024
1 parent 96d1706 commit 1900813
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
8 changes: 8 additions & 0 deletions app/helpers/open_graph_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ module OpenGraphHelper
include Rails.application.routes.url_helpers

def set_open_graph_tags(user)
twitter_handle = user.username.downcase

# Open Graph tags
content_for :og_title, user.full_name
content_for :og_description, user.description.truncate(160)
content_for :og_image, url_for("/uploads/og_images/#{user.username}_og.png")
content_for :og_image_alt, "#{user.full_name}'s profile image"
content_for :og_url, user_links_url(user.username)

# Twitter Card tags
content_for :twitter_card, 'summary_large_image'
content_for :twitter_site, "@#{twitter_handle}"
content_for :twitter_creator, "@#{twitter_handle}"
end
end
38 changes: 32 additions & 6 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,44 @@
<%= vite_javascript_tag 'application' %>
<link rel="icon" href="/favicon.ico" type="image/x-icon">

<!-- Open Graph Meta Tags -->
<!-- Generic Open Graph Meta Tags (for general application pages) -->
<%= tag.meta property: 'og:type', content: 'website' %>
<%= tag.meta property: 'og:site_name', content: 'Linkarooie' %>
<%= tag.meta property: 'og:locale', content: 'en_US' %>
<%= tag.meta property: 'og:updated_time', content: '2024-08-08T12:00:19Z' %>

<%= tag.meta property: 'og:title', content: 'Linkarooie - Simplify Your Online Presence' %>
<%= tag.meta property: 'og:description', content: 'Manage all your links in one place with Linkarooie. Create a central hub for your social and professional profiles.' %>
<%= tag.meta property: 'og:image', content: image_url('default_og_image.png') %>
<%= tag.meta property: 'og:image:alt', content: 'Linkarooie logo' %>
<%= tag.meta property: 'og:url', content: root_url %>

<!-- Generic Twitter Card Meta Tags (for general application pages) -->
<%= tag.meta name: 'twitter:card', content: 'summary_large_image' %>
<%= tag.meta name: 'twitter:title', content: 'Linkarooie - Simplify Your Online Presence' %>
<%= tag.meta name: 'twitter:description', content: 'Manage all your links in one place with Linkarooie. Create a central hub for your social and professional profiles.' %>
<%= tag.meta name: 'twitter:image', content: image_url('default_og_image.png') %>
<%= tag.meta name: 'twitter:image:alt', content: 'Linkarooie logo' %>
<%= tag.meta name: 'twitter:site', content: '@loftwah' %>
<%= tag.meta name: 'twitter:creator', content: '@loftwah' %>

<%= tag.meta property: 'og:title', content: content_for?(:og_title) ? content_for(:og_title) : 'Linkarooie - Simplify Your Online Presence' %>
<%= tag.meta property: 'og:description', content: content_for?(:og_description) ? content_for(:og_description) : 'Manage all your links in one place with Linkarooie.' %>
<%= tag.meta property: 'og:image', content: content_for?(:og_image) ? content_for(:og_image) : image_url('default_og_image.png') %>
<%= tag.meta property: 'og:image:alt', content: content_for?(:og_image_alt) ? content_for(:og_image_alt) : 'Default image description' %>
<%= tag.meta property: 'og:url', content: content_for?(:og_url) ? content_for(:og_url) : root_url %>
<!-- SEO Meta Tags -->
<%= tag.meta name: 'description', content: 'Linkarooie helps you manage all your links in one place, making it easy to simplify your online presence and create a central hub for your social and professional profiles.' %>
<%= tag.link rel: 'canonical', href: root_url %>

<!-- Optional: Structured Data for SEO -->
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebPage",
"headline": "Linkarooie - Simplify Your Online Presence",
"description": "Manage all your links in one place with Linkarooie. Create a central hub for your social and professional profiles.",
"url": "<%= root_url %>",
"image": "<%= image_url('default_og_image.png') %>",
"datePublished": "2024-08-08T12:00:19Z",
"creator": "Loftwah"
}
</script>
</head>

<body class="bg-gray-900 text-white">
Expand Down

0 comments on commit 1900813

Please sign in to comment.