FastComments.com

カスタマイズと設定

コンテキスト

ここでは、コメントウィジェットがサポートする各機能と設定についての詳細なドキュメントを確認できます。

本ドキュメントではコアコンセプトをカバーし、各機能領域について使い方やよくある落とし穴を含めて詳しく説明します。

コード例を示し、該当する行をハイライトします。該当する場合は設定ページのスクリーンショットも提供します。

コード例では当社のバニラJavaScriptライブラリを使用しますが、設定オプションはコメントウィジェットの全バージョン(React、Vue など)でまったく同じ名前を使用しています。

このガイドで説明するほとんどの設定と機能は、コードを書く必要はありません。

異なるページで同じコメントを表示する Internal Link


urlId パラメータはコメントがどのページ、またはどのIDに紐づくかを定義できるため、これらのページでは単に urlId を同じ値に設定すればよいです。

The Same Comments on Multiple Pages
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 "urlId": "https://example.com/source-page"
8}];
9</script>
10

カスタムフォント Internal Link

FastComments はカスタマイズ可能になるよう設計されており、ウィジェットで使用するフォントも例外ではありません。

デフォルトでは、FastComments は幅広いデバイスでできるだけ見栄えが良くなるように system font stack を使用します。

独自のフォントを定義するには、Custom CSS ドキュメント を参照してください。

そこにはカスタム CSS を定義する方法が記載されており、希望するフォントを設定できるようになります。

フォントの定義方法

フォントを上書きするには、.fast-comments, textarea セレクタを使用して CSS を定義することをお勧めします。例:

カスタム外部フォントの例
Copy CopyRun External Link
1
2@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap');
3.fast-comments, textarea {
4 font-family: 'Roboto', sans-serif;
5}
6

ダーク背景(ダークモード)への対応 Internal Link

デフォルトでは、FastComments のコメントウィジェットはほとんどのサイトでダークモードを自動的に検出します。

ダークモードが検出されると、FastComments は白背景に黒い文字から黒背景に白い文字へ切り替わります。画像も変更されます。

ページ読み込み時に、ウィジェットはコメントウィジェットの背後にあるページの背景がどれくらい暗いかを判定しようとします。これはつまり ページ自体は白い背景でも、コメントウィジェットを黒い背景のコンテナ内に置けば、ダークモードが コメントを読みやすくするために自動的に有効になるはず、ということです。

しかし、「luminance」を判定する検出メカニズムは、望むときにダークモードを有効にしない場合があります。強制的に有効にするには、次のように hasDarkBackground フラグを true に設定してください:

Force Dark Background Mode
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 "hasDarkBackground": true
8}];
9</script>
10

コメントからページへのリンク Internal Link

通知メールを送信したり、モデレーションページのようなユーザーインターフェースでコメントを表示したりする際に、コメントから それが掲載されているページへリンクできると便利です。

If URL ID isn't always an ID, then we have to store the URL some place else. That's what the "url" property is for, defined as follows.

Defining a Custom URL
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 "url": "https://example.com/article-5"
8}];
9</script>
10

一般的なユースケースは、コメントスレッドを記事のような識別子に紐付け、その後特定のページにリンクすることです。例えば:

Defining Custom URL and URL IDs together
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 "url": "https://example.com/article-5",
8 "urlId": "article-5"
9}];
10</script>
11

The URL does not get cleaned of common marketing parameters. By default, whatever the current page URL is, is the URL stored with the comment.

表示するページの決定 Internal Link

コメントを取得してレンダリングする際、コメントウィジェットはどのページから開始するかを知る必要があります。デフォルトでは最初のページから始まり、そのページのみがレンダリングされます。

必要に応じて、描画する正確なページを設定 startingPage としてコメントウィジェットに渡すことができます。

Specifying The Page to Render
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 "startingPage": 1
8}];
9</script>
10

ページ番号は0から始まることに注意してください。そのため、上の例は2ページ目をレンダリングします。


ページをリロードせずにコメントスレッドを切り替える Internal Link

We've covered how urlId is the page or article id the comments are tied to.

