Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 29, 2025

Fixes an issue where empty link text in crosslinks didn't render the target page title, unlike internal links which automatically populate titles when link text is omitted.

Problem

When using crosslink syntax with empty text like [](docs-content:///solutions/search/semantic-search.md), the link would render with no text, even when the target page has a title. This was inconsistent with internal links where [](local-file.md) automatically uses the target page's title.

The root cause was that crosslink processing bypassed the ProcessLinkText method that handles auto-title population for internal links.

Solution

Enhanced the crosslink processing pipeline to:

  1. Extended metadata structure: Added optional title property to LinkMetadata with backwards-compatible JSON serialization
  2. Enhanced resolver interface: Added TryGetLinkMetadata method to ICrossLinkResolver for accessing crosslink metadata
  3. Modified crosslink processing: Updated ProcessCrossLink to check for empty link text and populate with title from metadata when available

Behavior

  • [](crosslink://file.md) now auto-populates with the page title when available in crosslink metadata
  • When no title is available, link text remains empty (preserving existing behavior)
  • All existing crosslink functionality unchanged - this is purely additive
  • Fully backwards compatible with existing crosslink indexes

Testing

Added comprehensive tests covering:

  • Crosslinks with empty text that have titles in metadata (auto-populated)
  • Crosslinks with empty text that lack titles in metadata (remain empty)
  • Existing crosslink functionality (unchanged)

All 627 existing tests continue to pass, ensuring no regressions.

Original prompt

This section details on the original issue you should resolve

<issue_title>Empty link text doesn't render page title with crosslinks</issue_title>
<issue_description>### Describe the bug

When using the syntax [](docs-content:///solutions/search/semantic-search.md) the page title is not rendered if it's a crosslink.

Expected behavior

It should render the page title

Steps to reproduce

Add [](docs-content:///solutions/search/semantic-search.md) in markdown outside of docs-content.

Tooling

  • docs-builder
  • migration tooling
  • I'm not sure</issue_description>

<agent_instructions>cross links are validated using the link index. we might need to utilize that.

However, it's not holding that data. so find a backwards compatiable way to do it.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #1953

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] Empty link text doesn't render page title with crosslinks Fix empty crosslink text to auto-populate page titles Sep 29, 2025
@Copilot Copilot AI requested a review from reakaleek September 29, 2025 10:21
Copilot finished work on behalf of reakaleek September 29, 2025 10:21
@reakaleek reakaleek marked this pull request as ready for review September 29, 2025 10:33
@reakaleek reakaleek requested a review from a team as a code owner September 29, 2025 10:33
@reakaleek reakaleek requested a review from cotti September 29, 2025 10:33
@reakaleek reakaleek added the fix label Sep 29, 2025
@Copilot Copilot AI requested a review from reakaleek September 29, 2025 10:42
Copilot finished work on behalf of reakaleek September 29, 2025 10:42
@reakaleek
Copy link
Member

@copilot confirm my assumption.

So this will start adding the title to the link metadata. As long as it's null or empty. it will behave as before. But as soon as the link index started adding the title, the title will be rendered.

Copy link
Contributor Author

Copilot AI commented Sep 29, 2025

@copilot confirm my assumption.

So this will start adding the title to the link metadata. As long as it's null or empty. it will behave as before. But as soon as the link index started adding the t...

Correct. The implementation is fully backwards compatible:

  1. When title is null/empty: The behavior remains exactly as before - empty crosslinks stay empty
  2. When title is provided: Empty crosslinks will auto-populate with the title from the link metadata
  3. Existing crosslinks: All existing crosslinks with explicit text continue to work unchanged

The JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull) attribute on the Title property ensures that existing link indexes without titles continue to work without any changes to their JSON structure. Only when link indexes are updated to include titles will the auto-population feature activate.

Copilot finished work on behalf of reakaleek September 29, 2025 10:53
@Mpdreamz
Copy link
Member

I am worried this change will balloon the links.json files:

image

The logstash plugins links is already 4mb. We should check a before and after and compare.

@reakaleek
Copy link
Member

I am worried this change will balloon the links.json files:

image

The logstash plugins links is already 4mb. We should check a before and after and compare.

What do you think of a new json file that is uploaded and fetched for this purpose only.

I can see it useful also for the planned link popover preview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty link text doesn't render page title with crosslinks
3 participants