Skip to content

Fix page link titles showing site section name instead of target space title (#4542) - #4543

Open
kaicode wants to merge 2 commits into
GitbookIO:mainfrom
kaicode:main
Open

Fix page link titles showing site section name instead of target space title (#4542)#4543
kaicode wants to merge 2 commits into
GitbookIO:mainfrom
kaicode:main

Conversation

@kaicode

@kaicode kaicode commented Aug 25, 2026

Copy link
Copy Markdown

Summary

Fixes a regression introduced in #4525 (RND-12437) where Page Link blocks and other space refs displayed the site section title (e.g. "Practical Guides") instead of the target site-space title (e.g. "SNOMED CT EHR Requirements Guide") on preview and published sites.

Root cause: #4525 changed getSpaceRefText() to prefer the containing section title for resolved.text. Page Link blocks (content-ref) render resolved.text directly as the card title. On multi-space sites where each guide is its own space grouped under one section, every cross-space link in that section showed the same section name.

Fix:

  • Restore getSpaceRefText() to return the site-space (variant) title, falling back to the raw space title.
  • Move the section title into resolved.ancestors via a new getSpaceRefSectionLabel() helper, preserving the original RND-12437 intent for link preview breadcrumbs/tooltips without affecting card display text.

Reported by: SNOMED CT Document Library (docs.snomed.org) — all Page Link blocks under "Functional Guides" rendered as "Practical Guides".

Suggested Test plan

  • bun test packages/gitbook/src/lib/references.test.ts --preload ./tests/preload-bun.ts — all 23 tests pass
  • Verified the new SNOMED regression test fails without the fix:
    Expected: "SNOMED CT EHR Requirements Guide"
    Received: "Practical Guides"
    

The following items are suggested to complete testing. I have not done these yet. Let me know if I should set up a development environment and complete these myself.

  • Preview/publish a page with cross-space Page Link blocks in a multi-space site section and confirm each link shows its own site-space title
  • Hover an inline link to another space and confirm the section name appears in the breadcrumb, not as the main link text
  • Confirm direct space links on sites without sections still show the site-space title

@changeset-bot

changeset-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e06c536

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
gitbook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tgargula tgargula left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

L👌TM

@rodrcastro

Copy link
Copy Markdown
Contributor

@tgargula Can you make the necessary updates to the branch and workflows and merge this please? Want to make sure we are getting this solved for them asap :)

@github-actions

Copy link
Copy Markdown
Contributor

Summary of the deployments:

Version URL Status
Vercel
Cloudflare

Test content

Site 2v 2c
GitBook /url/gitbook.com/docs /url/gitbook.com/docs
E2E /url/gitbook.gitbook.io/test-gitbook-open /url/gitbook.gitbook.io/test-gitbook-open

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.

3 participants