Also, to recap, if not defined the urlId will default to the current page URL.

What about SPAs, or Single-Page-Applications, where the page or content the comments are tied to changes dynamically without a fresh page reload?

Angular、React、Vue など

With our libraries such as Angular and React, simply updating the urlId property passed to the widget will cause the comment widget to refresh. You can see this in action for the React app, for example, こちら.

VanillaJS

If you're using the VanillaJS library it is slightly more complicated as there isn't a framework like Angular or React to handle the data binding or state propagation.

When you instantiate the VanillaJS widget, it returns some functions which can be called to update it.

Here's a functional example where we change the page hash and update the comment widget:

ページハッシュの切り替え例
Copy CopyRun External Link
1
2<script src="https://cdn.fastcomments.com/js/embed-v2.min.js"></script>
3<button id="change-page"></button>
4<div id="fastcomments-widget"></div>
5<script>
6 (function fastCommentsMain() {
7 let config = {
8 tenantId: 'demo'
9 };
10 let instance = window.FastCommentsUI(document.getElementById('fastcomments-widget'), config);
11
12 let page = '#page-1';
13 function getNextPage() {
14 if (page === '#page-1') {
15 return '#page-2';
16 } else {
17 return '#page-1';
18 }
19 }
20
21 let button = document.getElementById('change-page');
22 function nextPage() {
23 page = getNextPage();
24 button.innerText = 'Go to ' + getNextPage();
25 window.location.hash = page;
26 let locationString = window.location.toString();
27
28 config.url = locationString; // 通知が正しいページにリンクできるように、url も更新します
29 config.urlId = locationString;
30
31 instance.update(config);
32 }
33 nextPage();
34 button.addEventListener('click', nextPage);
35 })();
36</script>
37

画像リダイレクトを無効化 Internal Link

デフォルトでは、FastComments はユーザーが画像をアップロードできるようにしています。ユーザーがその画像をクリックすると、FastComments はデフォルトで 別タブを開き、その画像をフルサイズで表示します。このフラグを true に設定するとこの動作が無効になります:

Disable Image Redirect
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 "disableImageRedirect": true
8}];
9</script>
10

画像のクリックを自分で捕捉する予定がない場合(onImageClicked を参照)、画像がクリック可能に見える見た目を取り除くために、これを何らかのスタイリングと組み合わせることを推奨します。

新しいコメントのハイライト Internal Link

FastComments は新しいコメントを強調表示するためのいくつかの方法を提供します。

First and foremost, by default comments that triggered an in-app notification (replies, replies in same thread, or comments on a page あなたが購読しているページのコメント)が自動的にユーザーのアバターがわずかに光る形で強調表示されます。色は CSS を使用して is-unread クラスでカスタマイズできます。

過去24時間に投稿されたコメントには 24hr クラスが適用されており、スタイリングに使用できます。

Finally, any new live comments that show up in the user's session will be highlighted for several seconds via an animation. This is done via the is-live CSS class and can be customized as well.

メールテンプレート Internal Link


FastComments からお客様へ送信されるメールはカスタマイズできます。テンプレート、ロジック、 翻訳もすべて変更できます。テキストはロケールごとにカスタマイズでき、スタイリング ドメインごとに変更することも可能です。 カスタムメールテンプレートの詳細はこちら


新しいライブコメントを下に表示する Internal Link

デフォルトでは、新しいライブコメントはリアルタイムで投稿されるとコメント一覧の上部に表示されます。

このオプションを有効にすると、新しいライブコメントは代わりに一覧の下部に追加されます。これは、ユーザーがコメントスレッドを閲覧している間にコメントがライブで投稿されたときの表示方法に影響します。

New Live Comments to Bottom
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 "newCommentsToBottom": true
8}];
9</script>
10

With this setting enabled:

  • 他のユーザーが投稿した新しいライブコメントはコメント一覧の下部に表示されます
  • ユーザーは既存のコメントの下に新しいコメントがリアルタイムで表示されるのを確認できます
  • これはライブコメントの更新にのみ影響し - 初回のページ読み込みには影響しません
  • ユーザーが議論を追っているときに読み進める流れを維持するのに役立ちます

