@zeno-cms/sdk 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +154 -30
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -202,56 +202,172 @@ if (error) {
202
202
  }
203
203
  ```
204
204
 
205
- ## Framework Examples
205
+ ## Framework Integrations
206
206
 
207
- ### React with TanStack Query
207
+ Built-in hooks, composables, stores and signals for every major framework — zero external dependencies.
208
+
209
+ ### React
210
+
211
+ ```tsx
212
+ // main.tsx — Setup provider once
213
+ import { ZenoProvider } from '@zeno-cms/sdk/react'
214
+
215
+ createRoot(document.getElementById('root')!).render(
216
+ <ZenoProvider apiKey={import.meta.env.VITE_ZENO_API_KEY}>
217
+ <App />
218
+ </ZenoProvider>
219
+ )
220
+ ```
221
+
222
+ ```tsx
223
+ // components/BlogList.tsx — Use hooks
224
+ import { useEntries } from '@zeno-cms/sdk/react'
225
+
226
+ export function BlogList() {
227
+ const { data: posts, isLoading, error } = useEntries('blog', {
228
+ status: 'published'
229
+ })
230
+
231
+ if (isLoading) return <p>Loading...</p>
232
+ if (error) return <p>Error: {error}</p>
233
+
234
+ return posts?.map(post => (
235
+ <article key={post.id}>
236
+ <h2>{post.data.title}</h2>
237
+ </article>
238
+ ))
239
+ }
240
+ ```
241
+
242
+ Available hooks: `useEntries`, `useEntry`, `useCollections`, `useCollection`, `useAssets`, `useAssetUrl`, `useProject`, `useLocales`, `useZeno`
243
+
244
+ ### Vue
208
245
 
209
246
  ```typescript
210
- import { useQuery } from '@tanstack/react-query'
211
- import { ZenoCMS } from '@zeno-cms/sdk'
247
+ // main.ts Setup plugin once
248
+ import { createZeno } from '@zeno-cms/sdk/vue'
212
249
 
213
- const zeno = new ZenoCMS()
250
+ app.use(createZeno({
251
+ apiKey: import.meta.env.VITE_ZENO_API_KEY
252
+ }))
253
+ ```
214
254
 
215
- export function usePosts() {
216
- return useQuery({
217
- queryKey: ['posts'],
218
- queryFn: async () => {
219
- const { data, error } = await zeno.getEntries('blog', {
220
- status: 'published'
221
- })
222
- if (error) throw new Error(error)
223
- return data ?? []
224
- }
255
+ ```vue
256
+ <!-- components/BlogList.vue -->
257
+ <script setup>
258
+ import { useEntries } from '@zeno-cms/sdk/vue'
259
+
260
+ const { data: posts, loading } = useEntries('blog', {
261
+ status: 'published'
262
+ })
263
+ </script>
264
+
265
+ <template>
266
+ <p v-if="loading">Loading...</p>
267
+ <article v-for="post in posts" :key="post.id">
268
+ <h2>{{ post.data.title }}</h2>
269
+ </article>
270
+ </template>
271
+ ```
272
+
273
+ Available composables: `useEntries`, `useEntry`, `useCollections`, `useCollection`, `useAssets`, `useLocales`, `useZeno`
274
+
275
+ ### Svelte
276
+
277
+ ```svelte
278
+ <!-- +layout.svelte — Setup once -->
279
+ <script lang="ts">
280
+ import { initZeno } from '@zeno-cms/sdk/svelte'
281
+ let { children } = $props()
282
+
283
+ initZeno({ apiKey: import.meta.env.VITE_ZENO_API_KEY })
284
+ </script>
285
+
286
+ {@render children()}
287
+ ```
288
+
289
+ ```svelte
290
+ <!-- components/BlogList.svelte -->
291
+ <script>
292
+ import { useEntries } from '@zeno-cms/sdk/svelte'
293
+
294
+ const { data: posts, loading, error } = useEntries('blog', {
295
+ status: 'published'
225
296
  })
