Action

Blog Post Idea to Things

Posted by raigmcclellan, Last update almost 6 years ago - Unlisted

This script will take the content of the current draft, create a Things task with a link to the draft, and tag the draft how you like so you can remember to write the brilliant blog post you just had the idea for.

Steps

  • script

    // Blog Post Idea to Things
    
    const postIdea = draft.content;
    var markdownText = "# " + postIdea
    
    // Take the content of the current draft, add a Markdown H1, and get link to draft to send to Things
    
    function setDraft() {
    	draft.content = "# " + postIdea;
    	draft.addTag(""); // Insert Drafts tag between quotations
    	draft.update();
    	return draft.permalink;
    }
    
    var draftURL = setDraft();
    
    // Create task in Things with post title as the task name and the URL to the draft in notes
    
    var todo = TJSTodo.create();
    todo.title = postIdea;
    todo.notes = draftURL;
    todo.list = ""; // Insert your project name between quotations
    todo.heading = ""; // Insert your heading between quotations
    
    // Create container to send task to Things
    
    var container = TJSContainer.create([todo]);
    
    // Send to Things via Callback URL
    
    var ncb = CallbackURL.create();
    ncb.baseURL = container.url;
    var success = ncb.open();
    if (success) {
    	console.log("Item added to Things");
    }
    else {
    	context.fail();
    }

Options

  • After Success Nothing
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.