ant-design-blazor/site/AntDesign.Docs/Shared/HighlightedCode.razor
2021-02-06 20:15:46 +08:00

36 lines
647 B
C#

@using AntDesign.Docs.Highlight
<pre class="language-@Language">
<code>
@sourceCode
</code>
</pre>
@inject IPrismHighlighter Highlighter
@code {
[Parameter]
public string Code { get; set; }
[Parameter]
public string Language { get; set; }
[Parameter]
public bool CanLoad { get; set; }
MarkupString sourceCode { get; set; }
bool hasLoaded = false;
protected override async Task OnParametersSetAsync()
{
if (CanLoad && !hasLoaded)
{
sourceCode = await Highlighter.HighlightAsync(Code, Language);
hasLoaded = true;
}
}
}