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

Link to author pages in byline of articles #3633

Merged
merged 14 commits into from
May 28, 2024
Merged

Link to author pages in byline of articles #3633

merged 14 commits into from
May 28, 2024

Conversation

mlbrgl
Copy link
Member

@mlbrgl mlbrgl commented May 22, 2024

see PoC in #3626

Adds links to author pages in byline of articles. Linear and modular topic pages got also upgraded as a side-effect, although they weren't originally part of the scope.

Screenshot 2024-05-23 at 10 26 36

Testing

Only published authors (as in published author pages) are linked to. The rest is output as text.

Validation

Warnings are output in the admin for unlinked authors. This is not a critical error as some authors, e.g. guest authors, won't have a profile on the site.

Screenshot 2024-05-23 at 10 22 02

Post-launch

Copy link
Member Author

mlbrgl commented May 22, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @mlbrgl and the rest of your teammates on Graphite Graphite

@mlbrgl mlbrgl changed the title fix(baker): remove progress bar throttling Link to author pages in byline of articles May 22, 2024
@mlbrgl mlbrgl force-pushed the byline-linking branch 2 times, most recently from 89066fc to 64874f2 Compare May 22, 2024 16:29
@owidbot
Copy link
Contributor

owidbot commented May 22, 2024

Quick links (staging server):

Site Admin Wizard

Login: ssh owid@staging-site-byline-linking

SVG tester:

Number of differences (default views): 0
Number of differences (all views): 0

Edited: 2024-05-22 16:47:03 UTC
Execution time: 1.22 seconds

@mlbrgl mlbrgl marked this pull request as ready for review May 23, 2024 09:35
@mlbrgl mlbrgl requested a review from ikesau May 23, 2024 09:36
Copy link
Member

@ikesau ikesau left a comment

Choose a reason for hiding this comment

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

V nice!

tested with local preview and bake with multiple permutations of authors. All good!

function _getPrefixedPath(prefix: string, gdoc: OwidGdoc): string {
function _getPrefixedPath(
prefix: string,
gdoc: { slug: string; content: { type?: OwidGdocType } }
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain this change? It seems fine because undefined is handled, but I'm just curious about where you encountered an undefined content.type 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

sure! This comes from Byline not having access to the full gdoc, where I wanted to use getCanonicalUrl().

content.type is possibly undefined in OwidGdocPostContent (which is why it is covered in the P.union below). It might be a chicken and egg thing, and we might not need the type to be possibly undefined in the first place, but I didn't look more into it.

@@ -131,24 +120,19 @@ function OwidTopicPageHeader({
<p className="topic-page-header__subtitle body-1-regular col-start-2 span-cols-8">
{content.subtitle}
</p>
<p className="topic-page-header__byline col-start-2 span-cols-8 col-sm-start-2 span-sm-cols-12">
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick, but I think I'd have given Byline a className prop, make it render a <p> instead of a fragment, and handle names.length === 0 in the component itself. I can see there's currently one place where it's being rendered inside a <div> but it's probably correct to have that be a <p> anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

good call, thanks!

// author is unlinked (which probably gets tangled with the "By: " text
// above). Additional markup, here in the form of a span, works more
// reliably.
if (!author.slug) return <span>{author.title}</span>
Copy link
Member

Choose a reason for hiding this comment

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

Just wondering if here we still want to link to the team page as a fallback? Not sure if a decision has already been made here but are we even going to be keeping those pages around? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

yes we might want to do that in case we're using the fallback "Our World in Data team". But for external contributors (which is rare, granted), this wouldn't be desirable in my opinion. I'd go for wait and see on this one.

{idx === names.length - 1
? ""
: idx === names.length - 2
? " and "
Copy link
Member

Choose a reason for hiding this comment

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

Pretty sure we'd want the oxford comma here

Copy link
Member Author

Choose a reason for hiding this comment

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

my thinking behind it was:

  • it seems like the main reason for it is to avoid confusion. Here, given that we don't have a real sentence, there isn't any possible confusion
  • we currently don't have it in the byline
  • it requires special handling when we only have two authors and don't want the oxford comma.

I won't change it for now, but let me know if you see things differently?

Copy link
Member Author

mlbrgl commented May 28, 2024

Merge activity

  • May 28, 5:09 AM EDT: @mlbrgl started a stack merge that includes this pull request via Graphite.
  • May 28, 5:11 AM EDT: Graphite rebased this pull request as part of a merge.
  • May 28, 5:12 AM EDT: @mlbrgl merged this pull request with Graphite.

@mlbrgl mlbrgl force-pushed the remove-progress-bar-throttling branch from 8ee226e to a860437 Compare May 28, 2024 09:09
Base automatically changed from remove-progress-bar-throttling to master May 28, 2024 09:10
@mlbrgl mlbrgl merged commit b98370b into master May 28, 2024
13 of 15 checks passed
@mlbrgl mlbrgl deleted the byline-linking branch May 28, 2024 09:12
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