public Posts(IDeliveryClient deliveryClient, SiteSettings site) { Dependencies.Add(nameof(Seo)); InputModules = new ModuleList { new Kontent <Post>(deliveryClient) .OrderBy(Post.PostDateCodename, SortOrder.Descending) .WithQuery(new DepthParameter(2), new IncludeTotalCountParameter()), new SetMetadata(nameof(Post.Tags), KontentConfig.Get <Post, ITaxonomyTerm[]>(post => post.Tags?.ToArray())), new SetMetadata(nameof(Post.Categories), KontentConfig.Get <Post, ITaxonomyTerm[]>(post => post.Categories?.ToArray())), new SetDestination(KontentConfig.Get((Post post) => new NormalizedPath(post.Url))), new SetMetadata(SearchIndex.SearchItemKey, Config.FromDocument((doc, ctx) => { var post = doc.AsKontent <Post>(); return(new LunrIndexDocItem(doc, post.Title, post.Body) { Description = post.MetadataMetaDescription, Tags = string.Join(", ", post.Tags.Select(t => t.Name)) }); })), }; ProcessModules = new ModuleList { new MergeContent(new ReadFiles(patterns: "post.cshtml")), new RenderRazor() .WithViewData("SEO", Config.FromDocument((doc, ctx) => { var home = ctx.Outputs.FromPipeline(nameof(Seo)).First().AsKontent <Kentico.Kontent.Statiq.Memoirs.Models.Home>(); var post = doc.AsKontent <Post>(); return(new SocialSharingMetadata(home, post)); })) .WithViewData("Title", KontentConfig.Get <Post, string>(p => p.Title)) .WithViewData("Author", KontentConfig.Get <Post, Author>(p => p.Author.OfType <Author>().FirstOrDefault())) .WithViewData("SiteMetadata", site) .WithModel(KontentConfig.As <Post>()), new KontentImageProcessor(), new OptimizeHtml(site.OptimizeOutput) .WithSettings(settings => { // conflicts with ratings settings.RemoveScriptStyleTypeAttribute = false; settings.MinifyJs = false; }) }; OutputModules = new ModuleList { new WriteFiles(), }; }
public Pages(IDeliveryClient deliveryClient, SiteSettings site) { Dependencies.Add(nameof(Seo)); InputModules = new ModuleList { new Kontent <Page>(deliveryClient) .OrderBy(Post.TitleCodename, SortOrder.Descending) .WithQuery(new DepthParameter(2), new IncludeTotalCountParameter()), new SetMetadata(nameof(Page.Tags), KontentConfig.Get <Page, ITaxonomyTerm[]>(post => post.Tags?.ToArray())), new SetMetadata(nameof(Page.Categories), KontentConfig.Get <Page, ITaxonomyTerm[]>(post => post.Categories?.ToArray())), new SetDestination(KontentConfig.Get((Page page) => new NormalizedPath(page.Url))), new SetMetadata(SearchIndex.SearchItemKey, Config.FromDocument((doc, ctx) => { var page = doc.AsKontent <Page>(); return(new LunrIndexDocItem(doc, page.Title, page.Body) { Description = page.MetadataMetaDescription, //Tags = string.Join(", ", post.Tags.Select( t => t.Name )) }); })), }; ProcessModules = new ModuleList { new MergeContent(new ReadFiles("page.cshtml")), new RenderRazor() .WithViewData("SEO", Config.FromDocument((doc, ctx) => { var home = ctx.Outputs.FromPipeline(nameof(Seo)).First().AsKontent <Kentico.Kontent.Statiq.Memoirs.Models.Home>(); var post = doc.AsKontent <Page>(); return(new SocialSharingMetadata(home, post)); })) .WithViewData("Title", KontentConfig.Get <Page, string>(p => p.Title)) .WithViewData("SiteMetadata", site) .WithModel(KontentConfig.As <Page>()), new KontentImageProcessor(), new OptimizeHtml() }; OutputModules = new ModuleList { new WriteFiles(), }; }