Contribution Point
In many cases, you would like to allow users to have fine-grained control over the exporter behavior, and maybe deeply integrate it with the Supernova interface as well. For this reason, exporters have access to contribution points, which allow them to directly integrate with Supernova.
Using contribution point
Contributions are done by expanding exporter.json
with contributes
key (object
). For example, this is how you would expand exporter.json
to contribute user configuration into Supernova interface:
To use specific functionality within the contribution point, simply add one of the following keys with their respective sub-definitions. Each key defines one specific area of contributions:
configuration
- Allows to define configuration values that can be changed by the user, and then accessed inside blueprints or to modify which files should be produced by the exporter.
Contribution Point: Configuration
Configuration allows you to expose certain properties of the exporter to the user without them needing to clone or fork your exporter to make the change:
There are three types of configuration options:
number
forcing numeric input from the user of your exporterstring
forcing string input from the user of your exporterboolean
forcing true/false input from the user of your exporter
Each of the entries in the configuration must define the following keys:
key
that you will use to reference this configuration in your blueprintslabel
which is human-readable description that will show inside the interfacetype
which defines the type of the configuration -number
,string
orboolean
default
value which is provided when the user doesn't override given values
Using configuration inside blueprints
Then, in your blueprint, simply retrieve that information:
The resulting variable will contain a prefixed value if user-provided one, or just Colors
if they did not.
Using configuration inside javascript
Using configuration inside output.json
output.json
Lastly, you can use configuration to define the behavior of the file output. In this case, you can use your boolean keys to decide whether a file should be generated, or not. Simply add when
to your output.json
entry that defines one file:
In this case, when generateColors
is true, colors.html
will be generated, but otherwise, it will be ignored and won't show at the output.
You can also use negation to take the opposite value:
This will generate colors.html
only when ignoreColors
is false. Note that in all cases, this key must be defined inside exporter.json
in contributes.configuration
, otherwise, an error will be thrown.
Last updated
Was this helpful?