Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xgqfrms/gatsby-tutorials-all-in-one

Gatsby-Tutorials-All-In-One
https://github.com/xgqfrms/gatsby-tutorials-all-in-one

apm app blog cnblogs gatsby pwa react ssg ssr typescript webfullstack xgqfrms

Last synced: about 1 month ago
JSON representation

Gatsby-Tutorials-All-In-One

Awesome Lists containing this project

README

        

# Gatsby-Tutorials-All-In-One

> cnblogs 迁移项目

https://cnblogs.xgqfrms.xyz/

## CLI

```sh
# create `static-website`
$ npm init gatsby
# 1. 交互式, 问答确认, ts & project-name

# 使用 `&&` 串行执行多个 Linux Shell 命令
$ cd static-website && gatsby develop

$ gatsby build

$ gatsby serve

```

> CLI `flags`

```sh
# ts version
$ npm init gatsby -y -ts my-site-name
# 2. 命令式, -y 无需交互问答确认, 直接指定 ts & project-name

```

https://github.com/gatsbyjs/gatsby-starter-minimal

https://github.com/gatsbyjs/gatsby-starter-minimal-ts

## demos

1. `/static/CNAME` ✅
2. custom domain

![](https://img2022.cnblogs.com/blog/740516/202208/740516-20220801021140400-1187664298.png)

https://gatsby-react-app.xgqfrms.xyz/

~~https://abc.xgqfrms.xyz/gatsby-react-app/~~

image

## CI/CD 自动化构建部署流程

1. 手动复制 readme 到 static 文件夹

2. gatsby build 会自动把 static 文件夹下的文件复制到 构建出来的 public 文件下

3. 所以 Action 只要指定 CI/CD 发布部署的根目录 folder 为 public 即可

```js
"scripts": {
"copy": "cp ./README.md ./static/",
"deploy": "npm run copy && gatsby build",
},
```

```yml
# ...
- name: Deploy to gh-pages 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: public
# The folder the action should deploy.
token: ${{ secrets.ACCESS_TOKEN }}
```

[deploy-gh-pages.yml](.github/workflows/deploy-gh-pages.yml)

## refs

https://www.gatsbyjs.com/docs/

https://www.gatsbyjs.com/docs/tutorial/