@unbloque/blog-core
v0.1.1
Published
Core blog functionality with database adapters for Next.js
Downloads
204
Maintainers
Readme
@unbloque/blog-core
Core blog functionality with database adapters for Next.js applications.
Installation
npm install @unbloque/blog-coreQuick Start
import { BlogService, MemoryAdapter } from '@unbloque/blog-core'
// Initialize with an adapter
const adapter = new MemoryAdapter()
const blog = new BlogService(adapter)
// Get all published posts
const posts = await blog.getPublishedPosts()Database Adapters
Supabase
import { SupabaseAdapter } from '@unbloque/blog-core'
const adapter = new SupabaseAdapter(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
)MongoDB
import { MongoDBAdapter } from '@unbloque/blog-core'
const adapter = new MongoDBAdapter(
process.env.MONGODB_URI!,
'blog' // database name
)Neon (PostgreSQL)
import { NeonAdapter } from '@unbloque/blog-core'
const adapter = new NeonAdapter(
process.env.DATABASE_URL!
)API Reference
BlogService
getPublishedPosts()- Get all published postsgetAllPosts(includeUnpublished)- Get all postsgetPostBySlug(slug)- Get a single post by sluggetPostById(id)- Get a single post by IDcreatePost(post)- Create a new postupdatePost(id, updates)- Update an existing postdeletePost(id)- Delete a postsearchPosts(query)- Search posts by query
Types
All TypeScript types are exported for use in your application:
import type { BlogPost, CreateBlogPost, UpdateBlogPost } from '@unbloque/blog-core'License
MIT
