Skip to content
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
61 changes: 55 additions & 6 deletions src/theme/BlogPostItem/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ export default function BlogPostItemFooterWrapper(props: Props): JSX.Element {
month: "short",
day: "numeric",
}).format(new Date(metadata.date));
const metaItems = [authorHandle, blogDate, readTimeText]
.filter(Boolean)
.join(META_SEPARATOR);
const metaDateAndTime = [blogDate, readTimeText].filter(Boolean).join(META_SEPARATOR);

const showAuthorCard = Boolean(isBlogPostPage && primaryAuthor && authorName);

Expand All @@ -111,7 +109,28 @@ export default function BlogPostItemFooterWrapper(props: Props): JSX.Element {
<section ref={authorCardRef} className={styles.authorCard} aria-label="Post author details">
<div className={styles.authorBody}>
<div className={styles.authorAvatarWrapper}>
{authorAvatar ? (
{githubUrl ? (
<Link
to={githubUrl}
className={styles.authorAvatarLink}
target="_blank"
rel="noopener noreferrer"
aria-label={`${authorName} on GitHub`}
>
{authorAvatar ? (
<img
className={styles.authorAvatar}
src={authorAvatar}
alt={`${authorName} profile picture`}
loading="lazy"
/>
) : (
<div className={styles.authorAvatarFallback} aria-hidden="true">
{authorName?.charAt(0).toUpperCase()}
</div>
)}
</Link>
) : authorAvatar ? (
<img
className={styles.authorAvatar}
src={authorAvatar}
Expand All @@ -137,10 +156,40 @@ export default function BlogPostItemFooterWrapper(props: Props): JSX.Element {
</div>
<div className={styles.authorIdentity}>
<div className={styles.authorNameRow}>
<p className={styles.authorName}>{authorName}</p>
{githubUrl ? (
<Link
to={githubUrl}
className={styles.authorName}
target="_blank"
rel="noopener noreferrer"
>
{authorName}
</Link>
) : (
<p className={styles.authorName}>{authorName}</p>
)}
<span className={styles.authorBadge}>Author</span>
</div>
{metaItems ? <p className={styles.authorMeta}>{metaItems}</p> : null}
{(authorHandle || metaDateAndTime) ? (
<p className={styles.authorMeta}>
{authorHandle && (
githubUrl ? (
<Link
to={githubUrl}
className={styles.authorHandleLink}
target="_blank"
rel="noopener noreferrer"
>
{authorHandle}
</Link>
) : (
authorHandle
)
)}
{authorHandle && metaDateAndTime ? META_SEPARATOR : null}
{metaDateAndTime}
</p>
) : null}
{authorSummary ? (
<p className={styles.authorSummary}>{authorSummary}</p>
) : null}
Expand Down
25 changes: 25 additions & 0 deletions src/theme/BlogPostItem/Footer/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
justify-content: center;
}

.authorAvatarLink {
display: block;
line-height: 0;
border-radius: 50%;
}

.authorAvatarLink:hover {
opacity: 0.85;
}

.authorAvatar,
.authorAvatarFallback {
width: 64px;
Expand Down Expand Up @@ -64,6 +74,21 @@
font-size: 1.75rem;
font-weight: 800;
line-height: 1.2;
color: var(--ifm-font-color-base);
text-decoration: none;
}

.authorName:hover {
text-decoration: underline;
}

.authorHandleLink {
color: inherit;
text-decoration: none;
}

.authorHandleLink:hover {
text-decoration: underline;
}

.authorNameRow {
Expand Down
Loading