Skip to content

Commit

Permalink
Add footer and sidebar shared partials
Browse files Browse the repository at this point in the history
- Add code in Factory to rejig links into the desired internal format
  • Loading branch information
KludgeKML committed Sep 5, 2024
1 parent 251921d commit a9b1350
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/models/content_item_factory.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
class ContentItemFactory
def self.build(content_hash)
content_hash["links"]["ordered_related_items"] = ordered_related_items(content_hash["links"]) if content_hash["links"]

content_item_class(content_hash).new(content_hash)
end

def self.content_item_class(_content_hash)
ContentItem
end

def self.ordered_related_items(links)
return [] if links["ordered_related_items_overrides"].present?

links["ordered_related_items"].presence || links.fetch(
"suggested_ordered_related_items", []
)
end
end
11 changes: 11 additions & 0 deletions app/views/shared/_footer_navigation.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% @contextual_footer = capture do %>
<%= render 'govuk_publishing_components/components/contextual_footer', content_item: @content_item.to_h %>
<% end %>
<% if @contextual_footer.present? %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= @contextual_footer %>
</div>
</div>
<% end %>
3 changes: 3 additions & 0 deletions app/views/shared/_sidebar_navigation.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="govuk-grid-column-one-third">
<%= render 'govuk_publishing_components/components/contextual_sidebar', content_item: @content_item.to_h %>
</div>

0 comments on commit a9b1350

Please sign in to comment.