Blog
Learn how to manage blog posts in your directory website using the built-in admin interface and database storage.
Dirstarter stores blog posts in your database and provides a full admin interface for creating, editing, and publishing them. Posts are written in Markdown and rendered on the frontend with react-markdown.
Managing Posts
Navigate to the Posts section in your admin dashboard to manage blog posts. From there you can:
- Create new posts with a rich text editor (Tiptap)
- Edit existing posts with live markdown preview
- Upload featured images via the media manager
- Schedule posts for future publication
- Duplicate posts for quick variations
Each post has the following fields:
| Field | Description |
|---|---|
title | The post title (required) |
slug | URL-friendly identifier, auto-generated from the title |
description | Short summary for SEO and post cards |
content | Full post content in Markdown |
imageUrl | Featured image URL |
status | Draft, Scheduled, or Published |
publishedAt | Publication date and time |
author | The user who created the post |
Database Schema
Blog posts are stored in the Post model:
model Post {
id String @id @default(cuid(2))
title String @db.Citext
slug String @unique
description String?
content String
plainText String @default("")
imageUrl String?
status PostStatus @default(Draft)
publishedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
author User @relation(fields: [authorId], references: [id])
authorId String
}
enum PostStatus {
Draft
Scheduled
Published
}The plainText field stores a stripped version of the Markdown content, used for calculating read time and powering search.
Configuration
Blog features can be configured in config/blog.ts:
export const blogConfig = {
tableOfContents: {
enabled: true,
},
}Migrating from MDX
If you're upgrading from an older version of Dirstarter that used file-based MDX blog posts (via Content Collections), a migration script is included to move your content into the database.
Make sure your content/posts/ directory contains your .md or .mdx blog files and that your database is running.
Run the migration script:
SKIP_ENV_VALIDATION=1 bun run scripts/migrate-posts.tsThe script will parse frontmatter, extract plain text, and insert each post into the database. Posts whose slug already exists in the database will be skipped, so the script is safe to run multiple times.
Once verified, you can safely remove the content/posts/ directory and any Content Collections configuration.
Related Resources
Last updated on