Obsidian as a CMS
- PLATFORM Web
- STACK
- WEBSITE https://portfolio.johnhazel.com
- GITHUB https://github.com/gjohnhazel/astro-blog
My own personal blog, with Obsidian as a CMS.
The concept intrigued me because I wanted to make blogging so enjoyable & accessible for myself that I would be drawn to do it and take joy in it.
It seemed simple enough of a concept. But the big challenge for me was that this was basically my first adventure into a serverless environment.
So my original code was built from a server-mindset and it took a good bit of perspective shifting to make it work for Vercel.
Anyway, it works now! Basically looks like: Obsidian > github/obsidian > github/astro-blog > vercel
- Use Obsidian Git Plugin to commit & push when a new Blog Post is up
- gjohnhazel/obsidian repo (private) receives the push and triggers a GitHub action to trigger this GitHub action in gjohnhazel/astro-blog.
- The GitHub action deploys to Vercel
- Vercel’s Build script calls on fetchContent.js which pulls the content from the Obsidian repo, does any transformations needed, and saves the images
- The build script finishes and the site is re-deployed with the updated content!
To re-create this:
- Fork or clone this repo
- In Obsidian, install this Obsidian git plugin
- Create the following GitHub action in your repo (obsidian/.github/workflows/main.yml)
name: Sync Blog from Obsidian to Astro Blog
on:
push:
paths:
- 'Blog/**'
repository_dispatch:
types: [simulate_push]
jobs:
trigger:
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
repository: gjohnhazel/astro-blog
event-type: update-blog # This should match the type expected by the receiving repo's workflow
- Create the following Secrets in your Repos under repo > Settings > Secrets and variables > Actions: a. In Obsidian repo, REPO_DISPATCH_TOKEN b. In astro-blog repo, TEABLE_API_KEY (if you take advantage of categories & Teable), VERCEL_PROJECT_ID, VERCEL_TOKEN