Feature: OG Social media cards

Not Original Gangsta, but ObjectGraph

Reason: images were showing on LinkedIn, but small.
This commit is contained in:
2026-05-10 21:34:07 +01:00
parent 764585c642
commit 061787e897
13 changed files with 300 additions and 105 deletions
@@ -66,4 +66,64 @@ defmodule FirehoseWeb.BlogControllerTest do
refute response =~ "post-status-banner"
end
end
describe "GET /blog/:blog_id/:slug - Open Graph meta tags" do
test "meta tags include og_title", %{conn: conn} do
response = conn |> get(~p"/blog/engineering/hello-world") |> html_response(200)
assert response =~ ~s(<meta property="og:title")
assert response =~ "Hello World"
end
test "meta tags include og_description", %{conn: conn} do
response = conn |> get(~p"/blog/engineering/hello-world") |> html_response(200)
assert response =~ ~s(<meta property="og:description")
end
test "meta tags include og_type article", %{conn: conn} do
response = conn |> get(~p"/blog/engineering/hello-world") |> html_response(200)
assert response =~ ~s(<meta property="og:type" content="article")
end
test "meta tags include twitter:card", %{conn: conn} do
response = conn |> get(~p"/blog/engineering/hello-world") |> html_response(200)
assert response =~ ~s(<meta name="twitter:card" content="summary_large_image")
end
test "meta tags include og_image when post has image", %{conn: conn} do
response = conn |> get(~p"/blog/engineering/why-firehose") |> html_response(200)
assert response =~ ~s(<meta property="og:image")
assert response =~ "firehose-logo.png"
end
test "meta tags have correct og_url", %{conn: conn} do
response = conn |> get(~p"/blog/engineering/hello-world") |> html_response(200)
assert response =~ ~s(<meta property="og:url" content="http://localhost:4002/blog/engineering/hello-world")
end
end
describe "GET /blog/:blog_id - Open Graph meta tags" do
test "meta tags include og_title for blog listing", %{conn: conn} do
response = conn |> get(~p"/blog/engineering") |> html_response(200)
assert response =~ ~s(<meta property="og:title")
end
test "meta tags have og_type website for blog listing", %{conn: conn} do
response = conn |> get(~p"/blog/engineering") |> html_response(200)
assert response =~ ~s(<meta property="og:type" content="website")
end
test "meta tags use summary twitter card for blog listing", %{conn: conn} do
response = conn |> get(~p"/blog/engineering") |> html_response(200)
assert response =~ ~s(<meta name="twitter:card" content="summary")
end
end
end