Something went wrong. Try again.
Personal website
Something went wrong. Try again.
1.9 kB · 63 lines
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263@* This file is part of NKK.
NKK is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
NKK is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with NKK. If not, see <http://www.gnu.org/licenses/>.*@
@using System.Text@inject IHttpContextAccessor HttpContextAccessor
@if (StripOuter) { @( (MarkupString)RenderHtml() )} else { <div @attributes="ExtraAttributes" class="@( UseTypographyStyle ? "tx" : "" ) @( ExtraAttributes?.GetValueOrDefault("class", "") )"> @( (MarkupString)RenderHtml() ) </div>}
@code { [Parameter] public RenderFragment? ChildContent { get; set; } [Parameter] public String? Content { get; set; } [Parameter] public FileInfo? File { get; set; } [Parameter] public bool UseTypographyStyle { get; set; } = true; [Parameter] public bool StripOuter { get; set; } = false; [Parameter(CaptureUnmatchedValues = true)] public Dictionary<String, Object>? ExtraAttributes { get; set; }
private String RenderHtml() { if (ChildContent != null && Content != null && File != null) throw new ArgumentException("Only one of Content, File, or ChildContent can be set."); if (File != null) Content = new StreamReader(File.FullName, Encoding.UTF8).ReadToEnd(); else if (ChildContent != null) Content = ChildContent.RenderString(); var md = new MarkdownConverter(Content ?? String.Empty, new MarkdownOptions { LocalLinkBase = HttpContextAccessor.HttpContext!.Request.Path }); return md.ToHtml(); }}