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: add social sharing buttons to blog posts #3698

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

AritraDey-Dev
Copy link

@AritraDey-Dev AritraDey-Dev commented Feb 17, 2025

fixes #3649
Description

Add social sharing buttons for Twitter and LinkedIn to blog posts.

  • BlogLayout.tsx

    • Add social sharing buttons for Twitter and LinkedIn at the top and bottom of each blog post.
    • Generate pre-filled sharing links including the blog post title, URL, and hashtags.
  • BlogPostItem.tsx

    • Add social sharing buttons for Twitter and LinkedIn.
    • Generate pre-filled sharing links including the blog post title, URL, and hashtags.
  • FeaturedBlogPost.tsx

    • Add social sharing buttons for Twitter and LinkedIn.
    • Generate pre-filled sharing links including the blog post title, URL, and hashtags.
  • index.tsx

    • Add social sharing buttons for Twitter and LinkedIn.
    • Generate pre-filled sharing links including the blog post title, URL, and hashtags.

Summary by CodeRabbit

  • New Features
    • Introduced social media sharing options across multiple blog sections.
    • Enabled users to share posts directly via Twitter and LinkedIn with pre-configured messages.
    • Added a dedicated SocialShareButtons component for streamlined sharing functionality.
    • Enhanced the visual layout by incorporating attractive, well-aligned sharing icons throughout the blog interface.

Copy link
Contributor

coderabbitai bot commented Feb 17, 2025

Walkthrough

The changes add social media sharing functionality to several blog-related components. New imports for Twitter and LinkedIn icons are introduced, and sharing URLs and texts are computed based on each blog post's details. Social sharing links are added in multiple locations within the layout, post items, featured posts, and the blog index page, enabling users to share content on Twitter and LinkedIn directly from the interface.

Changes

File(s) Summary of Changes
components/layout/BlogLayout.tsx Added import for SocialShareButtons; defined shareUrl and shareText variables; rendered SocialShareButtons twice with props in the JSX structure.
components/navigation/BlogPostItem.tsx
components/newsroom/FeaturedBlogPost.tsx
Added imports for IconTwitter and IconLinkedIn; defined shareUrl and shareText constants; added new social sharing link sections with styled anchor tags for Twitter and LinkedIn.
pages/blog/index.tsx Introduced IconTwitter and IconLinkedIn; added a new section with sharing anchor elements that construct URLs using encoded data, styled with a flexbox layout.
components/SocialShareButtons.tsx Introduced new SocialShareButtons component; defined props for url and text; rendered anchor elements for sharing on Twitter and LinkedIn with appropriate attributes.

Suggested labels

ready-to-merge

Suggested reviewers

  • derberg
  • magicmatatjahu
  • devilkiller-ag
  • akshatnema
  • sambhavgupta0705
  • anshgoyalevil
  • Mayaleeeee
  • asyncapi-bot-eve

Poem

Hopping through the code with delight,
I added sharing to brighten the night.
Twitter and LinkedIn in neat array,
Helping our blog posts find their way.
A rabbit’s cheer in every commit, hip-hip-hooray!
🐇✨


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

netlify bot commented Feb 17, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit ac70916
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/67b4134d8e690a00084b1273
😎 Deploy Preview https://deploy-preview-3698--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.

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: 3

🧹 Nitpick comments (1)
components/newsroom/FeaturedBlogPost.tsx (1)

115-132: Simplify icon size classes using Tailwind shorthand.

The icon size classes can be simplified using Tailwind's shorthand notation.

-  <IconTwitter className='h-6 w-6' />
+  <IconTwitter className='size-6' />
-  <IconLinkedIn className='h-6 w-6' />
+  <IconLinkedIn className='size-6' />
🧰 Tools
🪛 GitHub Actions: PR testing - if Node project

[warning] 122-122: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 130-130: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b240da and ee19852.

📒 Files selected for processing (4)
  • components/layout/BlogLayout.tsx (4 hunks)
  • components/navigation/BlogPostItem.tsx (3 hunks)
  • components/newsroom/FeaturedBlogPost.tsx (3 hunks)
  • pages/blog/index.tsx (2 hunks)
🧰 Additional context used
🪛 ESLint
components/newsroom/FeaturedBlogPost.tsx

[error] 1-15: Run autofix to sort these imports!

(simple-import-sort/imports)

pages/blog/index.tsx

[error] 1-17: Run autofix to sort these imports!

(simple-import-sort/imports)

components/layout/BlogLayout.tsx

[error] 1-16: Run autofix to sort these imports!

(simple-import-sort/imports)

components/navigation/BlogPostItem.tsx

[error] 1-16: Run autofix to sort these imports!

(simple-import-sort/imports)

🪛 GitHub Actions: PR testing - if Node project
components/newsroom/FeaturedBlogPost.tsx

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[warning] 122-122: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 130-130: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand

pages/blog/index.tsx

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[warning] 138-138: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[warning] 145-145: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 153-153: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand

components/layout/BlogLayout.tsx

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[warning] 98-98: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 106-106: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 146-146: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 154-154: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand

components/navigation/BlogPostItem.tsx

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[warning] 142-142: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 150-150: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand

⏰ Context from checks skipped due to timeout of 180000ms (1)
  • GitHub Check: Lighthouse CI
🔇 Additional comments (2)
components/newsroom/FeaturedBlogPost.tsx (1)

46-47: LGTM! Safe URL encoding implementation.

