Skip to content

Commit fe89238

Browse files
authored
fix(blog): refine author metadata formatting fallbacks
Agent-Logs-Url: https://github.com/recodehive/recode-website/sessions/4ba6f977-41d2-46cd-99e3-5ac21711336d
1 parent 6a9e07e commit fe89238

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

src/theme/BlogPostItem/Footer/index.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ function getGitHubUrl(author: {
2929
function getGitHubHandle(author: {
3030
key?: string;
3131
url?: string;
32-
name?: string;
3332
}): string | undefined {
3433
if (author.url && /github\.com\//i.test(author.url)) {
3534
const matched = author.url.match(/github\.com\/([^/?#]+)/i);
@@ -42,10 +41,6 @@ function getGitHubHandle(author: {
4241
return `@${author.key}`;
4342
}
4443

45-
if (author.name) {
46-
return `@${author.name.toLowerCase().replace(/\s+/g, "")}`;
47-
}
48-
4944
return undefined;
5045
}
5146

@@ -72,7 +67,6 @@ export default function BlogPostItemFooterWrapper(props: Props): JSX.Element {
7267
const authorHandle = primaryAuthor
7368
? getGitHubHandle({
7469
key: primaryAuthor.key,
75-
name: primaryAuthor.name,
7670
url: primaryAuthor.url,
7771
})
7872
: undefined;
@@ -83,11 +77,11 @@ export default function BlogPostItemFooterWrapper(props: Props): JSX.Element {
8377
profile?.title;
8478
const blogDate =
8579
metadata.date &&
86-
new Date(metadata.date).toLocaleDateString("en-US", {
80+
new Intl.DateTimeFormat(undefined, {
8781
year: "numeric",
8882
month: "short",
8983
day: "numeric",
90-
});
84+
}).format(new Date(metadata.date));
9185
const metaItems = [authorHandle, blogDate, readTimeText].filter(Boolean).join(" • ");
9286

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

0 commit comments

Comments
 (0)