This is a Gridsome Starter using the headless CMS Strapi. It is suppose to kick-start development with Strapi.
A Demo is hosted on Netlify.
Under the hood, the starter is using the source plugin @gridsome/source-strapi
to pull data from Strapi into Gridsome's data store.
Images provided by Strapi are downloaded and saved locally via onCreateNode
. Thus, the build version includes all images in /static
.
Rich text which is provided as markdown from Strapi is prepared via onCreateNode
and transformed to html using @gridsome/transformer-remark
.
Note: Steps that are marked with a check are already done and are just necessary if you set up a completely new project.
npm install @gridsome/source-strapi --save
export default {
plugins: [
{
use: '@gridsome/source-strapi',
options: {
apiURL: 'http://localhost:1337',
queryLimit: 1000, // Defaults to 100
contentTypes: ['post'],
// Possibility to login with a Strapi user,
// when content types are not publicly available (optional).
loginData: {
identifier: '',
password: ''
}
}
}
]
}
npx create-strapi-app gridsome-starter-strapi-cms --quickstart
.npm run strapi install graphql
. Open the GraphQL Playground (http://localhost:1337/graphql) to test your queries.npm run develop
.Plugins
> Content-Types Builder
> Create new collection type
).Post
.title
(text), subtitle
(text), article
(rich text) and image
(single media).Save
& Publish
.Collection Types
> Posts
> Add New Post
.Settings
> Roles
under USERS & PERMISSIONS PLUGIN
. Click on the column saying Public
. Put a check on find
and findOne
under Post
. Click on Save
.gridsome.config.js
add post
(API ID) under contentTypes
.Plugins
> Content-Types Builder
> Create new single type
).About
.title
(text) and article
(rich text).Save
& Publish
.Single Types
> About
.Settings
> Roles
under USERS & PERMISSIONS PLUGIN
. Click on the column saying Public
. Put a check on find
under About
. Click on Save
.gridsome.config.js
add about
(API ID) under singleTypes
.npm install --global @gridsome/cli
gridsome create gridsome-starter-strapi
to install default startercd gridsome-starter-strapi
to open the foldergridsome develop
to start a local dev server at http://localhost:8080
http://localhost:8080/___explore
.TypeError: gridsome.server.js: Cannot read property 'allStrapiPost' of undefined (31:10)
as an error after starting the gridsome development server, you likely forgot to create and/or publish your post in Strapi under Collection Types
> Posts
.