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.
Type Parameters
Section titled “Type Parameters”TMap
extends Record
<string
, CollectionAny
>
Record mapping collection names to their Collection definitions
TCollection
Section titled “TCollection”TCollection
extends Record
<string
, CollectionAny
> = TMap
The collection map type
Parameters
Section titled “Parameters”config
Section titled “config”Configuration object containing the collections to manage
collections
Section titled “collections”TCollection
Returns
Section titled “Returns”object
Object containing CmsTag for dependency injection and CmsLayer for providing the service
CmsLayer
Section titled “CmsLayer”CmsLayer:
Layer
<Cms
<TMap
,TCollection
,CmsError
|ContentStoreError
>,never
,ContentStore
>
CmsTag
Section titled “CmsTag”CmsTag:
Tag
<Cms
<TMap
,TCollection
,CmsError
|ContentStoreError
>,Cms
<TMap
,TCollection
,CmsError
|ContentStoreError
>>
Example
Section titled “Example”const { CmsTag, CmsLayer } = makeCms({ collections: { posts: postsCollection, users: usersCollection }});
// Use in your applicationconst program = Effect.gen(function* () { const cms = yield* CmsTag; const posts = yield* cms.getAll("posts"); return posts;}).pipe(Effect.provide(CmsLayer));