Stackbit Configuration
The @contentlayer/experimental-source-files-stackbit
API provides a stackbitConfigToDocumentTypes
method that transforms a Stackbit configuration object into Contentlayer configuration.
This applies only to source-files, as the content schema must be defined in files within the
repository or a shared package available in node_modules
.
stackbitConfigToDocumentTypes
This method is used to build out document types configuration that can used as the documentTypes
property in the makeSource
function.
Usage
stackbitConfigToDocumentTypes(stackbitConfig, options)
Example
The recommended pattern is to import the Stackbit configuration object (stackbit.config.js|ts
) in your Contentlayer configuration file (contentlayer.config.js|ts
).
Then use the stackbitConfigToDocumentTypes
function to transform the Stackbit models into Contentlayer document type definitions, extend or override properties as needed, and then use the result as the documentTypes
property passed to the makeSource
options.
// contentlayer.config.ts
import stackbitConfig from './stackbit.config.js'
import { stackbitConfigToDocumentTypes } from '@contentlayer/experimental-source-files-stackbit'
const documentTypes = stackbitConfigToDocumentTypes(stackbitConfig, {
documentTypes: {
Page: {
// extend page properties ...
},
},
})
export default makeSource({ contentDirPath: 'content', documentTypes })
See the integration guide for an example in overriding a particular document type.
Was this article helpful to you?
Provide feedback
Last edited on May 24, 2023.
Edit this page