Community Plugin
View plugin on GitHubgatsby-source-package
This plugin allows you to source the contents of package.json.
Install
npm install --save gatsby-source-packageor
yarn add gatsby-source-packageHow to use
Add the plugin to gatsby-config.js..
module.exports = {
plugins: [...`gatsby-source-package`],
};You may only source some of the keys in package.json:
module.exports = {
plugins: [
{
resolve: `gatsby-source-package`,
options: {
only: ['name', 'version', 'description'],
},
},
],
};Query package.json
The GraphQL query will match your package.json:
query {
package {
name
version
description
}
}Result:
{
"data": {
"package": {
"name": "gatsby-starter-hello-world",
"version": "0.1.0",
"description": "A simplified bare-bones starter for Gatsby"
}
},
"extensions": {}
}