Skip to content

Commit fe39596

Browse files
committed
only set it on hx-get
1 parent 7fa4cb8 commit fe39596

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/Elastic.Documentation.Site/Htmx.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public static string GetHxAttributes(
3131
string? hxIndicator = HxIndicator
3232
)
3333
{
34-
targetUrl = targetUrl.Contains('?') ? $"{targetUrl}&v={VersionHash}" : $"{targetUrl}?v={VersionHash}";
34+
var hxGetUrl = targetUrl.Contains('?') ? $"{targetUrl}&v={VersionHash}" : $"{targetUrl}?v={VersionHash}";
3535
var attributes = new StringBuilder();
36-
_ = attributes.Append($" hx-get={targetUrl}");
36+
_ = attributes.Append($" hx-get={hxGetUrl}");
3737
_ = attributes.Append($" hx-select-oob={hxSwapOob ?? GetHxSelectOob(hasSameTopLevelGroup)}");
3838
_ = attributes.Append($" hx-swap={hxSwap}");
3939
_ = attributes.Append($" hx-push-url={hxPushUrl}");

src/Elastic.Markdown/Myst/Renderers/HtmxLinkInlineRenderer.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ protected override void Write(HtmlRenderer renderer, LinkInline link)
2828
}
2929

3030
var url = link.GetDynamicUrl?.Invoke() ?? link.Url;
31-
if (url is not null)
32-
url = url.Contains('?') ? $"{url}&v={Htmx.VersionHash}" : $"{url}?v={Htmx.VersionHash}";
31+
var hxGetUrl = url;
32+
if (hxGetUrl is not null)
33+
hxGetUrl = hxGetUrl.Contains('?') ? $"{hxGetUrl}&v={Htmx.VersionHash}" : $"{hxGetUrl}?v={Htmx.VersionHash}";
3334

3435
var isCrossLink = (link.GetData("isCrossLink") as bool?) == true;
3536
var isHttpLink = url?.StartsWith("http") ?? false;
@@ -45,7 +46,7 @@ protected override void Write(HtmlRenderer renderer, LinkInline link)
4546
var targetRootNavigation = link.GetData($"Target{nameof(MarkdownFile.NavigationRoot)}") as INodeNavigationItem<INavigationModel, INavigationItem>;
4647
var hasSameTopLevelGroup = !isCrossLink && (currentRootNavigation?.Id == targetRootNavigation?.Id);
4748
_ = renderer.Write(" hx-get=\"");
48-
_ = renderer.WriteEscapeUrl(url);
49+
_ = renderer.WriteEscapeUrl(hxGetUrl);
4950
_ = renderer.Write('"');
5051
_ = renderer.Write($" hx-select-oob=\"{Htmx.GetHxSelectOob(hasSameTopLevelGroup)}\"");
5152
_ = renderer.Write($" hx-swap=\"{Htmx.HxSwap}\"");

0 commit comments

Comments
 (0)