Data files view
Data files/folders are pieces of content that do not belong to any markdown content, but live on their own. Most of the time, these data files are used to store additional information about your project/blog/website that will be used to render the content.
For example:
- navigation
- social media links
- contacts
- etc.
The data files dashboard allows you to quickly manage your data files.
Configuration
In order to use the data files dashboard, you will need to configure the extension with the following settings:
frontMatter.data.types
: This only defines the object and its fields. Use this setting, if you want to re-use a data type in various files/folders.frontMatter.data.files
: Defines how a single data file.frontMatter.data.folders
: Defines that all files of a folder need to be treated the same.
Creating a data file
To create a data file, you can use the frontMatter.data.files
setting.
"frontMatter.data.files": [
{
"id": "sponsors",
"title": "Sponsors",
"file": "[[workspace]]/data/sponsors.json",
"fileType": "json",
"labelField": "name",
"singleEntry": false,
"schema": {
"title": "Sponsors",
"type": "object",
"required": [
"name",
"url"
],
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"url": {
"type": "string",
"title": "URL"
},
"description": {
"type": "string",
"title": "Description"
}
}
}
}
]
InfoThe
singleEntry
setting is used to define if the data file is a single entry or a not.
The above sample can be used to create a sponsor data file which contains an array of sponsor object with url, name, and description as properties.
InfoUse the
[[workspace]]
placeholder to define the workspace folder. The extension will automatically replace this with the workspace folder path.
Defining a data schema
The schema
property is used to define the structure of the data file. The schema is defined using
the JSON Schema standard.
The following example shows a schema for a sponsor object:
{
"title": "Sponsors",
"type": "object",
"required": [
"name",
"url"
],
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"url": {
"type": "string",
"title": "URL"
},
"description": {
"type": "string",
"title": "Description",
"multiline": true
}
}
}
Field types
The following field types are supported:
string
number
boolean
array
object
When you are using the string
type, you can use the multiline
property to define if the field is
a multiline field.
Re-using a data type for files or folders
In some cases, you might want to re-use a data type for files or folders. You can do so by using the
frontMatter.data.types
setting in combination with the frontMatter.data.files
and/or
frontMatter.data.folders
settings.
First the data type, this is an object containing the id
and schema
properties.
"frontMatter.data.types": [
{
"id": "sponsors",
"schema": {
"title": "Sponsors",
"type": "object",
"required": [
"name",
"url"
],
"properties": {
"name": {
"type": "string",
"title": "Name"
},
"url": {
"type": "string",
"title": "URL"
},
"description": {
"type": "string",
"title": "Description"
}
}
}
}
]
In the frontMatter.data.files
and/or frontMatter.data.folders
settings, instead of defining the
schema
property, you can use the type
property to reference the data type.
"frontMatter.data.files": [
{
"title": "All sponsors",
"id": "all-sponsors",
"file": "[[workspace]]/data/sponsors",
"labelField": "name",
"type": "sponsors"
}
]
Importantwhen using data folders, the extension searches for
yml
,yaml
, andjson
files in the folder.
Feedback/comments
Did you spot an issue in our documentation, or want to contribute? Edit this page on Github!