Changing the default content type
If you want to change the default content type, open your
frontmatter.json and write an entry for the
frontMatter.taxonomy.contentTypes setting. Visual Studio Code will automatically autocomplete it with the default content type fields.
If in some case it wouldn't do this, here is the default content type structure:
Adapt the fields to your needs. For our documentation it looks as follows:
The metadata section on the editor panel will render the following fields:
Content type properties
For the content type you can configure the following properties:
|Name of the content type|
|Check the supported field types|
|Enum: ||File type of for the content type you define. The type will be used to create the file when creating content.|
|If set to |
|Defines a custom preview path for the content type. When the preview path is not set, the value from the frontMatter.preview.pathName setting will be used.|
|Specify a path to a template file that will be used when creating new content with the content type.|
|An optional post script that can be used after new content creation. In order to use this, you will have to set the value to the ID of your content script.|
Define your own type
In most cases, you'll work with multiple types of content where each type will have its defined set of fields. If this is the case for your website, you'll need to add another content type to the
Instead of overriding the default content type, you can also define a new content type. It requires you to specify the
nameproperty value needs to be equal to the
typevalue you set in your Markdown front matter. You best define it via a template so that it's always defined. A default template will be available when initializing Front Matter in your project in the
In the sample,
documentation is used as the content type name. This means that in your article, you'll need to add the
type: documentation to your front matter to let the editor panel understand which fields to show.
Fields: Check out the fields section to learn which fields are supported.
Using a template with the content type
When creating content that requires a pre-defined structure, you can use the
template property. The
template property allows you to link a template file. On content creation, the contents of the template file will be used to create the new content.
You can use the
template property on any of your content types, even on the default content type from Front Matter.
Run a script after your content is created
To run a custom script after your content is created, you can use the
postScript property. The
postScript property allows you to link a script file by referencing its
id. The script will be executed after the content is created which gives you access to the whole front matter object.
In your custom script setting, you need to make sure that this script is available:
Info: More information about custom scripts can be found in the custom actions section.