private HashSet <string> GetSitemap() { var root = Layout.Create() .AddController <TestController>("c") .Add("sitemap", Sitemap.Create()); using var runner = TestRunner.Run(root); using var response = runner.GetResponse("/sitemap"); return(response.GetSitemap()); }
public WebsiteRouter(IHandler parent, IHandlerBuilder content, IEnumerable <IConcernBuilder> concerns, IHandlerBuilder scripts, IHandlerBuilder styles, IResourceProvider?favicon, IMenuProvider?menu, ITheme theme) { Parent = parent; var layout = Layout.Create() .Add("scripts", scripts) .Add("styles", styles) .Add("sitemap.xml", Sitemap.Create()) .Add("robots.txt", BotInstructions.Default().Sitemap()) .Fallback(content); foreach (var concern in concerns) { layout.Add(concern); } if (favicon != null) { layout.Add("favicon.ico", Download.From(favicon).Type(ContentType.ImageIcon)); } if (theme.Resources != null) { layout.Add("resources", theme.Resources); } Handler = layout.Build(this); Theme = theme; Menu = menu ?? Websites.Menu.Create((r, _) => GetContent(r)).Build(); var scriptRouter = (ScriptRouter)scripts.Build(this); var styleRouter = (StyleRouter)styles.Build(this); Renderer = new WebsiteRenderer(Theme, Menu, scriptRouter, styleRouter); }
public void TestContent() { var root = CreateRoot(); File.WriteAllText(Path.Combine(root, "index.html"), "Index"); File.WriteAllText(Path.Combine(root, "file.html"), "File"); var layout = Layout.Create() .Add("spa", SinglePageApplication.From(root)) .Add("sitemap", Sitemap.Create()); using var runner = TestRunner.Run(layout); using var response = runner.GetResponse("/sitemap"); var sitemap = response.GetSitemap(); Assert.Contains("/spa/index.html", sitemap); Assert.Contains("/spa/file.html", sitemap); }
private IHandlerBuilder GetContent() { var root = Layout.Create(); var children = Layout.Create(); children.Index(Page.From("Child Index Page", "Child Index")); children.Add("child-other", Page.From("Child Other Page", "Child Other")); var content = Layout.Create(); content.Index(Page.From("Index Page", "Index")); content.Add("other", Page.From("Other Page", "Other")); content.Add("children", children); root.Add("sitemap.xml", Sitemap.Create()); root.Fallback(content); return(root); }