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

✨ article byline /team page fallback if no author present #3826

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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