Skip to content

fix: support direct image hyperlinks #640

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

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

Conversation

raymondanythings
Copy link

@raymondanythings raymondanythings commented Jun 2, 2025

fix #637

Description

adds native support for hyperlinks applied directly to image blocks. While Notion allows hyperlinks via image captions, exposing the link as a caption feels intrusive and affects the user experience.

To address this, we modify the asset-wrapper logic to properly detect and wrap images in anchor tags when a valid image_hyperlink is present.

Solution

  1. Introduced getURLInfo()
  • Determines whether the image should link to
    • a Notion page (/xxx pattern with UUID),
    • an external URL (validated using a URL regex).
  1. Improved link handling logic
  • Fallback order: imageHyperlink → caption
  • Automatically wraps the image with <components.PageLink> only when a valid link is detected.
  • Maintains support for internal Notion page routing via mapPageUrl.

Notion Test Page ID

2061b06afbf1807b8e35d35e7a7fd146

Copy link

vercel bot commented Jun 2, 2025

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

Name Status Preview Updated (UTC)
react-notion-x ✅ Ready (Inspect) Visit Preview Jun 6, 2025 3:54pm
react-notion-x-minimal-demo ✅ Ready (Inspect) Visit Preview Jun 6, 2025 3:54pm

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.

Support for hyperlinks attached to images
2 participants