FastComments.com

Add Comments To a Website


安裝

FastComments 讓你輕鬆在網站上加入留言功能,無論網站是靜態或動態、淺色或深色主題、公開或內部頁面。它應該易於安裝 並能適應任何類型的網站或網路應用程式。這可立即為你提供即時留言功能,在許多情況下無需進一步設定。


WordPress Internal Link

要在您的 WordPress 網站加入評論,您可以在此找到我們的 WordPress 外掛 這裡

完整的安裝指南與有關此外掛的文件在此

此外掛支援即時評論、SSO 與免程式碼安裝。安裝外掛後,只要在管理頁面依循安裝指南即可。它會引導您將 WordPress 安裝連接至您的帳戶。

透過我們的 WordPress 外掛由 FastComments 發表的任何評論,都可以自動同步回您的 WordPress 安裝,以便您保留對資料的控制。可以關閉此功能以限制 WordPress 資料庫的大小。

VanillaJS / HTML 片段 Internal Link

The VanillaJS 版本的 widget 是將評論加入您網站的最簡單方式,無需任何建置系統或伺服器端程式碼。

只要將下列程式碼片段加入任何頁面,即可在您的網站新增評論:

Simple Code Snippet
Copy CopyRun External Link
1
2<script async src="https://cdn.fastcomments.com/js/embed-v2-async.min.js"></script>
3<div id="fastcomments-widget"></div>
4<script>
5window.fcConfigs = [{
6 "tenantId": "demo"
7}];
8</script>
9

您可以在多個頁面使用相同的程式碼片段;它會自動為每個頁面建立獨立的討論串。

許多應用程式都有 "HTML Embed Code" 選項。選取該選項並將上方的程式碼片段貼入。

您也不需要帳戶即可試用! 如果您尚未登入,您可能會在上方的程式碼片段中看到 "tenantId: demo"。這樣會使用 demo 帳戶。

您可以在此找到有關設定 widget 的文件 這裡

所有版本的 FastComments widget 都是包裹在核心 VanillaJS 函式庫的封裝器。這讓我們能夠在一個地方新增功能並修正問題 - 變更會自動傳播到其他評論 widget 的變體。

Angular Internal Link

要在使用 Angular 建置的網站中加入評論,您可以在 NPM 找到我們的 Angular 函式庫 這裡

FastComments 的 Angular 評論元件支援與 VanillaJS 相同的所有功能 — 即時評論、單一登入(SSO)等等。

您需要 fastcomments-typescript,它是一個 peer 相依。請確保此相依已包含在您的 TypeScript 編譯中。 未來,此 peer 相依將移至 @types/fastcomments,這會簡化安裝程序。

透過 NPM 安裝 FastComments Angular
Copy Copy
1
2 npm install fastcomments-typescript --save
3 npm install ngx-fastcomments --save
4

這個 peer 相依應該被加入到您的 tsconfig.json 檔案中,例如:

新增 fastcomments-typescript peer 相依
Copy Copy
1
2"include": [
3 "src/**/*.ts",
4 "node_modules/fastcomments-typescript/src/index.ts"
5],
6

接著,將 FastCommentsModule 新增到您的應用程式中:

將模組新增到您的應用程式
Copy Copy
1
2import { BrowserModule } from '@angular/platform-browser';
3import { NgModule } from '@angular/core';
4
5import { AppComponent } from './app.component';
6import { FastCommentsModule } from 'ngx-fastcomments';
7
8@NgModule({
9 declarations: [
10 AppComponent
11 ],
12 imports: [
13 BrowserModule,
14 FastCommentsModule
15 ],
16 providers: [],
17 bootstrap: [AppComponent]
18})
19export class AppModule { }
20

使用

要開始,傳入示範租戶的設定物件:

使用 - 內聯設定
Copy Copy
1
2<lib-fastcomments [config]="{ tenantId: 'demo' }"></lib-fastcomments>
3

由於設定可能變得相當複雜,我們也可以傳入物件參考:

使用 - 傳入物件作為設定
Copy Copy
1
2<lib-fastcomments [config]="fastcommentsConfig"></lib-fastcomments>
3
使用 - EU
Copy Copy
1
2<lib-fastcomments [config]="{ tenantId: 'demo', region: 'eu' }"></lib-fastcomments>
3

該元件使用變更偵測,因此變更設定物件的任何屬性都會導致其重新載入。

您可以在 這裡 找到 Angular 元件所支援的設定。

React Internal Link

若要在使用 React 建立的網站加入留言功能,您可以在 NPM 上找到我們的 React 函式庫 這裡

FastComments React 評論元件支援與 VanillaJS 相同的所有功能 - 即時評論、SSO,等等。

