1 Star 0 Fork 0

samlet/strapi-heroku-cms-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Strapi with Gatsby Video Tutorial Series

This REPO contains the latest example code from the Gatsby / Strapi Video Tutorial Series. You can review the code directly, within the following directories.

NOTE: This is the BETA version of Strapi, ALPHA is not being maintained.

  • Code examples for the folder "cms". Path: ./tutorial/cms <- Strapi Project

  • Code examples for the folder "blog". Path: ./tutorial/blog. <- Gatsby Project

Instructions for cloning and using this repo locally

Create a folder, e.g. ./my-project and git clone this repo.

cd my-project
git clone https://github.com/strapi/strapi-heroku-cms-demo.git

Install this Strapi & Gatsby Project locally

From your command line, issue the following commands in order to install this Strapi and Gatsby project:

Path: ./my-project/

Install the Strapi part of the Project

git clone git@github.com:strapi/strapi-heroku-cms-demo.git
cd strapi-heroku-cms-demo
cd cms
npm install
strapi build

Once installed, you will need to do a few steps to replicate the final production environment (this steps are done also when you first upload and install to Heroku or other production environment):

  • Create a User: Under CONTENT TYPES -> Users - add a user.
  • Set WYIWYG to Visible: Under PLUGINS -> Content Manager -> Article -> [Tab] Edit View(Settings) -> Click on content -> Scroll down and toggle Display as WYSIWYG to ON.
  • Allow API Access: Under PLUGINS -> Roles & Permissions -> Public -> Article (check find and findone), User (check find and findone)
  • Enter your Cloudinary Credentials: Under PLUGINS -> FILES UPLOAD - COGWHEEL
  • Add Content: Under CONTENT TYPES -> Articles -> add content.

Test you local API routes

Upload to Heroku

You will need to have a Heroku account, and the Heroku CLI installed. Heroku install instructions

Do these steps to upload your Strapi project to Heroku:

  • Login to Heroku: heroku login
  • Initilize Git:
git init
git add .
git commit -am "Initial Commit"
  • Create a Heroku project (with a unique name for the URL)
heroku create my-uniquely-named-strapi-project
  • setup database configuration (DO NOT CUT AND PASTE - USE OWN SETTINGS)
heroku addons:create heroku-postgresql:hobby-dev
heroku config
heroku config:set DATABASE_USERNAME=example
heroku config:set DATABASE_PASSWORD=example
heroku config:set DATABASE_HOST=example.compute-2.amazonaws.com
heroku config:set DATABASE_PORT=5432
heroku config:set DATABASE_NAME=example
  • Push project to Heroku.
git push heroku master
  • Open your app project, and redo these steps to match your Development Environment:

  • Create a User: Under CONTENT TYPES -> Users - add a user.

  • Set WYIWYG to Visible: Under PLUGINS -> Content Manager -> Article -> [Tab] Edit View(Settings) -> Click on content -> Scroll down and toggle Display as WYSIWYG to ON.

  • Allow API Access: Under PLUGINS -> Roles & Permissions -> Public -> Article (check find and findone), User (check find and findone)

  • Enter your Cloudinary Credentials: Under PLUGINS -> FILES UPLOAD - COGWHEEL

  • Add Content: Under CONTENT TYPES -> Articles -> add content.

After you add content, you can go ahead and follow the next steps to create the Gatsby part of the project.

Install the Gatsby part of the Project

Open a new tab in your command line, and navigate to ./strapi-heroku-cms-demo/blog/:

Path: ./strapi-heroku-cms-demo/blog

npm install
gatsby develop

You can now check to see if Gatsby is running http://localhost:8000.

Push the Gatsby Project to a separate GitHub repo

You will need to create a separate repo to push just the Gatsby part of the project and which will link to Netlify.

git init
git add .
git commit -m "first commit"
git remote add origin git@github.com:YOUR-NAME/YOUR-NEW-EMPTY-REPO.git
git push -u origin master

Modify the Gatsby-Config file

Locate this code and replace the URL to match the URL from your Heroku install:

Path: ./blog/gatsby-config.js

    {
      resolve: `gatsby-source-strapi`,
      options: {
        apiURL: process.env.DEPLOY_URL
          ? "https://YOUR-APP-URL.herokuapp.com"
          : "http://localhost:1337",
        contentTypes: [`article`, `user`],
        queryLimit: 1000,
      },
    },

Configure Netlfiy

  • Login to Netlify with netlify login.

You will need to link netlify to this repo. Use the netlify init to do so.

netlify init

After configuring Netlify (see tutorial), you need to commit all the changes:

Commit these changes:

git add .
git commit -m "git commit -m "netlify config settings files"
git push
netlify open

Set-up the Netlify WebHook URL

The last step is to set-up the Netlify Webhook URL so it updates:

  • From your App, go to: Settings -> Build & deploy -> Continuous deployment -> Build hooks

    • Click Add build hook
    • Give your app a build hook name, e.g. strapiUpdate
    • Save it and then copy the issued URL to the clipboard
  • Change the staticWebsiteBuildURL variable found in custom.json.

These changes occur on your Strapi Project.

Path: ./cms/config/environments/production/custom.json

Replace the link with your link for the staticWebsiteBuildURL

Commit these changes:

git add .
git commit -m "Add webhook support"
git push heroku master

You are now ready to test and play with this installation. You can build or change this.

NOTE: You have NOT created a Repo for the Strapi part of the project, but this is highly recommended.

MIT License Copyright (c) 2019 David Kartuzinski aka Kai Dawei Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/samlet/strapi-heroku-cms-demo.git
git@gitee.com:samlet/strapi-heroku-cms-demo.git
samlet
strapi-heroku-cms-demo
strapi-heroku-cms-demo
master

搜索帮助