The implementation correctly uses encodeURIComponent for both the URL and text, ensuring safe sharing links.

components/layout/BlogLayout.tsx (1)

44-45:

❓ Verification inconclusive

Verify URL construction consistency across components.

The URL construction uses router.asPath while other components use post.slug. Ensure this difference is intentional.


🏁 Script executed:

#!/bin/bash
# Search for URL construction patterns
echo "Searching for URL construction patterns..."
rg "https://www\.asyncapi\.com.*\$\{.*\}" -A 2

Length of output: 142


Double-check URL construction consistency.
In components/layout/BlogLayout.tsx (lines 44–45), the URL is built using router.asPath while other components use post.slug. Since our initial search script didn’t yield the expected output, it’s advisable to manually verify that this divergence is intentional. Please confirm whether using router.asPath here is deliberate or if it should be aligned with the URL construction logic using post.slug elsewhere.

Comment on lines 44 to 45
const shareUrl = encodeURIComponent(`https://www.asyncapi.com${router.asPath}`);
const shareText = encodeURIComponent(post.title);
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

Extract social sharing buttons into a reusable component.

The social sharing buttons code is duplicated in the header and footer. Consider extracting this into a reusable component to improve maintainability.

Create a new component SocialShareButtons.tsx:

interface SocialShareButtonsProps {
  url: string;
  text: string;
}

export function SocialShareButtons({ url, text }: SocialShareButtonsProps) {
  return (
    <div className='mt-4 flex space-x-4'>
      <a
        href={`https://twitter.com/intent/tweet?text=${text}&url=${url}&hashtags=AsyncAPI`}
        target='_blank'
        rel='noopener noreferrer'
        className='text-blue-500 hover:text-blue-700'
      >
        <IconTwitter className='size-6' />
      </a>
      <a
        href={`https://www.linkedin.com/sharing/share-offsite/?url=${url}`}
        target='_blank'
        rel='noopener noreferrer'
        className='text-blue-700 hover:text-blue-900'
      >
        <IconLinkedIn className='size-6' />
      </a>
    </div>
  );
}

Then use it in the layout:

<SocialShareButtons url={shareUrl} text={shareText} />

Also applies to: 91-108, 139-156

