add open graph and twitter card meta tags
Product pages get og:type=product, og:url, og:image (hero image), and twitter:card=summary_large_image. All other shop pages get og:type=website and twitter:card=summary. og:title and og:description mirror the existing page title and meta description. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -52,6 +52,9 @@ defmodule BerrypodWeb.Shop.ProductShow do
|
||||
socket
|
||||
|> assign(:page_title, product.title)
|
||||
|> assign(:page_description, meta_description(product.description))
|
||||
|> assign(:og_type, "product")
|
||||
|> assign(:og_url, BerrypodWeb.Endpoint.url() <> "/products/#{slug}")
|
||||
|> assign(:og_image, og_image_url(all_images))
|
||||
|> assign(:product, product)
|
||||
|> assign(:all_images, all_images)
|
||||
|> assign(:gallery_images, gallery_images)
|
||||
@@ -216,6 +219,9 @@ defmodule BerrypodWeb.Shop.ProductShow do
|
||||
"""
|
||||
end
|
||||
|
||||
defp og_image_url([%{url: "/" <> _ = path} | _]), do: BerrypodWeb.Endpoint.url() <> path
|
||||
defp og_image_url(_), do: nil
|
||||
|
||||
defp meta_description(nil), do: nil
|
||||
|
||||
defp meta_description(text) do
|
||||
|
||||
Reference in New Issue
Block a user