From f41882bfddbfa9ac42415ebe6878c6307df5614b Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 29 Oct 2025 18:16:43 +0100 Subject: [PATCH] Extract explaining and implementation hiding helper --- app/helpers/cards_helper.rb | 7 +++++++ app/views/cards/show.html.erb | 5 +---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/helpers/cards_helper.rb b/app/helpers/cards_helper.rb index 2ab894086..5a3836361 100644 --- a/app/helpers/cards_helper.rb +++ b/app/helpers/cards_helper.rb @@ -33,4 +33,11 @@ module CardsHelper title << "assigned to #{card.assignees.map(&:name).to_sentence}" if card.assignees.any? title.join(" ") end + + def card_social_tags(card) + tag.meta(property: "og:title", content: "#{card.title} | #{card.collection.name}") + + tag.meta(property: "og:description", content: format_excerpt(@card&.description, length: 200)) + + tag.meta(property: "og:image", content: @card.image.attached? ? "#{request.base_url}#{url_for(@card.image)}" : "#{request.base_url}/app-icon.png") + + tag.meta(property: "og:url", content: card_url(@card)) + end end diff --git a/app/views/cards/show.html.erb b/app/views/cards/show.html.erb index 28b2476ce..c6204e31c 100644 --- a/app/views/cards/show.html.erb +++ b/app/views/cards/show.html.erb @@ -3,10 +3,7 @@ <%= turbo_stream_from @card %> <% content_for :head do %> - <%= tag.meta property: "og:title", content: "#{@card.title} | #{@card.collection.name}" %> - <%= tag.meta property: "og:description", content: format_excerpt(@card&.description, length: 200) %> - <%= tag.meta property: "og:image", content: @card.image.attached? ? "#{request.base_url}#{url_for(@card.image)}" : "#{request.base_url}/app-icon.png" %> - <%= tag.meta property: "og:url", content: card_url(@card) %> + <%= card_social_tags(@card) %> <% end %> <% content_for :header do %>