Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 10, 2025

This PR adds comprehensive support for GitHub Pull Request links to complement the existing GitHub Issue link functionality.

New Components Added

  • GithubPRLink - Client component that fetches PR data using useEffect
  • GithubPRLinkBase - Base component that accepts PR data as props
  • GithubPRLinkRsc - Server-side component for RSC environments

Key Features

PR State Indicators

  • Draft: Shows gray badge with draft icon
  • Open: Shows green badge with open PR icon
  • Merged: Shows purple badge with merge icon
  • Closed: Shows red badge with closed icon

API Integration

  • Fetches PR data from GitHub API using /repos/{owner}/{repo}/pulls/{number} endpoint
  • Supports both authenticated and unauthenticated requests
  • Handles rate limiting and error states consistently

Visual Design

  • Consistent styling with existing Issue Link components
  • Displays repository name, PR title, and number
  • Shows reaction counts (👍, 👀, ❤️, 🎉, 🚀)
  • Supports both inline and block display variants

Usage Examples

Basic Usage

import { GithubPRLink } from 'react-github-permalink';
import "react-github-permalink/dist/github-permalink.css";

<GithubPRLink prLink="https://github.com/facebook/react/pull/24652" />

With Custom Data

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

<GithubPRLinkBase
  prLink="https://github.com/facebook/react/pull/24652"
  data={{
    prTitle: "Add concurrent features to React",
    prNumber: "24652",
    prState: "closed",
    merged: true,
    isDraft: false,
    // ... other fields
  }}
/>

RSC Support

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

<GithubPRLinkRsc prLink="https://github.com/facebook/react/pull/24652" />

Implementation Details

  • URL Parsing: Added parseGithubPRLink() function specifically for PR URLs
  • Data Fetching: New defaultGetPRFn() that uses GitHub's Pull Request API
  • Type Safety: Added GithubPRLinkDataResponse type with PR-specific fields
  • Configuration: Extended BaseConfiguration to include getPRFn option
  • Testing: Added comprehensive tests for PR URL parsing
  • Documentation: Updated README with complete usage examples

Screenshots

The PR Link component displaying a merged PR with reactions:
PR Link Component

Backward Compatibility

This is a purely additive change - all existing functionality remains unchanged. The new components follow the same patterns as the existing Issue Link components for consistency.

Fixes #18.

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: 4058e70

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 failed.

Name Link
🔨 Latest commit 4058e70
🔍 Latest deploy log https://app.netlify.com/projects/react-github-permalink/deploys/686f5bb70738540008c71ef5

@Copilot Copilot AI changed the title [WIP] Add PR Link. Add GitHub Pull Request Link Support Jul 10, 2025
@Copilot Copilot AI requested a review from dwjohnston July 10, 2025 06:21
Copilot finished work on behalf of dwjohnston July 10, 2025 06:21
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 PR Link.

2 participants