Skip to content

Commit 1945fcf

Browse files
theletterfclaude
andcommitted
fix(page-card): apply UrlPathPrefix to resolved URLs
Page-card links were generating site-root-relative hrefs (e.g. /cli/stack/es) without the deployment path prefix, causing 404s in preview environments where the site is hosted under a subpath (e.g. /elastic/cli/pull/406/cli/stack/es). Apply the same UrlPathPrefix logic used by DiagnosticLinkInlineParser. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c434430 commit 1945fcf

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/Elastic.Markdown/Myst/Directives/PageCard/PageCardBlock.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public override void FinalizeAndValidate(ParserContext context)
5555
: relativeToSource;
5656

5757
ResolvedUrl = "/" + withoutExtension.Replace('\\', '/');
58+
59+
// Apply URL path prefix so links work in preview/sub-path deployments (same logic as DiagnosticLinkInlineParser)
60+
var urlPathPrefix = context.Build.UrlPathPrefix ?? string.Empty;
61+
if (!string.IsNullOrWhiteSpace(urlPathPrefix) && !ResolvedUrl.StartsWith(urlPathPrefix, StringComparison.OrdinalIgnoreCase))
62+
ResolvedUrl = $"{urlPathPrefix.TrimEnd('/')}{ResolvedUrl}";
5863
}
5964

6065
[GeneratedRegex(@"^\[([^\]]+)\]\(([^)]+)\)$")]

0 commit comments

Comments
 (0)