Skip to content

Commit

Permalink
Merge pull request #249 from loftwah/dl/og-image-fix-2
Browse files Browse the repository at this point in the history
last fix
  • Loading branch information
loftwah authored Dec 9, 2024
2 parents 8045a90 + 4789d8a commit 762e165
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 25 deletions.
2 changes: 1 addition & 1 deletion app/helpers/open_graph_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module OpenGraphHelper
def set_open_graph_tags(user)
default_title = 'Linkarooie - Simplify Your Online Presence'
default_description = 'Manage all your links in one place with Linkarooie.'
default_image = image_url('default_og_image.png')
default_image = 'https://linkarooie.syd1.digitaloceanspaces.com/defaults/default_og_image.png'

content_for :og_title, user.full_name.presence || default_title
content_for :og_description, user.description.presence&.truncate(160) || default_description
Expand Down
69 changes: 45 additions & 24 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,67 @@
<%= vite_client_tag %>
<%= vite_javascript_tag 'application' %>
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<!-- Generic Open Graph Meta Tags (for general application pages) -->

<!-- Open Graph Meta Tags -->
<%= 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:updated_time', content: Time.current.iso8601 %>

<% if content_for?(:og_title) %>
<%= tag.meta property: 'og:title', content: content_for(:og_title) %>
<% else %>
<%= tag.meta property: 'og:title', content: 'Linkarooie - Simplify Your Online Presence' %>
<% end %>

<% if content_for?(:og_description) %>
<%= tag.meta property: 'og:description', content: content_for(:og_description) %>
<% else %>
<%= 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.' %>
<% end %>

<%= 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 %>
<% if content_for?(:og_image) %>
<%= tag.meta property: 'og:image', content: content_for(:og_image) %>
<% else %>
<%= tag.meta property: 'og:image', content: 'https://linkarooie.syd1.digitaloceanspaces.com/defaults/default_og_image.png' %>
<% end %>

<!-- Generic Twitter Card Meta Tags (for general application pages) -->
<%= tag.meta name: 'twitter:card', content: content_for?(:og_image) ? content_for(:og_image) : image_url('default_og_image.png') %>
<%= 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' %>
<% if content_for?(:og_url) %>
<%= tag.meta property: 'og:url', content: content_for(:og_url) %>
<% else %>
<%= tag.meta property: 'og:url', content: request.original_url %>
<% end %>

<!-- Twitter Card Meta Tags -->
<%= tag.meta name: 'twitter:card', content: content_for(:twitter_card) || 'summary_large_image' %>
<%= tag.meta name: 'twitter:title', content: content_for(:og_title) || 'Linkarooie - Simplify Your Online Presence' %>
<%= tag.meta name: 'twitter:description', content: content_for(:og_description) || 'Manage all your links in one place with Linkarooie.' %>
<%= tag.meta name: 'twitter:image', content: content_for(:og_image) || 'https://linkarooie.syd1.digitaloceanspaces.com/defaults/default_og_image.png' %>
<%= tag.meta name: 'twitter:image:alt', content: 'Linkarooie profile image' %>
<% if content_for?(:twitter_site) %>
<%= tag.meta name: 'twitter:site', content: content_for(:twitter_site) %>
<%= tag.meta name: 'twitter:creator', content: content_for(:twitter_creator) %>
<% end %>

<!-- 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 %>
<%= tag.meta name: 'description', content: content_for(:og_description) || '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: content_for(:og_url) || request.original_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"
"headline": "<%= content_for(:og_title) || 'Linkarooie - Simplify Your Online Presence' %>",
"description": "<%= content_for(:og_description) || 'Manage all your links in one place with Linkarooie.' %>",
"url": "<%= content_for(:og_url) || request.original_url %>",
"image": "<%= content_for(:og_image) || 'https://linkarooie.syd1.digitaloceanspaces.com/defaults/default_og_image.png' %>",
"datePublished": "<%= Time.current.iso8601 %>",
"creator": "Linkarooie"
}
</script>
</head>

<body class="bg-gray-900 text-white">
<header class="bg-gray-800 shadow relative">
<div class="absolute top-0 right-0 mt-2 mr-2 z-50">
Expand Down

0 comments on commit 762e165

Please sign in to comment.