DirectoryMeta Class

Summary

Applies metadata from specified input documents to all input documents based on a directory hierarchy.
Assembly
Wyam.Core.dll
Namespace
Wyam.Core.Modules.Metadata
Interfaces
Base Types
  • Object
graph BT Type-->Base0["Object"] Type-.->Interface0["IModule"] click Interface0 "/api/Wyam.Common.Modules/IModule" Type["DirectoryMeta"] class Type type-node

Syntax

public class DirectoryMeta : IModule

Remarks

This module allows you to specify certain documents that contain common metadata for all other documents in the same directory (and optionally nested directories). It assumes that all input documents are generated from the file system (for example, from the Wyam.Core.Modules.IO.ReadFiles module). In other words, both the documents that contain the common metadata and the documents to which the common metadata should be applied should be passed as inputs to this module.

Documents that contain the common metadata are specified by file name using the WithMetadataFile method. You can specify more than one metadata file and/or metadata files at different levels in the directory hierarchy. If the same metadata key exists across multiple common metadata documents, the following can be used to determine which metadata value will get set in the target output documents:

  • Pre-existing metadata in the target document (common metadata will not overwrite existing metadata unless the replace flag is set).
  • Common metadata documents in the same directory as the target document (those registered first have a higher priority).
  • Common metadata documents in parent directories of the target document (but only if the inherited flag is set and those closer to the target document have a higher priority).

By default, documents that are identified as containing common metadata will be filtered and won't be contained in the sequence of output documents. PreserveMetadataFiles can be used to change this behavior.

Methods

Name Value Summary
Execute(IReadOnlyList<IDocument>, IExecutionContext) IEnumerable<IDocument>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
WithMetadataFile(DocumentConfig, bool, bool) DirectoryMeta
Specifies a file name to use as common metadata using a delegate so that the common metadata document can be specific to the input document.
WithMetadataFile(FilePath, bool, bool) DirectoryMeta
Specifies a file name to use as common metadata.
WithPreserveMetadataFiles() DirectoryMeta
Preserves the files that hold the common metadata and ensures they are included in the module output. Without this option, theses documents will be consumed by this module and will not be present in the module output.
GitHub