-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(blog): update home #543
Conversation
Reviewer's Guide by SourceryThis PR updates the blog's home page to display posts grouped by year instead of a paginated feed, improves tag normalization, and consolidates date formatting utilities. The changes also include various tag cleanup and categorization improvements across blog posts. Updated class diagram for post fetching and displayclassDiagram
class Page {
+Page()
+postsByYear: Map
+postCount: int
+pastYears: int
}
class getPostsByAllYear {
+getPostsByAllYear(fields: string[]): Map
}
class YearPost {
+YearPost(year: int)
}
Page --> getPostsByAllYear
Page --> YearPost
class normalizeTag {
+normalizeTag(tag: string): string
}
class dateFormat {
+dateFormat(date: Date, formatString: string): string
}
class distanceToNow {
+distanceToNow(dateTime: number | Date): string
}
class distanceFormat {
+distanceFormat(from: Date, to: Date): string
}
class TagList {
+TagList(tags: TagCount)
}
TagList --> normalizeTag
class Feed {
+Feed(posts: Post[])
}
Page --> Feed
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @duyet - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
const normalizedTag = tag | ||
.split(' ') | ||
.filter((word) => word.length > 0) | ||
.map((word) => { | ||
return word[0].toUpperCase() + word.toLowerCase().substring(1) | ||
}) | ||
.join(' ') | ||
|
||
return normalizedTag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Inline variable that is immediately returned (inline-immediately-returned-variable
)
const normalizedTag = tag | |
.split(' ') | |
.filter((word) => word.length > 0) | |
.map((word) => { | |
return word[0].toUpperCase() + word.toLowerCase().substring(1) | |
}) | |
.join(' ') | |
return normalizedTag | |
return tag | |
.split(' ') | |
.filter((word) => word.length > 0) | |
.map((word) => { | |
return word[0].toUpperCase() + word.toLowerCase().substring(1) | |
}) | |
.join(' '); | |
Explanation
Something that we often see in people's code is assigning to a result variableand then immediately returning it.
Returning the result directly shortens the code and removes an unnecessary
variable, reducing the mental load of reading the function.
Where intermediate variables can be useful is if they then get used as a
parameter or a condition, and the name can act like a comment on what the
variable represents. In the case where you're returning it from a function, the
function name is there to tell you what the result is, so the variable name
is unnecessary.
Summary by Sourcery
Update the blog's home page to display posts grouped by year, enhancing navigation and readability. Introduce a new page component for displaying posts by year. Improve tag normalization for consistent formatting. Update blog post metadata for clarity.
New Features:
Enhancements:
Documentation: