Presets

Properties that override the default behavior for component presets.

Component presets are like content templates for components. You can save arrangements of content that content editors can use to quickly create new components on your site.

See the feature guide for more information. Or see the presets configuration API reference for details on working specifically with presets.

Preset Directories

By default, Netlify Create looks for presets in .stackbit/presets and node_modules/@stackbit/components/presets. You can add to the defaults with the properties here.

presetSource

Adds directory paths for loading presets from custom directories or external packages.

Required
No
Allowed Values

An object with the following properties:

  • type: Must be set to files.
  • presetDirs: An array of directory paths containing presets to load. The path should be relative to the root of the project, and can include directories within node_modules.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
export default {
  presetSource: {
    type: 'files',
    presetDirs: ['node_modules/some-package/.stackbit/presets', 'my-presets'],
  },
  // other properties ...
}
  • All presets in all directories are loaded, regardless of any conflicts in model name or preset label.
  • Regardless of the directories provided in presetDirs, the following directories will be included:
    • .stackbit/presets
    • node_modules/@stackbit/components/presets
  • Ensure that presets being brought in from packages match the structure of the model that you're using in your project. Presets mismatching the schema of the model they represent are not currently supported.
  • Presets created by content editors will be placed in the .stackbit/presets directory. This behavior is not affected by these settings.

Handling References

When storing presets with content that references existing content (pages or components), you can control how the references are stored.

Each preset's behavior is determined by the JSON file for that preset. This means that your configuration values for handling references only applies to the point at which the preset is created, after which the JSON file determines the behavior of the preset.

duplicatableModels

This property is covered in the references configuration section.

nonDuplicatableModels

This property is covered in the references configuration section.

presetReferenceBehavior

This property is an alias for referenceBehavior. See the references configuration section for the full details. Shown below are notes specific to this property when used for presets.

This affects only newly-created presets. Changing this property has no affect on content created from existing presets. This is because preset configurations is stored when the preset is created. Presets must be changed directly for their behavior to change. See presets API reference for details.

Example: A PostFeed component preset includes a reference to a list of featured posts.

copyReference: New content created from the preset will refer to the same posts stored in the preset.

duplicateContents: Each post referenced in the preset will be duplicated, and the new posts will be used for the new content.