From f2f9a53100047e82c2a0e8b086627a137ad1f3e3 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Mon, 28 Jul 2025 16:44:42 -0500 Subject: [PATCH 1/2] Add open graph and twitter card tags to public cards and collections --- app/views/public/cards/show.html.erb | 12 ++++++++++++ app/views/public/collections/show.html.erb | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/app/views/public/cards/show.html.erb b/app/views/public/cards/show.html.erb index a2e3a980f..1ce32c4ba 100644 --- a/app/views/public/cards/show.html.erb +++ b/app/views/public/cards/show.html.erb @@ -1,5 +1,17 @@ <% @page_title = @card.title %> +<% 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: published_card_url(@card) %> + + <%= tag.meta property: "twitter:title", content: "#{@card.title} | #{@card.collection.name}" %> + <%= tag.meta property: "twitter:description", content: format_excerpt(@card&.description, length: 200) %> + <%= tag.meta property: "twitter:image", content: @card.image.attached? ? "#{request.base_url}#{url_for(@card.image)}" : "#{request.base_url}/app-icon.png" %> + <%= tag.meta property: "twitter:card", content: "summary_large_image" %> +<% end %> + <% content_for :header do %>
<%= link_to published_collection_url(@card.collection), class: "header__title btn borderless txt-large", style: "--btn-padding: 0.25ch 1ch 0.25ch 0.75ch; view-transistion-name: card-collection-title;", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %> diff --git a/app/views/public/collections/show.html.erb b/app/views/public/collections/show.html.erb index 3d7c2eba6..98df479b5 100644 --- a/app/views/public/collections/show.html.erb +++ b/app/views/public/collections/show.html.erb @@ -1,5 +1,17 @@ <% @page_title = @collection.name %> +<% content_for :head do %> + <%= tag.meta property: "og:title", content: "#{@collection.name} | #{Account.sole.name}" %> + <%= tag.meta property: "og:description", content: format_excerpt(@collection&.public_description, length: 200) %> + <%= tag.meta property: "og:image", content: "#{request.base_url}/app-icon.png" %> + <%= tag.meta property: "og:url", content: published_collection_url(@collection) %> + + <%= tag.meta property: "twitter:title", content: "#{@collection.name} | #{Account.sole.name}" %> + <%= tag.meta property: "twitter:description", content: format_excerpt(@collection&.public_description, length: 200) %> + <%= tag.meta property: "twitter:image", content: "#{request.base_url}/app-icon.png" %> + <%= tag.meta property: "twitter:card", content: "summary_large_image" %> +<% end %> + <% content_for :header do %>

From 6b6cec3026736d063ee3f19cecb7bf7895433acf Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Mon, 28 Jul 2025 16:59:44 -0500 Subject: [PATCH 2/2] Add open graph tags for unfurling private URLs, too --- app/views/cards/index.html.erb | 6 ++++++ app/views/cards/show.html.erb | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/app/views/cards/index.html.erb b/app/views/cards/index.html.erb index 3ac8073e3..c82053692 100644 --- a/app/views/cards/index.html.erb +++ b/app/views/cards/index.html.erb @@ -2,6 +2,12 @@ <%= render "filters/broadcasts", filter: @filter %> +<% content_for :head do %> + <%= tag.meta property: "og:title", content: @page_title %> + <%= tag.meta property: "og:description", content: Account.sole.name %> + <%= tag.meta property: "og:url", content: cards_url(@filter.as_params) %> +<% end %> + <% content_for :header do %> <%= render "cards/index/header", filter: @filter %> <% end %> diff --git a/app/views/cards/show.html.erb b/app/views/cards/show.html.erb index 185f61955..78e2fd4ef 100644 --- a/app/views/cards/show.html.erb +++ b/app/views/cards/show.html.erb @@ -1,6 +1,13 @@ <% @page_title = @card.title %> <%= 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: collection_card_path(@card.collection, @card) %> +<% end %> + <% content_for :header do %> <% if @card.creating? && @card.can_recover_abandoned_creation? %>