透過 NPM 的 FastComments React
Copy Copy
1
2npm install --save fastcomments-react
3
透過 Yarn 的 FastComments React
Copy Copy
1
2yarn add fastcomments-react
3
React 範例
Copy Copy
1
2import React, { Component } from 'react'
3
4import {FastCommentsCommentWidget} from 'fastcomments-react'
5
6class Example extends Component {
7 render() {
8 return <FastCommentsCommentWidget tenantId="demo" />
9 }
10}
11

如果您位於歐盟(EU),您可能需要這樣設定 region 參數:

React 範例 - 歐盟
Copy Copy
1
2 <FastCommentsCommentWidget tenantId="demo" region="eu" />
3

您可以在 這裡 找到 React 元件所支援的設定。


Vue Internal Link

若要在以 Vue 建置的網站中加入留言,您可以在 NPM 找到我們的 Vue 函式庫,請見 這裡

此外,vue-next 函式庫也可在 NPM 找到,請見 這裡

原始程式碼可在 GitHub 找到。

FastComments Vue 留言元件支援與 VanillaJS 相同的所有功能 - 即時留言、sso,等等。

以下說明針對 Vue 3,因為它已經推出一段時間;不過 FastComments 也透過 fastcomments-vue 函式庫支援 Vue 2。

透過 NPM 的 FastComments Vue
Copy Copy
1
2npm install --save fastcomments-vue-next
3
透過 Yarn 的 FastComments Vue
Copy Copy
1
2yarn add fastcomments-vue-next
3
Vue 範例
Copy Copy
1
2<template>
3 <img alt="Vue logo" src="./assets/logo.png">
4 <fast-comments v-bind:config="{tenantId: 'demo'}"/>
5</template>
6
7<script>
8import {FastComments} from 'fastcomments-vue-next';
9
10export default {
11 name: 'App',
12 components: {
13 FastComments
14 }
15}
16</script>
17

如果您位於歐盟,您會想將 region 設為 EU

FastComments Vue - 歐盟
Copy Copy
1
2<fast-comments v-bind:config="{tenantId: 'demo', region: 'eu'}"/>
3

The fastcomments-vue and fastcomments-vue-next libraries support the same configuration as the VanillaJS commenting widget.

您可以在 這裡 找到 Vue 元件支援的設定。


TypeScript Internal Link

FastComments的TypeScript定義(包括傳遞給評論小工具的所有配置的類型)可以在NPM的這裡找到。

您可以在GitHub的這裡找到它。

同一頁面上的多個實例 Internal Link

評論小工具的每個實例都是隔離的。因此,FastComments本質上支援每頁多個實例,或多個實例指向同一聊天串。

例如,對於VanillaJS函式庫,您只需將評論小工具繫結到不同的DOM節點。如果您只想更新頁面上的當前串,請參閱無需重新載入頁面切換評論串

在多個實例之間同步身份驗證狀態

讓我們來看一個自訂單頁應用程式的例子,它是一個常見問題列表,每個問題都有自己的評論串。

在這種情況下,我們在DOM中同時有多個FastComments實例。

這沒問題,但會給使用者體驗帶來一些挑戰。

考慮這個流程:

  1. 使用者訪問包含問題列表的頁面,每個問題都有自己的評論小工具。
  2. 使用者輸入使用者名稱和電子郵件,並在其中一個串上留下問題。
  3. 他們看到另一個有疑問的FAQ項目。
  4. 他們去再次評論。他們需要再次輸入電子郵件和使用者名稱嗎?

在這種情況下,FastComments會為您處理小工具實例之間的身份驗證狀態同步。在第四步,使用者將已經臨時通過身份驗證,因為他們在同一頁面上輸入了使用者名稱和電子郵件。

常見使用情境 Internal Link

立即顯示即時評論

評論小工具預設是即時的,但即時評論會顯示在「顯示N條新評論」按鈕下方,以防止頁面內容移動。

在某些情況下,仍然希望立即顯示新評論,而無需點擊按鈕。

在這種情況下,您需要啟用showLiveRightAway標誌,您可以在這裡找到文檔。

允許匿名評論(不要求電子郵件)

預設情況下,FastComments要求使用者在評論時留下電子郵件。

這可以停用,說明在這裡

自訂樣式

我們的許多客戶將自己的樣式套用於評論小工具。您可以在這裡找到文檔。

在多個網域上顯示相同的評論

在多個網站上顯示相同的評論是FastComments開箱即用支援的功能。請參閱我們關於此主題的文檔

更改當前頁面

FastComments支援SPA和複雜應用程式。更改當前頁面很簡單,在這裡有介紹。