Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
using System.Collections.Generic;
using Statiq.Common;
using Statiq.Core;
using Statiq.Razor;
using Statiq.Yaml;
namespace StatiqTutorial
/// <summary>
/// Pipeline responsible for processing features markdown files into features listing HTML documents using Razor templates.
/// </summary>
public class FeaturesListingRazorPipeline : Pipeline
public FeaturesListingRazorPipeline()
InputModules = new ModuleList
// Reads the content of files from the file system into the content of new documents.
// <see href="">ReadFiles</see>
new ReadFiles(pattern: "content/features/*.md"),
ProcessModules = new ModuleList
// Extracts the first part of the content for each document and sends it to a child module for processing.
// <see href="">ExtractFrontMatter</see>
new ExtractFrontMatter(
// Parses YAML content for each input document and stores the result in it's metadata.
// <see href="">ParseYaml</see>
new ParseYaml()
// Replaces documents in the current pipeline.
// <see href="">ReplaceDocuments</see>
new ReplaceDocuments(
Config.FromContext(context =>
return (IEnumerable<IDocument>) new []
// Provides properties and instance methods for working with paths.
// <see href="">NormalizedPath</see>
new NormalizedPath("features-razor.html"),
new KeyValuePair<string, object>(Keys.Children, context.Inputs)
OutputModules = new ModuleList
// Load Razor template to IDocument content.
// <see href="">MergeContent</see>.
// <see href="">Content propery of IDocument</see>
new MergeContent(new ReadFiles("FeaturesListing.cshtml")),
// Render HTML file from Razor template and document typed as HomeViewModel model.
// <see href="">RenderRazor</see>
new RenderRazor().WithModel(Config.FromDocument((document, context) =>
var featureDocuments = document.GetChildren();
List<Feature> features = new List<Feature>();
foreach (var featureDocument in featureDocuments)
var featureTitle = featureDocument.GetString("Title");
var featureDescription = featureDocument.GetString("Description");
var slug = featureDocument.Source.FileNameWithoutExtension.ToString();
features.Add(new Feature(featureTitle, featureDescription, slug));
return new FeaturesListingViewModel(features);
// Flush to the output.
// <see href="">WriteFiles</see>.
new WriteFiles()