Note that this setting only affects where new live comments are placed as they arrive in real-time. It does not affect the initial sort order when the page loads.

無限スクロールを有効化 Internal Link

デフォルトでは、FastComments ウィジェットは表示されているすべてのコメントに合わせて縦方向に自動的にサイズを調整します。ページネーションは現在のページ末尾にある「次を表示」ボタンで行われます。これは多くのユーザーにとって最も自然に感じられる操作方法であると判断しているためです。

しかし、無限スクロールの方が好まれるケースもあります。例えば、Stream Chat 製品ではこの機能を使用しています。

enableInfiniteScrolling フラグを true に設定することで、「次を表示」ボタンを非表示にして無限スクロールに切り替えることができます:

Enabling Infinite Scrolling
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 "enableInfiniteScrolling": true
8}];
9</script>
10

これにはカスタム CSS の追加も必要です。スクロールを有効にするには、.comments セレクタに対して次のようなカスタム CSS を追加します。例えば:

無限スクロールを有効にする
Copy CopyRun External Link
1
2.comments {
3 max-height: 500px;
4 overflow-y: auto;
5}
6

完全な動作例は次のとおりです:

Enabling Infinite Scrolling
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 "enableInfiniteScrolling": true,
8 "customCSS": ".comments { max-height: 500px; overflow-y: auto; }"
9}];
10</script>
11

上の例では customCSS プロパティを使用していますが、パフォーマンスの観点からは代わりにウィジェット設定 UI を使用することを推奨します。 カスタム CSS のドキュメントを参照してください。

すべてのコメントを一度に表示する(ページネーションを無効化) Internal Link

ページネーションを無効にして、すべてのコメントを一度にレンダリングするには、startingPageを-1に設定します。

Render All Comments
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 "startingPage": -1
8}];
9</script>
10

新しいトップレベルコメントを禁止する Internal Link

noNewRootCommentstrue に設定すると、ウィジェットはルート返信エリアを非表示にしますが、ユーザーは返信 を子コメントに対して行うことができます。例えば、ページ読み込み時に条件付きでこれを設定し、一部のユーザーのみがトップレベルのコメントを残せるようにすることができます。

Prevent New Root Comments
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 "noNewRootComments": true
8}];
9</script>
10

返信の最大階層 Internal Link


デフォルトでは、FastComments は返信のネストを無制限に許可し、ユーザーが返信に対して際限なく返信できるスレッド構造を作成します。

maxReplyDepth オプションを使うと、返信スレッドの深さを制限できます。最大深度に達すると、そのレベルのコメントには返信ボタンが表示されなくなります。

Limiting Reply Depth to 2 Levels
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 "maxReplyDepth": 2
8}];
9</script>
10

With maxReplyDepth set to 2:

  • ユーザーはトップレベルでコメントできます(depth 0)
  • ユーザーはトップレベルのコメントに返信できます(depth 1)
  • その返信にさらに返信できます(depth 2)
  • depth 2 を超える返信は許可されません

maxReplyDepth を 1 に設定すると、トップレベルのコメントへの返信のみが許可され、より平坦な議論の構造になります。

maxReplyDepth を 0 に設定すると、すべての返信が無効になり、トップレベルのコメントのみが許可されます。指定しない場合、返信は無制限にネストされます。

シングルサインオン (SSO) の概要 Internal Link

SSO(シングルサインオン)は、ユーザーが別のアカウントを作成することなく FastComments を利用できるようにするための一連の規約です。

匿名コメントを許可していないと仮定すると、FastComments でコメントするにはアカウントが必要です。サインアップは非常に簡単で、ユーザーはコメント時にメールアドレスを入力するだけです。 しかし、それすらも避けたいサイトがあることは理解しています。

どうやって利用できますか?

現在、すべてのアカウントタイプで SSO にアクセスできます。ただし、SSO ユーザーの最大数はプランによって異なります。他の機能と同様に、Pro プラン以上では直接的な開発サポートが提供されます。

