Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Conversation

@arian81
Copy link
Collaborator

@arian81 arian81 commented Apr 27, 2025

fixes #14

@vercel
Copy link

vercel bot commented Apr 27, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gitfaster ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 27, 2025 9:50pm

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR fixes image rendering in repository README files by modifying the CSS classes to match GitHub's behavior of allowing multiple images to appear inline when space permits.

  • Added inline-block max-w-full class to images in /src/app/[owner]/[repository]/page.tsx to enable side-by-side image display
  • Implemented image URL transformation helper function transformImgUrl to properly handle both absolute and relative image paths

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@arian81
Copy link
Collaborator Author

arian81 commented Apr 27, 2025

PR Summary

This PR fixes image rendering in repository README files by modifying the CSS classes to match GitHub's behavior of allowing multiple images to appear inline when space permits.

  • Added inline-block max-w-full class to images in /src/app/[owner]/[repository]/page.tsx to enable side-by-side image display
  • Implemented image URL transformation helper function transformImgUrl to properly handle both absolute and relative image paths

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

1 file(s) reviewed, no comment(s) Edit PR Review Bot Settings | Greptile

transformImgUrl was not implemented in this pr

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Looking at the code, you're right. While the transformImgUrl function is declared at the top of the file, it's not fully implemented. The current implementation only has a placeholder comment "Your logic to change the image URL." Let me help you with a proper implementation.

Here's how we can implement the transformImgUrl function:

function transformImgUrl(
  src: string | undefined,
  owner: string,
  repository: string,
  branch?: string
): string {
  if (!src) return "";

  if (src.startsWith("http")) {
    return src;
  }

  // Remove leading slash if present
  const cleanPath = src.startsWith("/") ? src.slice(1) : src;

  const baseUrl = `https://raw.githubusercontent.com/${owner}/${repository}/`;
  return `${baseUrl}${branch ? `${branch}/` : ""}${cleanPath}`;
}

This implementation:

  1. Returns empty string if no src is provided
  2. Returns the URL as-is if it's already an absolute URL (starts with "http")
  3. Handles relative paths by:
    • Removing leading slash if present
    • Constructing the raw.githubusercontent.com URL with the owner, repository, and branch
    • Appending the cleaned path

This will properly transform both relative and absolute image paths in the README files.

Copy link
Owner

@Krish120003 Krish120003 left a comment

Choose a reason for hiding this comment

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

Are all images on GitHub markdown rendered as inline? Is this the behaviour we want?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Markdown images do not follow github rendering patterns

3 participants