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, Stackbit 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.
1
2
3
4
5
6
7
- 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.
duplicatableModels
nonDuplicatableModels
presetReferenceBehavior
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.