Skip to content

Commit e9e38d8

Browse files
authored
fix(blog): use site locale fallback and theme variables in author card
Agent-Logs-Url: https://github.com/recodehive/recode-website/sessions/4ba6f977-41d2-46cd-99e3-5ac21711336d
1 parent fe89238 commit e9e38d8

2 files changed

Lines changed: 23 additions & 23 deletions

File tree

src/theme/BlogPostItem/Footer/index.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from "react";
22
import Link from "@docusaurus/Link";
3+
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
34
import { useBlogPost } from "@docusaurus/plugin-content-blog/client";
45
import BlogPostItemFooterOriginal from "@theme-original/BlogPostItem/Footer";
56
import type BlogPostItemFooterType from "@theme/BlogPostItem/Footer";
@@ -9,6 +10,7 @@ import { getAuthorProfile } from "../../../utils/authors";
910
import styles from "./styles.module.css";
1011

1112
type Props = WrapperProps<typeof BlogPostItemFooterType>;
13+
const META_SEPARATOR = " • ";
1214

1315
function getGitHubUrl(author: {
1416
key?: string;
@@ -45,6 +47,7 @@ function getGitHubHandle(author: {
4547
}
4648

4749
export default function BlogPostItemFooterWrapper(props: Props): JSX.Element {
50+
const { siteConfig } = useDocusaurusContext();
4851
const { metadata, isBlogPostPage } = useBlogPost();
4952
const primaryAuthor = metadata.authors?.[0];
5053

@@ -77,12 +80,14 @@ export default function BlogPostItemFooterWrapper(props: Props): JSX.Element {
7780
profile?.title;
7881
const blogDate =
7982
metadata.date &&
80-
new Intl.DateTimeFormat(undefined, {
83+
new Intl.DateTimeFormat(siteConfig.i18n?.defaultLocale || "en-US", {
8184
year: "numeric",
8285
month: "short",
8386
day: "numeric",
8487
}).format(new Date(metadata.date));
85-
const metaItems = [authorHandle, blogDate, readTimeText].filter(Boolean).join(" • ");
88+
const metaItems = [authorHandle, blogDate, readTimeText]
89+
.filter(Boolean)
90+
.join(META_SEPARATOR);
8691

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

@@ -93,18 +98,18 @@ export default function BlogPostItemFooterWrapper(props: Props): JSX.Element {
9398
<section className={styles.authorCard} aria-label="Post author details">
9499
<div className={styles.authorBody}>
95100
<div className={styles.authorAvatarWrapper}>
96-
{authorAvatar ? (
97-
<img
98-
className={styles.authorAvatar}
99-
src={authorAvatar}
100-
alt={`${authorName} profile picture`}
101-
loading="lazy"
102-
/>
103-
) : (
104-
<div className={styles.authorAvatarFallback} aria-hidden="true">
105-
{authorName?.charAt(0).toUpperCase()}
106-
</div>
107-
)}
101+
{authorAvatar ? (
102+
<img
103+
className={styles.authorAvatar}
104+
src={authorAvatar}
105+
alt={`${authorName} profile picture`}
106+
loading="lazy"
107+
/>
108+
) : (
109+
<div className={styles.authorAvatarFallback} aria-hidden="true">
110+
{authorName?.charAt(0).toUpperCase()}
111+
</div>
112+
)}
108113
<span className={styles.verifiedBadge} aria-hidden="true">
109114
110115
</span>

src/theme/BlogPostItem/Footer/styles.module.css

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
height: 18px;
3232
border-radius: 999px;
3333
border: 2px solid var(--ifm-background-color);
34-
background: #34c38f;
35-
color: #fff;
34+
background: var(--ifm-color-success);
35+
color: var(--ifm-color-white);
3636
display: grid;
3737
place-items: center;
3838
font-size: 11px;
@@ -84,8 +84,8 @@
8484
border-radius: 999px;
8585
font-size: 0.75rem;
8686
font-weight: 600;
87-
color: #2563eb;
88-
background: #dbeafe;
87+
color: var(--ifm-color-primary);
88+
background: var(--ifm-color-primary-contrast-background);
8989
}
9090

9191
.authorMeta {
@@ -126,11 +126,6 @@
126126
text-decoration: none;
127127
}
128128

129-
[data-theme="dark"] .authorBadge {
130-
color: #bfdbfe;
131-
background: color-mix(in srgb, #1d4ed8 35%, transparent);
132-
}
133-
134129
@media (max-width: 640px) {
135130
.authorCard {
136131
padding: 1rem;

0 commit comments

Comments
 (0)