Skip to content

factory

factory<TMap, TCollection>(): Tag<Cms<TMap, TCollection, CmsError | ContentStoreError>, Cms<TMap, TCollection, CmsError | ContentStoreError>>

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

Factory function that creates a Context.Tag for a CMS instance. This tag is used to identify and inject CMS instances in the Effect context.

TMap extends Record<string, CollectionAny>

Record mapping collection names to their Collection definitions

TCollection extends Record<string, CollectionAny> = TMap

The collection map type

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

A Context.Tag for the CMS type

const CmsTag = factory<{ posts: PostCollection }>();
// Use in an Effect
const getCms = Effect.gen(function* () {
const cms = yield* CmsTag;
return cms;
});