Skip to content

Build 'shared_navigation' schema and 'navigation_items' reverse link with expandable members [WHIT-3342]#4085

Draft
ChrisBAshton wants to merge 8 commits into
mainfrom
whitehall-navigation
Draft

Build 'shared_navigation' schema and 'navigation_items' reverse link with expandable members [WHIT-3342]#4085
ChrisBAshton wants to merge 8 commits into
mainfrom
whitehall-navigation

Conversation

@ChrisBAshton

@ChrisBAshton ChrisBAshton commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

What

  • Defines a new shared_navigation content type
  • Defines a new shared_navigations->navigation_items reverse link
  • Configures the shared_navigation content type to have its details.menu_items hash included when it is surfaced in link expansion
  • Configures a new REVERSE_LINKS_WITH_MEMBER_EXPANSION feature for Publishing API in which all members of a link are also expanded. See below.

REVERSE_LINKS_WITH_MEMBER_EXPANSION

When running DownstreamPayload.new(Document.find_by(content_id: press_release_content_id, locale: "en").editions.last, 1, draft: true).expanded_links.

Before - only the Press Release content item itself would be expanded in shared_navigations[n].links:

{shared_navigations:
  [{content_id: "81392be0-5ccc-4a84-8431-79f1920b7242",
    title: "Chris shared navigation June",
    locale: "en",
    analytics_identifier: nil,
    api_path: "/api/content/chris-shared-navigation-june--2",
    base_path: "/chris-shared-navigation-june--2",
    document_type: "shared_navigation",
    public_updated_at: "2026-06-02T14:58:28Z",
    schema_name: "shared_navigation",
    withdrawn: false,
    details: {menu_items: [{type: "press_release", content_id: "26086fc1-fbd6-4291-b308-3f334d380d56"}, {type: "publication", content_id: "c6caa8d4-5557-42ea-935b-d45d640d4269"}]},
    links:
     {navigation_items:
       [{content_id: "26086fc1-fbd6-4291-b308-3f334d380d56",
         title: "Foreign Secretary statement on the situation in Lebanon",
         locale: "en",
         analytics_identifier: nil,
         api_path: "/api/content/government/news/foreign-secretary-statement-on-the-situation-in-lebanon--2",
         base_path: "/government/news/foreign-secretary-statement-on-the-situation-in-lebanon--2",
         document_type: "press_release",
         public_updated_at: "2026-03-15T23:02:00Z",
         schema_name: "news_article",
         withdrawn: false,
         links: {}}]}}],

After - ALL of the documents linked to the shared navigation are now expanded in shared_navigations[n].links:

{shared_navigations:
  [{content_id: "81392be0-5ccc-4a84-8431-79f1920b7242",
    title: "Chris shared navigation June",
    locale: "en",
    analytics_identifier: nil,
    api_path: "/api/content/chris-shared-navigation-june--2",
    base_path: "/chris-shared-navigation-june--2",
    document_type: "shared_navigation",
    public_updated_at: "2026-06-02T14:58:28Z",
    schema_name: "shared_navigation",
    withdrawn: false,
    details: {menu_items: [{type: "press_release", content_id: "26086fc1-fbd6-4291-b308-3f334d380d56"}, {type: "publication", content_id: "c6caa8d4-5557-42ea-935b-d45d640d4269"}]},
    links:
     {navigation_items:
       [{content_id: "26086fc1-fbd6-4291-b308-3f334d380d56",
         title: "Foreign Secretary statement on the situation in Lebanon",
         locale: "en",
         analytics_identifier: nil,
         api_path: "/api/content/government/news/foreign-secretary-statement-on-the-situation-in-lebanon--2",
         base_path: "/government/news/foreign-secretary-statement-on-the-situation-in-lebanon--2",
         document_type: "press_release",
         public_updated_at: "2026-03-15T23:02:00Z",
         schema_name: "news_article",
         withdrawn: false,
         links: {}},
        {content_id: "c6caa8d4-5557-42ea-935b-d45d640d4269",
         title: "Youth justice plans: guidance for youth justice services",
         locale: "en",
         analytics_identifier: nil,
         api_path: "/api/content/government/publications/youth-justice-plans-guidance-for-youth-justice-services",
         base_path: "/government/publications/youth-justice-plans-guidance-for-youth-justice-services",
         document_type: "guidance",
         public_updated_at: "2025-01-21T14:33:30Z",
         schema_name: "publication",
         withdrawn: false,
         links: {}}]}}],

This is essential for developing the new "shared navigation" feature for landing pages in Q2, as these links define the content of the navigation. The shared_navigation content item itself will only have the structure of the navigation in its details hash.

(The latter is currently an arbitrary hash, but the idea is it would contain metadata such as whether a given navigation item should be hidden/shown/highlighted, its order, which nav items are nested within it, etc. The Publishing API schema for it has been kept deliberately permissive for now while we iron out those requirements.)

Why

In order to support the new "shared navigation" feature for landing pages, a key deliverable of Q2.

Jira: https://gov-uk.atlassian.net/browse/WHIT-3342


This application is owned by the Content APIs team. Please let us know in #govuk-content-apis when you raise any PRs.

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

Follow these steps if you are doing a Rails upgrade.

Also configures it to be a non-renderable format.
Publishing a 'shared_navigation' content item, linked to
'navigation_items' content items, creates a bidirectional
relationship.
We need the `details` in order to know the shape of the navigation.
The actual content will live in the `links` as
`links.navigation_items`.
@ChrisBAshton ChrisBAshton changed the title [WHIT-3342] Build 'shared_navigation' schema and 'navigation_items' reverse link with expandable members [WHIT-3342] Jun 2, 2026
The example shows:

- How we express navigation _structure_ (menu_items, nested
  menu_items for submenus etc)
- How we map that to a flat array of content item hashes via links
- How we could support external links in future (via 'type')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant