Skip to content

Commit

Permalink
Merge pull request #3826 from owid/team-page-fallback
Browse files Browse the repository at this point in the history
✨ article byline `/team` page fallback if no author present
  • Loading branch information
ikesau authored Jul 30, 2024
2 parents 4909eca + b8d7a86 commit 23969c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
3 changes: 2 additions & 1 deletion adminSiteServer/mockSiteRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ getPlainRouteNonIdempotentWithRWTransaction(
mockSiteRouter,
"/*",
async (req, res, trx) => {
const slug = req.path.replace(/^\//, "")
// Remove leading and trailing slashes
const slug = req.path.replace(/^\/|\/$/g, "")

try {
const page = await renderGdocsPageBySlug(trx, slug)
Expand Down
17 changes: 2 additions & 15 deletions site/gdocs/components/LinkedAuthor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,9 @@ export default function LinkedAuthor({
/>
) : undefined

// Somehow, using a fragment here messes up the hydration process and causes
// some links to be applied to the wrong authors, but only if the first
// 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 className={className}>
{image}
{author.name}
</span>
)
}

const path = getCanonicalUrl("", {
slug: author.slug,
// If there's no author slug, this will link to /team/
slug: author.slug || "",
content: { type: OwidGdocType.Author },
})
return (
Expand Down

0 comments on commit 23969c0

Please sign in to comment.