#6基于 GitHub Discussions 的博客站点(简约,便捷):GG 教程

ygr99ygr992023/11/09

1699521819186.png

介绍 GG

GG: A gatsby website builder based on github discussions
Github:https://github.com/lencx/gg
网站:https://gg.nofwl.com

部署

Step1:fork 项目

点击项目 右上角的 Fork 按钮,fork 后,可以对仓库进行重命名,修改成自己喜欢的名称。

Step2:开启 Discussions

Settings -> General -> Features -> Discussions

Step3:创建配置

在 Discussions -> New discussion 中新增一个标题为 rgd.yml 的 issues,并在内容框中输入以下代码:

简单配置:

我试了这个,别的没试

# github 用户名
owner: rwasm
# github 仓库名称
repo: rwasm.github.io

website:
  logo: https://user-images.githubusercontent.com/16164244/162659556-64dd7da8-321f-4525-bbbf-975f02b4800f.png
  # 网站标题
  title: GG
  description: Webassembly resources, tools, and related blogs, etc.

manifest:
  name: GG
  short_name: GG
  start_url: /
  background_color: '#fafafa'
  theme_color: '#232629'
  display: standalone
  icon: https://user-images.githubusercontent.com/16164244/162659556-64dd7da8-321f-4525-bbbf-975f02b4800f.png

完整配置:

```yml
### 必须配置
# github 用户名,支持个人或组织
owner: lencx
# github 仓库名称
repo: gg

### 可选配置,如果 type 为 `issues` 类型,才需要以下配置
# type: `issues` | `discussions` | `discussions2`, default is `discussions`
# discussions:表示需要写 discussions 的仓库与 fork 此项目的仓库为同一个
# discussions2:表示需要写 discussions 的仓库与 fork 此项目的仓库彼此独立
type: issues
issues-owner: <github_owner>
issues-repo: <github_repo>
# state: `open` or `closed`, default is `all`
issues-state: closed

### 可选配置,如果 type 为 `discussions2` 类型,才需要以下配置
# type: `issues` | `discussions` | `discussions2`, default is `discussions`
type: discussions2
# 写 discussions 的用户名及仓库名
dis-owner: <github_owner>
dis-repo: <github_repo>

### 域名配置
# 个人域名,如果没有则不需要设置
# 默认使用 github 二级域名,即 https://<owner>.github.io/<repo>
cname: gg.nofwl.com

### website 配置
website:
  # 1. 格式为 png 的 240x240 正方形图片
  # 2. 在线图片 URL 地址,不设置则使用默认 logo
  logo: https://user-images.githubusercontent.com/16164244/162659556-64dd7da8-321f-4525-bbbf-975f02b4800f.png
  # 网站标题
  title: GG
  # 网站描述
  description: A gatsby website builder based on github discussions

### PWA Manifest 配置
# https://www.gatsbyjs.com/plugins/gatsby-plugin-manifest
manifest:
  name: GG
  short_name: GG
  start_url: /
  background_color: '#fafafa'
  theme_color: '#232629'
  display: standalone
  # 1. 格式为 png 的 240x240 正方形图片
  # 2. 在线图片 URL 地址,不设置则使用默认 logo
  icon: https://user-images.githubusercontent.com/16164244/162659556-64dd7da8-321f-4525-bbbf-975f02b4800f.png

配置参考:

https://github.com/fe-cool/hunter/discussions/2
https://github.com/rwasm/rwasm.github.io/discussions/2
https://github.com/lencx/gg/discussions/2

Step4:生成 Token

生成 Token

New personal access token
1699520520416.png

Note - 备注随便输入,主要做标识
Expiration:No expiration - 过期时间看需要,这里选择不过期
Select scopes: workflow - 只需要勾选 workflow
点击 Generate token 按钮,然后复制生成好的 Token

构建

点击 Actions Tab 项,在 All workflows 中选择 github pages,点击 Enable workflow,每隔一小时会自动触发一次构建。当自动构建过一次之后,会在 github pages 下产生记录,点击最新一条记录,会看到 Re-run all jobs 按钮,点击它就可以手动执行构建。(我是新创建了一条 Discussions 出现了这个)


开启 github pages

1699520832550.png

就可以看到访问站点了!
之后每次增加Discussions,相当于增加一条文章! (同时修改很方便)
1699521339913.png

1699521459919.png