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 df685e2
Show file tree
Hide file tree
Showing 9 changed files with 61 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 %>
5 changes: 5 additions & 0 deletions lib/data/landing_page_content_items/be_kinder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ navigation_groups:
- text: Be thankful
href: "/landing-page/be-thankful"
blocks:
- type: metadata
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
5 changes: 5 additions & 0 deletions lib/data/landing_page_content_items/be_thankful.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ navigation_groups:
- text: Be thankful
href: "/landing-page/be-thankful"
blocks:
- type: metadata
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
5 changes: 5 additions & 0 deletions lib/data/landing_page_content_items/donate_to_charity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ navigation_groups:
- text: Be thankful
href: "/landing-page/be-thankful"
blocks:
- type: metadata
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
5 changes: 5 additions & 0 deletions lib/data/landing_page_content_items/exercise_more.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ navigation_groups:
- text: Be thankful
href: "/landing-page/be-thankful"
blocks:
- type: metadata
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
5 changes: 5 additions & 0 deletions lib/data/landing_page_content_items/goals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ navigation_groups:
- text: Be thankful
href: "/landing-page/be-thankful"
blocks:
- type: metadata
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
5 changes: 5 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,11 @@ navigation_groups:
- text: Be thankful
href: "/landing-page/be-thankful"
blocks:
- type: metadata
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
5 changes: 5 additions & 0 deletions lib/data/landing_page_content_items/learn_something_new.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ navigation_groups:
- text: Be thankful
href: "/landing-page/be-thankful"
blocks:
- type: metadata
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
5 changes: 5 additions & 0 deletions lib/data/landing_page_content_items/tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ navigation_groups:
- text: Be thankful
href: "/landing-page/be-thankful"
blocks:
- type: metadata
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 df685e2

Please sign in to comment.