Skip to content

Commit

Permalink
Add parsed_content_item method to clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
1pretz1 committed Jul 21, 2022
1 parent 0666708 commit f485c27
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/presenters/content_item/manual_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def manual_content_item
@manual_content_item ||= Services.content_store.content_item(base_path)
end

def parsed_content_item
manual_content_item.parsed_content
end

def published
display_date(manual_content_item["first_published_at"])
end
Expand Down
4 changes: 4 additions & 0 deletions app/presenters/content_item_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def initialize(content_item, requested_path, view_context)
@part_slug = requesting_a_part? ? requested_path.split("/").last : nil
end

def parsed_content_item
content_item.parsed_content
end

def requesting_a_part?
false
end
Expand Down
3 changes: 1 addition & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
<%= render 'govuk_publishing_components/components/breadcrumbs',
breadcrumbs: [ { url: "/", title: "Home" } , { url: "/brexit", title: "Brexit" } ] %>
<% else %>
<%= render 'govuk_publishing_components/components/contextual_breadcrumbs',
content_item: @content_item.try(:manual_content_item) || @content_item.content_item.parsed_content %>
<%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: @content_item.parsed_content_item %>
<% end %>
<% end %>

Expand Down

0 comments on commit f485c27

Please sign in to comment.