コード例 #1
0
        public ArticlesPipeline(IDeliveryClient client)
        {
            InputModules = new ModuleList
            {
                new Kontent <Article>(client)
                .WithItemsFeed()
            };

            ProcessModules = new ModuleList
            {
                new MergeContent(
                    new ReadFiles(patterns: "_Detail.cshtml")
                    ),
                new RenderRazor()
                .WithModel(KontentConfig.As <Article>()),
                new SetDestination(
                    Config.FromDocument((doc, ctx)
                                        => new NormalizedPath($"{doc.AsKontent<Article>().Slug}.html")
                                        )
                    )
            };

            OutputModules = new ModuleList {
                new WriteFiles()
            };
        }
コード例 #2
0
ファイル: Posts.cs プロジェクト: Adrenalinaws/O
        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(),
            };
        }
コード例 #3
0
ファイル: Pages.cs プロジェクト: Adrenalinaws/O
        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(),
            };
        }
コード例 #4
0
 public HeroPipeline(IDeliveryClient client)
 {
     ProcessModules = new ModuleList
     {
         new Kontent <Hero>(client)
         .WithQuery(
             new EqualsFilter("system.codename", "hero"),
             new LimitParameter(1)
             ),
         new MergeContent(
             new ReadFiles(patterns: "_Hero.cshtml")
             ),
         new RenderRazor()
         .WithModel(KontentConfig.As <Hero>()),
         new SetDestination(new NormalizedPath("index.html")),
         new WriteFiles()
     };
 }