Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
feat(comment): add twikoo and giscus
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Jun 3, 2022
1 parent 025a429 commit 417eaa6
Show file tree
Hide file tree
Showing 38 changed files with 1,007 additions and 70 deletions.
16 changes: 11 additions & 5 deletions docs/comment/src/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,32 @@ title: API Config
icon: config
---

## type
## provider

- Type: `'valine' | 'vssue' | 'disable'`
- Required: true
- Type: `"Giscus" | "Twikoo" | "Waline" | 'Valine' | 'Vssue' | "None"`
- Default: `"None"`

Comment service provider.

Setting it to `'disable'` will only disable the comment feature.

## comment

- Type: `boolean`
- Default: `true`

Whether to enable comment feature by default.

## Giscus config

- [See here](giscus.md)

## Waline config

- [See here](waline.md)

## Twikoo config

- [See here](twikoo.md)

## Vssue config

- [See here](vssue.md)
Expand Down
53 changes: 53 additions & 0 deletions docs/comment/src/config/giscus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: Giscus Options
icon: github
---

## repo

- Type: `string`
- Required: No

The name of repository to store discussions.

## repoId

- Type: `string`
- Required: No

The ID of repository to store discussions. Generate through [Giscus Page](https://giscus.app/)

## category

- Type: `string`
- Required: No

The name of the discussion category.

## categoryId

- Type: `string`
- Required: No

The ID of the discussion category. Generate through [Giscus Page](https://giscus.app/)

## mapping

- Type: `string`
- Default: `"pathname"`

Page - Discussion mapping. For details see [Giscus Page](https://giscus.app/)

## reactionsEnabled

- Type: `boolean`
- Default: `true`

Whether enable reactions or not

## inputPosition

- Type: `"top" | "bottom"`
- Default: `"top"`

Input position
11 changes: 11 additions & 0 deletions docs/comment/src/config/twikoo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Twikoo Options
icon: comment
---

## envId

- Type: `string`
- Required: Yes

Vercel address
23 changes: 14 additions & 9 deletions docs/comment/src/guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,35 @@ title: Guide
icon: creative
---

This plugin register `<CommentService />` comonent globally.
This plugin register `<CommentService />` component globally.

We recommended you to insert the comment component (`<CommentService />`) after the `<PageNav />` component.

By default, `<CommentService />` component is enabled globally. You can disable it locally by setting `comment: false` in page frontmatter.

To keep it globally disabled, please set `comment` to `false` in the plugin options. Then you can set `comment: true` in page frontmatter to enable it locally.

You can choose from 3 comment service provider: Waline, Vssue and Valine.
Currently you can choose from Giscus, Waline, Valine, Vssue and Twikoo.

::: tip Comparison between services
::: tip Comment service selection

- Waline uses a backend server to support comment and pageview statistics, and you can comment without logging in to any account. It needs extra configuration on backend, and you can deploy on vercel for free.
- Vssue uses the issue panel of the code platform repo and requires the user to login or register the corresponding platform account.
- Valine uses leancloud to support pageview statistics, and you can comment without logging in to any account

If your site is for the general public rather than programmers, Waline is recommended, otherwise Vssue is recommended.
- Giscus is recommended if your blog or documentation is primarily geared towards programmers.
- If your blog or documentation is for the general public, Waline is recommended.

:::

### Waline
## Giscus

See [Giscus Config Guide](giscus.md)

## Waline

See [Waline Config Guide](waline.md)

## Twikoo

See [Twikoo Config Guide](twikoo.md)

### Vssue

See [Vssue Config Guide](vssue.md)
Expand Down
27 changes: 27 additions & 0 deletions docs/comment/src/guide/giscus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Giscus
icon: github
---

Giscus is a GitHub Discussion based commenting system that is easy to start.

<!-- more -->

## Preparation

1. You need to create a public repository and open discussion as a place to store comments
1. You need to install the [Giscus App](https://github.com/apps/giscus) to have permission to access the corresponding repository.

After completing the above steps, please go to the [Giscus page](https://giscus.app) to get your settings. You just need to fill in the repository and Discussion categories, then scroll to the "Enable giscus" section at the bottom of the page and copy the `data-repo`, `data-repo-id`, `data-category` and `data-category-id` four items as they are required.

## Config

Please pass `data-repo`, `data-repo-id`, `data-category` and `data-category-id` as plugin options as `repo`, `repoId`, `category` `categoryId`.

::: info Darkmode

To let Giscus use the correct theme, you need to pass a boolean value to `<CommentService />` via the `darkmode` property, indicating whether darkmode is currently enabled.

:::

For other options, see [Giscus Config](../config/giscus.md).
24 changes: 24 additions & 0 deletions docs/comment/src/guide/twikoo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: Twikoo
icon: comment
---

A concise, safe and free static site commenting system, based on [Tencent Cloud Development](https://curl.qcloud.com/KnnJtUom).

<!-- more -->

## Getting started

### Vercel Deployment

1. Apply for [MongoDB](https://www.mongodb.com/cloud/atlas/register) account
1. Create a free MongoDB database, the recommended region is `AWS / N. Virginia (us-east-1)`
1. Click CONNECT on the Clusters page, follow the steps to allow connections from all IP addresses ([Why?](https://vercel.com/support/articles/how-to-allowlist-deployment-ip-address)), create Database user, and record the database connection string, please change the `<password>` in the connection string to the database password
1. Sign up for a [Vercel](https://vercel.com/signup) account
1. Click the button below to deploy Twikoo to Vercel in one click

[![Vercel](https://vercel.com/button)](https://vercel.com/import/project?template=https://github.com/imaegoo/twikoo/tree/dev/src/vercel-min)

1. Go to Settings - Environment Variables, add the environment variable `MONGODB_URI`, the value is the database connection string in step 3
1. Go to Overview, click the link under Domains, if the environment configuration is correct, you can see the prompt "Twikoo cloud function is running normally"
1. Vercel Domains (with `https://` prefix, eg `https://xxx.vercel.app`) is your environment ID
14 changes: 11 additions & 3 deletions docs/comment/src/zh/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ icon: config

## type

- 类型: `'valine' | 'vssue' | 'disable'`
- 必填: 是
- 类型: `"Giscus" | "Twikoo" | "Waline" | 'Valine' | 'Vssue' | "None"`
- 默认值: `"None"`

使用 Valine 还是 Vssue。设置为 `'disabled'` 仅会禁用评论功能
使用的评论服务

## comment

Expand All @@ -17,10 +17,18 @@ icon: config

是否默认启用评论功能。

## Giscus 选项

- [点击查看](giscus.md)

## Waline 选项

- [点击查看](waline.md)

## Twikoo 选项

- [点击查看](twikoo.md)

## Vssue 选项

- [点击查看](vssue.md)
Expand Down
53 changes: 53 additions & 0 deletions docs/comment/src/zh/config/giscus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: Giscus 选项
icon: github
---

## repo

- 类型: `string`
- 必填: 是

存放评论的仓库

## repoId

- 类型: `string`
- 必填: 是

仓库 ID,请从 [Giscus 页面](https://giscus.app/zh-CN) 生成。

## category

- 类型: `string`
- 必填: 是

讨论分类

## categoryId

- 类型: `string`
- 必填: 是

讨论分类 ID,请从 [Giscus 页面](https://giscus.app/zh-CN) 生成。

## mapping

- 类型: `string`
- 默认值: `"pathname"`

页面 ↔️ discussion 映射关系,详见 [Giscus 页面](https://giscus.app/zh-CN)

## reactionsEnabled

- 类型: `boolean`
- 默认值: `true`

是否启用主帖子上的反应

## inputPosition

- 类型: `"top" | "bottom"`
- 默认值: `"top"`

输入框的位置
18 changes: 18 additions & 0 deletions docs/comment/src/zh/config/twikoo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: Twikoo 选项
icon: comment
---

## envId

- 类型: `string`
- 必填: 是

腾讯云环境 ID 或 Vercel 地址。

## repoId

- 类型: `string`
- 默认值: `"ap-shanghai"`

腾讯云区域。
21 changes: 13 additions & 8 deletions docs/comment/src/zh/guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,27 @@ icon: creative

如果你需要保持全局禁用,请在插件选项中设置 `comment``false`。这样你可以在特定页面的 frontmatter 中设置 `comment: true` 来局部启用它。

有三个评论插件可以选择: Waline、VssueValine
目前可以从 Giscus、WalineTwikoo 中选择

::: tip 评论服务的比较
::: tip 评论服务选择

- Waline 需要后端服务器以及额外的配置,支持页面访问量统计,无需登录账号即可评论。可以使用 Vercel。
- Vssue 使用代码平台仓库的 issue 面板,需要用户登录或注册相应平台账号。
- Valine 使用 leancloud,支持页面访问量统计,无需登录账号即可评论

如果你的站点面向大众而非程序员,推荐使用 Waline;反之推荐 Vssue。
- 如果你的博客或文档主要面向程序员,建议使用 Giscus。
- 如果你的博客或文档面向大众,建议使用 Waline。

:::

### Waline
## Giscus

[详见 Giscus 指南](giscus.md)

## Waline

[详见 Waline 指南](waline.md)

## Twikoo

[详见 Twikoo 指南](twikoo.md)

### Vssue

[详见 Vssue 指南](vssue.md)
Expand Down
27 changes: 27 additions & 0 deletions docs/comment/src/zh/guide/giscus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
title: Giscus
icon: github
---

Giscus 是一个基于 GitHub Discussion 的评论系统,启用简便。

<!-- more -->

## 准备工作

1. 你需要创建一个公开仓库,并开启评论区,以作为评论存放的地点
1. 你需要安装 [Giscus App](https://github.com/apps/giscus),使其有权限访问对应仓库。

在完成以上步骤后,请前往 [Giscus 页面](https://giscus.app/zh-CN) 获得你的设置。你只需要填写仓库和 Discussion 分类,之后滚动到页面下部的 “启用 giscus” 部分,复制 `data-repo`, `data-repo-id`, `data-category``data-category-id` 四项,因为它们是必须的。

## 配置

请将 `data-repo`, `data-repo-id`, `data-category``data-category-id` 作为插件选项传入 `repo`, `repoId`, `category` `categoryId`

::: info 夜间模式

为了能使 Giscus 使用正确的主题,你需要为 `<CommentService />` 通过 `darkmode` 属性传入一个布尔值,代表当前是否开启夜间模式。

:::

其他的配置项详见 [Giscus 配置](../config/giscus.md)
Loading

0 comments on commit 417eaa6

Please sign in to comment.