297
+ </script>
298
+
299
+ {#if $loading}
300
+ <p>Loading...</p>
301
+ {:else}
302
+ {#each $posts ?? [] as post}
303
+ <article>
304
+ <h2>{post.data.title}</h2>
305
+ </article>
306
+ {/each}
307
+ {/if}
308
+ ```
309
+
310
+ Available stores: `useEntries`, `useEntry`, `useCollections`, `useCollection`, `useAssets`, `useAssetUrl`, `useProject`, `useLocales`, `useZeno`
311
+
312
+ ### Angular
313
+
314
+ ```typescript
315
+ // app.config.ts — Setup provider once
316
+ import { provideZeno } from '@zeno-cms/sdk/angular'
317
+
318
+ export const appConfig = {
319
+ providers: [
320
+ provideZeno({ apiKey: environment.zenoApiKey })
321
+ ]
226
322
  }
227
323
  ```
228
324
 
229
- ### Next.js App Router
325
+ ```typescript
326
+ // components/blog-list.component.ts
327
+ import { Component } from '@angular/core'
328
+ import { useEntries } from '@zeno-cms/sdk/angular'
329
+
330
+ @Component({
331
+ selector: 'app-blog-list',
332
+ template: `
333
+ @if (posts.loading()) { <p>Loading...</p> }
334
+ @for (post of posts.data(); track post.id) {
335
+ <article>
336
+ <h2>{{ post.data.title }}</h2>
337
+ </article>
338
+ }
339
+ `
340
+ })
341
+ export class BlogListComponent {
342
+ posts = useEntries('blog', { status: 'published' })
343
+ }
344
+ ```
345
+
346
+ Available signals: `useEntries`, `useEntry`, `useCollections`, `useCollection`, `useAssets`, `useAssetUrl`, `useProject`, `useLocales`, `injectZeno`
347
+
348
+ ### Next.js (Server Components)
230
349
 
231
350
  ```typescript
232
- // app/blog/page.tsx
351
+ // app/blog/page.tsx — Server-side, no hooks needed
233
352
  import { ZenoCMS } from '@zeno-cms/sdk'
234
353
 
235
354
  const zeno = new ZenoCMS()
236
355
 
237
356
  export default async function BlogPage() {
238
357
  const { data: posts } = await zeno.getEntries('blog', {
239
- status: 'published',
240
- locale: 'en'
358
+ status: 'published'
241
359
  })
242
360
 
243
- return (
244
- <main>
245
- {posts?.map(post => (
246
- <article key={post.id}>
247
- <h2>{post.data.title as string}</h2>
248
- </article>
249
- ))}
250
- </main>
251
- )
361
+ return posts?.map(post => (
362
+ <article key={post.id}>
363
+ <h2>{post.data.title as string}</h2>
364
+ </article>
365
+ ))
252
366
  }
253
367
  ```
254
368
 
369
+ For Client Components, use `ZenoProvider` + hooks from `@zeno-cms/sdk/react`.
370
+
255
371
  ### Astro
256
372
 
257
373
  ```astro
@@ -328,7 +444,9 @@ If the allowed domains list is empty, requests are accepted from any origin.
328
444
  The SDK automatically detects and reads the API key from:
329
445
 
330
446
  - **Node.js**: `process.env.ZENO_API_KEY`
331
- - **Vite/Astro**: `import.meta.env.ZENO_API_KEY`
447
+ - **Next.js (client)**: `process.env.NEXT_PUBLIC_ZENO_API_KEY`
448
+ - **Vite / React / Vue / Svelte**: `import.meta.env.VITE_ZENO_API_KEY`
449
+ - **Astro**: `import.meta.env.PUBLIC_ZENO_API_KEY`
332
450
  - **Browser**: Pass directly via `new ZenoCMS({ apiKey: '...' })`
333
451
 
334
452
  ## TypeScript
@@ -338,13 +456,19 @@ Full TypeScript support with exported types:
338
456
  ```typescript
339
457
  import {
340
458
  ZenoCMS,
459
+ ZenoConfig,
341
460
  ZenoResponse,
342
461
  Collection,
343
462
  Entry,
344
463
  Asset,
464
+ AssetUrl,
345
465
  Locale,
466
+ Project,
467
+ Field,
468
+ HealthStatus,
346
469
  PaginationParams,
347
- FilterParams
470
+ FilterParams,
471
+ EmailParams
348
472
  } from '@zeno-cms/sdk'
349
473
  ```
350
474
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeno-cms/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Official SDK for Zeno CMS - Fetch content, manage assets, send emails and more",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",