Skip to content

makeCms

makeCms<TMap, TCollection>(config): object

Defined in: packages/core/src/cms.ts:585

Creates a CMS instance with its associated Context.Tag and Layer. This is the main factory function for creating a complete CMS setup.

TMap extends Record<string, CollectionAny>

Record mapping collection names to their Collection definitions

TCollection extends Record<string, CollectionAny> = TMap

The collection map type

Configuration object containing the collections to manage

TCollection

object

Object containing CmsTag for dependency injection and CmsLayer for providing the service

CmsLayer: Layer<Cms<TMap, TCollection, CmsError | ContentStoreError>, never, ContentStore>

CmsTag: Tag<Cms<TMap, TCollection, CmsError | ContentStoreError>, Cms<TMap, TCollection, CmsError | ContentStoreError>>

const { CmsTag, CmsLayer } = makeCms({
collections: {
posts: postsCollection,
users: usersCollection
}
});
// Use in your application
const program = Effect.gen(function* () {
const cms = yield* CmsTag;
const posts = yield* cms.getAll("posts");
return posts;
}).pipe(Effect.provide(CmsLayer));