Drafts 5 has become my go to app for all things text on iOS. I do my blogging and much of my other writing for work in it due to its powerful automation. I’ve been using its scripting abilities to post my blog posts to my Micro.blog hosted blog since the app released last spring.

As I’ve gotten more comfortable with JavaScript, I’ve wanted to rework some of how my Post to Micro.blog script works. With Manton’s announcement yesterday that Micro.blog hosted blogs could now have categories, I knew this was the right time to rework my script.

So I give you “Post to Micro.blog (w/Categories)”. Catchy name, right? You can totally change it when you install it.

Essentially, the script will send a request to the Micro.blog server for a list of all categories you have setup on your blog. If you have any, it will provide a prompt for you to select categories to post to. You can also select in the prompt whether your post has a title (like this one) or not.

There’s little configuration required on the user’s end. All you have to do is run the script once, and it will ask for your Micro.blog token. Once you enter this, it will be stored in Drafts’s Credentials (not on anything of mine or having to do with this script at all), and will be used until you delete it from the Drafts’s setting. You will not be asked for your token again unless you delete.

Also, this script takes advantage of Drafts’s “safe_title” template which strips extra characters (like Markdown headings) from the title. This means you can have a Markdown H1 in the title of your post for clarity when writing, editing, and accessing, but this will be excluded from what is sent to Micro.blog.

I’m pleased with how this turned out, and hope it’s helpful to the Micro.blog community as a whole. If you have any questions or find any issues, please reach out to me at @craigmcclellan.