Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP merge hardcoded bits content into content items #3775

Closed
wants to merge 5 commits into from

Conversation

richardTowers
Copy link
Contributor

@richardTowers richardTowers commented Sep 23, 2024

Work in progress mechanism for extending content items with hardcoded content in collections.

This approach is being considered for a project that's currently [OFFICIAL], so I can't give full details of the use case. If you know, then you know. If you don't know, then don't worry. If you worry, you just suffer twice.

Opening this early as a draft to facilitate discussion of the general approach. There's a bit of not-very-good explanation in the READMEs I've added.

Before After
image image

... todo - actually render them
@leenagupte
Copy link
Contributor

I think that rather than hard coding the content into a rendering app, it should be put into a publishing app.
The presentation logic could be updated to pick up content from the YAML file to be passed to publishing-api. It would mean having to update the content schema, but that's something that will be required anyway.
Publishing the content via a publishing tool means that it will also be pushed to search without any extra effort.

The work in the rendering app could then be focused on rendering the extra fields from the content item as usual. This is similar to the approach we took for sign in pages. Though in that case, there wasn't an existing content item that needed to be extended.

There are things to work out, such as what the publishing workflow will be for any content changes, but it means that we'd be adding far fewer hacks to the system for content item changes that are expected to be permanent.

Comment on lines 15 to 18
<% @organisation.content_extensions&.each do |content_extension| %>
<%= render partial: "content_extension_#{content_extension["document_type"]}", locals: { content_extension: } %>
<% end %>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are multiple "hub" like pages that behave a bit like parts, it'd probably be better to render this new type of content in frontend, that already handles parts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming we're adorning the existing organisation pages with some extra components here. Appreciate that might not be the approach we end up taking though.

@richardTowers
Copy link
Contributor Author

I think that rather than hard coding the content into a rendering app, it should be put into a publishing app.

I think there's advantages to each approach. The big advantage of having the content in the frontend app is that it can change at exactly the same cadence as the ERB templates that render it. So changing the structure of the content and the structure the template expects can be done in one commit.

If we put the content anywhere in the publishing system, there's more coordination needed - changes to the structure of the content item need to consider backwards compatibility with the current version of the frontend, and even if we don't mind breaking

Clearly we eventually need the content to be in the publishing system, but having it directly in the frontend on day 1 feels like it could be a big advantage while the design / structure might need to change rapidly.

The presentation logic could be updated to pick up content from the YAML file to be passed to publishing-api. It would mean having to update the content schema, but that's something that will be required anyway.

Eventually, yes. Or we could use a generic bit of the schema where anything is allowed (which we'd have to add once, but then wouldn't need to keep updating).

Publishing the content via a publishing tool means that it will also be pushed to search without any extra effort.

That's true. The approach in this PR won't get the content into search, so I'd be chalking that up as a problem for later (basically when we eventually do move the content into a publishing tool, after its structure has crystallised). Search mostly just includes the body of pages (as I understand it), so actually the sorts of components I'm thinking about here (featured documents, video embeds, hero images) might not make it to search even then.

The work in the rendering app could then be focused on rendering the extra fields from the content item as usual. This is similar to the approach we took for sign in pages. Though in that case, there wasn't an existing content item that needed to be extended.

I wasn't involved in the sign in pages, so I'm not sure what the approach we took there looked like. I think most of the work here will still happen in the rendering app, looking at extra fields in the content item - it's just we'll also be hardcoding the content here.

There are things to work out, such as what the publishing workflow will be for any content changes, but it means that we'd be adding far fewer hacks to the system for content item changes that are expected to be permanent.

I think we're just talking about two different places to put the same hack 😅 - it's hardcoded content, whether it's hardcoded in Whitehall or Collections. I don't having it in one place or the other results in fewer hacks.

For me, it's a tradeoff between:

  • make it as similar to real publishing as possible (hardcode things in Whitehall and publlish to publishing-api)
  • make it as easy to update the frontend as possible (hardcode things in the frontend and don't touch publishing-api)

Given the need to deliver quickly, I'd vote for the hardcoding things in the frontend.

@richardTowers
Copy link
Contributor Author

Sorry about the unfinished sentences in my comment yesterday 😅 - Rory was barking in my face.

I've added some screenshots which show that this approach "works" (although obviously it's not a particularly good implementation of a hero image component, even if the image itself is very good).

@leenagupte
Copy link
Contributor

To be honest, I think this is all a bit premature as we don't have any designs yet and it's likely that we're going to have to render multiple linked pages.

Saying that, it's very easy to make things extremely flexible by hard-coding directly into the frontend, and then struggling later to apply that flexibility into the publishing app. We struggled with this on the COVID landing page, when we had to reduce flexibility of the sections to move it into collections publisher. I think timeline section was never moved for this reason.

I do think we should be using the content schemas to restrict how the data is presented so that we don't have to "take away" flexibility later.

@govuk-ci govuk-ci temporarily deployed to collections-pr-3775 September 24, 2024 10:55 Inactive
@richardTowers
Copy link
Contributor Author

Closing this as it's just us scratching ideas together.

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.

3 participants