Skip to content

Commit

Permalink
Allow document list heading to be configured
Browse files Browse the repository at this point in the history
Also updates the default heading.
  • Loading branch information
leenagupte committed Nov 29, 2024
1 parent d269898 commit 4c72237
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/models/landing_page/block/document_list.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module LandingPage::Block
class DocumentList < Base
attr_reader :taxon_base_path
attr_reader :taxon_base_path, :heading

TAXON_SEARCH_FIELDS = %w[title
link
Expand All @@ -12,6 +12,7 @@ def initialize(block_hash, landing_page)
super

@taxon_base_path = data["taxon_base_path"]
@heading = data["heading"]
end

def full_width?
Expand Down
4 changes: 3 additions & 1 deletion app/views/landing_page/blocks/_document_list.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<% heading = block.heading || "Latest Updates" %>

<% if block.items.any? %>
<%= render "govuk_publishing_components/components/heading", {
text: "Press Notices",
text: heading,
padding: true,
border_top: 5,
margin_bottom: 3
Expand Down
5 changes: 4 additions & 1 deletion docs/building_blocks_for_flexible_content.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,17 @@ A wrapper around the [Big number component](https://components.publishing.servic

#### Document list

A wrapper around the [Document list component](https://components.publishing.service.gov.uk/component-guide/document_list)
A wrapper around the [Document list component](https://components.publishing.service.gov.uk/component-guide/document_list) with a title that will only appear if there are any items in the list (if the list is entirely empty the heading will not appear either)

The document list can either be populated with the most recent content tagged to a taxon or from a hard-coded list.

If the `taxon_base_path` is provided and the taxon exists and it has content tagged to it, the document list will be populated with that content. If not, it will default to the hard-coded list.

If the `heading` is provided that will be used, otherwise it will default to the hard-coded heading.

```yaml
- type: document_list
heading: My Favourite Things
taxon_base_path: /government/government-efficiency-transparency-and-accountability
items:
- text: An example link
Expand Down
1 change: 1 addition & 0 deletions lib/data/landing_page_content_items/tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ blocks:
theme: two_thirds_one_third
blocks:
- type: document_list
heading: "Latest things"
items:
- text: An example title for this press notice 1
path: "https://www.gov.uk"
Expand Down

0 comments on commit 4c72237

Please sign in to comment.