【发布时间】:2019-10-10 23:16:15
【问题描述】:
将 Wyam 嵌入到 asp.net 核心 MVC 解决方案中的正确方法是什么?
由于项目需要高级身份验证,我已将其嵌入到 MVC 中。 我目前将它嵌入到 MVC 控制器中,使用控制器读取生成的 html 文件并通过视图呈现它。
文件以下列方式提供
public IActionResult Index()
{
return ServeMarkdownPage("index");
}
[Route("{pageName}")]
public IActionResult ServeMarkdownPage([FromRoute]string pageName)
{
if (!System.IO.File.Exists($"HtmlOutput//{pageName}.html"))
{
return View("Error");
}
var content = System.IO.File.ReadAllText($"HtmlOutput//{pageName}.html");
return View("MarkdownPage", new MarkdownPageViewModel { HtmlContent = content });
}
视图只是将html内容输出到页面中。
@Html.Raw(Model.HtmlContent)
Markdown 生成是通过引擎实例的实例化并将其转换为 html 来完成的。 在这种情况下,waym 配方似乎被忽略了。
var engine = new Wyam.Core.Execution.Engine();
engine.FileSystem.InputPaths.Add(new DirectoryPath("Markdown"));
engine.FileSystem.OutputPath = new DirectoryPath("HtmlOutput");
engine.Pipelines.Add(new Pipeline(
"DocumentationPages",
new ReadFiles("**/*.md"),
new FrontMatter(new Yaml()),
new Markdown(),
new WriteFiles(".html")));
var docsRecipe = new Docs();
docsRecipe.Apply(engine);
这可以以更好的方式完成吗?配方是否正确调用?
【问题讨论】:
-
刚刚在文档wyam.io/docs/usage/embedding 中看到了这一点。
Once the engine is configured, execute it with a call to Engine.Execute(). This will start evaluation of the pipelines and any output messages will be sent to the configured trace endpoints.
标签: c# asp.net-mvc wyam