This state file extends imposer to support importing trees of markdown documents during imposer apply
. To use it, require dirtsimple/postmark
from a shell
block in your imposer-project.md
or another state file, then use any of these API functions to mark directories for import:
postmark-module() { __postmark-set modules content "$1"; }
postmark-content() { __postmark-set content modules "$1"; }
# don't include the cache in option diffs
exclude-options postmark_option_cache
- Use
postmark-module
directory on directories that contain prepackaged content that postmark should not modify, e.g.postmark-module "vendor/some/package/content"
. - Use
postmark-content
directory on directories containing content that postmark is allowed to modify (i.e., to add an autogeneratedID:
field).
The implementation just runs the trees with the specified options: first the modules, then the content.
Imposer::task('Postmark Tree')
-> reads( ['postmark', 'modules'], ['postmark', 'content'] )
-> steps( function ($modules, $content) {
if ( ! ($modules || $content) ) return;
$cmd = new dirtsimple\Postmark\PostmarkCommand;
if ($content) $cmd->tree(array_keys((array) $content), []);
if ($modules) $cmd->tree(array_keys((array) $modules), ['skip-create'=>true]);
});
__postmark-set() {
FILTER '%s as $tmp | .postmark.'$1'[$tmp] = true | del(.postmark.'$2'[$tmp])' "$3"
}