This module is used by the CLI app, and is meant for generating an output module out of function details. Decode a file from one or many JSON frontmatter values.
{ dir : List String
, functions : Dict String UndecodedFunction
}
The outline of a yet-to-be-decoded module.
{ inputFilePath : Path
, type_ : Content.Function.FunctionType
, frontmatter : Json.Decode.Value
}
Information about an undecoded function. filePath
is the path
of the input file whose contents are decoded to form the function body.
functionType
is whether this function's type is a singleton or collection item.
Singleton function types are named Content
, whereas collection item types are named CollectionItem
.
This gets converted to a Content.Type.Path and used to query for the decoder.
{ filePath = "ingredients/egg.md", functionType = Content.Function.SingletonFunction, ... } == Content.Type.Single [ "Content", "Ingredients", "Egg" ]
{ filePath = "[recipes].md", functionType = Content.Function.CollectionItemFunction, ... } == Content.Type.Collection [ "Content", "Recipes" ]
fileFrontmatter
contains the JSON encoded frontmatter value of the file. This function expects data
to be in the same shape as gray-matter output.
{
"content": "A string containing the file body",
"data": {
"title": "An object containing file attributes",
"date": "2016-08-04T18:53:38.297Z"
}
}
{ path : Path
, contents : String
, actions : List { with : String
, args : Json.Encode.Value }
}
The outputted file.
Actions are consumed by the elm-frontmatter
npm package, and contain
instructions to be processed by JS code, currently limited to image processing.
generate : Path.Platform -> (Content.Type.Path -> Content.Decode.QueryResult) -> UndecodedModule -> Result GenerationError Module
Takes a function that can query for a decoder based on type path, and an undecoded module. Returns the file path and contents for the decoded module.
Gets returnd when file generation fails