govuk_publishing_components
govuk_publishing_components copied to clipboard
Related navigation component is intrinsically tied to content item
What
The related navigation component is built in such a way that it is tightly coupled to the expected output of the content store API. This has likely been done so that developers can pass a content_item
instance on a given page and there isn't any need to further process the data. This has 2 emergent negative effects:
- The component is very strict on what information it is asked to render. If you want to render something that doesn't fit the existing scope of the content API, it'll need to be built into the component.
- The component requires rocket operator style notation to render:
"object_with_quotes_and_rocket_operator" => {
"label_in_quotes" => "Some nice data",
}
and won't render at all if "JSON" style notation, the notation that our gem documentation generates, is used:
json_style_object: {
label_without_quotes: "Some nice data",
}
Both of these issues make using the component on a page in the same way but not consuming explicit content item data incredibly difficult and limits our ability to built consistent templates across GOV.UK.
Proposal
- Remove the reliance on rocket operator notation
- Remove other data checks that would block the component from rendering if content data-specific attributes weren't present
- Extended the API to allow for "custom" information to be rendered
Some comments following the issue triage today:
- Explore may have time to do this as we're working in this space at the moment
- We should add a note to the docs to use rocket notation/data straight from the content item whilst we're finding time to fix this properly
One option might be to see if the component could be adjusted to accept both notations.