Skip to content

Fix reusable content cross-space page reference resolution #3321

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

emmerich
Copy link
Contributor

Summary

  • Fixed broken links to pages in the parent space of reusable content when used across different sites
  • Added parentSpaceContext to GitBookSpaceContext type for tracking parent space information
  • Enhanced resolveContentRef to check parent space when page resolution fails in current space
  • Added comprehensive unit tests for the new functionality

Background

When reusable content contains links to pages in its parent space, these links were broken when the reusable content was used in a different space/site. This happened because the pages array was set to [] for cross-space reusable content to prevent unwanted cross-site linking.

Solution

The fix introduces a parentSpaceContext field in GitBookSpaceContext that preserves information about the parent space (where the reusable content originates). When page resolution fails in the current space, the system now checks the parent space and uses the existing resolveContentRefInSpace function to generate proper absolute URLs.

Changes

  • GitBookSpaceContext type: Added optional parentSpaceContext field
  • ReusableContent component: Now includes parent space context when rendering cross-space content
  • resolveContentRef function: Added fallback logic to check parent space for page resolution
  • Unit tests: Comprehensive test coverage for the new functionality

Test plan

  • Unit tests pass for all new functionality
  • Existing functionality remains intact (tests pass)
  • Cross-space links resolve to absolute URLs for security
  • Same-space reusable content behavior unchanged
  • Manual testing with actual reusable content across different sites

🤖 Generated with Claude Code

- Add parentSpaceContext to GitBookSpaceContext type for tracking parent space information
- Update ReusableContent component to include parent space context when rendering content from different spaces
- Enhance resolveContentRef to check parent space when page resolution fails in current space
- Add comprehensive unit tests for the new parent space fallback functionality

This resolves broken links to pages in the parent space of reusable content when used across different sites.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link

changeset-bot bot commented Jun 14, 2025

⚠️ No Changeset found

Latest commit: fac5fcf

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

argos-ci bot commented Jun 14, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v1 (Inspect) ✅ No changes detected - Jun 14, 2025, 1:01 PM
customers-v2 (Inspect) ⚠️ Changes detected (Review) 77 changed Jun 14, 2025, 1:03 PM
default (Inspect) ⚠️ Changes detected (Review) 5 changed Jun 14, 2025, 1:03 PM
v2-cloudflare (Inspect) ✅ No changes detected - Jun 14, 2025, 1:05 PM
v2-vercel (Inspect) ✅ No changes detected - Jun 14, 2025, 1:05 PM

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.

1 participant