- Clone this repository
git clone git@github.com:pixel-point/gatsby-starter.git
- Install dependencies
npm install
- Copy .env.example and rename it into .env
npm run start
npm run build
npm run serve
npm run clean
├── src
│ ├── components
│ │ ├── pages — React components that are being used specifically on a certain page
│ │ └── shared — React components that are being used across the whole website
│ ├── hooks
│ ├── images — Images that are being quired using graphql. Read more about it here — gatsbyjs.org/docs/working-with-images. Also note, that folder structure should be equal to the structure of components folder
│ ├── layouts
│ ├── pages
│ ├── styles
│ ├── templates
│ ├── utils
│ └── html.js — HTML template for all generated pages. Read more about it here — gatsbyjs.org/docs/custom-html
├── static
│ └── fonts - Self-hosted fonts
├── gatsby-browser.js — This file is where Gatsby expects to find any usage of the Gatsby browser APIs (if any). These allow customization/extension of default Gatsby settings affecting the browser. Read more about it here — gatsbyjs.org/docs/browser-apis
├── gatsby-config.js — This is the main configuration file for a Gatsby site. This is where you can specify information about your site (metadata) like the site title and description, which Gatsby plugins you’d like to include, etc. Read more about it here — gatsbyjs.org/docs/gatsby-config
├── gatsby-node.js — This file is where Gatsby expects to find any usage of the Gatsby Node APIs (if any). These allow customization/extension of default Gatsby settings affecting pieces of the site build process. Read more about it here — gatsbyjs.org/docs/node-apis
└── gatsby-ssr.js — This file is where Gatsby expects to find any usage of the Gatsby server-side rendering APIs (if any). These allow customization of default Gatsby settings affecting server-side rendering. Read more about it here — gatsbyjs.org/docs/ssr-apis
- Main JavaScript File
- SASS File
- Index File
- Folder with images
- Folder with icons
Also, each component may include another component that follows all above listed rules.
component
├── nested-component
│ ├── images
│ │ └── image.png
│ ├── icons
│ │ └── icon.svg
│ ├── nested-component.js
│ ├── nested-component.module.scss
│ └── index.js
├── images
│ └── image.png
├── icons
│ └── icon.svg
├── component.js
├── component.module.scss
└── index.js
ESLint helps find and fix code style issues and force developers to follow same rules. Current configuration is based on Airbnb style guide.
Additional commands:
npm run lint
Run it to check the current status of eslint issues across project.
npm run lint:fix
Run it to fix all possible issues.
Prettier helps to format code based on defined rules. Difference between Prettier and ESLint.
Additional commands:
npm run format
Run it to format all files across the project.
Following extensions required to simplify the process of keeping the same code style across the project:
After installation enable "ESLint on save" by adding to your VS Code settings.json the following line:
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
You can navigate to settings.json by using Command Pallete (CMD+Shift+P) and then type "Open settings.json".
To enable Prettier go to Preferences -> Settings -> type "Format". Then check that you have esbenp.prettier-vscode as default formatter, and also enable "Format On Save".
Reload VS Code and auto-format will work for you.
All style variables that being used across the whole application are stored in src/styles/variables.scss.