FastComments.com

Add Members-Only Live Commenting to ghost Sites

With FastComments we can easily add live, members-only commenting to any site built with Ghost.

We will be able to メンバーのユーザー名やアバターを自動的にインポートし、コメント返信通知を設定できるようになります。

注意 このチュートリアルには FastComments アカウントが必要です。まずサインアップしてから戻ってくることをお勧めします。ここでアカウントを作成できます。

In this tutorial we'll be targeting a blog built with Ghost, but with a little know-how the same instructions apply to any type of site.

This tutorial starts from the perspective of a user who is very new to Ghost. Users experienced in editing their themes can skip to Step 4.

If you're having trouble, feel free to send your exported theme template to your support representative(それでもステップ1〜5が必要です)。

ステップ 1: テーマをダウンロードする Internal Link

FastCommentsをGhostに正しく追加するには、テーマファイルを編集する必要があります。

まずは、現在のテーマまたは使用したいテーマをダウンロードしましょう。

サイトのダッシュボードに移動し、左下の歯車をクリックします:

設定を開く
設定を開く

次に Design オプションを選択します:

デザインを選択
デザインを選択

厳密にはテーマを変更しているわけではありませんが、左下の Change Theme をクリックします:

テーマを変更
テーマを変更

右上で Advanced を選択します:

Advancedを選択
Advancedを選択

...そして現在のテーマまたは希望するテーマをダウンロードします:

テーマをダウンロード
テーマをダウンロード

ステップ 2: テーマをローカルにインストールする Internal Link


zipファイルをダウンロードしたので、フォルダに解凍します。デフォルトの casper.zip をダウンロードし、Windows の Downloads\casper に解凍しました。

次に、LTS またはそれ以降のバージョンの NodeJS がインストールされていることを確認してください。入手はこちら: https://nodejs.org/en/download/

NodeJS がインストールされたら、コードエディタをインストールします。

当社では Webstorm を推奨(および使用)しています。30日間のトライアル(クレジットカード不要)で入手できます: https://www.jetbrains.com/webstorm/

次に良い無料の選択肢はおそらく Visual Studio Code でしょう: https://code.visualstudio.com/download

エディタのセットアップが完了し、テーマフォルダをエディタで開いたら、IDE のターミナルを開き、次を実行します:

テーマをインストール
Copy Copy
1
2npm install
3

出力は次のようになります(警告は無視して構いません):

npm install の成功時の出力
npm install の成功時の出力

これにより、後で実行するコマンドのためにテーマの依存関係が設定されます。また、エクスポートはテーマの依存関係がインストールされていることに依存するため、インポートし直す際に正しく動作するには依存関係が必要です。


ステップ 3: 新しいテーマに名前を付ける Internal Link


テーマをエディタで開いた状態で、package.json を開き、name フィールドを別の値に変更してください。今回は末尾に -fastcomments を追加します:

テーマ名を変更
テーマ名を変更

IDE を使用している場合、この変更は自動的に保存されます。


ステップ 4: 投稿テンプレートを開く Internal Link


これからブログ記事で使用されているテンプレートを開きます。名前は post.hbs です:

post.hbs を開く
post.hbs を開く

ステップ 5: FastComments のコードを追加する Internal Link

Next we need to identify where to add the FastComments.com widget code.

If you're using the default casper theme, you'll see a section like this at line 82:

無効化されたコメントセクション
無効化されたコメントセクション

If you're using other themes, you won't see this, and will need to add this code after the last </section>:

セクションの例
Copy Copy
1
2<section class="article-comments gh-canvas">
3</section>
4

You should have something like this ready:

コメントコード用テンプレートの準備完了
コメントコード用テンプレートの準備完了

Once ready, copy the FastComments.com widget code:

Ghost 用 FastComments.com コメントコードスニペット
Copy Copy
1
2<script src="https://cdn.fastcomments.com/js/embed-v2.min.js"></script>
3<div id="fastcomments-widget"></div>
4<script>
5 (function () {
6 let simpleSSO = null;
7
8 {{#if access}}
9 {{#if @member}}
10 simpleSSO = {
11 id: '{{ @member.uuid }}',
12 email: '{{@member.email}}',
13 username: '{{@member.name}}',
14 avatar: '{{ @member.avatar_image }}',
15 optedInNotifications: true,
16 optedInSubscriptionNotifications: true,
17 displayLabel: '{{@member.labels}}'
18 }
19 {{/if}}
20 {{/if}}
21
22 FastCommentsUI(document.getElementById('fastcomments-widget'), {
23 tenantId: "demo",
24 urlId: window.location.pathname,
25 allowAnon: false,
26 simpleSSO: simpleSSO
27 });
28 })();
29</script>
30

...and it should look like this:

FastComments.com コメントコードを追加
FastComments.com コメントコードを追加

Coding done. Now we just have to re-import our theme!

ステップ 6: テーマをエクスポートする Internal Link

今度はテーマファイルを再びzipファイルにまとめる必要があります。これを行うには、Ghostの組み込み機能を使用してください。

エディタのターミナルをもう一度開き、npm run zipを実行します。

テーマをエクスポート
Export Your Theme

This will package the theme into a zip file in dist/casper-fastcomments.zip (if that is what you've named the theme in Step Three).

ステップ 7: テーマを Ghost にアップロードする Internal Link

Ghostのダッシュボードに戻り、テーマをアップロードしましょう:

テーマをアップロード
テーマをアップロード

私の場合、zipファイルは次の場所にあります。distフォルダーに注意してください:

アップロードするZipを選択
アップロードするZipを選択

アップロードした新しいテーマを有効化するのを忘れないでください(Ghostが確認を促します)。

完了! Internal Link


これでメンバー向けに FastComments のライブコメント機能が有効になっているはずです!

成功!
成功!

Ghost に FastComments を設定したこと、おめでとうございます!ドメインエラーが発生した場合、またはコメント欄をカスタマイズする方法を知りたい場合は、読み進めてください!


カスタマイズ Internal Link


FastComments はあなたのサイトに合わせてカスタマイズできるように設計されています。

カスタムスタイリングを追加したり、設定を調整したい場合は、方法を確認するためにカスタマイズのドキュメントをご覧ください