@autoblogwriter/sdk 3.0.0 → 3.0.1
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 +29 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ npm install @autoblogwriter/sdk
|
|
|
14
14
|
|
|
15
15
|
## v3 Migration (Breaking Changes)
|
|
16
16
|
|
|
17
|
-
Version `3.0.0` removes legacy `BlogAuto*` symbols and legacy webhook/env identifiers.
|
|
17
|
+
Version `3.0.0` removes legacy `BlogAuto*` symbols and legacy webhook/env identifiers. There are no compatibility aliases in v3.
|
|
18
18
|
|
|
19
19
|
### API Rename Map
|
|
20
20
|
|
|
@@ -68,6 +68,34 @@ import "@autoblogwriter/sdk/styles.css";
|
|
|
68
68
|
| `@autoblogwriter/sdk/revalidate` | Server | `createRevalidateRouteHandler`, `verifyWebhookSignature` |
|
|
69
69
|
| `@autoblogwriter/sdk/styles.css` | Client | Default dark-theme styles for all components |
|
|
70
70
|
|
|
71
|
+
## Quick Start (Next.js App Router)
|
|
72
|
+
|
|
73
|
+
1. Install the package:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npm install @autoblogwriter/sdk
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
2. Configure environment variables:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
AUTOBLOGWRITER_API_KEY=ba_pk_your_api_key
|
|
83
|
+
AUTOBLOGWRITER_WORKSPACE_SLUG=your-workspace
|
|
84
|
+
AUTOBLOGWRITER_REVALIDATE_SECRET=your_webhook_secret
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
3. Fetch and render posts:
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
import { fetchBlogPosts } from "@autoblogwriter/sdk/next";
|
|
91
|
+
import { BlogPostList } from "@autoblogwriter/sdk/react";
|
|
92
|
+
|
|
93
|
+
export default async function BlogPage() {
|
|
94
|
+
const { posts } = await fetchBlogPosts({ limit: 20 });
|
|
95
|
+
return <BlogPostList posts={posts} />;
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
71
99
|
## Security Notes (Read First)
|
|
72
100
|
- Never ship AutoBlogWriter API keys in public, client-side code.
|
|
73
101
|
- Run the SDK inside Next.js server components, route handlers, or your own backend proxy.
|
|
@@ -358,36 +386,6 @@ For a light theme, override the color variables:
|
|
|
358
386
|
| `.ba-post-meta` | `<BlogPost>` | Date and reading time |
|
|
359
387
|
| `.ba-markdown` | `<Markdown>` | Markdown content wrapper |
|
|
360
388
|
|
|
361
|
-
## Low-Level Client Configuration
|
|
362
|
-
|
|
363
|
-
For advanced use cases where you need more control than the env-based helpers provide, you can create a client directly:
|
|
364
|
-
|
|
365
|
-
```ts
|
|
366
|
-
import { createAutoBlogWriterClient } from "@autoblogwriter/sdk";
|
|
367
|
-
|
|
368
|
-
const client = createAutoBlogWriterClient({
|
|
369
|
-
apiUrl: "https://api.autoblogwriter.app",
|
|
370
|
-
apiKey: process.env.AUTOBLOGWRITER_API_KEY!,
|
|
371
|
-
workspaceId: process.env.AUTOBLOGWRITER_WORKSPACE_ID,
|
|
372
|
-
workspaceSlug: process.env.AUTOBLOGWRITER_WORKSPACE_SLUG,
|
|
373
|
-
authMode: "bearer", // or "x-api-key"
|
|
374
|
-
headers: { "x-trace-id": "..." },
|
|
375
|
-
timeoutMs: 10_000,
|
|
376
|
-
fetch: globalThis.fetch, // optional custom fetch
|
|
377
|
-
});
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
| Option | Type | Required | Description |
|
|
381
|
-
| --- | --- | --- | --- |
|
|
382
|
-
| `apiUrl` | `string` | yes | Root API URL, e.g. `https://api.autoblogwriter.app`. Trailing slash removed automatically. |
|
|
383
|
-
| `apiKey` | `string` | yes | Workspace-scoped API key created in the AutoBlogWriter dashboard. |
|
|
384
|
-
| `workspaceId` | `string` | one of `workspaceId` or `workspaceSlug` | Optional; used for account scoping. |
|
|
385
|
-
| `workspaceSlug` | `string` | one of `workspaceId` or `workspaceSlug` | Required for public content APIs (`/v1/public/:workspaceSlug/...`). |
|
|
386
|
-
| `authMode` | `"bearer" \| "x-api-key"` | no (default `"bearer"`) | Sends the API key via `Authorization: Bearer` or `x-api-key`. |
|
|
387
|
-
| `headers` | `Record<string, string>` | no | Additional static headers (merged on each request). |
|
|
388
|
-
| `fetch` | `typeof fetch` | no | Provide a custom fetch implementation (e.g., for SSR polyfills). |
|
|
389
|
-
| `timeoutMs` | `number` | no | Optional request timeout enforced client-side. |
|
|
390
|
-
|
|
391
389
|
## Revalidation
|
|
392
390
|
|
|
393
391
|
When AutoBlogWriter publishes a post it can ping your Next.js site so cached pages refresh immediately.
|
package/package.json
CHANGED