オプションを比較した後、各オプションの詳細を説明します。

ユーザーとコメントの移行

Disqus のような SSO を提供するプラットフォームから移行する場合、すでにユーザーとそのコメントが存在します。

コメントは移行の一環として、API、Import UI、またはカスタマーサポートによってインポートされます。使用しているプラットフォームを Import UI がサポートしている場合、エラー処理、アバターやメディアの抽出とアップロード、バッチジョブの監視システムが組み込まれているため、Import UI を使用することを推奨します。

ユーザー自体は、コメントスレッドを初めて表示したときに自動的に追加されます。あるいは、API を通じて事前に追加することもできますが、その作業は多くの利点をもたらしません。

コメントがインポートされ、SSO ユーザーが API で手動追加されていない場合、ユーザーが任意のコメントスレッドを初めて表示してアカウントが作成される際に、該当するコメントは自動的にそのユーザーのアカウントに移行されます。その後、ユーザーは元のコメントを管理、編集、削除できるようになります。

自動移行はメールアドレスまたはユーザー名で行われます。Disqus のようにエクスポート時にメールアドレスを提供しないプラットフォームもあるため、その場合はユーザー名にフォールバックします。

  • SSO ペイロードに一致するユーザー名とメールアドレスを渡している限り、通知やメンションが機能するように、個々のコメントオブジェクトにそのメールアドレスを追加します。

コメントとユーザーを同時にインポートしたい場合は、API を介してユーザーがインポートされた後に、サポートと連携してコメントをそれぞれのユーザーアカウントに移行してください。

まとめると、移行で最も簡単な手順は次のとおりです:

  1. Import comments.
    1. Import UI を Manage Data -> Imports で使用している場合、アバターやその他のメディアは自動的に移行されます。
  2. Setup Secure or Simple SSO.
  3. Let the migration happen per-user automatically when they log in for the first time.
    1. 一般的に、ユーザーが 50,000 件未満のコメントしか持っていない場合、ページ読み込み時間に追加される時間は通常 1 秒未満です。

WordPress Users

If you're using our WordPress プラグイン then there is no code to write! Simply go to the plugin's Admin page, click SSO Settings, and then Enable.

This will take you to a single-button click wizard which will create your API key, send it over to your WordPress install and turn SSO on. We've consolidated this into a single button click for you.

Note that if you are installing the plugin for the first time you will have to follow up the setup process before you see the admin page with the SSO Settings button.

WordPress SSO - Moderators

FastComments WordPress plugin でコメントした際にモデレーターの横に "Moderator" バッジを表示するには、該当ユーザーが FastComments ダッシュボードでも Moderator として追加され、メールアドレスが確認済みである必要がある点に注意してください。

カスタム統合

カスタム統合の場合、2 つのオプションがあります。

オプション1 - Secure SSO

With Secure SSO, FastComments knows that the user commenting, voting, and reading comments is a real user on your site.

As long as you create a valid payload, the user will always have a seamless commenting experience.

With Secure SSO, the SSO payload is created server-side using HMAC authentication and then passed to the widget on the client.

With Secure SSO, the user's account is completely separate from the rest of the FastComments user-base. This means if we have two partners Company A and Company B, each can have an SSO user with the username "Bob".

要件

  • サーバーサイド開発に関する基本的な知識。
  • 秘密の API キーを扱う際の基本的な知識。
  • API 開発またはサーバーサイドレンダリングに関する基本的な知識。

利点

  • セキュア。
  • シームレスなコメント体験。

欠点

  • サーバーサイドの開発を要する。

ユーザーデータの更新

Secure SSO では、SSO ユーザーペイロードを渡すたびに、そのユーザーの情報を最新の内容で更新します。例えば、ユーザー名が X の場合に SSO ペイロードで Y を渡すと、ユーザー名は Y になります。

この方法で値を削除したい場合は、それらを null に設定してください(undefined ではありません)。

Secure SSO API

SSO ユーザーと対話するための API も提供しています。詳細は ドキュメント を参照してください。

