Skip to content

Commit 230b332

Browse files
Angie Jonesclaude
authored andcommitted
fix(docs): resolve code review issues in blog layout
- Remove hardcoded author map from Info/index.tsx; the wrapped Info component already renders resolved author data from Docusaurus - Replace client-side new Date().toLocaleDateString() with metadata.formattedDate in BlogListPage to avoid timezone-based off-by-one day shifts for viewers west of UTC Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Angie Jones <angie@Angies-MacBook-Pro.local>
1 parent f6e8de8 commit 230b332

File tree

2 files changed

+6
-88
lines changed

2 files changed

+6
-88
lines changed

documentation/src/theme/BlogListPage/index.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ function BlogListPageMetadata(props: Props): ReactNode {
3030
);
3131
}
3232

33-
const formatDate = (dateString: string): string =>
34-
new Date(dateString).toLocaleDateString('en-US', {
35-
year: 'numeric',
36-
month: 'long',
37-
day: 'numeric'
38-
});
39-
4033
const getAuthorName = (author: any): string =>
4134
typeof author === 'string' ? author : (author.name || author.key || author);
4235

@@ -83,14 +76,14 @@ function FeaturedPost({ post }: { post: any }) {
8376
const url = useBaseUrl(post.content.metadata.permalink);
8477
const imageUrl = post.content.frontMatter.image ? useBaseUrl(post.content.frontMatter.image) : null;
8578
const title = post.content.metadata.title;
86-
const date = post.content.metadata.date;
79+
const formattedDate = post.content.metadata.formattedDate;
8780
const description = post.content.metadata.description || post.content.frontMatter.description;
8881
const authors = post.content?.metadata?.authors || post.content?.frontMatter?.authors || [];
8982

9083
return (
9184
<article className={styles.featuredPost}>
9285
<div className={styles.featuredContent}>
93-
<div className={styles.featuredDate}>{formatDate(date)}</div>
86+
<div className={styles.featuredDate}>{formattedDate}</div>
9487
<h2 className={styles.featuredTitle}>
9588
<a href={url}>{title}</a>
9689
</h2>
@@ -114,7 +107,7 @@ function BlogPostGrid({ posts }: { posts: any[] }) {
114107
const url = useBaseUrl(post.content.metadata.permalink);
115108
const imageUrl = post.content.frontMatter.image ? useBaseUrl(post.content.frontMatter.image) : null;
116109
const title = post.content.metadata.title;
117-
const date = post.content.metadata.date;
110+
const formattedDate = post.content.metadata.formattedDate;
118111
const description = post.content.metadata.description || post.content.frontMatter.description;
119112
const authors = post.content?.metadata?.authors || post.content?.frontMatter?.authors || [];
120113

@@ -126,7 +119,7 @@ function BlogPostGrid({ posts }: { posts: any[] }) {
126119
</div>
127120
)}
128121
<div className={styles.postContent}>
129-
<div className={styles.postDate}>{formatDate(date)}</div>
122+
<div className={styles.postDate}>{formattedDate}</div>
130123
<h3 className={styles.postTitle}>
131124
<a href={url}>{title}</a>
132125
</h3>

documentation/src/theme/BlogPostItem/Header/Info/index.tsx

Lines changed: 2 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -6,97 +6,22 @@ import { useBlogPost } from '@docusaurus/plugin-content-blog/client';
66
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
77
import SocialShare from '@site/src/components/SocialShare';
88

9-
interface Author {
10-
name: string;
11-
image_url?: string;
12-
title?: string;
13-
}
14-
159
type Props = WrapperProps<typeof InfoType>;
1610

1711
function buildPostUrl(siteUrl: string, permalink: string): string {
1812
const base = siteUrl.endsWith('/') ? siteUrl.slice(0, -1) : siteUrl;
1913
return `${base}${permalink}`;
2014
}
2115

22-
function AuthorDisplay({ authors }: { authors: string[] }) {
23-
if (!authors || authors.length === 0) return null;
24-
25-
// Author data - simplified mapping for the key authors
26-
const authorData: Record<string, Author> = {
27-
adewale: {
28-
name: "Adewale Abati",
29-
image_url: "https://avatars.githubusercontent.com/u/4003538?v=4"
30-
},
31-
angie: {
32-
name: "Angie Jones",
33-
image_url: "https://avatars.githubusercontent.com/u/15972783?v=4"
34-
},
35-
tania: {
36-
name: "Tania Chakraborty",
37-
image_url: "https://avatars.githubusercontent.com/u/126204004?v=4"
38-
},
39-
mic: {
40-
name: "Michael Neale",
41-
image_url: "https://avatars.githubusercontent.com/u/14976?v=4"
42-
}
43-
};
44-
45-
const authorsToDisplay = authors.slice(0, 3);
46-
const hasMore = authors.length > 3;
47-
48-
return (
49-
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
50-
{authorsToDisplay.map((authorKey, index) => {
51-
const author = authorData[authorKey] || { name: authorKey };
52-
53-
return (
54-
<div key={index} style={{ display: 'flex', alignItems: 'center', gap: '0.25rem' }}>
55-
{author.image_url && (
56-
<img
57-
src={author.image_url}
58-
alt={author.name}
59-
style={{
60-
width: '20px',
61-
height: '20px',
62-
borderRadius: '50%',
63-
border: '1px solid var(--ifm-color-emphasis-200)'
64-
}}
65-
/>
66-
)}
67-
<span style={{ fontSize: '0.85rem', color: 'var(--ifm-color-content-secondary)' }}>
68-
{author.name}
69-
</span>
70-
</div>
71-
);
72-
})}
73-
{hasMore && (
74-
<span style={{ fontSize: '0.85rem', color: 'var(--ifm-color-content-secondary)' }}>
75-
+{authors.length - 3} more
76-
</span>
77-
)}
78-
</div>
79-
);
80-
}
81-
8216
export default function InfoWrapper(props: Props): JSX.Element {
83-
const { metadata, isBlogPostPage, frontMatter } = useBlogPost();
17+
const { metadata, isBlogPostPage } = useBlogPost();
8418
const { siteConfig } = useDocusaurusContext();
8519

8620
const postUrl = buildPostUrl(siteConfig.url, metadata.permalink);
87-
const authors = frontMatter.authors || [];
8821

8922
return (
90-
<div style={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '0.5rem' }}>
23+
<div style={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '0.25rem' }}>
9124
<Info {...props} />
92-
93-
{authors.length > 0 && (
94-
<>
95-
<span style={{ margin: '0 0.125rem' }}> · </span>
96-
<AuthorDisplay authors={authors} />
97-
</>
98-
)}
99-
10025
{isBlogPostPage && (
10126
<>
10227
<span style={{ margin: '0 0.125rem' }}> · </span>

0 commit comments

Comments
 (0)