A source plugin for Gatsby that allows reading data from Google Sheets.
Forked from brandonmp/gatsby-source-google-sheets to allow pulling the entire sheet as an objects and using public sheets
Why go through the hassle of setting up a complicated headless CMS when Google Sheets already has user permissions, revision history, and a powerful UI?
This source plugin for Gatsby JS will turn any Google Sheets worksheet into a GraphQL type for build-time consumption.
yarn add gatsby-source-google-spreadsheets
Next you need to decide if you wish to authenticate with a service account or an API key.
Or if you wish to use an API Key not only must the Spreadsheet in question be visible to the web, but it must also have been explicitly published.
https://docs.google.com/spreadsheets/d/$SPREADSHEET_ID/edit?usp=sharingStandard source plugin installation.
// gatsby-config.js
// ...
{
resolve: 'gatsby-source-google-spreadsheets',
options: {
spreadsheetId: 'get this from the sheet url',
apiKey: 'GOOGLE-API-KEY'
// Or
credentials: require('./path-to-credentials-file.json')
}
},
// OR using environment variables
{
resolve: 'gatsby-source-google-spreadsheets',
options: {
spreadsheetId: process.env.SPREADSHEET_ID,
apiKey: process.env.GOOGLE_API_KEY,
// OR
credentials: {
type: 'service_account',
project_id: process.env.PROJECT_ID,
private_key_id: process.env.PRIVATE_KEY_ID,
private_key: process.env.PRIVATE_KEY.replace(/(\\r)|(\\n)/g, '\n'),
client_email: process.env.CLIENT_EMAIL,
client_id: '',
auth_uri: 'https://accounts.google.com/o/oauth2/auth',
token_uri: 'https://oauth2.googleapis.com/token',
auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs',
client_x509_cert_url: `https://www.googleapis.com/robot/v1/metadata/x509/${process.env.PROJECT_ID}%40appspot.gserviceaccount.com`,
},
}
},
// ...
The plugin makes the following conversions before feeding Gatsby nodes:
if (
"value".replace(/[,\.\d]/g, "").length === 0
&& "value" !== ""
) {
...assume value is a number and handle accordingly
}
A few notes:
👤 Cian Butler butlerx@notthe.cloud
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a ⭐️ if this project helped you!
Copyright © 2020 Cian Butler butlerx@notthe.cloud.
This project is MIT licensed.
$ claude mcp add gatsby-source-google-spreadsheets \
-- python -m otcore.mcp_server <graph>