您的问题有很多东西,如果没有,我会尝试逐步回答,如果您需要有关如何创建页面等的更多详细信息,请告诉我,我会更新我的答案以添加更多如果需要,请提供详细信息。
如果您想将源代码从 Netlify 更改为 Strapi,您需要在您的 gatsby-config.js 中进行设置,将 gatsby-plugin-netlify-cms 插件替换为类似的内容:
{
resolve: `gatsby-source-strapi`,
options: {
apiURL: `http://localhost:1337`,
queryLimit: 1000, // Default to 100
contentTypes: [`article`, `user`],
//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: "",
},
},
},
请注意,您必须安装所需的插件并删除不必要的插件,以减少捆绑包并提高使用启动器时的性能。
下一步是使用 GraphQL 从您的源 CMS(文章、帖子、页面等)创建页面。也许这个博客helps you。但作为一个简短的总结,您需要在 gatsby-node.js 中创建查询以从 Strapi CMS 检索数据并使用 Gatsby 的 API 创建页面。
这个想法与您的初学者相同,但是,您将使用 Strapi CMS 提供的对象,而不是使用 gatsby-source-filesystem 和 allMarkdownRemark 在您的页面创建中。您可以使用 gatsby develop 并输入 localhost:8000/___graphql 来检查查询和可用对象。
请记住,您将始终从多个来源查询静态数据(即预下载的数据),因此当您运行开发命令时,数据会被下载并通过 GraphQL 访问。
您可以在其starter repository 中查看更多信息。