-
Notifications
You must be signed in to change notification settings - Fork 19
fix: make readme images inline-block #15
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this 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-fullclass to images in/src/app/[owner]/[repository]/page.tsxto enable side-by-side image display - Implemented image URL transformation helper function
transformImgUrlto 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 |
There was a problem hiding this 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:
- Returns empty string if no src is provided
- Returns the URL as-is if it's already an absolute URL (starts with "http")
- 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.
Krish120003
left a comment
There was a problem hiding this 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?
fixes #14