
語言 🇹🇼 繁體中文
文件
入門
設定
在你的 Jekyll 網站新增留言
這是 FastComments 的官方 Jekyll 函式庫。
在您的 Jekyll 網站嵌入即時評論、聊天和審閱小工具。
儲存庫
線上展示 
若要在本機查看針對公開 demo 租戶運行的所有標籤,請複製儲存庫並執行:
cd example
bundle install
bundle exec jekyll serve
每個 widget 在 example/ 底下都有自己的頁面,您可以直接將其複製到自己的 Jekyll 網站中。
快速上手 
在 _config.yml 中設定你的租戶 ID(只需一次):
fastcomments:
tenant_id: demo
然後在想要放置元件的位置加入標籤,可以是佈局、文章或頁面:
{% raw %}{% fastcomments %}{% endraw %}
就這樣。將 demo 替換成你的 FastComments 租戶 ID(可在
設定 > API/SSO 找到)。
標籤 
| Tag | Description |
|---|---|
fastcomments | 即時留言功能,支援回覆、投票、審核與即時更新 |
fastcomments_comment_count | 當前頁面的留言數量 |
fastcomments_comment_count_bulk | 清單/索引頁面上多個頁面的留言數量 |
fastcomments_live_chat | 即時串流聊天小工具 |
fastcomments_collab_chat | 協作式內嵌留言(文字註解) |
fastcomments_image_chat | 圖像註解留言 |
fastcomments_recent_comments | 全站最近留言 |
fastcomments_recent_discussions | 最近活躍的討論串 |
fastcomments_reviews_summary | 星級評分評論摘要 |
fastcomments_top_pages | 討論最多的頁面 |
fastcomments_user_activity_feed | 每位使用者的活動動態 |
範例
{% raw %}{# 留言數量。該小工具會自行呈現標籤,例如「0 則留言」 #}
{% fastcomments_comment_count %}
{# 即時聊天 #}
{% fastcomments_live_chat %}
{# 協作聊天。指定一個帶 CSS 選擇器的內容元素 #}
<article id="post-body">
<p>Highlight me to leave a comment.</p>
</article>
{% fastcomments_collab_chat target="#post-body" %}
{# 圖像聊天。指定一個帶 CSS 選擇器的圖像元素 #}
<img id="hero" src="/hero.jpg" alt="Hero image">
{% fastcomments_image_chat target="#hero" %}
{# 評論摘要 #}
{% fastcomments_reviews_summary %}
{# 使用者活動動態。需要 user_id #}
{% fastcomments_user_activity_feed user_id="demo:demo-user" %}
{# 部落格索引的批量留言計數 #}
{% for post in site.posts %}
<a href="\{{ post.url }}">\{{ post.title }}</a>
<span class="fast-comments-count" data-fast-comments-url-id="\{{ post.url }}"></span>
{% endfor %}
{% fastcomments_comment_count_bulk %}{% endraw %}
設定 
設定來源有三處。後面的來源會勝出:
- 全域預設 在
_config.yml底下的fastcomments:鍵。 - 頁面上下文,自動為頁面作用域的小工具派生(見下方)。
- 標籤屬性 直接寫在標籤本身。
因此,標籤上的 url_id 會覆蓋由頁面派生的值,而頁面派生的值又會覆蓋任何全域預設。
屬性語法
屬性為 key=value 的配對,使用 snake_case:
{% raw %}{% fastcomments url_id="my-stable-id" readonly=true count=20 %}{% endraw %}
- Quoted values (
"..."or'...') are literal strings. - Unquoted
true/falsebecome booleans, and numbers become numbers. - Unquoted anything else is resolved as a Liquid variable from the page context, e.g.
url_id=page.slug. (Liquid does not expand{% raw %}\{{ ... }}{% endraw %}inside a tag's attributes, so use the barepage.slugform rather than"{% raw %}\{{ page.slug }}{% endraw %}".)
Snake_case attribute and config keys are mapped automatically to the camelCase keys FastComments
expects (tenant_id → tenantId, url_id → urlId, page_title → pageTitle,
has_dark_background → hasDarkBackground, and so on). Any other option from the
widget configuration
passes straight through the same way.
由頁面派生的值
對於頁面作用域的 widgets (fastcomments, fastcomments_comment_count, fastcomments_live_chat,
fastcomments_collab_chat, fastcomments_image_chat),這些值會自動從當前頁面填入,除非你自行設定:
url_id←page.url(a stable identifier independent of the visiting domain)url←site.url+page.url(only whenurlis set in_config.yml)page_title←page.title
Site-wide widgets (recent comments/discussions, top pages, reviews summary, user activity feed, bulk count) are not tied to a page and do not derive these.
歐盟資料駐留
歐盟客戶請新增 region: eu,可以全域設定:
fastcomments:
tenant_id: your-tenant-id
region: eu
或是每個標籤設定: {% raw %}{% fastcomments region="eu" %}{% endraw %}。小工具將會從歐盟的 CDN 載入。
維護狀態 
這些元件是我們核心 VanillaJS 元件的封裝。我們可以自動更新那些元件(修復錯誤、加入功能),而不需要發佈這個程式庫,所以即便這個程式庫可能一段時間不會發佈,也不代表 FastComments 沒有在積極開發中!歡迎查看 我們的部落格 以獲取更新。重大破壞性 API 變更或功能不會在未提升此程式庫版本的情況下,併入到底層核心程式庫。
需要幫助?
如果您在使用 Jekyll 函式庫時遇到任何問題或有任何疑問,請:
貢獻
歡迎貢獻!請造訪 GitHub 倉庫 以取得貢獻指南。