# @unbloque/blog-core

Core blog functionality with database adapters for Next.js applications.

## Installation

```bash
npm install @unbloque/blog-core
```

## Quick Start

```typescript
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

```typescript
import { SupabaseAdapter } from '@unbloque/blog-core'

const adapter = new SupabaseAdapter(
  process.env.NEXT_PUBLIC_SUPABASE_URL!,
  process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
)
```

### MongoDB

```typescript
import { MongoDBAdapter } from '@unbloque/blog-core'

const adapter = new MongoDBAdapter(
  process.env.MONGODB_URI!,
  'blog' // database name
)
```

### Neon (PostgreSQL)

```typescript
import { NeonAdapter } from '@unbloque/blog-core'

const adapter = new NeonAdapter(
  process.env.DATABASE_URL!
)
```

## API Reference

### BlogService

- `getPublishedPosts()` - Get all published posts
- `getAllPosts(includeUnpublished)` - Get all posts
- `getPostBySlug(slug)` - Get a single post by slug
- `getPostById(id)` - Get a single post by ID
- `createPost(post)` - Create a new post
- `updatePost(id, updates)` - Update an existing post
- `deletePost(id)` - Delete a post
- `searchPosts(query)` - Search posts by query

## Types

All TypeScript types are exported for use in your application:

```typescript
import type { BlogPost, CreateBlogPost, UpdateBlogPost } from '@unbloque/blog-core'
```

## License

MIT
