FileName

Optimizes a specified metadata key as a filename.
This module takes the value of the specified metadata key and optimizes it for use as a filename by removing reserved characters, white-listing characters, etc.

Usage

  • FileName()

    Sets the metadata key WriteFileName to an optimized version of SourceFileName. Also sets the metadata key WritePath to Path.Combine(RelativeFileDir, WriteFileName).

  • FileName(DocumentConfig fileName)

    Sets the metadata key WriteFileName to an optimized version of the return value of the delegate. Also sets the metadata key WritePath to Path.Combine(RelativeFileDir, WriteFileName).

    • fileName

      A delegate that should return a string with the filename to optimize.

  • FileName(DocumentConfig fileName, string outputKey)

    Sets the specified metadata key to an optimized version of the return value of the delegate. Does not automatically set the WritePath metadata key.

    • fileName

      A delegate that should return a string with the filename to optimize.

    • outputKey

      The metadata key to use for the optimized filename.

  • FileName(string inputKey)

    Sets the metadata key WriteFileName to an optimized version of the specified input metadata key. Also sets the metadata key WritePath to Path.Combine(RelativeFileDir, WriteFileName).

    • inputKey

      The metadata key to use for the input filename.

  • FileName(string inputKey, string outputKey)

    Sets the specified metadata key to an optimized version of the specified input metadata key. Does not automatically set the WritePath metadata key.

    • inputKey

      The metadata key to use for the input filename.

    • outputKey

      The metadata key to use for the optimized filename.

Fluent Methods

Chain these methods together after the constructor to modify behavior.

  • PreservePath(bool preservePath)

    Indicates whether to set the metadata key WritePath to Path.Combine(RelativeFileDir, WriteFileName).

    • preservePath

      If set to true, the WritePath metadata key is set.

  • PreservePath(string outputKey)

    Indicates whether to set the specified metadata key to Path.Combine(RelativeFileDir, WriteFileName).

    • outputKey

      The metadata key to set.

  • WithAllowedCharacters(IEnumerable<string> allowedCharacters)

    Specifies the characters to allow in the filename.

    • allowedCharacters

      The allowed characters.

Input Metadata

The metadata values listed below apply to individual documents and are typically set from front matter (with just the name of the key) and used as inputs to the module to control behavior.

  • Keys.RelativeFileDir: Wyam.Common.IO.DirectoryPath

    The path to the folder containing the file relative to the input folder.

  • Keys.SourceFileName: Wyam.Common.IO.FilePath

    The file name of the original file with extension.

Output Metadata

The metadata values listed below apply to individual documents and are created and set by the module as indicated in their descriptions.

  • Keys.WriteFileName: Wyam.Common.IO.FilePath

    The file name to use when writing the file.

  • Keys.WritePath: Wyam.Common.IO.FilePath

    The path to use when writing the file.

GitHub