Action
Post to Writeas Blog
UPDATES
over 2 years ago
-Actually listed publicly in the directory
over 2 years ago
-Actually listed publicly in the directory
over 2 years ago
-Listed publicly in the directory
over 2 years ago
-Name update
-Description update
over 2 years ago
-Modified/unified the credential identifier to “Write.as.”
Post to a named Write.as blog (“collection”) via the Write.as API.
The URL of the result is logged, copied to the system clipboard, and inserted in the current draft as a markdown-formatted hyperlink.
For more information, see this action’s corresponding GitHub issue.
Steps
-
script
// setup and request credentials let credential = Credential.create("Writeas", "Enter your target Writeas blog slug (collection) and Writeas/Snapas API auth token."); credential.addTextField("collection", "Collection"); credential.addPasswordField("token", "Access Token"); credential.authorize(); const token = credential.getValue("token"); const collection = credential.getValue("collection"); // make post let endpoint = `https://write.as/api/collections/${collection}/posts`; // configure post details // for more information, see: // https://developers.write.as/docs/api let data = { "body": draft.content, }; // create and post HTTP request var http = HTTP.create(); var response = http.request({ "url": endpoint, "method": "POST", "data": data, "headers": { "Authorization" : token, } }); // log result post URL and copy to clipboard if (response.statusCode == 201) { let d = JSON.parse(response.responseText); console.log("Posted to Writeas. URL: " + d.data.url); app.setClipboard(d.data.url); draft.setTemplateTag("walink", d.data.url); } else { console.log("Write.as Error: " + response.error); context.fail(); }
-
insertText
template - [[[display_title]]]([[walink]])
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.