bearblog
v0.1.0
Published
CLI that syncs a directory of markdown files to Bear Blog
Maintainers
Readme
bearblog
CLI that syncs a directory of markdown files to Bear Blog. The local directory IS your blog — bearblog sync creates, updates, and deletes posts to match local state.
Install
npm install -g bearblogOr run ad-hoc with npx bearblog.
Quick start
cd ~/my-blog
bearblog init # prompts for email, password, subdomain
echo "# Hello" > hello.md
bearblog sync # pushes hello.md to your blogCommands
bearblog init — interactive setup. Creates .bear.json, .bear-password, .bear-session.json, and updates .gitignore. Run once per blog directory.
bearblog sync — make the remote blog match the local directory:
- Local
.mdfiles not yet synced → created - Local
.mdfiles already synced → updated - Files that were synced but no longer exist locally → deleted remotely
Add --dry-run to preview actions without making changes.
Post format
Markdown with YAML frontmatter:
---
title: My Post
slug: my-post
tags: tag1, tag2
published: true
---
Markdown body.title— post title (defaults to filename without.md)slug— URL slug (maps to Bear Blog'slinkfield)tags— comma-separated string or YAML arraypublished—true(default) orfalse(draft)- Any other keys pass through to Bear Blog's header (e.g.
canonical_url,meta_description,is_page)
Files
| File | Contents | Git |
|---|---|---|
| .bear.json | email + subdomain | commit |
| .bear-password | plaintext password | gitignore |
| .bear-sync.json | filename → post ID map | commit |
| .bear-session.json | Bear Blog session cookies | gitignore |
bearblog init writes all four and appends the gitignored files to .gitignore.
Ownership
bearblog sync only touches posts it created. Posts made via Bear Blog's web UI or by other tools are never updated, never deleted, never read. The sync map (.bear-sync.json) is the ownership record: if a remote post ID isn't in the map, it's not ours.
How it works
Bear Blog has no API. This CLI authenticates via Django's login form, scrapes CSRF tokens, and submits posts as form data — like a browser would. Session cookies are cached so you don't re-login every run.
License
MIT
