autoblogger 0.1.17 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -507
- package/dist/index.d.mts +107 -10
- package/dist/index.d.ts +107 -10
- package/dist/index.js +751 -142
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +740 -141
- package/dist/index.mjs.map +1 -1
- package/dist/lib/markdown.d.mts +14 -1
- package/dist/lib/markdown.d.ts +14 -1
- package/dist/lib/markdown.js +27 -2
- package/dist/lib/markdown.js.map +1 -1
- package/dist/lib/markdown.mjs +23 -1
- package/dist/lib/markdown.mjs.map +1 -1
- package/dist/styles/article.d.mts +2 -2
- package/dist/styles/article.d.ts +2 -2
- package/dist/styles/article.js +2 -2
- package/dist/styles/article.js.map +1 -1
- package/dist/styles/article.mjs +2 -2
- package/dist/styles/article.mjs.map +1 -1
- package/dist/styles/autoblogger.css +64 -12
- package/dist/ui.d.mts +109 -11
- package/dist/ui.d.ts +109 -11
- package/dist/ui.js +626 -508
- package/dist/ui.js.map +1 -1
- package/dist/ui.mjs +574 -467
- package/dist/ui.mjs.map +1 -1
- package/package.json +6 -1
- package/prisma/schema.prisma +13 -0
package/README.md
CHANGED
|
@@ -3,609 +3,172 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/autoblogger)
|
|
4
4
|
[](https://github.com/hrosenblume/autoblogger/blob/main/LICENSE)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
An AI-powered CMS that embeds into your Next.js app. Write blog posts with AI assistance, manage revisions, handle comments, and auto-generate drafts from RSS feeds.
|
|
7
7
|
|
|
8
8
|
```bash
|
|
9
9
|
npm install autoblogger
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## What is Autoblogger?
|
|
15
|
-
|
|
16
|
-
Autoblogger is an **embeddable CMS package**. Instead of running a separate blog platform like WordPress or Ghost, you install Autoblogger as an npm package and mount it inside your Next.js app. It becomes part of your application—using your database, your auth system, and your hosting.
|
|
17
|
-
|
|
18
|
-
**This is not a standalone application.** It's a library that provides:
|
|
19
|
-
|
|
20
|
-
1. **A React dashboard** — A full writer/admin interface you mount at a route like `/writer`
|
|
21
|
-
2. **API handlers** — RESTful endpoints you mount at a route like `/api/cms`
|
|
22
|
-
3. **Data utilities** — Functions to query posts, render markdown, generate SEO metadata
|
|
23
|
-
|
|
24
|
-
You keep full control. Autoblogger uses your Prisma client, respects your auth, and stores everything in your database.
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## Who is this for?
|
|
29
|
-
|
|
30
|
-
- **Developers building blogs** who want a writing dashboard without building one from scratch
|
|
31
|
-
- **Teams** who need collaborative editing with comments and revision history
|
|
32
|
-
- **AI-assisted writers** who want to generate drafts with Claude or GPT
|
|
33
|
-
- **Content aggregators** who want to auto-draft posts from RSS feeds
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## Features
|
|
38
|
-
|
|
39
|
-
| Feature | Description |
|
|
40
|
-
|---------|-------------|
|
|
41
|
-
| **AI Writing** | Generate essays with Claude or GPT. Stream responses in real-time. Chat to refine your content. |
|
|
42
|
-
| **WYSIWYG Editor** | Tiptap-based editor with formatting toolbar. Syncs to markdown for storage. |
|
|
43
|
-
| **Revision History** | Every save creates a revision. Browse and restore any previous version. |
|
|
44
|
-
| **Inline Comments** | Highlight text and leave comments. Reply in threads. Resolve when done. |
|
|
45
|
-
| **RSS Auto-Draft** | Subscribe to RSS feeds. Filter articles by keywords. Auto-generate draft posts from news. |
|
|
46
|
-
| **Tag Management** | Organize posts with tags. Bulk edit from the settings panel. |
|
|
47
|
-
| **User Roles** | Admin, writer, and drafter roles with different permissions. |
|
|
48
|
-
| **SEO Fields** | Custom title, description, keywords, and OG image per post. |
|
|
49
|
-
| **Preview Links** | Generate expiring preview URLs for unpublished drafts. |
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## Requirements
|
|
54
|
-
|
|
55
|
-
Before installing, make sure you have:
|
|
56
|
-
|
|
57
|
-
- **Next.js 14 or 15** (App Router)
|
|
58
|
-
- **React 18 or 19**
|
|
59
|
-
- **Prisma 5 or 6** with a configured database
|
|
60
|
-
- **Node.js 20+**
|
|
61
|
-
|
|
62
|
-
You'll also need API keys if you want AI features:
|
|
63
|
-
|
|
64
|
-
- **Anthropic API key** for Claude models
|
|
65
|
-
- **OpenAI API key** for GPT models
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
## Installation
|
|
70
|
-
|
|
71
|
-
### Quick Start (CLI)
|
|
72
|
-
|
|
73
|
-
The fastest way to set up Autoblogger is with the CLI:
|
|
12
|
+
## Quick Start
|
|
74
13
|
|
|
75
14
|
```bash
|
|
76
15
|
npx autoblogger init
|
|
77
16
|
```
|
|
78
17
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
5. Run the database migration
|
|
86
|
-
6. Optionally import existing markdown content
|
|
87
|
-
|
|
88
|
-
**CLI Options:**
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
npx autoblogger init --yes # Skip prompts, use defaults
|
|
92
|
-
npx autoblogger init --dry-run # Preview changes without writing files
|
|
93
|
-
npx autoblogger init --skip-migrate # Skip database migration
|
|
94
|
-
npx autoblogger init --import=./posts # Import content after setup
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
**Import Existing Content:**
|
|
98
|
-
|
|
99
|
-
If you have markdown or MDX files, import them into the database:
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
npx autoblogger import ./content/posts
|
|
103
|
-
npx autoblogger import ./posts --status=published # Import as published
|
|
104
|
-
npx autoblogger import ./posts --tag=imported # Add a tag to all
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Manual Installation
|
|
108
|
-
|
|
109
|
-
If you prefer to set things up manually:
|
|
110
|
-
|
|
111
|
-
#### Step 1: Install the package
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
npm install autoblogger
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
This installs Autoblogger and its dependencies (Tiptap editor, AI SDKs, markdown utilities).
|
|
118
|
-
|
|
119
|
-
#### Step 2: Add the database models
|
|
120
|
-
|
|
121
|
-
Autoblogger needs several tables in your database. Copy the models from the package's schema file into your own Prisma schema.
|
|
122
|
-
|
|
123
|
-
**Option A: Copy the file and merge manually**
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
# View the schema
|
|
127
|
-
cat node_modules/autoblogger/prisma/schema.prisma
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
Then copy the models (Post, Revision, Comment, User, Tag, etc.) into your `prisma/schema.prisma`.
|
|
18
|
+
The CLI automatically:
|
|
19
|
+
- Detects your Next.js and Prisma setup
|
|
20
|
+
- Adds required database models to your schema
|
|
21
|
+
- Creates config, API route, and dashboard page
|
|
22
|
+
- Patches Tailwind to include Autoblogger styles
|
|
23
|
+
- Runs the database migration
|
|
131
24
|
|
|
132
|
-
|
|
25
|
+
Visit `/writer` to start writing.
|
|
133
26
|
|
|
134
|
-
|
|
135
|
-
cp node_modules/autoblogger/prisma/schema.prisma ./prisma/schema.prisma
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
The required models are:
|
|
139
|
-
|
|
140
|
-
| Model | Purpose |
|
|
141
|
-
|-------|---------|
|
|
142
|
-
| `Post` | Blog posts with title, markdown content, status, SEO fields |
|
|
143
|
-
| `Revision` | Version history for posts |
|
|
144
|
-
| `Comment` | Inline editor comments with threading |
|
|
145
|
-
| `User` | CMS users with roles (admin, writer, drafter) |
|
|
146
|
-
| `Tag` | Tags for organizing posts |
|
|
147
|
-
| `PostTag` | Many-to-many relation between posts and tags |
|
|
148
|
-
| `AISettings` | AI model preferences and prompt templates |
|
|
149
|
-
| `IntegrationSettings` | Feature flags like auto-draft enabled |
|
|
150
|
-
| `TopicSubscription` | RSS feed subscriptions for auto-drafting |
|
|
151
|
-
| `NewsItem` | Individual RSS items fetched from subscriptions |
|
|
152
|
-
|
|
153
|
-
#### Step 3: Run the migration
|
|
154
|
-
|
|
155
|
-
After adding the models to your schema:
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
npx prisma migrate dev --name add-autoblogger
|
|
159
|
-
```
|
|
27
|
+
## Features
|
|
160
28
|
|
|
161
|
-
|
|
29
|
+
- **AI Writing** — Generate essays with Claude or GPT. Stream responses in real-time.
|
|
30
|
+
- **Chat Modes** — Ask questions, let AI edit directly (Agent mode), or generate outlines (Plan mode).
|
|
31
|
+
- **WYSIWYG Editor** — Tiptap-based editor with formatting toolbar. Syncs to markdown.
|
|
32
|
+
- **Revision History** — Every save creates a revision. Browse and restore any version.
|
|
33
|
+
- **Inline Comments** — Highlight text and leave threaded comments.
|
|
34
|
+
- **RSS Auto-Draft** — Subscribe to feeds, filter by keywords, auto-generate drafts.
|
|
35
|
+
- **User Roles** — Admin, writer, and drafter with different permissions.
|
|
36
|
+
- **SEO Fields** — Custom title, description, keywords, and OG image per post.
|
|
162
37
|
|
|
163
|
-
|
|
38
|
+
## Requirements
|
|
164
39
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
40
|
+
- Next.js 14 or 15 (App Router)
|
|
41
|
+
- Prisma 5 or 6
|
|
42
|
+
- Node.js 20+
|
|
168
43
|
|
|
169
|
-
|
|
44
|
+
For AI features, you'll need API keys from [Anthropic](https://console.anthropic.com/) and/or [OpenAI](https://platform.openai.com/).
|
|
170
45
|
|
|
171
46
|
## Configuration
|
|
172
47
|
|
|
173
|
-
|
|
48
|
+
The CLI creates `lib/cms.ts` for you. Customize it as needed:
|
|
174
49
|
|
|
175
50
|
```typescript
|
|
176
51
|
// lib/cms.ts
|
|
177
52
|
import { createAutoblogger } from 'autoblogger'
|
|
178
|
-
import { prisma } from '@/lib/db'
|
|
179
|
-
import { auth } from '@/lib/auth'
|
|
53
|
+
import { prisma } from '@/lib/db'
|
|
54
|
+
import { auth } from '@/lib/auth'
|
|
180
55
|
|
|
181
56
|
export const cms = createAutoblogger({
|
|
182
|
-
// Required: Your Prisma client instance
|
|
183
57
|
prisma,
|
|
184
|
-
|
|
185
|
-
// Required: Authentication configuration
|
|
186
58
|
auth: {
|
|
187
|
-
// Function that returns the current session/user
|
|
188
59
|
getSession: () => auth(),
|
|
189
|
-
|
|
190
|
-
// Check if user is an admin (can access settings, manage users)
|
|
191
60
|
isAdmin: (session) => session?.user?.role === 'admin',
|
|
192
|
-
|
|
193
|
-
// Check if user can publish posts (admins and writers can, drafters can't)
|
|
194
61
|
canPublish: (session) => ['admin', 'writer'].includes(session?.user?.role ?? ''),
|
|
195
62
|
},
|
|
196
|
-
|
|
197
|
-
// Optional: AI configuration
|
|
198
63
|
ai: {
|
|
199
64
|
anthropicKey: process.env.ANTHROPIC_API_KEY,
|
|
200
65
|
openaiKey: process.env.OPENAI_API_KEY,
|
|
201
66
|
},
|
|
202
|
-
|
|
203
|
-
// Optional: File upload handler
|
|
204
|
-
storage: {
|
|
205
|
-
upload: async (file: File) => {
|
|
206
|
-
// Implement your upload logic here (S3, Cloudflare R2, Vercel Blob, etc.)
|
|
207
|
-
// Return an object with the public URL
|
|
208
|
-
const url = await uploadToYourStorage(file)
|
|
209
|
-
return { url }
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
67
|
})
|
|
213
68
|
```
|
|
214
69
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
Add these to your `.env.local`:
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
# Database (you probably already have this)
|
|
221
|
-
DATABASE_URL="postgresql://..."
|
|
222
|
-
|
|
223
|
-
# AI API keys (optional, only needed for AI features)
|
|
224
|
-
ANTHROPIC_API_KEY="sk-ant-..."
|
|
225
|
-
OPENAI_API_KEY="sk-..."
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
## Mounting the API
|
|
231
|
-
|
|
232
|
-
Autoblogger needs API routes to handle requests from the dashboard. Create a catch-all route:
|
|
233
|
-
|
|
234
|
-
```typescript
|
|
235
|
-
// app/api/cms/[...path]/route.ts
|
|
236
|
-
import { cms } from '@/lib/cms'
|
|
237
|
-
import { NextRequest } from 'next/server'
|
|
238
|
-
|
|
239
|
-
async function handler(
|
|
240
|
-
req: NextRequest,
|
|
241
|
-
{ params }: { params: Promise<{ path: string[] }> }
|
|
242
|
-
) {
|
|
243
|
-
const { path } = await params
|
|
244
|
-
return cms.handleRequest(req, path.join('/'))
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export { handler as GET, handler as POST, handler as PATCH, handler as DELETE }
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
This single file handles all CMS API routes:
|
|
251
|
-
|
|
252
|
-
| Route | Purpose |
|
|
253
|
-
|-------|---------|
|
|
254
|
-
| `GET /api/cms/posts` | List all posts |
|
|
255
|
-
| `POST /api/cms/posts` | Create a new post |
|
|
256
|
-
| `PATCH /api/cms/posts/:id` | Update a post |
|
|
257
|
-
| `DELETE /api/cms/posts/:id` | Delete a post |
|
|
258
|
-
| `GET /api/cms/revisions` | List revisions |
|
|
259
|
-
| `POST /api/cms/revisions/:id/restore` | Restore a revision |
|
|
260
|
-
| `GET /api/cms/comments` | List comments |
|
|
261
|
-
| `POST /api/cms/ai/generate` | Generate essay with AI |
|
|
262
|
-
| `POST /api/cms/ai/chat` | Chat with AI (streaming) |
|
|
263
|
-
| ... | And more |
|
|
70
|
+
## Displaying Posts
|
|
264
71
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
## Mounting the Dashboard
|
|
268
|
-
|
|
269
|
-
The dashboard is a React component that renders the full CMS interface. Mount it at a route in your app:
|
|
270
|
-
|
|
271
|
-
```typescript
|
|
272
|
-
// app/writer/[[...path]]/page.tsx
|
|
273
|
-
import { AutobloggerDashboard } from 'autoblogger/ui'
|
|
274
|
-
import { auth } from '@/lib/auth'
|
|
275
|
-
import { redirect } from 'next/navigation'
|
|
276
|
-
|
|
277
|
-
export default async function WriterPage({
|
|
278
|
-
params
|
|
279
|
-
}: {
|
|
280
|
-
params: Promise<{ path?: string[] }>
|
|
281
|
-
}) {
|
|
282
|
-
// Protect this route - only authenticated users
|
|
283
|
-
const session = await auth()
|
|
284
|
-
if (!session) {
|
|
285
|
-
redirect('/login')
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
const { path } = await params
|
|
289
|
-
|
|
290
|
-
return (
|
|
291
|
-
<AutobloggerDashboard
|
|
292
|
-
apiBasePath="/api/cms"
|
|
293
|
-
session={session}
|
|
294
|
-
path={path?.join('/') || ''}
|
|
295
|
-
/>
|
|
296
|
-
)
|
|
297
|
-
}
|
|
298
|
-
```
|
|
299
|
-
|
|
300
|
-
The `[[...path]]` syntax is a catch-all route that captures the dashboard's internal navigation:
|
|
301
|
-
|
|
302
|
-
| URL | Dashboard Page |
|
|
303
|
-
|-----|----------------|
|
|
304
|
-
| `/writer` | Post list (drafts, published, suggested) |
|
|
305
|
-
| `/writer/editor/my-post-slug` | Edit a specific post |
|
|
306
|
-
| `/writer/settings` | Settings overview |
|
|
307
|
-
| `/writer/settings/ai` | AI model and prompt configuration |
|
|
308
|
-
| `/writer/settings/users` | User management |
|
|
309
|
-
| `/writer/settings/tags` | Tag management |
|
|
310
|
-
| `/writer/settings/topics` | RSS topic subscriptions |
|
|
311
|
-
|
|
312
|
-
---
|
|
313
|
-
|
|
314
|
-
## Configuring Tailwind
|
|
315
|
-
|
|
316
|
-
Autoblogger's UI uses Tailwind CSS. Add the package's files to your Tailwind content configuration so the classes aren't purged:
|
|
317
|
-
|
|
318
|
-
```javascript
|
|
319
|
-
// tailwind.config.js
|
|
320
|
-
module.exports = {
|
|
321
|
-
presets: [require('autoblogger/styles/preset')],
|
|
322
|
-
content: [
|
|
323
|
-
'./app/**/*.{js,ts,jsx,tsx}',
|
|
324
|
-
'./components/**/*.{js,ts,jsx,tsx}',
|
|
325
|
-
// Add this line to include Autoblogger's components
|
|
326
|
-
'./node_modules/autoblogger/dist/**/*.{js,mjs}',
|
|
327
|
-
],
|
|
328
|
-
darkMode: 'class',
|
|
329
|
-
// ... rest of your config
|
|
330
|
-
}
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
The `autoblogger/styles/preset` includes:
|
|
334
|
-
- Typography scale (`text-title`, `text-h1`, `text-h2`, `text-h3`, `text-body`, `text-table`)
|
|
335
|
-
- Color tokens (`bg-background`, `text-muted-foreground`, `border-border`, etc.)
|
|
336
|
-
- Border radius utilities
|
|
337
|
-
|
|
338
|
-
---
|
|
339
|
-
|
|
340
|
-
## Styling
|
|
341
|
-
|
|
342
|
-
Autoblogger includes a complete theme with CSS variables, prose styles, and editor styling. Import it in your global CSS:
|
|
343
|
-
|
|
344
|
-
```css
|
|
345
|
-
/* app/globals.css */
|
|
346
|
-
@import 'autoblogger/styles/autoblogger.css';
|
|
347
|
-
|
|
348
|
-
@tailwind base;
|
|
349
|
-
@tailwind components;
|
|
350
|
-
@tailwind utilities;
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
This provides:
|
|
354
|
-
- **Light and dark mode colors** — shadcn/ui Zinc theme tokens
|
|
355
|
-
- **Typography scale** — Consistent heading and body sizes
|
|
356
|
-
- **Prose styles** — Article content formatting (headings, paragraphs, lists, code, blockquotes)
|
|
357
|
-
- **Editor styles** — Tiptap focus states and placeholder styling
|
|
358
|
-
- **Animations** — Fade-in effects with reduced motion support
|
|
359
|
-
|
|
360
|
-
### Customizing
|
|
361
|
-
|
|
362
|
-
Override any CSS variable after the import:
|
|
363
|
-
|
|
364
|
-
```css
|
|
365
|
-
@import 'autoblogger/styles/autoblogger.css';
|
|
366
|
-
|
|
367
|
-
:root {
|
|
368
|
-
--primary: 221 83% 53%; /* Custom blue primary */
|
|
369
|
-
}
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
Or pass custom styles when creating the CMS:
|
|
373
|
-
|
|
374
|
-
```typescript
|
|
375
|
-
// lib/cms.ts
|
|
376
|
-
export const cms = createAutoblogger({
|
|
377
|
-
// ... other config
|
|
378
|
-
styles: {
|
|
379
|
-
container: 'max-w-3xl mx-auto px-8',
|
|
380
|
-
title: 'text-4xl font-serif',
|
|
381
|
-
prose: 'prose prose-lg dark:prose-invert',
|
|
382
|
-
},
|
|
383
|
-
})
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
---
|
|
387
|
-
|
|
388
|
-
## Displaying Posts on Your Site
|
|
389
|
-
|
|
390
|
-
Use the CMS data layer to fetch posts for your public pages:
|
|
72
|
+
Fetch published posts for your public pages:
|
|
391
73
|
|
|
392
74
|
```typescript
|
|
393
75
|
// app/blog/page.tsx
|
|
394
76
|
import { cms } from '@/lib/cms'
|
|
395
|
-
import Link from 'next/link'
|
|
396
77
|
|
|
397
78
|
export default async function BlogPage() {
|
|
398
79
|
const { posts } = await cms.data.posts.findAll({
|
|
399
80
|
where: { status: 'published' },
|
|
400
81
|
orderBy: { publishedAt: 'desc' },
|
|
401
|
-
take: 20,
|
|
402
82
|
})
|
|
403
83
|
|
|
404
84
|
return (
|
|
405
|
-
<
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
<Link href={`/blog/${post.slug}`}>
|
|
411
|
-
{post.title}
|
|
412
|
-
</Link>
|
|
413
|
-
</li>
|
|
414
|
-
))}
|
|
415
|
-
</ul>
|
|
416
|
-
</div>
|
|
85
|
+
<ul>
|
|
86
|
+
{posts.map(post => (
|
|
87
|
+
<li key={post.id}><a href={`/blog/${post.slug}`}>{post.title}</a></li>
|
|
88
|
+
))}
|
|
89
|
+
</ul>
|
|
417
90
|
)
|
|
418
91
|
}
|
|
419
92
|
```
|
|
420
93
|
|
|
421
|
-
|
|
94
|
+
Render a single post:
|
|
422
95
|
|
|
423
96
|
```typescript
|
|
424
97
|
// app/blog/[slug]/page.tsx
|
|
425
98
|
import { cms } from '@/lib/cms'
|
|
426
99
|
import { renderMarkdown } from 'autoblogger/markdown'
|
|
427
|
-
import { generateSeoMetadata } from 'autoblogger/seo'
|
|
428
100
|
import { notFound } from 'next/navigation'
|
|
429
101
|
|
|
430
|
-
export default async function PostPage({
|
|
431
|
-
params
|
|
432
|
-
}: {
|
|
433
|
-
params: Promise<{ slug: string }>
|
|
434
|
-
}) {
|
|
102
|
+
export default async function PostPage({ params }: { params: Promise<{ slug: string }> }) {
|
|
435
103
|
const { slug } = await params
|
|
436
104
|
const post = await cms.data.posts.findBySlug(slug)
|
|
437
105
|
|
|
438
|
-
if (!post || post.status !== 'published')
|
|
439
|
-
notFound()
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
const html = renderMarkdown(post.markdown)
|
|
106
|
+
if (!post || post.status !== 'published') notFound()
|
|
443
107
|
|
|
444
108
|
return (
|
|
445
109
|
<article>
|
|
446
110
|
<h1>{post.title}</h1>
|
|
447
|
-
|
|
448
|
-
<div
|
|
449
|
-
className="prose dark:prose-invert"
|
|
450
|
-
dangerouslySetInnerHTML={{ __html: html }}
|
|
451
|
-
/>
|
|
111
|
+
<div className="prose" dangerouslySetInnerHTML={{ __html: renderMarkdown(post.markdown) }} />
|
|
452
112
|
</article>
|
|
453
113
|
)
|
|
454
114
|
}
|
|
115
|
+
```
|
|
455
116
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
const post = await cms.data.posts.findBySlug(slug)
|
|
464
|
-
|
|
465
|
-
if (!post) return {}
|
|
466
|
-
|
|
467
|
-
return generateSeoMetadata(post)
|
|
468
|
-
}
|
|
117
|
+
## CLI Reference
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npx autoblogger init # Interactive setup
|
|
121
|
+
npx autoblogger init --yes # Use defaults, no prompts
|
|
122
|
+
npx autoblogger init --dry-run # Preview changes
|
|
123
|
+
npx autoblogger import ./posts # Import markdown files
|
|
469
124
|
```
|
|
470
125
|
|
|
471
|
-
|
|
126
|
+
## Keyboard Shortcuts
|
|
472
127
|
|
|
473
|
-
|
|
128
|
+
| Shortcut | Action |
|
|
129
|
+
|----------|--------|
|
|
130
|
+
| ⌘K | Toggle chat panel |
|
|
131
|
+
| ⌘⇧A | Toggle Ask/Agent mode |
|
|
132
|
+
| ⌘. | Toggle theme |
|
|
133
|
+
| ⌘/ | Toggle view |
|
|
134
|
+
| N | New article |
|
|
135
|
+
| Esc | Go back |
|
|
474
136
|
|
|
475
|
-
|
|
137
|
+
## Package Exports
|
|
476
138
|
|
|
477
139
|
```typescript
|
|
478
|
-
//
|
|
140
|
+
// Server
|
|
479
141
|
import { createAutoblogger } from 'autoblogger'
|
|
142
|
+
import { runAutoDraft } from 'autoblogger'
|
|
480
143
|
|
|
481
|
-
// UI
|
|
144
|
+
// UI
|
|
482
145
|
import { AutobloggerDashboard } from 'autoblogger/ui'
|
|
146
|
+
import { ChatProvider, ChatPanel, ChatButton } from 'autoblogger/ui'
|
|
483
147
|
|
|
484
|
-
//
|
|
485
|
-
import { renderMarkdown,
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
import { generateSeoMetadata } from 'autoblogger/seo'
|
|
489
|
-
|
|
490
|
-
// Article styles — CSS class helpers for consistent article layout
|
|
491
|
-
import { ARTICLE_STYLES } from 'autoblogger/styles/article'
|
|
148
|
+
// Utilities
|
|
149
|
+
import { renderMarkdown, htmlToMarkdown } from 'autoblogger/markdown'
|
|
150
|
+
import { getSeoValues } from 'autoblogger/seo'
|
|
151
|
+
import { ARTICLE_CLASSES } from 'autoblogger/styles/article'
|
|
492
152
|
```
|
|
493
153
|
|
|
494
|
-
---
|
|
495
|
-
|
|
496
|
-
## CLI Reference
|
|
497
|
-
|
|
498
|
-
Autoblogger includes a CLI for project setup and content management.
|
|
499
|
-
|
|
500
|
-
### Commands
|
|
501
|
-
|
|
502
|
-
| Command | Description |
|
|
503
|
-
|---------|-------------|
|
|
504
|
-
| `npx autoblogger init` | Set up Autoblogger in your Next.js project |
|
|
505
|
-
| `npx autoblogger import <path>` | Import markdown/MDX content into the database |
|
|
506
|
-
|
|
507
|
-
### Init Options
|
|
508
|
-
|
|
509
|
-
| Option | Description |
|
|
510
|
-
|--------|-------------|
|
|
511
|
-
| `--yes`, `-y` | Skip prompts and use defaults |
|
|
512
|
-
| `--skip-migrate` | Don't run database migration |
|
|
513
|
-
| `--import=<path>` | Import content from specified path after setup |
|
|
514
|
-
| `--dry-run` | Show what would be done without making changes |
|
|
515
|
-
|
|
516
|
-
### Import Options
|
|
517
|
-
|
|
518
|
-
| Option | Description |
|
|
519
|
-
|--------|-------------|
|
|
520
|
-
| `--status=<status>` | Set imported posts status (`draft` or `published`) |
|
|
521
|
-
| `--tag=<tag>` | Add a tag to all imported posts |
|
|
522
|
-
| `--dry-run` | Show what would be imported without making changes |
|
|
523
|
-
|
|
524
|
-
---
|
|
525
|
-
|
|
526
|
-
## AI Models
|
|
527
|
-
|
|
528
|
-
Autoblogger supports these AI models out of the box:
|
|
529
|
-
|
|
530
|
-
| ID | Name | Provider | Description |
|
|
531
|
-
|----|------|----------|-------------|
|
|
532
|
-
| `claude-sonnet` | Sonnet 4.5 | Anthropic | Fast, capable, best value |
|
|
533
|
-
| `claude-opus` | Opus 4.5 | Anthropic | Highest quality, slower |
|
|
534
|
-
| `gpt-5.2` | GPT-5.2 | OpenAI | Latest OpenAI flagship |
|
|
535
|
-
| `gpt-5-mini` | GPT-5 Mini | OpenAI | Fast and cost-efficient |
|
|
536
|
-
|
|
537
|
-
### AI Features
|
|
538
|
-
|
|
539
|
-
- **URL Context**: Paste a URL into your prompt and the AI will fetch and read the article content
|
|
540
|
-
- **Chat Modes**: Rewrite, expand, shorten, or chat freely with your content
|
|
541
|
-
- **Custom Prompts**: Configure prompt templates in **Settings → AI**
|
|
542
|
-
|
|
543
|
-
Configure the default model and custom prompts in the dashboard under **Settings → AI**.
|
|
544
|
-
|
|
545
|
-
---
|
|
546
|
-
|
|
547
|
-
## User Roles
|
|
548
|
-
|
|
549
|
-
Autoblogger supports three roles:
|
|
550
|
-
|
|
551
|
-
| Role | Permissions |
|
|
552
|
-
|------|-------------|
|
|
553
|
-
| `admin` | Full access. Manage users, settings, publish/delete any post. |
|
|
554
|
-
| `writer` | Create posts, publish their own posts, edit drafts. |
|
|
555
|
-
| `drafter` | Create drafts only. Cannot publish. |
|
|
556
|
-
|
|
557
|
-
Roles are stored in the `User.role` field. Your auth configuration determines how roles are checked.
|
|
558
|
-
|
|
559
|
-
---
|
|
560
|
-
|
|
561
154
|
## Troubleshooting
|
|
562
155
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
Make sure you're importing from the correct path and that the package is installed:
|
|
566
|
-
|
|
567
|
-
```bash
|
|
568
|
-
npm install autoblogger
|
|
569
|
-
```
|
|
570
|
-
|
|
571
|
-
### Tailwind classes not applying
|
|
572
|
-
|
|
573
|
-
Add the package to your Tailwind content config:
|
|
574
|
-
|
|
156
|
+
**Tailwind classes not applying?** Add to your Tailwind content config:
|
|
575
157
|
```javascript
|
|
576
|
-
content: [
|
|
577
|
-
// ... your files
|
|
578
|
-
'./node_modules/autoblogger/dist/**/*.{js,mjs}',
|
|
579
|
-
]
|
|
158
|
+
content: ['./node_modules/autoblogger/dist/**/*.{js,mjs}']
|
|
580
159
|
```
|
|
581
160
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
161
|
+
**Styles missing?** Import in `globals.css` before Tailwind directives:
|
|
162
|
+
```css
|
|
163
|
+
@import 'autoblogger/styles/autoblogger.css';
|
|
164
|
+
```
|
|
585
165
|
|
|
166
|
+
**AI not working?** Check your environment variables:
|
|
586
167
|
```bash
|
|
587
168
|
ANTHROPIC_API_KEY="sk-ant-..."
|
|
588
169
|
OPENAI_API_KEY="sk-..."
|
|
589
170
|
```
|
|
590
171
|
|
|
591
|
-
And that you're passing them in the config:
|
|
592
|
-
|
|
593
|
-
```typescript
|
|
594
|
-
ai: {
|
|
595
|
-
anthropicKey: process.env.ANTHROPIC_API_KEY,
|
|
596
|
-
openaiKey: process.env.OPENAI_API_KEY,
|
|
597
|
-
}
|
|
598
|
-
```
|
|
599
|
-
|
|
600
|
-
### Database errors
|
|
601
|
-
|
|
602
|
-
Make sure you've:
|
|
603
|
-
1. Added all required models to your Prisma schema
|
|
604
|
-
2. Run `npx prisma migrate dev`
|
|
605
|
-
3. Run `npx prisma generate`
|
|
606
|
-
|
|
607
|
-
---
|
|
608
|
-
|
|
609
172
|
## License
|
|
610
173
|
|
|
611
174
|
MIT © [Hunter Rosenblume](https://github.com/hrosenblume)
|