Skip to content
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

Closed

Conversation

MadhavDhatrak
Copy link

@MadhavDhatrak MadhavDhatrak commented Feb 2, 2025

Description

  • Enhanced blog cards with dedicated "Read More" button for better UX
  • Fixed card clickable area to prevent accidental navigation
  • Improved visual hierarchy and layout consistency

Related issue(s)

'Fixes #3640 '
screen-recording-2025-02-02-220448_vAcWVEom.mp4

Summary by CodeRabbit

  • New Features

    • Introduced a “Read More” button for blog posts, offering a clear call-to-action for accessing full articles.
  • Style

    • Updated the layout for blog post displays with refined visual design and hover effects.
    • Repositioned content details such as images, reading time, and author information to enhance the user interface.

Copy link
Contributor

coderabbitai bot commented Feb 2, 2025

Walkthrough

This 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

File(s) Change Summary
components/navigation/BlogPostItem.tsx - Added import for the Button component.
- Replaced a wrapping Link with a span for the main content.
- Moved Link to wrap a new Button at the bottom.
- Adjusted styling and layout structure.
components/newsroom/FeaturedBlogPost.tsx - Added import for the Button component.
- Appended a new div containing a Paragraph (for reading time) and a Button with "Read More →".
- Updated layout to emphasize the call-to-action element.

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
Loading
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
Loading

Possibly related issues

  • [asyncapi/website#3640]: The issue calls for a dedicated "Read More" button to prevent accidental navigation by ensuring interactive elements are clearly defined, which aligns with the changes in this PR.

Suggested labels

ready-to-merge

Suggested reviewers

  • derberg
  • magicmatatjahu
  • devilkiller-ag
  • sambhavgupta0705
  • akshatnema
  • Mayaleeeee
  • anshgoyalevil

Poem

I'm a rabbit hopping 'round the code,
New buttons in place, a fresh new mode.
"Read More" shines with gentle light,
Guiding readers through the night.
Hop along and click away—
A joyful code day on display!
🐇✨ Happy coding!


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@github-actions github-actions bot left a 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.

Copy link

netlify bot commented Feb 2, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ff06f5f
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/67a05614f09d6600083290ce
😎 Deploy Preview https://deploy-preview-3641--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@MadhavDhatrak MadhavDhatrak changed the title feat: Enhance blog cards with read more button feat: enhance blog cards with read more button Feb 2, 2025
Copy link

codecov bot commented Feb 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (326082b) to head (ff06f5f).
Report is 2 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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:

  1. Line 107: <span data-testid='FeaturedBlogPost-RT'>{post.readingTime} min read</span>
  2. 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

📥 Commits

Reviewing files that changed from the base of the PR and between ae25e36 and 8bf2b71.

📒 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

Comment on lines +97 to +109
<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>
Copy link
Contributor

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:

  1. Using window.open directly is not recommended for security reasons
  2. 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.

Suggested change
<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>

@anshgoyalevil
Copy link
Member

Please read the contributing guidelines. PRs are expected to be created after the issue has been triaged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] - Enhance Blog Cards with Read More Button
2 participants