CreateTree Class
Adds metadata to the input documents that describes the position of each one in a tree structure.
Namespace
Statiq.Core
Interfaces
Base Types
graph BT Type-->Base0["Module"] click Base0 "/api/Statiq.Common/Module" Base0-->Base1["object"] Type-.->Interface0["IModule"] click Interface0 "/api/Statiq.Common/IModule" Type["CreateTree"] class Type type-node

Syntax

public class CreateTree : Module, IModule

Remarks

By default, this module is configured to generate a tree that mimics the directory structure of each document's destination path. Any documents with a file name of "index.*" are automatically promoted to the node that represents the parent folder level. For any folder that does not contain an "index.*" file, an empty placeholder tree node is used to represent the folder.

Note that if you clone documents from the tree, the relationships of the cloned document (parent, child, etc.) will not be updated to the new clones. In other words, your new document will still be pointing to the old versions of it's parent, children, etc. To update the tree after cloning documents you will need to recreate it by rerunning this module on all the newly created documents again.

Constructors

Name Summary
CreateTree() Creates a new tree module.

Methods

Name Return Value Summary
AfterExecution(IExecutionContext, ExecutionOutputs) void
Called after each module execution.
Inherited from Module
AfterExecutionAsync(IExecutionContext, ExecutionOutputs) Task
Called after each module execution.
Inherited from Module
BeforeExecution(IExecutionContext) void
Called before each module execution.
Inherited from Module
BeforeExecutionAsync(IExecutionContext) Task
Called before each module execution.
Inherited from Module
ExecuteAsync(IExecutionContext) Task<IEnumerable<IDocument>>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
Inherited from Module
ExecuteContextAsync(IExecutionContext) Task<IEnumerable<IDocument>>
Executes the module once for all input documents.
ExecuteInputAsync(IDocument, IExecutionContext) Task<IEnumerable<IDocument>>
Executes the module.
Inherited from Module
Finally(IExecutionContext) void
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
FinallyAsync(IExecutionContext) Task
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
WithChildrenKey(string) CreateTree
Changes the default children metadata key.
WithNesting(bool, bool) CreateTree
Indicates that the module should only output root nodes (instead of all nodes which is the default behavior).
WithPlaceholderFactory(Func<string[], IMetadata, IExecutionContext, Task<IDocument>>) CreateTree
Allows you to specify a factory function for the creation of placeholder documents which get created to represent nodes in the tree for which there was no input document. The factory gets passed the current tree path, the set of tree metadata that should be set in the document, and the execution context which can be used to create a new document. If the factory function returns null, a new document with the tree metadata is created.
WithRoots(Config<bool>) CreateTree
Specifies for each document if it is a root of a tree. This results in splitting the generated tree into multiple smaller ones, removing the root node from the set of children of it's parent and setting it's parent to null.
WithSort(Func<IDocument, IDocument, IExecutionContext, int>) CreateTree
This specifies how the children of a given tree node should be sorted. The default behavior is to preserve the original sorting order of the input documents.
WithTreePath(Config<string[]>) CreateTree
Defines the structure of the tree. If the delegate returns null the document is excluded from the tree.
WithTreePathKey(string) CreateTree
Changes the default tree path metadata key.

Extension Methods