Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@raygesualdo/gatsby-plugin-settings
Advanced tools
Gatsby plugin to manage user settings more effectively
A Gatsby plugin to consume YAML, TOML, and/or JSON files and expose their data as global site settings via Gatsby's GraphQL layer.
NOTE: This plugin was originally developed to dovetail with NetlifyCMS's file collections feature.
$ npm install --save @raygesualdo/gatsby-plugin-settings
// In your gatsby-config.js
plugins: [
{
resolve: '@raygesualdo/gatsby-plugin-settings',
options: {
path: `${__dirname}/path/to/settings/directory`,
},
},
]
NOTE: options.path
must exist before starting Gatsby!
In the directory specified in options.path
, create YAML, TOML and/or JSON files.
// contributors.json
[
{ name: 'Jane Smith', handle: 'janesmith03' },
{ name: 'Dwayne Jones', handle: 'dwayne_jones' },
]
# social.yml
facebook: 'myFacebookHandle'
twitter: 'myTwitterHandle'
linkedin: 'myLinkedinHandle'
# location.toml
[address]
streetAddress = "123 Main Street"
city = "Springfield"
Then query them as you would any other Gatsby data.
query Settings {
siteSettings {
contributors {
name
handle
}
social {
facebook
twitter
linkedin
}
location {
address {
streetAddress
city
}
}
}
}
The above query would result in the following data set:
{
"data": {
"siteSettings": {
"contributors": [
{
"name": "Jane Smith",
"handle": "janesmith03"
},
{
"name": "Dwayne Jones",
"handle": "dwayne_jones"
}
],
"social": {
"facebook": "myFacebookHandle",
"twitter": "myTwitterHandle",
"linkedin": "myLinkedinHandle"
},
"location": {
"address": {
"streetAddress": "123 Main Street",
"city": "Springfield"
}
}
}
}
}
Currently, only one instance of this plugin is allowed per site.
This plugin supports the following file extensions: .yml
, .yaml
, .toml
, and .json
This will add both a siteSettings
and allSiteSettings
fields to the root GraphQL query. Only siteSettings
is to be used. allSiteSettings
is a side-effect of Gatsby assuming all node types are collections.
When working with arrays of data, values as the same path cannot be of different types. This requirement is due to GraphQL's strongly-typed schema; neither this plugin nor Gatsby can change that. For instance, the following YAML file will throw an error:
oops:
- 1
- "a string"
This plugin watches your settings file and will hot-reload your settings when values change but your query schema does not e.g. changing a value or adding an item to a pre-existing array. Settings changes that affect your query schema will require a full restart of Gatsby's dev mode, e.g. adding a settings file or changing a key name.
FAQs
Gatsby plugin to manage user settings more effectively
We found that @raygesualdo/gatsby-plugin-settings demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.