Skip to content

Commit

Permalink
Merge pull request #4282 from alphagov/import-share-links-variant
Browse files Browse the repository at this point in the history
Add share links variant to landing page
  • Loading branch information
AshGDS authored Oct 15, 2024
2 parents 2c880a2 + 12fd372 commit da724ee
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/models/block/share_links.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Block
class ShareLinks < Block::Base
attr_reader :links

def initialize(block_hash)
super(block_hash)

@links = data.fetch("links").map { |l| { href: l["href"], text: l["text"], icon: l["icon"] } }
end
end
end
12 changes: 12 additions & 0 deletions app/views/landing_page/blocks/_share_links.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% if block.links.any? %>
<%= render "govuk_publishing_components/components/heading", {
text: "Share links heading",
padding: true
} %>
<%= render "govuk_publishing_components/components/share_links", {
square_icons: true,
columns: true,
links: block.links
} %>
<% end %>
17 changes: 17 additions & 0 deletions lib/data/landing_page_content_items/landing_page.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,20 @@ blocks:
blocks:
- type: govspeak
content: <h2><a href="http://gov.uk">Title 2 govspeak title goes here</a></h2>
- type: share_links
links:
- href: "/twitter-share-link"
text: "Twitter"
icon: "twitter"
- href: "/instagram-share-link"
text: "Instagram"
icon: "instagram"
- href: "/flickr-share-link"
text: "Flickr"
icon: "flickr"
- href: "/facebook-share-link"
text: "Facebook"
icon: "facebook"
- href: "/youtube-share-link"
text: "YouTube"
icon: "youtube"

0 comments on commit da724ee

Please sign in to comment.