UNPKG

@stackbit/utils

Version:
51 lines 2.08 kB
import type * as StackbitTypes from '@stackbit/types'; /** * The `createContentSourceWithDrafts()` function enhances the provided content * source with "Content Drafts" capabilities, enabling editors to modify multiple * content fields on a page and then save all pending changes into the CMS in a * single action. This reduces the number of content writes in the CMS. * For instance, when using this with `GitContentSource`, all pending changes are * saved in a single commit. * * To retrieve draft content in the web framework and reflect changes in Create * before they are saved to the CMS (e.g., Git), run the web framework with the * `STACKBIT_API_KEY` environment variable set to the value of the `localId` * variable printed when running `stackbit dev` locally. Then, pass the * `STACKBIT_API_KEY` to the `getCSIDocuments()` method from the `@stackbit/utils` * package to retrieve the draft content from the Create server. * * ```javascript * const result = await getCSIDocuments({ * stackbitApiKey: process.env.STACKBIT_API_KEY * }); * ``` * * You can also pass additional data to filter out specific documents by ID: * * ``` * {"documentSpecs": [{srcType: "git", srcProjectId: "...", "srcDocumentId": "..."}]} * ``` * * For example, after running `stackbit dev`, the command will print: * * ``` * info: localId: ab1...9yz * ``` * * Use the `localId` value to set the `STACKBIT_API_KEY` environment variable * when running your web framework: * * ``` * STACKBIT_API_KEY=ab1...9yz npm run dev * ``` * * Then, use the `STACKBIT_API_KEY` to fetch documents with pending "draft" * changes and render them on a page. * * When the project runs in Create Cloud, a different `STACKBIT_API_KEY` will be * generated and injected into the environment variables. */ export declare function createContentSourceWithDrafts<ContentSourceType extends StackbitTypes.ContentSourceInterface<any, any, any, any, any>>(options: { contentSource: ContentSourceType; }): ContentSourceType; //# sourceMappingURL=content-source-with-drafts.d.ts.map