-
-
Notifications
You must be signed in to change notification settings - Fork 765
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: enhance blog cards with read more button #3641
feat: enhance blog cards with read more button #3641
Conversation
WalkthroughThis pull request updates two components by introducing a dedicated "Read More" button. In both the BlogPostItem and FeaturedBlogPost components, the previous implementation—where the entire blog card was clickable—has been modified. A new Button component is imported and incorporated into each relevant component, with layout adjustments to isolate navigation to the button. Additional styling updates and component rearrangements, such as updated hover effects and repositioned elements, support a clearer, more intentional interaction model. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant BlogPostItem
participant Button
User->>BlogPostItem: View blog post summary
BlogPostItem->>Button: Render "Read More" button
User->>Button: Click "Read More" button
Button-->>User: Navigate to full blog post
sequenceDiagram
participant User
participant FeaturedBlogPost
participant Button
User->>FeaturedBlogPost: View featured blog post
FeaturedBlogPost->>Button: Render "Read More →" button with reading time info
User->>Button: Click the button
Button-->>User: Navigate to the detailed post
Possibly related issues
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
✅ Deploy Preview for asyncapi-website ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3641 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 20 20
Lines 732 732
=========================================
Hits 732 732 ☔ View full report in Codecov by Sentry. |
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.
Actionable comments posted: 1
🔭 Outside diff range comments (2)
components/newsroom/FeaturedBlogPost.tsx (2)
48-125
: Remove the wrapping Link component to fix clickable area.The entire card is still wrapped in a Link component, which contradicts the PR objective of fixing clickable areas to prevent accidental navigation. The dedicated Read More button should be the only clickable element.
Apply this diff to fix the issue:
- <Link href={post.slug}> <span className={ - 'flex h-full cursor-pointer flex-col divide-y divide-gray-200 overflow-hidden rounded-lg border border-gray-200 shadow-md transition-all duration-300 ease-in-out hover:shadow-lg md:max-w-164 md:flex-row' + 'flex h-full flex-col divide-y divide-gray-200 overflow-hidden rounded-lg border border-gray-200 shadow-md transition-all duration-300 ease-in-out hover:shadow-lg md:max-w-164 md:flex-row' } data-testid='FeaturedBlogPostItem-Link' > ... </span> - </Link>
102-108
: Remove duplicate reading time display.The reading time is displayed twice:
- Line 107:
<span data-testid='FeaturedBlogPost-RT'>{post.readingTime} min read</span>
- Lines 112-114:
<Paragraph>{post.readingTime} min read</Paragraph>
This creates redundancy in the UI.
Remove one of the reading time displays, preferably keeping the one at the bottom with the Read More button for better visual hierarchy.
Also applies to: 111-114
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
components/navigation/BlogPostItem.tsx
(2 hunks)components/newsroom/FeaturedBlogPost.tsx
(2 hunks)
🧰 Additional context used
📓 Learnings (1)
components/navigation/BlogPostItem.tsx (1)
Learnt from: akshatnema
PR: asyncapi/website#3262
File: components/navigation/BlogPostItem.tsx:80-87
Timestamp: 2024-11-12T06:59:33.851Z
Learning: In the `BlogPostItem` component, the parent `Link` wraps the entire content, so inner `Link` components around the title and excerpt are unnecessary.
⏰ Context from checks skipped due to timeout of 180000ms (1)
- GitHub Check: Lighthouse CI
🔇 Additional comments (3)
components/newsroom/FeaturedBlogPost.tsx (1)
116-121
: LGTM: Read More button implementation.The Button component implementation looks good:
- Clear call-to-action text
- Consistent styling with hover effects
- Proper data-testid for testing
components/navigation/BlogPostItem.tsx (2)
58-63
: LGTM: Fixed clickable area implementation.Good job replacing the wrapping Link with a span and removing the cursor-pointer style. This aligns with the PR objective of preventing accidental navigation.
130-136
: LGTM: Read More button implementation.The Button component implementation looks good:
- Properly wrapped in Next.js Link component
- Consistent styling with the FeaturedBlogPost component
- Clear call-to-action text
<button | ||
key={index} | ||
data-alt={author.name} | ||
className='cursor-pointer border-none bg-inherit p-0 hover:underline' | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
|
||
// Handle the click event, e.g., navigate to author.link | ||
window.open(author.link, '_blank'); | ||
}} | ||
> | ||
{author.name} | ||
</button> | ||
) : ( | ||
author.name | ||
) | ||
// Handle the click event, e.g., navigate to author.link | ||
window.open(author.link, '_blank'); | ||
}} | ||
> | ||
{author.name} | ||
</button> |
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.
🛠️ Refactor suggestion
Improve author link implementation.
The current implementation using button elements for author links can be improved:
- Using
window.open
directly is not recommended for security reasons - The implementation doesn't handle keyboard navigation properly
Consider using Next.js Link component with proper security attributes:
- <button
- key={index}
- data-alt={author.name}
- className='cursor-pointer border-none bg-inherit p-0 hover:underline'
- onClick={(e) => {
- e.preventDefault();
- window.open(author.link, '_blank');
- }}
- >
- {author.name}
- </button>
+ <Link
+ key={index}
+ href={author.link}
+ target="_blank"
+ rel="noopener noreferrer"
+ className='hover:underline'
+ >
+ {author.name}
+ </Link>
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
<button | |
key={index} | |
data-alt={author.name} | |
className='cursor-pointer border-none bg-inherit p-0 hover:underline' | |
onClick={(e) => { | |
e.preventDefault(); | |
// Handle the click event, e.g., navigate to author.link | |
window.open(author.link, '_blank'); | |
}} | |
> | |
{author.name} | |
</button> | |
) : ( | |
author.name | |
) | |
// Handle the click event, e.g., navigate to author.link | |
window.open(author.link, '_blank'); | |
}} | |
> | |
{author.name} | |
</button> | |
<Link | |
key={index} | |
href={author.link} | |
target="_blank" | |
rel="noopener noreferrer" | |
className='hover:underline' | |
> | |
{author.name} | |
</Link> |
Please read the contributing guidelines. PRs are expected to be created after the issue has been triaged. |
Description
Related issue(s)
'Fixes #3640 'screen-recording-2025-02-02-220448_vAcWVEom.mp4
Summary by CodeRabbit
New Features
Style