Neon Gatsby
Table of Contents
Getting Started
- Clone this repository
git clone git@github.com:neondatabase/website.git- Install dependencies
npm install- Fill environment variables
cp .env.example .envUsage
Run the website
npm run startBuild the website
npm run buildRun the built website
npm run serveClean Gatsby cache
npm run cleanChecks broken links
npm run check:broken-links -- https://neon.techThe command may take time, be patient. You can also specify which part of the website you want to check by passing a specific URL, for example https://neon.tech/docs for checking the Docs
N.B. The automatic check is done every Monday at midnight by GitHub CI. You can find the reports on the "Actions" tab
Project Structure
├── docs — Documentation sources in `mdbook` format, see [Documentation](#docs) section
├── 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
│ ├── pages
│ ├── styles
│ ├── templates
│ ├── utils
│ └── html.jsx — HTML template for all generated pages. Read more about it here — gatsbyjs.org/docs/custom-html
├── static
│ └── fonts
├── gatsby-browser.js — Usage of the Gatsby browser APIs. Read more about it [here](gatsbyjs.org/docs/browser-apis)
├── gatsby-config.js — Main configuration file for a Gatsby site. Read more about it [here](gatsbyjs.org/docs/gatsby-config)
├── gatsby-node.js — Usage of the Gatsby Node APIs. [Read more about it here](gatsbyjs.org/docs/node-apis)
└── gatsby-ssr.js — Usage of the Gatsby server-side rendering APIs. [Read more about it here](gatsbyjs.org/docs/ssr-apis)
Component Folder Structure
Each component includes
- Main JavaScript File
- Index File
Each component optionally may include
- Folder with images and icons
- Folder with data
Also, each component may include another component that follows all above listed rules.
Example structure
component
├── nested-component
│ ├── data
│ │ └── nested-component-lottie-data.json
│ ├── images
│ │ ├── nested-component-image.jpg
│ │ ├── nested-component-inline-svg.inline.svg
│ │ └── nested-component-url-svg.url.svg
│ ├── nested-component.js
│ └── index.js
├── data
│ └── component-lottie-data.json
├── images
│ ├── component-image.jpg
│ ├── component-inline-svg.inline.svg
│ └── component-url-svg.url.svg
├── component.js
└── index.jsCode Style
ESLint
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 lintRun it to check the current status of eslint issues across project.
npm run lint:fixRun it to fix all possible issues.
Prettier
Prettier helps to format code based on defined rules. Difference between Prettier and ESLint.
Additional commands:
npm run formatRun it to format all files across the project.
VS Code
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.
Docs
Documentation for docs is described in content/docs/README.md