├── .gitignore ├── LICENSE.txt ├── README.md ├── screenshot.png ├── starter.json ├── starter ├── .env.example ├── .eslintrc ├── gatsby-config.js ├── gatsby-node.js ├── package.json ├── src │ ├── assets │ │ └── css │ │ │ └── main.css │ ├── components │ │ ├── articles.js │ │ ├── card.js │ │ ├── layout.js │ │ ├── nav.js │ │ └── seo.js │ ├── images │ │ ├── .gitkeep │ │ └── favicon.png │ └── pages │ │ ├── 404.js │ │ ├── article │ │ └── {StrapiArticle.slug}.js │ │ ├── category │ │ └── {StrapiCategory.slug}.js │ │ └── index.js └── yarn.lock └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # dotenv environment variable files 55 | .env* 56 | !.env.example 57 | 58 | # gatsby files 59 | .cache/ 60 | public 61 | 62 | # Mac files 63 | .DS_Store 64 | 65 | # Yarn 66 | yarn-error.log 67 | .pnp/ 68 | .pnp.js 69 | # Yarn Integrity file 70 | .yarn-integrity 71 | 72 | # Custom 73 | 74 | .vscode 75 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **:no_entry: DEPRECATED** 2 | 3 | This repository is no longer maintained and only works for Strapi v3. You can find the latest Strapi v4 version of this starter on the [starters-and-templates monorepo](https://github.com/strapi/starters-and-templates/tree/main/packages/starters/gatsby-blog). 4 | 5 | --- 6 | 7 | # Strapi Starter Gatsby Blog 8 | 9 | Gatsby starter for creating a blog with Strapi. 10 | 11 | ![screenshot image](/screenshot.png) 12 | 13 | This starter allows you to try Strapi with Gatsby with the example of a simple blog. It is fully customizable and due to the fact that it is open source, fully open to contributions. So do not hesitate to add new features and report bugs! 14 | 15 | ## Features 16 | 17 | - 2 Content types: Article, Category 18 | - 2 Created articles 19 | - 3 Created categories 20 | - Responsive design using UIkit 21 | - SEO and social media friendly 22 | 23 | This starter uses the [Strapi blog template](https://github.com/strapi/strapi-template-blog) 24 | 25 | Check out all of our starters [here](https://strapi.io/starters) 26 | 27 | Pages: 28 | 29 | - "/" to display every articles 30 | - "/article/:id" to display one article 31 | - "/category/:id" display articles depending on the category 32 | 33 | ## Getting started 34 | 35 | Use our `create-strapi-starter` CLI to create your project. 36 | 37 | ```sh 38 | npx create-strapi-starter@3 my-site gatsby-blog 39 | ``` 40 | 41 | The CLI will create a monorepo, install dependencies, and run your project automatically. 42 | 43 | The Gatsby frontend server will run here => [http://localhost:8000](http://localhost:8000) 44 | 45 | The Strapi backend server will run here => [http://localhost:1337](http://localhost:1337) 46 | 47 | ## Deploying to production 48 | 49 | You will need to deploy the `frontend` and `backend` projects separately. Here are the docs to deploy each one: 50 | 51 | - [Deploy Strapi](https://strapi.io/documentation/developer-docs/latest/setup-deployment-guides/deployment.html#hosting-provider-guides) 52 | - [Deploy Gatsby](https://www.gatsbyjs.com/docs/deploying-and-hosting/) 53 | 54 | Don't forget to setup the environment variables on your production app: 55 | 56 | For the frontend the following environment variable is required: 57 | - `API_URL`: URL of your Strapi backend, without trailing slash 58 | 59 | 60 | Enjoy this starter! 61 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/strapi/strapi-starter-gatsby-blog/70289432f42c645ce6826ff4683eabe6519db90d/screenshot.png -------------------------------------------------------------------------------- /starter.json: -------------------------------------------------------------------------------- 1 | { 2 | "template": "https://github.com/strapi/strapi-template-blog" 3 | } 4 | -------------------------------------------------------------------------------- /starter/.env.example: -------------------------------------------------------------------------------- 1 | GATSBY_ROOT_URL=http://localhost:8000 2 | API_URL=http://localhost:1337 3 | -------------------------------------------------------------------------------- /starter/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "prettier/prettier": ["error", {}] 4 | }, 5 | "extends": ["react-app", "plugin:prettier/recommended"] 6 | } 7 | -------------------------------------------------------------------------------- /starter/gatsby-config.js: -------------------------------------------------------------------------------- 1 | require("dotenv").config({ 2 | path: `.env`, 3 | }); 4 | 5 | module.exports = { 6 | plugins: [ 7 | "gatsby-plugin-react-helmet", 8 | { 9 | resolve: `gatsby-source-filesystem`, 10 | options: { 11 | name: `images`, 12 | path: `${__dirname}/src/images`, 13 | }, 14 | }, 15 | { 16 | resolve: "gatsby-source-strapi", 17 | options: { 18 | apiURL: process.env.API_URL || "http://localhost:1337", 19 | collectionTypes: ["article", "category", "writer"], 20 | singleTypes: [`homepage`, `global`], 21 | queryLimit: 1000, 22 | }, 23 | }, 24 | "gatsby-plugin-image", 25 | "gatsby-transformer-sharp", 26 | "gatsby-plugin-sharp", 27 | { 28 | resolve: `gatsby-plugin-manifest`, 29 | options: { 30 | name: "gatsby-starter-default", 31 | short_name: "starter", 32 | start_url: "/", 33 | background_color: `#663399`, 34 | theme_color: `#663399`, 35 | display: `minimal-ui`, 36 | icon: `src/images/favicon.png`, 37 | }, 38 | }, 39 | "gatsby-plugin-offline", 40 | ], 41 | }; 42 | -------------------------------------------------------------------------------- /starter/gatsby-node.js: -------------------------------------------------------------------------------- 1 | exports.onCreateWebpackConfig = ({ 2 | actions, 3 | plugins, 4 | stage 5 | }) => { 6 | actions.setWebpackConfig({ 7 | resolve: { 8 | alias: { 9 | path: require.resolve("path-browserify") 10 | }, 11 | fallback: { 12 | fs: false, 13 | } 14 | } 15 | }) 16 | if (stage === 'build-javascript' || stage === 'develop') { 17 | actions.setWebpackConfig({ 18 | plugins: [ 19 | plugins.provide({ process: 'process/browser' }) 20 | ] 21 | }) 22 | } 23 | } -------------------------------------------------------------------------------- /starter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gatsby-starter-default", 3 | "private": true, 4 | "description": "A simple starter to get up and developing quickly with Gatsby", 5 | "version": "0.1.0", 6 | "author": "Kyle Mathews ", 7 | "dependencies": { 8 | "@blocks/kit": "0.0.28", 9 | "@emotion/core": "^10.0.28", 10 | "babel-preset-gatsby": "^1.3.0", 11 | "gatsby": "^3.3.0", 12 | "gatsby-plugin-image": "^1.2.1", 13 | "gatsby-plugin-manifest": "^3.3.0", 14 | "gatsby-plugin-offline": "^4.2.0", 15 | "gatsby-plugin-react-helmet": "^4.2.0", 16 | "gatsby-plugin-sharp": "^3.3.0", 17 | "gatsby-source-filesystem": "3.3.0", 18 | "gatsby-source-strapi": "^1.0.1", 19 | "gatsby-transformer-sharp": "^3.3.0", 20 | "moment": "^2.26.0", 21 | "path-browserify": "^1.0.1", 22 | "process": "^0.11.10", 23 | "prop-types": "^15.7.2", 24 | "react": "^17.0.1", 25 | "react-dom": "^17.0.1", 26 | "react-helmet": "^6.1.0", 27 | "react-markdown": "^4.3.1", 28 | "react-moment": "^0.9.7" 29 | }, 30 | "devDependencies": { 31 | "@typescript-eslint/eslint-plugin": "2.x", 32 | "@typescript-eslint/parser": "2.x", 33 | "babel-eslint": "10.x", 34 | "eslint": "7.x", 35 | "eslint-config-prettier": "^6.11.0", 36 | "eslint-config-react-app": "^5.2.1", 37 | "eslint-plugin-flowtype": "4.x", 38 | "eslint-plugin-import": "2.x", 39 | "eslint-plugin-jsx-a11y": "6.x", 40 | "eslint-plugin-prettier": "^3.1.4", 41 | "eslint-plugin-react": "7.x", 42 | "eslint-plugin-react-hooks": "2.x", 43 | "prettier": "^2.1.1" 44 | }, 45 | "keywords": [ 46 | "gatsby" 47 | ], 48 | "license": "MIT", 49 | "scripts": { 50 | "build": "gatsby build", 51 | "develop": "gatsby develop --open", 52 | "dev": "npm run develop", 53 | "lint": "eslint ./src", 54 | "lint:fix": "eslint ./src --fix", 55 | "start": "npm run develop", 56 | "serve": "gatsby serve", 57 | "clean": "gatsby clean", 58 | "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1" 59 | }, 60 | "repository": { 61 | "type": "git", 62 | "url": "https://github.com/gatsbyjs/gatsby-starter-default" 63 | }, 64 | "bugs": { 65 | "url": "https://github.com/gatsbyjs/gatsby/issues" 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /starter/src/assets/css/main.css: -------------------------------------------------------------------------------- 1 | a { 2 | text-decoration: none !important; 3 | } 4 | 5 | h1 { 6 | font-family: Staatliches !important; 7 | font-size: 120px !important; 8 | } 9 | 10 | #category { 11 | font-family: Staatliches !important; 12 | font-weight: 500 !important; 13 | } 14 | 15 | #title { 16 | letter-spacing: 0.4px !important; 17 | font-size: 22px !important; 18 | font-size: 1.375rem !important; 19 | line-height: 1.13636 !important; 20 | } 21 | 22 | #banner { 23 | margin: 20px !important; 24 | height: 800px !important; 25 | } 26 | 27 | #editor { 28 | font-size: 16px !important; 29 | font-size: 1rem !important; 30 | line-height: 1.75 !important; 31 | } 32 | 33 | .uk-navbar-container { 34 | background: #fff !important; 35 | font-family: Staatliches !important; 36 | } 37 | 38 | img:hover { 39 | opacity: 1 !important; 40 | transition: opacity 0.25s cubic-bezier(0.39, 0.575, 0.565, 1) !important; 41 | } -------------------------------------------------------------------------------- /starter/src/components/articles.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Card from "./card"; 3 | 4 | const Articles = ({ articles }) => { 5 | const leftArticlesCount = Math.ceil(articles.length / 5); 6 | const leftArticles = articles.slice(0, leftArticlesCount); 7 | const rightArticles = articles.slice(leftArticlesCount, articles.length); 8 | 9 | return ( 10 |
11 |
12 |
13 | {leftArticles.map((article, i) => { 14 | return ( 15 | 19 | ); 20 | })} 21 |
22 |
23 |
24 | {rightArticles.map((article, i) => { 25 | return ( 26 | 30 | ); 31 | })} 32 |
33 |
34 |
35 |
36 | ); 37 | }; 38 | 39 | export default Articles; 40 | -------------------------------------------------------------------------------- /starter/src/components/card.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Link } from "gatsby"; 3 | import { GatsbyImage } from "gatsby-plugin-image"; 4 | 5 | const Card = ({ article }) => { 6 | return ( 7 | 8 |
9 |
10 | 14 |
15 |
16 |

17 | {article.node.category.name} 18 |

19 |

20 | {article.node.title} 21 |

22 |
23 |
24 |
25 |
26 | {article.node.author.picture && ( 27 | 35 | )} 36 |
37 |
38 |

39 | {article.node.author.name} 40 |

41 |
42 |
43 |
44 |
45 |
46 | 47 | ); 48 | }; 49 | 50 | export default Card; 51 | -------------------------------------------------------------------------------- /starter/src/components/layout.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import PropTypes from "prop-types"; 3 | import { StaticQuery, graphql } from "gatsby"; 4 | import Nav from "./nav"; 5 | import Seo from "./seo"; 6 | 7 | const Layout = ({ children, seo }) => ( 8 | ( 25 | <> 26 | 27 |