Skip to content

Commit

Permalink
Add metadata block for social sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGDS committed Nov 13, 2024
1 parent 9c4b27f commit c40fd52
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/views/landing_page/blocks/_metadata.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<%
page_title = @content_item.title
page_title = block.data["title"] if block.data["title"]

page_description = @content_item.description
page_description = block.data["description"] if block.data["description"]

featured_image = image_path(block.data["featured_image"])

url = "https://www.gov.uk" + @content_item.base_path
%>
<% content_for :extra_headers do %>
<meta name="description" content="<%= page_description %>" />
<meta property="og:title" content="<%= page_title %>">
<meta property="og:description" content="<%= page_description %>">
<meta property="og:url" content="<%= url %>">
<meta property="og:image" content="<%= featured_image %>">
<meta property="og:site_name" content="GOV.UK">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image:alt" content="<%= block.data["featured_image_alt"] %>">
<% end %>
6 changes: 6 additions & 0 deletions lib/data/landing_page_content_items/homepage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ navigation_groups:
- text: Be thankful
href: "/landing-page/be-thankful"
blocks:
- type: metadata
page_url: "/landing-page/homepage"
featured_image: landing_page/placeholder/desktop.png
featured_image_alt: a grey placeholder image
title: "Add title here to override Whitehall"
description: "Add description here to override Whitehall"
- type: main_navigation
navigation_group_id: Top Menu
- type: hero
Expand Down

0 comments on commit c40fd52

Please sign in to comment.