Oouhammmourachid /
Public
ouhammmourachid / blog-cms
PublicHeadless blog backend: drafts, scheduled publishing, tags, cover images, automatic slugs and an RSS feed.
- CMS
- 0 deploys
- 0 forks
Blog CMS with scheduled posts and RSS
Headless blog backend: drafts, scheduled publishing, tags, cover images, automatic slugs and an RSS feed.
What you get
- Draft, scheduled and published states; a cron job publishes scheduled posts every 5 minutes
- Slugs are generated from the title and kept unique
published_atis filled the moment a post goes live- Readers see only published posts; authors also see their own drafts
- RSS 2.0 feed of the latest 20 posts at
GET /rss.xml
Collections
tags
| Field | Type | Notes |
|---|---|---|
name (required) | text | |
slug (required) | text |
| Action | Who can do it |
|---|---|
| List / view | anyone |
| Create | signed-in users |
| Update | signed-in users |
| Delete | signed-in users |
posts
| Field | Type | Notes |
|---|---|---|
title (required) | text | |
slug | text | Generated from the title if empty |
excerpt | text | Used in lists and RSS |
body | editor | Rich text (HTML) |
cover | file | Images up to 10 MB |
tags | relation → tags (many) | |
status (required) | select | draft, scheduled or published |
publish_at | date | When a scheduled post goes live |
published_at | date | Set automatically |
author (required) | relation → users | Set by a hook to the signed-in user |
| Action | Who can do it |
|---|---|
| List / view | status = 'published' || author = @request.auth.id |
| Create | signed-in users |
| Update | author = @request.auth.id |
| Delete | author = @request.auth.id |
Hooks
All hooks are in pb_hooks/main.pb.js and commented.
Setup
- Any signed-in user can write posts. For a single-author blog, set the posts create rule to
@request.auth.id = "YOUR_USER_ID", and do the same for tags. - Set the environment variable
BLOG_SITE_URL: Your blog's public URL, used for links in the RSS feed (defaults to the Application URL)
Quick start
import PocketBase from "pocketbase"
const pb = new PocketBase("https://YOUR-INSTANCE.pocketshub.com")
// Published posts, newest first:
const posts = await pb.collection("posts").getList(1, 10, {
filter: "status = 'published'", sort: "-published_at", expand: "tags",
})
// One post by slug:
const post = await pb.collection("posts").getFirstListItem(`slug = "${slug}"`)
// Schedule a post:
await pb.collection("posts").create({
title: "Hello world", body: "<p>...</p>", status: "scheduled", publish_at: "2027-01-01 09:00:00Z",
})
Notes
- Cover images come with a 1200x630 thumbnail, the size social cards use.
License
MIT
2 collections, 1 relation. Hover a collection to trace its relations