Skip to content

Commit 72bff93

Browse files
authored
feat(docsite): link blog author names to their GitHub profile (#3474)
The full article byline now renders each author's name as a link to their GitHub profile when the resolved author has an href (i.e. a github handle is set in the author registry). Authors without a derivable profile render as plain text, so nothing regresses for team/non-GitHub identities. Linking is gated to the full variant only: the compact card byline renders inside BlogCard's card-wide anchor, where a nested <a> would be invalid HTML and break hydration.
1 parent fc7b77b commit 72bff93

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

apps/docsite/src/components/blog/AuthorByline.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
*/
88

99
import * as stylex from '@stylexjs/stylex';
10+
import {Fragment} from 'react';
1011
import {Avatar} from '@astryxdesign/core/Avatar';
1112
import {AvatarGroup} from '@astryxdesign/core/AvatarGroup';
1213
import {Text} from '@astryxdesign/core/Text';
14+
import {Link} from '@astryxdesign/core/Link';
1315
import {HStack} from '@astryxdesign/core/Layout';
1416
import {Divider} from '@astryxdesign/core/Divider';
1517
import {resolveAuthor} from '../../content/blog/authors';
@@ -54,7 +56,10 @@ export function AuthorByline({
5456
const resolved = authors.map(resolveAuthor);
5557
const avatarSize = variant === 'full' ? 'small' : 'tiny';
5658
const textType = variant === 'full' ? 'body' : 'supporting';
57-
const names = resolved.map(a => a.name).join(', ');
59+
// Only link author names in the full (article) byline. The compact byline
60+
// renders inside a card-wide anchor (BlogCard), where a nested <a> would be
61+
// invalid HTML and break hydration.
62+
const linkAuthors = variant === 'full';
5863

5964
return (
6065
<HStack
@@ -69,7 +74,23 @@ export function AuthorByline({
6974
))}
7075
</AvatarGroup>
7176
<Text type={textType} color="secondary">
72-
{names}
77+
{resolved.map((author, i) => (
78+
<Fragment key={author.key}>
79+
{i > 0 ? ', ' : ''}
80+
{linkAuthors && author.href ? (
81+
<Link
82+
href={author.href}
83+
type={textType}
84+
color="secondary"
85+
target="_blank"
86+
rel="noopener noreferrer">
87+
{author.name}
88+
</Link>
89+
) : (
90+
author.name
91+
)}
92+
</Fragment>
93+
))}
7394
</Text>
7495
<Divider orientation="vertical" xstyle={styles.divider} />
7596
</>

0 commit comments

Comments
 (0)