Skip to content
Merged
Changes from 3 commits
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
14 changes: 8 additions & 6 deletions src/Elastic.Markdown/Myst/Directives/DirectiveHtmlRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// See the license.txt file in the project root for more information.

using Elastic.Markdown.Diagnostics;
using Elastic.Markdown.Myst.CodeBlocks;
using Elastic.Markdown.Myst.FrontMatter;
using Elastic.Markdown.Myst.Settings;
using Elastic.Markdown.Myst.Substitution;
Expand Down Expand Up @@ -85,11 +84,14 @@ protected override void Write(HtmlRenderer renderer, DirectiveBlock directiveBlo

private void WriteImage(HtmlRenderer renderer, ImageBlock block)
{
var imageUrl =
block.ImageUrl != null &&
(block.ImageUrl.StartsWith("/_static") || block.ImageUrl.StartsWith("_static"))
? $"{block.Build.UrlPathPrefix}/{block.ImageUrl.TrimStart('/')}"
: block.ImageUrl;
var imageUrl = block.ImageUrl;
if (!string.IsNullOrEmpty(block.ImageUrl))
{
if (block.ImageUrl.StartsWith('/') || block.ImageUrl.StartsWith("_static"))
imageUrl = $"{block.Build.UrlPathPrefix}/{block.ImageUrl.TrimStart('/')}";
else
imageUrl = block.Build.UrlPathPrefix + block.CurrentFile.DirectoryName!.Replace(block.Build.ConfigurationPath.DirectoryName!, "") + "/" + block.ImageUrl;
}
var slice = Image.Create(new ImageViewModel
{
Label = block.Label,
Expand Down
Loading