When defining a mock configuration for a given slice, in .slicemachine/mock-config.json
file, you can alter the way a mock will be generated. This configuration occurs per field and depends on the widget type the field points to.
When a config
object is passed to ST Widget, it merges it with its own default values. These default values are:
blocks
{ min: number, max: number }, which defines the number of times a "pattern" will be repeated (see below)sentencesPerParagraph
{ min: number, max: number }, which defines the number of sentences that will be generated per paragraphwordsPerSentence
{ min: number, max: number }, which defines the number of words hat will be generated per sentenceTo generate interesting mocks, the widget uses a pattern system, where a pattern is defined as an array of text types (eg. ['heading1', 'paragraph']
) that will be repeated a defined blocks
number of times. This is useful to generate repeating content, like a blog post might be.
When passing a pattern
array to the mock configuration, it gets repeated between blocks.min
and blocks.max
times.
Predefined pattern types:
Instead of specifying your own pattern
, you can a special key called patternType
with one of these values:
PARAGRAPH
: returns a ['paragraph']
patternHEADING
: returns largest defined heading (eg. ['heading2']
)PARAGRAPH_WITH_HEADING
: returns largest defined heading + paragraph (eg. ['heading1', 'paragraph']
)Content:
Instead of passing a config
object to the ST widget, you can pass it a content
property. It will behave differently depending of what you feed it with:
1) Create a RichText of type Heading by using a heading text type found in my config