guardian / dotcom-rendering

The Guardian web rendering service (aka DCR/DCAR)
https://www.theguardian.com
Apache License 2.0
251 stars 28 forks source link

Byline Job Titles Incorrectly Appearing On The Same Line #9876

Closed JamieB-gu closed 5 months ago

JamieB-gu commented 8 months ago

On analysis articles, if the piece only has a single contributor, the byline is meant to include the name of the author on one line and the job title (if present) on another. However, in some cases they're both appearing on the same line, one after another.

Piece Screenshot
Correct https://www.theguardian.com/environment/2023/dec/13/what-the-cop28-agreement-says-and-what-it-means byline
Incorrect https://www.theguardian.com/environment/2023/dec/11/the-climate-crisis-will-amplify-the-uks-existing-health-inequalities byline-inline
Incorrect https://www.theguardian.com/australia-news/2023/dec/13/labor-gaza-ceasefire-policy-stance-un byline-inline-2

Why?

The styles that wrap the job title onto a new line can be found here:

https://github.com/guardian/dotcom-rendering/blob/9905ceb642bb20c2c6c21c92129e269c46fd994f/dotcom-rendering/src/components/HeadlineByline.tsx#L104-L107

and are applied here only if the piece has a single contributor:

https://github.com/guardian/dotcom-rendering/blob/9905ceb642bb20c2c6c21c92129e269c46fd994f/dotcom-rendering/src/components/HeadlineByline.tsx#L208-L209

However, the current logic says a piece only has a single contributor if the byline does not include the word "and":

https://github.com/guardian/dotcom-rendering/blob/9905ceb642bb20c2c6c21c92129e269c46fd994f/dotcom-rendering/src/lib/byline.ts#L16-L19

The examples above have the word "and" in the job title:

so this logic assumes there's more than one contributor, the additional styles do not get applied, and the name and job title appear on the same line.

Possible Solution

AR doesn't suffer from the same problem because it uses CAPI's bylineHtml field, which tends to separate the different parts of the byline into different elements.

https://github.com/guardian/dotcom-rendering/blob/9905ceb642bb20c2c6c21c92129e269c46fd994f/apps-rendering/src/components/Byline/Byline.defaults.tsx#L83-L87

DCR doesn't currently have access to this version of the byline because it's not passed through from frontend. One option would be to update the frontend models to include this and use it instead.

paperboyo commented 8 months ago

DCAR should defo get access to much betterer bylineHtml. But not sure everything can be 100% sorted (?):

image

[URL]

Central Production will be helpful (as always!) in knowing about and finding all the possible values for that field… In short, there is no such thing as “Byline Job Title”.

georgeblahblah commented 5 months ago

An example of a byline with two contributors: https://www.theguardian.com/uk-news/2024/apr/03/levelling-up-what-has-the-government-spent-and-where

georgeblahblah commented 5 months ago

I think the data model we get from CAPI (even if we pass the Byline HTML field to DCR) doesn't support a full solution to this issue, because any solution just exposes a different edge case. Given this is fairly low impact I'm inclined to close it.

The variants of byline/contributor combinations I've discovered are:

  1. Sole contributor (<a>A Name</a>)
  2. Sole contributor w/ job (<a>A Name</a> Health and wellness correspondent)
  3. Multiple contributor (<a>A Name</a> and <a>Another Name</a>)
  4. Contributor + byline (<a>A Name</a> and Another Name)
  5. Byline (A Name)
  6. Multiple byline (A Name and Another Name)
  7. I do not know if it's possible to have a byline (but not be a contributor) and a "job" e.g A Name Health and wellness correspondent