Blogging from Bear
For a long time I’ve wanted to be able to easily blog directly from Bear - the Markdown notes app on Mac and iOS. I pictured a way you could published just by adding a hash tag to your Bear note, and it would magically just appear somewhere on the internet.
Well, now that is a reality!
Bear recently added a CLI (command line interface), which allows for scripts and other tools to directly query Bear’s internal note database. This allows you, for example, to find all the notes with a particular tag.
Bear’s notes are Markdown - a simple, human readable way of adding highlighting, headings and links to text. Markdown is a like more human readable form of HTML, and is easily parsed and processed by computers, enabling them to do this such as convert you note into HTML for publishing on the web. (Markdown has also become the lingua franca of AI tools, mainly because of this kind of ease and flexibility).
What I realised is, given the new CLI tool, it is now possible to build an app that runs in the background and periodically extracts all notes with a particular tag, converts them to HTML and publishes them onto the web.
I build BearBlog (a not-great temporary name) to do this. I just runs in the Mac menu bar and periodically queries Bear - if it finds any new notes that are tagged for publication, it extracts them, generates the HTML, and publishes up to a Cloudflare website. This blog post you are reading was built using this exact tool. All I did was write this as a note in bear, and add a tag. Boom! Everything else was automatic!
I have a few tweaks to make to tidy things up and make it ready for release, but I’ll be publishing the tool on a Github repo soon. Stay tuned.