Note that when using Secure SSO, users are automatically created behind the scenes on page load. You do not have to bulk import your users.

オプション2 - Simple SSO

The alternative to Secure SSO is to simply pass the user information to the commenting widget.

Providing an email with Simple SSO is not required, however without this their comments will show as "Unverified".

注: As of early 2022 usernames with Simple SSO do not need to be unique across all of FastComments.com.

Ideally, Simple SSO should only be picked when developing on a platform that doesn't provide backend access.

要件

  • クライアントサイド開発に関する基本的な知識。
  • 少なくともユーザーのメールアドレスを把握していること。

利点

  • 単純。
  • すべてのアクティビティは引き続き検証されます。
  • ユーザーが自分のユーザー名やメールアドレスを入力することはありません。

欠点

  • クライアント側のペイロードが偽造されて任意のユーザーになり得るため、Secure SSO より安全性は低くなります。

Simple SSO API

Simple SSO フローで自動的に作成されたユーザーは SSOUser オブジェクトとして保存されます。これらは SSOUser API を介してアクセスおよび管理できます。詳細は ドキュメント を参照してください。

カスタム統合 - シンプルなシングルサインオン (SSO) Internal Link

Simple SSO を使うと、コメントウィジェットにユーザー情報を提供できるため、ユーザーはコメント時にユーザー名やメールアドレスを入力する必要がなくなります。

Simple SSO は次のように設定できます:

Simple SSO
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 "simpleSSO": {
8 "username": "Bob",
9 "email": "bob@example.com",
10 "avatar": "https://example.com/bob.png",
11 "websiteUrl": "https://example.com/profiles/bob",
12 "displayName": "Bob's Name",
13 "displayLabel": "VIP User",
14 "loginURL": "https://example.com/login",
15 "logoutURL": "https://example.com/logout",
16 "badgeConfig": {
17 "badgeIds": [
18 "badge-id-1",
19 "badge-id-2"
20 ],
21 "pageBadgeIds": [
22 "badge-id-3"
23 ],
24 "override": false
25 }
26 }
27}];
28</script>
29

ユーザーはログインした状態になり、裏で SSO ユーザーが作成されます。API から取得された場合、ユーザーの createdFromSimpleSSOtrue に設定されます。

Notes:

  • メールアドレスは Simple SSO における一意の識別子です。
  • Simple SSO でメールアドレスを提供する必要はありませんが、デフォルトではコメントは "Unverified" と表示されます。 メールアドレスが提供されない場合、ユーザーは完全に認証されません。
  • NEW 2022年1月以降: fastcomments.com 全体でユーザー名が一意である必要はありません
  • メールアドレスが提供され、かつユーザーが元々 Secure SSO から作成されていなかった場合、Simple SSO は SSO ユーザーを自動的に作成および更新できます。
  • ユーザーに付与するバッジは badgeConfig プロパティで指定できます。badgeIds 配列にはユーザーに関連付けるグローバルバッジの ID が含まれます。pageBadgeIds 配列には現在のページ(urlId)にスコープされたバッジ ID が含まれます — これらのバッジは割り当てられたページでのみ表示されます。overridetrue に設定されている場合、既存の表示中のバッジを置き換えます(グローバルとページスコープは独立して上書きされます);false の場合は既存のバッジに追加されます。

カスタム統合 - Disqus SSOからの移行 Internal Link

Disqus と FastComments Secure SSO の最大の違いは、Disqus が暗号化に SHA1 を使用しているのに対し、当社は SHA256 を使用している点です。

つまり、Disqus からの移行は簡単です - 使用するハッシュアルゴリズムを SHA1 から SHA256 に変更し、UI に渡されるプロパティ名を更新するだけです。

カスタム統合 - Commento SSOからの移行 Internal Link

Commento は大幅に異なる SSO アプローチを採用しています - ユーザーを認証するために呼び出すエンドポイントを用意する必要があります。

FastComments はその逆で - 単にユーザーの情報をあなたの秘密鍵でエンコードしてハッシュし、それを渡すだけです。

コールバック Internal Link

