Source plugin for pulling locales from contentful spaces. It creates a list with all the locales available and exposes information like default locale and fallback locale.
# npm
npm install --save gatsby-source-contentful-locales
# yarn
yarn add gatsby-source-contentful-locales
// In your gatsby-config.js
// Learn about environment variables on Gatsby: https://gatsby.dev/env-vars
module.exports = {
plugins: [
{
resolve: `gatsby-source-contentful-locales`,
options: {
spaceId: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
},
},
],
}
spaceId [string][required]
Contentful spaceId
accessToken [string][required]
Contentful delivery api key
{
allContentfulLocale {
totalCount
edges {
node {
id
code
name
default
fallbackCode
}
}
}
}
{
"data": {
"allContentfulLocale": {
"totalCount": 2,
"edges": [
{
"node": {
"id": "a649bd83-324f-55de-9a70-1d94d96880f3",
"code": "en-US",
"name": "English (United States)",
"default": true,
"fallbackCode": null
}
},
{
"node": {
"id": "74a15964-622b-5992-af9b-fea2e2d8fd69",
"code": "es",
"name": "Spanish",
"default": false,
"fallbackCode": "en-US"
}
}
]
}
}
}