packages/gatsby-transformer-toml/README.md
Parses TOML files.
npm install gatsby-transformer-toml
// In your gatsby-config.js
plugins: [`gatsby-transformer-toml`]
This plugin is using NPM toml package to parse TOML documents. As long as your TOML is valid, you shouldn't have any issues.
Live demo of TOML to JSON conversion using toml is here.
If you have user.toml in your project, with contents like this:
userName = "Random User"
userAvatar = "https://api.adorable.io/avatars/150/test.png"
userDescription = "Lorem..."
[userLink]
label='Website'
url='//mywebsite.example.local'
icon='fa fa-link'
Then you'll be able to query your data using:
query {
userToml {
userName
userAvatar
userDescription
userLink {
label
url
icon
}
}
}
And the result will be:
{
"data": {
"userToml": {
"userName": "Random User",
"userAvatar": "https://api.adorable.io/avatars/150/test.png",
"userDescription": "Lorem...",
"userLink": {
"label": "Website",
"url": "//mywebsite.example.local",
"icon": "fa fa-link"
}
}
}
}