コメントウィジェット用のすべてのライブラリ(現在は Angular、React、Vue)はコールバックをサポートしています。

コールバックは設定オブジェクトで指定し、各ライブラリで同じシグネチャを持ちます。

サポートされているコールバックは以下です:

  • onInit
  • onAuthenticationChange
  • onRender
  • commentCountUpdated
  • onReplySuccess
  • onVoteSuccess
  • onImageClicked
  • onOpenProfile
  • onCommentSubmitStart
  • onCommentsRendered

正確なシグネチャはTypeScript 定義で確認できます。

以下はすべてのコールバックを使用した例です:

コールバックの例
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>
5 window.fcConfigs = [{
6 target: '#fastcomments-widget',
7 tenantId: 'demo',
8 onInit: function () {
9 console.log('Library started to fetch comments!');
10 },
11 onAuthenticationChange: function (eventName, userObj) {
12 console.log('User authenticated!', eventName, userObj);
13 },
14 onRender: function () {
15 console.log('Render event happened!');
16 },
17 commentCountUpdated: function (newCount) {
18 console.log('New comment count:', newCount);
19 },
20 onReplySuccess: function (comment) {
21 console.log('New comment saved!', comment);
22 },
23 onVoteSuccess: function (comment, voteId, direction, status) {
24 console.log('New vote saved!', comment, voteId, direction, status);
25 },
26 onImageClicked: function (src) {
27 console.log('Image clicked!', src);
28 },
29 onOpenProfile: function (userId) {
30 console.log('User tried to open profile', userId);
31 // return true; // デフォルトの動作(fastcomments.com のユーザープロファイルを開く)を防ぐには true を返します。
32 },
33 onCommentSubmitStart: function(comment, continueSubmitFn, cancelFn) {
34 console.log('Trying to submit comment', comment);
35 setTimeout(function() { // 非同期動作をエミュレートしています(API 呼び出し等)。
36 if(confirm('Should submit?')) {
37 continueSubmitFn();
38 } else {
39 cancelFn('Some optional error message');
40 }
41 }, 1000);
42 },
43 onCommentsRendered: function(comments) {
44 // comments はページのデフォルトのソート順で並べられます。デフォルトのソートは Most Relevant(例:投票数が多いもの等)や Newest First である場合があります。
45 const topCommentInList = comments[0];
46 console.log('First Comment Rendered:', topCommentInList.avatarSrc, topCommentInList.commenterName, topCommentInList.commentHTML);
47 }
48 }];
49</script>
50

ページタイトル Internal Link

現在のページタイトルは指定された urlId に関連付けられ、モデレーションツールで使用するために保存されます。

デフォルトでは、これは document.title から取得されます。

必要に応じて、独自のページタイトルを次のように指定できます:

Specifying The Page Title
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 "pageTitle": "Article 42"
8}];
9</script>
10

コメント数とネストされた返信の全件カウント Internal Link

コメントウィジェットの上部に表示されるコメント数は、すべての「トップレベル」コメントを表示することもできます。すなわちページや記事自体に直接返信された返信を表示することも、 またはすべてのネストされたコメントの総数を表示することもできます。

By default, this is true - it is a count of the latter - all comments. コメントウィジェットの古いバージョンでは、 デフォルト値は false です。

We can change the behavior, so that it is a count of all nested comments by setting the countAll flag to true.

Counting All Comments
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 "countAll": true
8}];
9</script>
10

If we wanted the count to reflect only the top level comments, we set the flag to false.

Counting Top Level Comments
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 "countAll": false
8}];
9</script>
10

This currently cannot be customized without code changes.

グループIDのメンション Internal Link

オートコンプリートの**@mentions**で使用するIDの一覧。ユーザー同士のグループが交差していない場合にタグ付けされないようにしたいときに便利です。

指定すると、@文字を入力したときに、他のグループに属するユーザーのみがオートコンプリートに表示されます。

Limit Groups for Mentions
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 "mentionGroupIds": [
8 "yxZAhjzda",
9 "QT19nXbqB"
10 ]
11}];
12</script>
13