Posting to Pagecord with Obsidian

Last night, I decided to finally install Obsidian on my iPad Pro and see what all the fuss is about. Since I wanted to use it to post to my blog, I also installed the Pagecord plugin and the Templater plugin.

The Pagecord plugin handles publishing, but it doesn’t generate front matter for you. So to make my life easier, I created a new blog post template to auto-populate the slug, timestamp, and other front matter:

<%*
const t = await tp.system.prompt("Post title");
const s = t.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
const y = tp.date.now("YYYY");
const md = tp.date.now("MM-DD");
const folder = "Posts/" + y;
if ( !app.vault.getAbstractFileByPath("Posts") ) { await app.vault.createFolder("Posts"); }
if ( !app.vault.getAbstractFileByPath(folder) ) { await app.vault.createFolder(folder); }
await tp.file.move(folder + "/" + md + "-" + s);
tR += "---\n";
tR += "title: \"" + t.replace(/"/g, '\"') + "\"\n";
tR += "slug: " + s + "\n";
tR += "status: draft\n";
tR += "tags: []\n";
tR += "published_at: " + tp.date.now("YYYY-MM-DD[T]HH:mm:ssZ") + "\n";
tR += "canonical_url: \n";
tR += "hidden: false\n";
tR += "locale: en\n";
tR += "---\n";
%>

When I want to create a new post, I run Templater: Create new note from template and choose the blog post template. I’m then prompted for a post title, which is also used to automatically create the post file (named like MM-DD-some-post-slug) in the Posts/YYYY folder (YYYY is the current year). The slug is automatically created from the title I provided, and the status set to draft.

When I’m ready to publish, I run Pagecord: Publish to blog (draft) to send the post to Pagecord as a draft and the API does its thing. Then I check & preview the post in the Pagecord admin. If it looks good, I publish it. If it needs changes, I come back to Obsidian, make the changes, and run Pagecord: Publish to blog (draft) again to update the post.

I’m new to Obsidian, but this is pretty neat. I’m not sure how often I’ll use it, but at least I have an easy workflow if I do.

To be honest, I think I still prefer post by email since I can save email drafts and resume from any of my devices (Obsidian is $5/mo for multi-device sync). The only downside I’ve run into with posting by email is that I can’t post drafts, but I’m hoping the ability to do so gets added in the future.

Note: This was posted from Obsidian with the template and steps described above.