For a better reading experience, read the original article here
After more than a week of busy work, I opened the blog scaffolding that I migrated from Jekyll to Gatsby. This scaffolding is out of the box, suitable for students who do not want to touch the code, of course, it also provides high scalability, and can customize the development of their own pages
Gatsby is a page generator based on React and GraphQL, using source data (CMS, MarkDown, API, DataBase, YAML, JSON, CSV…). Generate a static page, very suitable for blog page development. See the Gatsby official website [1] for more information.
start
First install the Gatsby command line tool:
npm install -g gatsby-cli
Copy the code
Then use the blog template [2] to build a quick blog framework:
gatsby new my-blog-starter https://github.com/zhouyuexie/gatsby-starter-quiet
Copy the code
Switch to your project directory and launch
cd my-blog-starter/
gatsby dev
Copy the code
The development of
Your site runs at http://localhost:8000!
Note: This is the second linkhttp://localhost:8000/___graphql
This is a tool that queries all your data. If you need more information about this tool, please check out the official documentationGatsby tutorial.
Open and edit the SRC /templates/posts-list.tsx file. The browser will refresh immediately after you save the Settings.
The deployment of
Run YARN Build to compile your site with all static content in the./public folder.
To upload the file to your own server, edit the./deploy.sh file to add information about your server, and then execute YARN deploy
Project directory
The project catalog is as follows:
.├ ── node_modules ├─.src ├─.getTignore ├─.getTierrc ├─.babelrc ├─.tsConfig.json ├─ ├─ Passwords.js ├─ Passwords.js ├─ Passwords.js ├─ Passwords.js ├─ Passwords.js ├─ Package-Lock. json ├── ├── ├─ ├─ download.json └.mdCopy the code
Main document meanings:
- /node_modules: project dependencies.
- / SRC: contains all project source code, which will be compiled into static pages.
- .gitignore: files ignored by Git
- . Prettierrc: Configuration file for Prettier Prettier keeps your code formatted correctly.
- Gatsby -browser.js: the Gatsby Browser APIs file.
- Gatsby -config.js: This is the main gatsby configuration file, where all plug-ins are configured and metadata data is included. Check config Docs for more information.
- Js: the Gatsby Node APIs file.
- Js: The Gatsby Server-side Rendering APIs file
- Json: typescript configuration file
- Tslint. json: Typescript code detection
- tasks:
gatsby-node.js
Related tasks. - static: Static file, easy to copy
public
Access is provided in the file. - posts: MarkDown format blog, related image references are also in the internal folder
images
.
other
You can check another example article on the use of MarkDown in Gatsby to understand the features of MarkDown in Gatsby.
If you have any problems or questions, you can open an issue to me.
-
Gatsby ↩ ︎
-
Gatsby – the starter – the -quiet ↩ ︎