//[Route("{pagename}")] public ActionResult DisplayPage(string pageName) { if (!string.IsNullOrEmpty(pageName) && pageName.EndsWith("/")) { pageName = pageName.TrimEnd('/'); return(RedirectPermanent("~/" + pageName)); } SetMeta(); SetPartnerCanonicalLink(); if (String.IsNullOrEmpty(pageName)) { pageName = "Index"; } // Check if physical page exists and use standard one, if not use content service var viewName = pageName.Replace("-", string.Empty); var result = ViewEngines.Engines.FindView(this.ControllerContext, viewName, null); if (result == null || result.View == null) { var filesPath = HostingEnvironment.MapPath("~/App_Data/vc-contents"); var service = new ContentPublishingService(filesPath, new[] { new LiquidTemplateEngine(filesPath) }); var item = service.GetContentItem(pageName.Contains("/") ? pageName : String.Format("/pages/{0}", pageName)); if (item != null) { SetSpecialMeta(item); return(this.View(item.Layout, item)); } else { throw new HttpException(404, "Page doesn't exist."); } } return(View(viewName)); }
public void Can_generate_content_item() { var service = new ContentPublishingService("data", new [] { new LiquidTemplateEngine("data"), }); var item = service.GetContentItem("yaml-header-input.md"); }