Documentation

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:

FieldDescription
titleThe post title (required)
slugURL-friendly identifier, auto-generated from the title
descriptionShort summary for SEO and post cards
contentFull post content in Markdown
imageUrlFeatured image URL
statusDraft, Scheduled, or Published
publishedAtPublication date and time
authorThe user who created the post

Database Schema

Blog posts are stored in the Post model:

prisma/schema.prisma
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:

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.ts

The 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.

Last updated on

On this page

Join hundreds of directory builders

Build your directory, launch, earn

Don't waste time on Stripe subscriptions or designing a pricing section. Get started today with our battle-tested stack and built-in monetization features.

Get Lifetime Access