Shikensu.Contrib

Premade functions to manipulate your bundles/definitions with.

Contrib

clearMetadata : Bundle -> Bundle

Clear metadata.

clone : Path File -> Path File -> Bundle -> Bundle

Clone.

For each definition that has the given relativePath (1st argument), make a clone with a new relativePath (2nd argument), and add that into the compendium just after the matching definition.

>>> clone "index.html" "200.html" bundle
copyPropsToMetadata : Bundle -> Bundle

Copy definition properties into the metadata.

enclose : String -> Bundle -> Bundle

Append the given directory path to the directory path of each definition.

exclude : Path File -> Bundle -> Bundle

Exclude.

Filter out the definitions that have the given relativePath.

insertMetadata : Dict String Value -> Bundle -> Bundle

Insert additional metadata.

rename : Path File -> Path File -> Bundle -> Bundle

Rename.

Change the relativePath of the definitions that match a given relativePath. For example, if you have a definition with the relativePath path a/b/example.html:

>>> rename
..>   (Path.file [ "a", "b", "example.html" ])
..>   (Path.file [ "example", "index.html" ])
..>   compendium
renameExtension : String -> String -> Bundle -> Bundle

Rename extension.

Example:

>>> renameExtension "markdown" "html" compendium
..> -- The definitions that had the extensionName "markdown"
..> -- now have the extensionName "html"
renderContent : (Definition -> Maybe Bytes) -> Bundle -> Bundle

Render content.

Replace the content property by providing a renderer. A renderer is a function with the signature Definition -> Maybe Bytes. You can use this to render templates, markdown, etc.

replaceMetadata : Dict String Value -> Bundle -> Bundle

Replace metadata.

Replace the current metadata dictionary with another one.

setContent : Bytes -> Bundle -> Bundle

Set content.

Set content directly.

transformContent : (Definition -> Maybe Bytes) -> Bundle -> Bundle

Transform content.

Alias for renderContent.

withBaseName : String -> Bundle -> Bundle

Only keep definitions with the given base name.

withDirectory : Path Directory -> Bundle -> Bundle

Only keep definitions with the given directory path.

withExtension : String -> Bundle -> Bundle

Only keep definitions with the given extension.

withMetadata : String -> Value -> Bundle -> Bundle

Only keep definitions with the given metadata.