Extract explaining and implementation hiding helper

This commit is contained in:
David Heinemeier Hansson
2025-10-29 18:16:43 +01:00
parent e59f756c01
commit f41882bfdd
2 changed files with 8 additions and 4 deletions
+7
View File
@@ -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
+1 -4
View File
@@ -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 %>