Comment on lines +135 to +152
<div className='mt-4 flex space-x-4'>
<a
href={`https://twitter.com/intent/tweet?text=${shareText}&url=${shareUrl}&hashtags=AsyncAPI`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 hover:text-blue-700'
>
<IconTwitter className='h-6 w-6' />
</a>
<a
href={`https://www.linkedin.com/sharing/share-offsite/?url=${shareUrl}`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-700 hover:text-blue-900'
>
<IconLinkedIn className='h-6 w-6' />
</a>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Prevent social share clicks from triggering parent Link navigation.

The social sharing buttons are inside a parent Link component, which might cause unintended navigation when clicking the share buttons.

-              <div className='mt-4 flex space-x-4'>
+              <div className='mt-4 flex space-x-4' onClick={(e) => e.preventDefault()}>
                 <a
                   href={`https://twitter.com/intent/tweet?text=${shareText}&url=${shareUrl}&hashtags=AsyncAPI`}
                   target='_blank'
                   rel='noopener noreferrer'
                   className='text-blue-500 hover:text-blue-700'
+                  onClick={(e) => e.stopPropagation()}
                 >
                   <IconTwitter className='size-6' />
                 </a>
                 <a
                   href={`https://www.linkedin.com/sharing/share-offsite/?url=${shareUrl}`}
                   target='_blank'
                   rel='noopener noreferrer'
                   className='text-blue-700 hover:text-blue-900'
+                  onClick={(e) => e.stopPropagation()}
                 >
                   <IconLinkedIn className='size-6' />
                 </a>
               </div>

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 GitHub Actions: PR testing - if Node project

[warning] 142-142: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 150-150: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand

Comment on lines +138 to +155
<div className='mt-8 flex space-x-4 justify-center'>
<a
href={`https://twitter.com/intent/tweet?text=${encodeURIComponent('Check out this blog!')}&url=${encodeURIComponent('https://www.asyncapi.com/blog/2024-annual-summary#social-media')}`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 hover:text-blue-700'
>
<IconTwitter className='h-6 w-6' />
</a>
<a
href={`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent('https://www.asyncapi.com/blog/2024-annual-summary#social-media')}`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-700 hover:text-blue-900'
>
<IconLinkedIn className='h-6 w-6' />
</a>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove hardcoded values and maintain URL consistency.

The sharing implementation uses hardcoded values and a different URL format compared to other components.

-          <div className='mt-8 flex space-x-4 justify-center'>
+          <div className='mt-8 flex justify-center space-x-4'>
             <a
-              href={`https://twitter.com/intent/tweet?text=${encodeURIComponent('Check out this blog!')}&url=${encodeURIComponent('https://www.asyncapi.com/blog/2024-annual-summary#social-media')}`}
+              href={`https://twitter.com/intent/tweet?text=${encodeURIComponent('Check out AsyncAPI Blog!')}&url=${encodeURIComponent('https://www.asyncapi.com/blog')}`}
               target='_blank'
               rel='noopener noreferrer'
               className='text-blue-500 hover:text-blue-700'
             >
-              <IconTwitter className='h-6 w-6' />
+              <IconTwitter className='size-6' />
             </a>
             <a
-              href={`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent('https://www.asyncapi.com/blog/2024-annual-summary#social-media')}`}
+              href={`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent('https://www.asyncapi.com/blog')}`}
               target='_blank'
               rel='noopener noreferrer'
               className='text-blue-700 hover:text-blue-900'
             >
-              <IconLinkedIn className='h-6 w-6' />
+              <IconLinkedIn className='size-6' />
             </a>
           </div>
📝 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
<div className='mt-8 flex space-x-4 justify-center'>
<a
href={`https://twitter.com/intent/tweet?text=${encodeURIComponent('Check out this blog!')}&url=${encodeURIComponent('https://www.asyncapi.com/blog/2024-annual-summary#social-media')}`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 hover:text-blue-700'
>
<IconTwitter className='h-6 w-6' />
</a>
<a
href={`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent('https://www.asyncapi.com/blog/2024-annual-summary#social-media')}`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-700 hover:text-blue-900'
>
<IconLinkedIn className='h-6 w-6' />
</a>
</div>
<div className='mt-8 flex justify-center space-x-4'>
<a
href={`https://twitter.com/intent/tweet?text=${encodeURIComponent('Check out AsyncAPI Blog!')}&url=${encodeURIComponent('https://www.asyncapi.com/blog')}`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 hover:text-blue-700'
>
<IconTwitter className='size-6' />
</a>
<a
href={`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent('https://www.asyncapi.com/blog')}`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-700 hover:text-blue-900'
>
<IconLinkedIn className='size-6' />
</a>
</div>
🧰 Tools
🪛 GitHub Actions: PR testing - if Node project

[warning] 138-138: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[warning] 145-145: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 153-153: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand

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: 3

🧹 Nitpick comments (1)
components/layout/BlogLayout.tsx (1)

43-45: Make URL construction more robust.

The URL construction should handle different environments and ensure the base URL is consistent.

Consider using environment variables or a configuration constant for the base URL:

-  const shareUrl = `https://www.asyncapi.com${router.asPath}`;
+  const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'https://www.asyncapi.com';
+  const shareUrl = `${baseUrl}${router.asPath}`;
   const shareText = post.title;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee19852 and 375dfb3.

📒 Files selected for processing (2)
  • components/SocialShareButtons.tsx (1 hunks)
  • components/layout/BlogLayout.tsx (4 hunks)
🧰 Additional context used
🪛 ESLint
components/SocialShareButtons.tsx

[error] 1-2: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 2-2: Expected 1 empty line after import statement not followed by another import.

(import/newline-after-import)


[error] 4-4: Delete ··

(prettier/prettier)


[error] 5-5: Replace ···· with ··

(prettier/prettier)


[error] 6-6: Delete ··

(prettier/prettier)


[error] 7-7: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 7-7: Delete ··

(prettier/prettier)


[error] 8-8: Delete ··

(prettier/prettier)


[error] 9-9: Delete ··

(prettier/prettier)


[error] 10-10: Delete ··

(prettier/prettier)


[error] 11-11: Delete ··

(prettier/prettier)


[error] 12-12: Delete ··

(prettier/prettier)


[error] 13-13: Delete ··

(prettier/prettier)


[error] 14-14: Replace ·········· with ········

(prettier/prettier)


[error] 15-15: Delete ··

(prettier/prettier)


[error] 16-16: Delete ··

(prettier/prettier)


[error] 17-17: Replace ·········· with ········

(prettier/prettier)


[error] 18-18: Delete ··

(prettier/prettier)


[error] 19-19: Delete ··

(prettier/prettier)


[error] 20-20: Delete ··

(prettier/prettier)


[error] 21-21: Delete ··

(prettier/prettier)


[error] 22-22: Delete ··

(prettier/prettier)


[error] 23-23: Delete ··

(prettier/prettier)


[error] 24-24: Delete ··

(prettier/prettier)


[error] 25-25: Delete ··

(prettier/prettier)


[error] 26-26: Delete ··

(prettier/prettier)


[error] 27-27: Delete ··

(prettier/prettier)


[error] 28-28: Replace ···· with ··

(prettier/prettier)


[error] 29-29: Replace ··} with }⏎

(prettier/prettier)


[error] 29-29: Newline required at end of file but not found.

(eol-last)

components/layout/BlogLayout.tsx

[error] 1-15: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 15-15: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 15-15: Delete ·

(prettier/prettier)

🪛 GitHub Actions: PR testing - if Node project
components/SocialShareButtons.tsx

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[error] 2-2: Expected 1 empty line after import statement not followed by another import. import/newline-after-import


[error] 4-4: Delete ·· prettier/prettier


[error] 5-5: Replace ···· with ·· prettier/prettier


[error] 6-6: Delete ·· prettier/prettier


[error] 7-7: Trailing spaces not allowed. no-trailing-spaces


[error] 8-8: Delete ·· prettier/prettier


[error] 8-10: Delete ·· prettier/prettier


[error] 9-9: Delete ·· prettier/prettier


[error] 10-10: Delete ·· prettier/prettier


[error] 11-11: Delete ·· prettier/prettier


[error] 12-12: Delete ·· prettier/prettier


[error] 13-13: Delete ·· prettier/prettier


[error] 14-14: Replace ·········· with ········ prettier/prettier


[error] 15-15: Delete ·· prettier/prettier


[error] 16-16: Delete ·· prettier/prettier


[error] 17-17: Replace ·········· with ········ prettier/prettier


[error] 18-18: Delete ·· prettier/prettier


[error] 19-19: Delete ·· prettier/prettier


[error] 20-20: Delete ·· prettier/prettier


[error] 21-21: Delete ·· prettier/prettier


[error] 22-22: Delete ·· prettier/prettier


[error] 23-23: Delete ·· prettier/prettier


[error] 24-24: Delete ·· prettier/prettier


[error] 25-25: Delete ·· prettier/prettier


[error] 26-26: Delete ·· prettier/prettier


[error] 27-27: Delete ·· prettier/prettier


[error] 28-28: Replace ···· with ·· prettier/prettier


[error] 29-29: Replace ··} with }⏎ prettier/prettier


[error] 29-29: Newline required at end of file but not found. eol-last

components/layout/BlogLayout.tsx

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[error] 15-15: Trailing spaces not allowed. no-trailing-spaces


[error] 15-15: Delete · prettier/prettier

🔇 Additional comments (1)
components/layout/BlogLayout.tsx (1)

90-90: LGTM! Clean implementation of social sharing buttons.

The SocialShareButtons component is properly implemented in both the header and article sections, following the recommended refactoring pattern.

Also applies to: 121-121

Comment on lines +8 to +29
export function SocialShareButtons({ url, text }: SocialShareButtonsProps) {
return (
<div className='mt-4 flex space-x-4'>
<a
href={`https://twitter.com/intent/tweet?text=${text}&url=${url}&hashtags=AsyncAPI`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 hover:text-blue-700'
>
<IconTwitter className='size-6' />
</a>
<a
href={`https://www.linkedin.com/sharing/share-offsite/?url=${url}`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-700 hover:text-blue-900'
>
<IconLinkedIn className='size-6' />
</a>
</div>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add URL encoding for share parameters.

The URL and text parameters should be properly encoded to prevent XSS and ensure the sharing links work correctly with special characters.

Apply this diff to add URL encoding:

 export function SocialShareButtons({ url, text }: SocialShareButtonsProps) {
   return (
     <div className='mt-4 flex space-x-4'>
       <a
-        href={`https://twitter.com/intent/tweet?text=${text}&url=${url}&hashtags=AsyncAPI`}
+        href={`https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}&url=${encodeURIComponent(url)}&hashtags=AsyncAPI`}
         target='_blank'
         rel='noopener noreferrer'
         className='text-blue-500 hover:text-blue-700'
       >
         <IconTwitter className='size-6' />
       </a>
       <a
-        href={`https://www.linkedin.com/sharing/share-offsite/?url=${url}`}
+        href={`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(url)}`}
         target='_blank'
         rel='noopener noreferrer'
         className='text-blue-700 hover:text-blue-900'
       >
         <IconLinkedIn className='size-6' />
       </a>
     </div>
   );
 }
📝 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
export function SocialShareButtons({ url, text }: SocialShareButtonsProps) {
return (
<div className='mt-4 flex space-x-4'>
<a
href={`https://twitter.com/intent/tweet?text=${text}&url=${url}&hashtags=AsyncAPI`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 hover:text-blue-700'
>
<IconTwitter className='size-6' />
</a>
<a
href={`https://www.linkedin.com/sharing/share-offsite/?url=${url}`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-700 hover:text-blue-900'
>
<IconLinkedIn className='size-6' />
</a>
</div>
);
}
export function SocialShareButtons({ url, text }: SocialShareButtonsProps) {
return (
<div className='mt-4 flex space-x-4'>
<a
href={`https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}&url=${encodeURIComponent(url)}&hashtags=AsyncAPI`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 hover:text-blue-700'
>
<IconTwitter className='size-6' />
</a>
<a
href={`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(url)}`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-700 hover:text-blue-900'
>
<IconLinkedIn className='size-6' />
</a>
</div>
);
}
🧰 Tools
🪛 ESLint

[error] 8-8: Delete ··

(prettier/prettier)


[error] 9-9: Delete ··

(prettier/prettier)


[error] 10-10: Delete ··

(prettier/prettier)


[error] 11-11: Delete ··

(prettier/prettier)


[error] 12-12: Delete ··

(prettier/prettier)


[error] 13-13: Delete ··

(prettier/prettier)


[error] 14-14: Replace ·········· with ········

(prettier/prettier)


[error] 15-15: Delete ··

(prettier/prettier)


[error] 16-16: Delete ··

(prettier/prettier)


[error] 17-17: Replace ·········· with ········

(prettier/prettier)


[error] 18-18: Delete ··

(prettier/prettier)


[error] 19-19: Delete ··

(prettier/prettier)


[error] 20-20: Delete ··

(prettier/prettier)


[error] 21-21: Delete ··

(prettier/prettier)


[error] 22-22: Delete ··

(prettier/prettier)


[error] 23-23: Delete ··

(prettier/prettier)


[error] 24-24: Delete ··

(prettier/prettier)


[error] 25-25: Delete ··

(prettier/prettier)


[error] 26-26: Delete ··

(prettier/prettier)


[error] 27-27: Delete ··

(prettier/prettier)


[error] 28-28: Replace ···· with ··

(prettier/prettier)


[error] 29-29: Replace ··} with }⏎

(prettier/prettier)


[error] 29-29: Newline required at end of file but not found.

(eol-last)

🪛 GitHub Actions: PR testing - if Node project

[error] 8-8: Delete ·· prettier/prettier


[error] 8-10: Delete ·· prettier/prettier


[error] 9-9: Delete ·· prettier/prettier


[error] 10-10: Delete ·· prettier/prettier


[error] 11-11: Delete ·· prettier/prettier


[error] 12-12: Delete ·· prettier/prettier


[error] 13-13: Delete ·· prettier/prettier


[error] 14-14: Replace ·········· with ········ prettier/prettier


[error] 15-15: Delete ·· prettier/prettier


[error] 16-16: Delete ·· prettier/prettier


[error] 17-17: Replace ·········· with ········ prettier/prettier


[error] 18-18: Delete ·· prettier/prettier


[error] 19-19: Delete ·· prettier/prettier


[error] 20-20: Delete ·· prettier/prettier


[error] 21-21: Delete ·· prettier/prettier


[error] 22-22: Delete ·· prettier/prettier


[error] 23-23: Delete ·· prettier/prettier


[error] 24-24: Delete ·· prettier/prettier


[error] 25-25: Delete ·· prettier/prettier


[error] 26-26: Delete ·· prettier/prettier


[error] 27-27: Delete ·· prettier/prettier


[error] 28-28: Replace ···· with ·· prettier/prettier


[error] 29-29: Replace ··} with }⏎ prettier/prettier


[error] 29-29: Newline required at end of file but not found. eol-last

Comment on lines +1 to +6
import IconTwitter from './icons/Twitter';
import IconLinkedIn from './icons/LinkedIn';
interface SocialShareButtonsProps {
url: string;
text: string;
}
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

Fix import sorting.

The imports need to be sorted according to the project's conventions.

Apply this diff to fix the import sorting:

-import IconTwitter from './icons/Twitter';
-import IconLinkedIn from './icons/LinkedIn';
+import IconLinkedIn from './icons/LinkedIn';
+import IconTwitter from './icons/Twitter';

interface SocialShareButtonsProps {
  url: string;
  text: string;
}
📝 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
import IconTwitter from './icons/Twitter';
import IconLinkedIn from './icons/LinkedIn';
interface SocialShareButtonsProps {
url: string;
text: string;
}
import IconLinkedIn from './icons/LinkedIn';
import IconTwitter from './icons/Twitter';
interface SocialShareButtonsProps {
url: string;
text: string;
}
🧰 Tools
🪛 ESLint

[error] 1-2: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 2-2: Expected 1 empty line after import statement not followed by another import.

(import/newline-after-import)


[error] 4-4: Delete ··

(prettier/prettier)


[error] 5-5: Replace ···· with ··

(prettier/prettier)


[error] 6-6: Delete ··

(prettier/prettier)

🪛 GitHub Actions: PR testing - if Node project

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[error] 2-2: Expected 1 empty line after import statement not followed by another import. import/newline-after-import


[error] 4-4: Delete ·· prettier/prettier


[error] 5-5: Replace ···· with ·· prettier/prettier


[error] 6-6: Delete ·· prettier/prettier

@@ -12,6 +12,7 @@ import AuthorAvatars from '../AuthorAvatars';
import Head from '../Head';
import TOC from '../TOC';
import Container from './Container';
import { SocialShareButtons } from '../SocialShareButtons';
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

Remove trailing space in import statement.

The import statement has a trailing space that needs to be removed.

Apply this diff to fix the formatting:

-import { SocialShareButtons } from '../SocialShareButtons'; 
+import { SocialShareButtons } from '../SocialShareButtons';
📝 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
import { SocialShareButtons } from '../SocialShareButtons';
import { SocialShareButtons } from '../SocialShareButtons';
🧰 Tools
🪛 ESLint

[error] 1-15: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 15-15: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 15-15: Delete ·

(prettier/prettier)

🪛 GitHub Actions: PR testing - if Node project

[error] 15-15: Trailing spaces not allowed. no-trailing-spaces


[error] 15-15: Delete · prettier/prettier

@AritraDey-Dev AritraDey-Dev force-pushed the feat/add-social-media-icons branch from 375dfb3 to ac70916 Compare February 18, 2025 04:57
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 (1)
pages/blog/index.tsx (1)

1-17: ⚠️ Potential issue

Sort imports according to project standards.

The imports need to be sorted to comply with the project's standards and fix the pipeline failure.

Apply this diff to sort the imports:

-import { useRouter } from 'next/router';
-import React, { useContext, useEffect, useState } from 'react';
+import React, { useContext, useEffect, useState } from 'react';
+import { useRouter } from 'next/router';

-import Empty from '@/components/illustrations/Empty';
-import GenericLayout from '@/components/layout/GenericLayout';
-import Loader from '@/components/Loader';
-import BlogPostItem from '@/components/navigation/BlogPostItem';
-import Filter from '@/components/navigation/Filter';
-import Heading from '@/components/typography/Heading';
-import Paragraph from '@/components/typography/Paragraph';
-import TextLink from '@/components/typography/TextLink';
-import BlogContext from '@/context/BlogContext';
-import type { IBlogPost } from '@/types/post';
-import { HeadingLevel, HeadingTypeStyle } from '@/types/typography/Heading';
-import { ParagraphTypeStyle } from '@/types/typography/Paragraph';
-import IconTwitter from '@/components/icons/Twitter';
-import IconLinkedIn from '@/components/icons/LinkedIn';
+import BlogContext from '@/context/BlogContext';
+import Empty from '@/components/illustrations/Empty';
+import GenericLayout from '@/components/layout/GenericLayout';
+import IconLinkedIn from '@/components/icons/LinkedIn';
+import IconTwitter from '@/components/icons/Twitter';
+import Loader from '@/components/Loader';
+import BlogPostItem from '@/components/navigation/BlogPostItem';
+import Filter from '@/components/navigation/Filter';
+import Heading from '@/components/typography/Heading';
+import Paragraph from '@/components/typography/Paragraph';
+import TextLink from '@/components/typography/TextLink';
+import type { IBlogPost } from '@/types/post';
+import { HeadingLevel, HeadingTypeStyle } from '@/types/typography/Heading';
+import { ParagraphTypeStyle } from '@/types/typography/Paragraph';
🧰 Tools
🪛 ESLint

[error] 1-17: Run autofix to sort these imports!

(simple-import-sort/imports)

🪛 GitHub Actions: PR testing - if Node project

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 375dfb3 and ac70916.

📒 Files selected for processing (5)
  • components/SocialShareButtons.tsx (1 hunks)
  • components/layout/BlogLayout.tsx (4 hunks)
  • components/navigation/BlogPostItem.tsx (3 hunks)
  • components/newsroom/FeaturedBlogPost.tsx (3 hunks)
  • pages/blog/index.tsx (2 hunks)
🧰 Additional context used
🪛 ESLint
components/newsroom/FeaturedBlogPost.tsx

[error] 1-15: Run autofix to sort these imports!

(simple-import-sort/imports)

components/layout/BlogLayout.tsx

[error] 1-15: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 15-15: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 15-15: Delete ·

(prettier/prettier)

components/SocialShareButtons.tsx

[error] 1-2: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 2-2: Expected 1 empty line after import statement not followed by another import.

(import/newline-after-import)


[error] 4-4: Delete ··

(prettier/prettier)


[error] 5-5: Replace ···· with ··

(prettier/prettier)


[error] 6-6: Delete ··

(prettier/prettier)


[error] 7-7: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 7-7: Delete ··

(prettier/prettier)


[error] 8-8: Delete ··

(prettier/prettier)


[error] 9-9: Delete ··

(prettier/prettier)


[error] 10-10: Delete ··

(prettier/prettier)


[error] 11-11: Delete ··

(prettier/prettier)


[error] 12-12: Delete ··

(prettier/prettier)


[error] 13-13: Delete ··

(prettier/prettier)


[error] 14-14: Replace ·········· with ········

(prettier/prettier)


[error] 15-15: Delete ··

(prettier/prettier)


[error] 16-16: Delete ··

(prettier/prettier)


[error] 17-17: Replace ·········· with ········

(prettier/prettier)


[error] 18-18: Delete ··

(prettier/prettier)


[error] 19-19: Delete ··

(prettier/prettier)


[error] 20-20: Delete ··

(prettier/prettier)


[error] 21-21: Delete ··

(prettier/prettier)


[error] 22-22: Delete ··

(prettier/prettier)


[error] 23-23: Delete ··

(prettier/prettier)


[error] 24-24: Delete ··

(prettier/prettier)


[error] 25-25: Delete ··

(prettier/prettier)


[error] 26-26: Delete ··

(prettier/prettier)


[error] 27-27: Delete ··

(prettier/prettier)


[error] 28-28: Replace ···· with ··

(prettier/prettier)


[error] 29-29: Replace ··} with }⏎

(prettier/prettier)


[error] 29-29: Newline required at end of file but not found.

(eol-last)

components/navigation/BlogPostItem.tsx

[error] 1-16: Run autofix to sort these imports!

(simple-import-sort/imports)

pages/blog/index.tsx

[error] 1-17: Run autofix to sort these imports!

(simple-import-sort/imports)

🪛 GitHub Actions: PR testing - if Node project
components/newsroom/FeaturedBlogPost.tsx

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[warning] 122-122: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 130-130: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand

components/layout/BlogLayout.tsx

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[error] 15-15: Trailing spaces not allowed. no-trailing-spaces


[error] 15-15: Delete · prettier/prettier

components/SocialShareButtons.tsx

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[error] 2-2: Expected 1 empty line after import statement not followed by another import. import/newline-after-import


[error] 4-4: Delete ·· prettier/prettier


[error] 5-5: Replace ···· with ·· prettier/prettier


[error] 6-6: Delete ·· prettier/prettier


[error] 7-7: Trailing spaces not allowed. no-trailing-spaces


[error] 8-8: Delete ·· prettier/prettier


[error] 9-9: Delete ·· prettier/prettier


[error] 14-14: Replace ·········· with ········ prettier/prettier


[error] 29-29: Newline required at end of file but not found. eol-last

components/navigation/BlogPostItem.tsx

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[warning] 142-142: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 150-150: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand

pages/blog/index.tsx

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[warning] 138-138: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[warning] 145-145: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 153-153: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand

⏰ Context from checks skipped due to timeout of 180000ms (3)
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
🔇 Additional comments (8)
components/SocialShareButtons.tsx (2)

1-2: Fix import sorting.

The imports need to be sorted according to the project's conventions.

Apply this diff to fix the import sorting:

-import IconTwitter from './icons/Twitter';
-import IconLinkedIn from './icons/LinkedIn';
+import IconLinkedIn from './icons/LinkedIn';
+import IconTwitter from './icons/Twitter';
🧰 Tools
🪛 ESLint

[error] 1-2: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 2-2: Expected 1 empty line after import statement not followed by another import.

(import/newline-after-import)

🪛 GitHub Actions: PR testing - if Node project

[error] 1-1: Run autofix to sort these imports! simple-import-sort/imports


[error] 2-2: Expected 1 empty line after import statement not followed by another import. import/newline-after-import


8-29: Add URL encoding for share parameters.

The URL and text parameters should be properly encoded to prevent XSS and ensure the sharing links work correctly with special characters.

Apply this diff to add URL encoding:

 export function SocialShareButtons({ url, text }: SocialShareButtonsProps) {
   return (
     <div className='mt-4 flex space-x-4'>
       <a
-        href={`https://twitter.com/intent/tweet?text=${text}&url=${url}&hashtags=AsyncAPI`}
+        href={`https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}&url=${encodeURIComponent(url)}&hashtags=AsyncAPI`}
         target='_blank'
         rel='noopener noreferrer'
         className='text-blue-500 hover:text-blue-700'
       >
         <IconTwitter className='size-6' />
       </a>
       <a
-        href={`https://www.linkedin.com/sharing/share-offsite/?url=${url}`}
+        href={`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(url)}`}
         target='_blank'
         rel='noopener noreferrer'
         className='text-blue-700 hover:text-blue-900'
       >
         <IconLinkedIn className='size-6' />
       </a>
     </div>
   );
 }
🧰 Tools
🪛 ESLint

[error] 8-8: Delete ··

(prettier/prettier)


[error] 9-9: Delete ··

(prettier/prettier)


[error] 10-10: Delete ··

(prettier/prettier)


[error] 11-11: Delete ··

(prettier/prettier)


[error] 12-12: Delete ··

(prettier/prettier)


[error] 13-13: Delete ··

(prettier/prettier)


[error] 14-14: Replace ·········· with ········

(prettier/prettier)


[error] 15-15: Delete ··

(prettier/prettier)


[error] 16-16: Delete ··

(prettier/prettier)


[error] 17-17: Replace ·········· with ········

(prettier/prettier)


[error] 18-18: Delete ··

(prettier/prettier)


[error] 19-19: Delete ··

(prettier/prettier)


[error] 20-20: Delete ··

(prettier/prettier)


[error] 21-21: Delete ··

(prettier/prettier)


[error] 22-22: Delete ··

(prettier/prettier)


[error] 23-23: Delete ··

(prettier/prettier)


[error] 24-24: Delete ··

(prettier/prettier)


[error] 25-25: Delete ··

(prettier/prettier)


[error] 26-26: Delete ··

(prettier/prettier)


[error] 27-27: Delete ··

(prettier/prettier)


[error] 28-28: Replace ···· with ··

(prettier/prettier)


[error] 29-29: Replace ··} with }⏎

(prettier/prettier)


[error] 29-29: Newline required at end of file but not found.

(eol-last)

🪛 GitHub Actions: PR testing - if Node project

[error] 8-8: Delete ·· prettier/prettier


[error] 9-9: Delete ·· prettier/prettier


[error] 14-14: Replace ·········· with ········ prettier/prettier


[error] 29-29: Newline required at end of file but not found. eol-last

components/layout/BlogLayout.tsx (2)

15-15: Remove trailing space in import statement.

The import statement has a trailing space that needs to be removed.

Apply this diff to fix the formatting:

-import { SocialShareButtons } from '../SocialShareButtons'; 
+import { SocialShareButtons } from '../SocialShareButtons';
🧰 Tools
🪛 ESLint

[error] 1-15: Run autofix to sort these imports!

(simple-import-sort/imports)


[error] 15-15: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 15-15: Delete ·

(prettier/prettier)

🪛 GitHub Actions: PR testing - if Node project

[error] 15-15: Trailing spaces not allowed. no-trailing-spaces


[error] 15-15: Delete · prettier/prettier


43-44: LGTM! Share URL and text computation.

The variables are correctly defined and will provide proper values for social sharing.

components/newsroom/FeaturedBlogPost.tsx (1)

46-47: LGTM! URL encoding is properly implemented.

The encodeURIComponent is correctly used for both the URL and text parameters.

components/navigation/BlogPostItem.tsx (2)

56-57: LGTM! URL encoding is properly implemented.

The encodeURIComponent is correctly used for both the URL and text parameters.


135-152: Prevent social share clicks from triggering parent Link navigation.

The social sharing buttons are inside a parent Link component, which might cause unintended navigation when clicking the share buttons.

Apply this diff to prevent event propagation:

-              <div className='mt-4 flex space-x-4'>
+              <div className='mt-4 flex space-x-4' onClick={(e) => e.preventDefault()}>
                 <a
                   href={`https://twitter.com/intent/tweet?text=${shareText}&url=${shareUrl}&hashtags=AsyncAPI`}
                   target='_blank'
                   rel='noopener noreferrer'
                   className='text-blue-500 hover:text-blue-700'
+                  onClick={(e) => e.stopPropagation()}
                 >
-                  <IconTwitter className='h-6 w-6' />
+                  <IconTwitter className='size-6' />
                 </a>
                 <a
                   href={`https://www.linkedin.com/sharing/share-offsite/?url=${shareUrl}`}
                   target='_blank'
                   rel='noopener noreferrer'
                   className='text-blue-700 hover:text-blue-900'
+                  onClick={(e) => e.stopPropagation()}
                 >
-                  <IconLinkedIn className='h-6 w-6' />
+                  <IconLinkedIn className='size-6' />
                 </a>
               </div>
🧰 Tools
🪛 GitHub Actions: PR testing - if Node project

[warning] 142-142: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 150-150: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand

pages/blog/index.tsx (1)

138-155: Remove hardcoded values and maintain URL consistency.

The social sharing implementation has several issues:

  1. Hardcoded URL points to a specific blog post instead of the blog index
  2. Generic sharing text doesn't reflect the blog index content
  3. Tailwind CSS classes need optimization

Apply this diff to fix the issues:

-          <div className='mt-8 flex space-x-4 justify-center'>
+          <div className='mt-8 flex justify-center space-x-4'>
             <a
-              href={`https://twitter.com/intent/tweet?text=${encodeURIComponent('Check out this blog!')}&url=${encodeURIComponent('https://www.asyncapi.com/blog/2024-annual-summary#social-media')}`}
+              href={`https://twitter.com/intent/tweet?text=${encodeURIComponent('Discover the latest stories from the AsyncAPI community!')}&url=${encodeURIComponent('https://www.asyncapi.com/blog')}`}
               target='_blank'
               rel='noopener noreferrer'
               className='text-blue-500 hover:text-blue-700'
             >
-              <IconTwitter className='h-6 w-6' />
+              <IconTwitter className='size-6' />
             </a>
             <a
-              href={`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent('https://www.asyncapi.com/blog/2024-annual-summary#social-media')}`}
+              href={`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent('https://www.asyncapi.com/blog')}`}
               target='_blank'
               rel='noopener noreferrer'
               className='text-blue-700 hover:text-blue-900'
             >
-              <IconLinkedIn className='h-6 w-6' />
+              <IconLinkedIn className='size-6' />
             </a>
           </div>

Additionally, consider extracting this into a reusable component to maintain consistency with other blog components as mentioned in the PR objectives.

🧰 Tools
🪛 GitHub Actions: PR testing - if Node project

[warning] 138-138: Invalid Tailwind CSS classnames order tailwindcss/classnames-order


[warning] 145-145: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 153-153: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand

Comment on lines +115 to +132
<div className='mt-4 flex space-x-4'>
<a
href={`https://twitter.com/intent/tweet?text=${shareText}&url=${shareUrl}&hashtags=AsyncAPI`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 hover:text-blue-700'
>
<IconTwitter className='h-6 w-6' />
</a>
<a
href={`https://www.linkedin.com/sharing/share-offsite/?url=${shareUrl}`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-700 hover:text-blue-900'
>
<IconLinkedIn className='h-6 w-6' />
</a>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Prevent social share clicks from triggering parent Link navigation.

The social sharing buttons are inside a parent Link component, which might cause unintended navigation when clicking the share buttons.

Apply this diff to prevent event propagation:

-              <div className='mt-4 flex space-x-4'>
+              <div className='mt-4 flex space-x-4' onClick={(e) => e.preventDefault()}>
                 <a
                   href={`https://twitter.com/intent/tweet?text=${shareText}&url=${shareUrl}&hashtags=AsyncAPI`}
                   target='_blank'
                   rel='noopener noreferrer'
                   className='text-blue-500 hover:text-blue-700'
+                  onClick={(e) => e.stopPropagation()}
                 >
-                  <IconTwitter className='h-6 w-6' />
+                  <IconTwitter className='size-6' />
                 </a>
                 <a
                   href={`https://www.linkedin.com/sharing/share-offsite/?url=${shareUrl}`}
                   target='_blank'
                   rel='noopener noreferrer'
                   className='text-blue-700 hover:text-blue-900'
+                  onClick={(e) => e.stopPropagation()}
                 >
-                  <IconLinkedIn className='h-6 w-6' />
+                  <IconLinkedIn className='size-6' />
                 </a>
               </div>
📝 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
<div className='mt-4 flex space-x-4'>
<a
href={`https://twitter.com/intent/tweet?text=${shareText}&url=${shareUrl}&hashtags=AsyncAPI`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 hover:text-blue-700'
>
<IconTwitter className='h-6 w-6' />
</a>
<a
href={`https://www.linkedin.com/sharing/share-offsite/?url=${shareUrl}`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-700 hover:text-blue-900'
>
<IconLinkedIn className='h-6 w-6' />
</a>
</div>
<div className='mt-4 flex space-x-4' onClick={(e) => e.preventDefault()}>
<a
href={`https://twitter.com/intent/tweet?text=${shareText}&url=${shareUrl}&hashtags=AsyncAPI`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-500 hover:text-blue-700'
onClick={(e) => e.stopPropagation()}
>
<IconTwitter className='size-6' />
</a>
<a
href={`https://www.linkedin.com/sharing/share-offsite/?url=${shareUrl}`}
target='_blank'
rel='noopener noreferrer'
className='text-blue-700 hover:text-blue-900'
onClick={(e) => e.stopPropagation()}
>
<IconLinkedIn className='size-6' />
</a>
</div>
🧰 Tools
🪛 GitHub Actions: PR testing - if Node project

[warning] 122-122: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand


[warning] 130-130: Classnames 'h-6, w-6' could be replaced by the 'size-6' shorthand! tailwindcss/enforces-shorthand

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] <Social Sharing Buttons on Blogs>
1 participant