Action
Load Draft Post
Loads a selected draft into a Writing module. Requires Drafts 5.6.
Steps
-
script
// Import draft post let root = "Draft Posts/"; let fmCloud = FileManager.createCloud(); let fileNames = []; let files = fmCloud.listContents(root); for (var file of files) { var f = file.replace(root,''); f = f.replace('.md',''); fileNames.push(f) } /*--- Prompt ---*/ var p = Prompt.create(); p.title = "Select File"; p.message = "Select the file you want to import into Drafts"; for (var fileName of fileNames) { p.addButton(fileName); } var con = p.show(); if (con) { // Get selected path let path = root + p.buttonPressed + ".md" let content = fmCloud.readString(path) let d = Draft.create(); d.content = content; d.addTag("post"); d.update(); editor.load(d); editor.activate(); } else { context.cancel(); }
-
includeAction
name Writing Module
Options
-
After Success Default Notification Info Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.