Skip to content

Commit

Permalink
fix(byline): hydration discrepancy causing error in link target
Browse files Browse the repository at this point in the history
fix(byline): hydration issues
  • Loading branch information
mlbrgl committed May 23, 2024
1 parent 1352bca commit 978136d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions site/gdocs/components/Byline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useLinkedAuthor } from "../utils.js"
export const Byline = ({ names }: { names: string[] }) => {
return (
<>
By:{" "}
{"By: "}
{names.map((name, idx) => (
<React.Fragment key={name}>
<LinkedAuthor name={name} />
Expand All @@ -23,7 +23,12 @@ export const Byline = ({ names }: { names: string[] }) => {

const LinkedAuthor = ({ name }: { name: string }) => {
const author = useLinkedAuthor(name)
if (!author.slug) return <>{author.title}</>
// 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>{author.title}</span>

const path = getCanonicalUrl("", {
slug: author.slug,
Expand Down

0 comments on commit 978136d

Please sign in to comment.