Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System.Reflection;
using Elastic.Documentation.Extensions;
using Elastic.Documentation.Site;
using Elastic.Documentation.Site.Navigation;
using Elastic.Markdown.IO;
Expand All @@ -14,6 +16,11 @@ namespace Elastic.Markdown.Myst.Renderers;

public class HtmxLinkInlineRenderer : LinkInlineRenderer
{
private static readonly string Version =
Assembly.GetExecutingAssembly().GetCustomAttributes<AssemblyInformationalVersionAttribute>()
.FirstOrDefault()?.InformationalVersion ?? "0.0.0";
private static readonly string VersionHash = ShortId.Create(Version);

protected override void Write(HtmlRenderer renderer, LinkInline link)
{
if (renderer.EnableHtmlForInline && !link.IsImage)
Expand All @@ -25,7 +32,8 @@ protected override void Write(HtmlRenderer renderer, LinkInline link)
return;
}

var url = link.GetDynamicUrl != null ? link.GetDynamicUrl() : link.Url;
var url = link.GetDynamicUrl?.Invoke() ?? link.Url;
url = $"{url}?v={VersionHash}";

var isCrossLink = (link.GetData("isCrossLink") as bool?) == true;
var isHttpLink = url?.StartsWith("http") ?? false;
Expand Down
Loading