mirror of https://github.com/abpframework/abp.git
2 changed files with 46 additions and 0 deletions
@ -0,0 +1,20 @@ |
|||||
|
@using Volo.CmsKit.Web.Contents; |
||||
|
@using System.Dynamic |
||||
|
@using Volo.Abp.Data |
||||
|
@using Volo.CmsKit.Web.Renderers; |
||||
|
|
||||
|
@model ContentFragmentViewComponent |
||||
|
|
||||
|
@inject IMarkdownToHtmlRenderer MarkdownRenderer |
||||
|
|
||||
|
@foreach (var contentFragment in Model.PageDto.ContentFragments) |
||||
|
{ |
||||
|
if (contentFragment.Type == "Markdown") |
||||
|
{ |
||||
|
@Html.Raw(await MarkdownRenderer.RenderAsync(contentFragment.GetProperty<string>("Content"))) |
||||
|
} |
||||
|
else if (contentFragment.Type == "Widget") |
||||
|
{ |
||||
|
@await Component.InvokeAsync(contentFragment.GetProperty<string>("Type"), contentFragment.ExtraProperties.ConvertToDynamicObject()) |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Widgets; |
||||
|
using Volo.CmsKit.Contents; |
||||
|
|
||||
|
namespace Volo.CmsKit.Web.Contents; |
||||
|
|
||||
|
[Widget( |
||||
|
AutoInitialize = true |
||||
|
)] |
||||
|
[ViewComponent(Name = "ContentFragment")] |
||||
|
public class ContentFragmentViewComponent : ViewComponent |
||||
|
{ |
||||
|
public PageDto PageDto { get; set; } |
||||
|
|
||||
|
public ContentFragmentViewComponent() |
||||
|
{ |
||||
|
PageDto = new(); |
||||
|
} |
||||
|
|
||||
|
public virtual async Task<IViewComponentResult> InvokeAsync(PageDto pageDto) |
||||
|
{ |
||||
|
return View("~/Contents/ContentFragment.cshtml", new ContentFragmentViewComponent() { PageDto = pageDto }); |
||||
|
} |
||||
|
} |
||||
|
|
||||
Loading…
Reference in new issue