Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 10, 2025

This PR adds a new GithubRepositoryLink component that displays GitHub repository information including star and fork counts, addressing the need for repository links in blog posts and documentation.

✨ Features

  • Repository name with GitHub icon - Displays as a clickable link to the repository
  • Star count - Shows ⭐ with the number of stars
  • Fork count - Shows 🍴 with the number of forks
  • Description - Optional repository description display
  • Clean GitHub-style styling - Matches existing components

🔧 Component Variants

  • Block variant (default) - Full card-style display with header, stats, and description
  • Inline variant - Compact single-line display for embedding in text
  • Configurable options - showDescription and showCounts props to control display

📦 Implementation

Following the existing library patterns, the implementation includes:

  • GithubRepositoryLinkBase - Base component that accepts data as props
  • GithubRepositoryLink - Client component with data fetching
  • GithubRepositoryLinkRsc - RSC variant for Next.js 13+ app router

🎨 Usage Examples

Basic Usage (Client Component)

import { GithubRepositoryLink } from 'react-github-permalink';

export function MyBlogPost() {
  return (
    <div>
      <p>Check out this amazing repository:</p>
      <GithubRepositoryLink repositoryLink="https://github.com/dwjohnston/react-github-permalink" />
    </div>
  );
}

Inline Usage

<p>
  See the code at 
  <GithubRepositoryLink 
    repositoryLink="https://github.com/dwjohnston/react-github-permalink" 
    variant="inline" 
  /> 
  for more details.
</p>

RSC Usage

import { GithubRepositoryLinkRsc } from 'react-github-permalink/dist/rsc';

export function ServerComponent() {
  return (
    <GithubRepositoryLinkRsc repositoryLink="https://github.com/dwjohnston/react-github-permalink" />
  );
}

🔗 API Integration

  • Fetches repository data from GitHub API: https://api.github.com/repos/{owner}/{repo}
  • Supports authentication via GitHub tokens
  • Proper error handling with user-friendly messages
  • Rate limiting awareness

📚 Documentation & Testing

  • Complete Storybook stories demonstrating all features
  • URL parser tests for repository link parsing
  • All existing tests continue to pass
  • TypeScript types for full type safety

🎨 Component Preview

The component displays beautifully with repository information:

GithubRepositoryLink Component

🚀 Technical Details

  • Added parseGithubRepositoryLink utility function for URL parsing
  • Extended configuration system with defaultGetRepositoryFn
  • Updated TypeScript types with GithubRepositoryLinkDataResponse
  • Added comprehensive CSS styling that matches existing components
  • Maintains backward compatibility with existing components

The implementation perfectly addresses the original issue requirement for "a repository link, could have number of forks and stars displayed" and provides a flexible, reusable component that integrates seamlessly with the existing library architecture.

Fixes #37.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • storybook.js.org
    • Triggering command: node /home/REDACTED/work/react-github-permalink/react-github-permalink/node_modules/.bin/storybook dev -p 6006 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link

changeset-bot bot commented Jul 10, 2025

⚠️ No Changeset found

Latest commit: 079fe90

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented Jul 10, 2025

Deploy Preview for react-github-permalink ready!

Name Link
🔨 Latest commit 079fe90
🔍 Latest deploy log https://app.netlify.com/projects/react-github-permalink/deploys/686f5b0fa0193b0008617523
😎 Deploy Preview https://deploy-preview-67--react-github-permalink.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 project configuration.

@Copilot Copilot AI changed the title [WIP] Add repository link. Add GithubRepositoryLink component with star and fork counts Jul 10, 2025
@Copilot Copilot AI requested a review from dwjohnston July 10, 2025 06:19
Copilot finished work on behalf of dwjohnston July 10, 2025 06:19
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.

Add repository link.

2 participants