Skip to content

Conversation

@cotti
Copy link
Contributor

@cotti cotti commented Nov 11, 2025

Fixes #2190

On assembler builds, image URLs were not being adjusted to their final paths. We can access this information through the context's PositionalNavigation.

newUrl = newUrl[3..];
offset--;
}
newUrl = Path.GetFullPath(Path.Combine(urlPathPrefix, snippet.RelativeFolder, url))
if (currentUrl.LastIndexOf('/') > 0)
{
var basePath = currentUrl[..currentUrl.LastIndexOf('/')];
newUrl = Path.GetFullPath(Path.Combine(basePath, url));
@cotti cotti enabled auto-merge (squash) November 11, 2025 23:54
Copy link
Member

@reakaleek reakaleek left a comment

Choose a reason for hiding this comment

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

Would testing help verify this?

Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

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

I think we can simplify this a bit using:

		if (context.Build.AssemblerBuild && context.TryFindDocument(fi) is MarkdownFile currentMarkdown)
		{
			// Acquire navigation-aware path
			if (context.PositionalNavigation.MarkdownNavigationLookup.TryGetValue(currentMarkdown, out var currentNavigation))
			{
				var uri = new Uri(new UriBuilder("http", "localhost", 80, currentNavigation.Url).Uri, url);
				newUrl = uri.AbsolutePath;
			}
			else
				context.EmitError($"Failed to acquire navigation for current markdown file '{currentMarkdown.FileName}' while resolving relative url '{url}'.");
		}

cotti and others added 2 commits November 12, 2025 10:30
Co-authored-by: Martijn Laarman <Mpdreamz@gmail.com>
else
context.EmitError($"Failed to acquire navigation for current markdown file '{currentMarkdown.FileName}' while resolving relative url '{url}'.");

newUrl = $"/{Path.Combine(newUrl.StartsWith(urlPathPrefix) ? string.Empty : urlPathPrefix, newUrl.TrimStart('/'))
@reakaleek
Copy link
Member

Would testing help verify this?

I took a stab at creating a appropriate test for this:

#2199

I was able to verify, that the test succeeds with your changes and fails without your changes.

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.

Images from reference repos are not loading

4 participants