diff --git a/lib/berrypod_web/components/layouts/shop_root.html.heex b/lib/berrypod_web/components/layouts/shop_root.html.heex index 0b59dc1..7376304 100644 --- a/lib/berrypod_web/components/layouts/shop_root.html.heex +++ b/lib/berrypod_web/components/layouts/shop_root.html.heex @@ -14,6 +14,31 @@ <.live_title suffix={" · #{@theme_settings.site_name}"}> {assigns[:page_title]} + <% og_title = + if assigns[:page_title], + do: "#{assigns[:page_title]} · #{@theme_settings.site_name}", + else: @theme_settings.site_name + + og_description = + assigns[:page_description] || + @theme_settings.site_description || + "Welcome to #{@theme_settings.site_name}" %> + + + + + <%= if assigns[:og_url] do %> + + <% end %> + <%= if assigns[:og_image] do %> + + + + <% else %> + + <% end %> + + <%= for preload <- Berrypod.Theme.Fonts.preload_links( @theme_settings.typography, diff --git a/lib/berrypod_web/live/shop/product_show.ex b/lib/berrypod_web/live/shop/product_show.ex index e4eff08..dbe3170 100644 --- a/lib/berrypod_web/live/shop/product_show.ex +++ b/lib/berrypod_web/live/shop/product_show.ex @@ -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