@eteration/gatsby-source-strapi
v1.0.0-alpha.0
Published
Gatsby source plugin for building websites using Strapi as a data source
Downloads
51
Maintainers
Readme
gatsby-source-strapi
Source plugin for pulling documents into Gatsby from a Strapi API.
Why did we fork
Some of ur image URLs are not standard so we needed to skip them. This version ignores a media file if it cannot be fetched.
WARNING: This is the README for v1.0.0-alpha.0 make sure to install it with @alpha to try it out
Install
npm install --save @eteration/gatsby-source-strapi@alpha
How to use
// In your gatsby-config.js
plugins: [
{
resolve: `gatsby-source-strapi`,
options: {
apiURL: `http://localhost:1337`,
queryLimit: 1000, // Default to 100
contentTypes: [
`article`,
`user`,
// if you don't want to leave the definition of an api endpoint to the pluralize module
{
name: `collection-name`,
endpoint: `custom-endpoint`,
},
],
//If using single types place them in this array.
singleTypes: [`home-page`, `contact`],
// Possibility to login with a strapi user, when content types are not publically available (optional).
loginData: {
identifier: '',
password: '',
},
},
},
];
How to query
You can query Document nodes created from your Strapi API like the following:
{
allStrapiArticle {
edges {
node {
id
title
content
}
}
}
}
To query images you can do the following:
{
allStrapiArticle {
edges {
node {
id
singleImage {
localFile {
publicURL
}
}
multipleImages {
localFile {
publicURL
}
}
}
}
}
}