示例#1
0
        private static IModuleList GetModules(PagesSettings settings)
        {
            ModuleList moduleList = new ModuleList
            {
                {
                    MarkdownFiles,
                    new ModuleCollection
                    {
                        new ReadFiles(ctx => GetGlobbingPattern(ctx, settings.PagesPattern, settings.IgnorePaths, "md")),
                        new Meta(WebKeys.EditFilePath, (doc, ctx) => doc.FilePath(Keys.RelativeFilePath)),
                        new If(settings.ProcessIncludes, new Include()),
                        new FrontMatter(new Yaml.Yaml()),
                        new Execute(ctx => new Markdown.Markdown()
                                    .UseConfiguration(settings.MarkdownConfiguration.Invoke <string>(ctx))
                                    .UseExtensions(settings.MarkdownExtensionTypes.Invoke <IEnumerable <Type> >(ctx)))
                    }
                },
                {
                    RazorFiles,
                    new Concat
                    {
                        new ReadFiles(
                            ctx => GetGlobbingPattern(ctx, settings.PagesPattern, settings.IgnorePaths, "cshtml")),
                        new Meta(WebKeys.EditFilePath, (doc, ctx) => doc.FilePath(Keys.RelativeFilePath)),
                        new If(settings.ProcessIncludes, new Include()),
                        new FrontMatter(new Yaml.Yaml())
                    }
                },
                {
                    WriteMetadata,
                    new ModuleCollection
                    {
                        new Excerpt(),
                        new Title(),
                        new WriteFiles(".html").OnlyMetadata()
                    }
                }
            };

            // Tree and sort
            Comparison <IDocument> sort = settings.Sort
                                          ?? ((x, y) => Comparer.Default.Compare(x.String(Keys.Title), y.String(Keys.Title)));

            if (settings.CreateTree)
            {
                Tree tree = settings.TreePlaceholderFactory == null
                    ? new Tree().WithNesting(true, true)
                    : new Tree().WithNesting(true, true).WithPlaceholderFactory(settings.TreePlaceholderFactory);
                tree.WithSort(sort);
                moduleList.Add(CreateTreeAndSort, tree);
            }
            else
            {
                moduleList.Add(CreateTreeAndSort, new Sort(sort));
            }
            return(moduleList);
        }
示例#2
0
 /// <summary>
 /// Creates the pipeline.
 /// </summary>
 /// <param name="name">The name of this pipeline.</param>
 /// <param name="settings">The settings for the pipeline.</param>
 public Pages(string name, PagesSettings settings)
     : base(name, GetModules(settings))
 {
 }