
語言 🇹🇼 繁體中文
🇺🇸
English
🇧🇬
Български
🇨🇳
简体中文
🇹🇼
繁體中文
🇭🇷
Hrvatski
🇩🇰
Dansk
🇳🇱
Nederlands
🇺🇸
English (US)
🇨🇦
Français (Canada)
🇫🇷
Français (France)
🇩🇪
Deutsch
🇨🇾
Ελληνικά (Κύπρος)
🇬🇷
Ελληνικά
🇮🇱
עברית
🇮🇹
Italiano
🇯🇵
日本語
🇰🇷
한국어
🇵🇱
Polski
🇧🇷
Português (Brasil)
🇷🇺
Русский
🇺🇦
Русский (Украина)
🇧🇦
Српски (БиХ)
🇷🇸
Srpski (Latinica)
🇲🇪
Српски (Црна Гора)
🇷🇸
Српски
🇸🇮
Slovenščina
🇪🇸
Español
🇺🇦
Українська
🇹🇷
Türkçe
文件
快速開始
設定
使用
Add Comments to Your Eleventy (11ty) Site
這是 FastComments 的官方 Eleventy (11ty) 函式庫。
在你的 Eleventy (11ty) 網站中嵌入即時留言、聊天室和審查小工具。
儲存庫
線上示範 
在 https://fastcomments.com/commenting-system-for-11ty 即時試用每個小工具。
線上展示 
若要在本機查看針對公開的 demo 租戶運行的每個短碼與流程,請複製該儲存庫並執行:
cd example
npm install
npm start
每個元件在 example/src/pages/ 下都有自己的頁面,你可以直接將它們複製到自己的 Eleventy 網站中。
快速上手 
在你的 Eleventy 設定檔(.eleventy.js 或 eleventy.config.js)中註冊此外掛:
const { fastcommentsPlugin } = require('fastcomments-11ty');
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(fastcommentsPlugin);
};
或使用 ESM:
import { fastcommentsPlugin } from 'fastcomments-11ty';
export default function(eleventyConfig) {
eleventyConfig.addPlugin(fastcommentsPlugin);
}
然後在你的模板中使用短碼。在 Nunjucks(.njk):
{% fastcomments { tenantId: "demo" } %}
在 Liquid(.liquid):
{% fastcomments tenantId: "demo" %}
將 "demo" 替換為你的 FastComments 租戶 ID。
短代碼 
| 短碼 | 描述 |
|---|---|
fastcomments |
具有回覆、投票等功能的留言小工具 |
fastcommentsCommentCount |
顯示頁面留言數 |
fastcommentsImageChat |
圖片註解留言 |
fastcommentsLiveChat |
即時聊天小工具 |
fastcommentsCollabChat |
協作內聯留言 |
fastcommentsRecentComments |
整站近期留言 |
fastcommentsRecentDiscussions |
最近活躍的討論串 |
fastcommentsReviewsSummary |
星級評分評論摘要 |
fastcommentsTopPages |
最多討論的頁面 |
fastcommentsUserActivityFeed |
使用者活動動態 |
範例
{# 內聯顯示留言計數 #}
This page has {% fastcommentsCommentCount { tenantId: "demo" } %} comments.
{# 即時聊天 #}
{% fastcommentsLiveChat { tenantId: "demo" } %}
{# 協作聊天 — 以 CSS 選擇器指定目標內容元素 #}
<article id="post-body">
<p>Highlight me to leave a comment.</p>
</article>
{% fastcommentsCollabChat { tenantId: "demo", target: "#post-body" } %}
{# 圖片聊天 — 以 CSS 選擇器指定目標圖像元素 #}
<img id="hero" src="/hero.jpg" alt="Hero image" />
{% fastcommentsImageChat { tenantId: "demo", target: "#hero" } %}
{# 評論摘要 #}
{% fastcommentsReviewsSummary { tenantId: "demo" } %}
{# 使用者活動動態 #}
{% fastcommentsUserActivityFeed { tenantId: "demo", userId: "demo:demo-user" } %}
外掛選項 
eleventyConfig.addPlugin(fastcommentsPlugin, {
// 只註冊部分短代碼:
shortcodes: ['fastcomments', 'fastcommentsCommentCount'],
// 為每個註冊的短代碼名稱新增前綴(例如 "fc" -> "fcFastcomments"):
prefix: 'fc'
});
手動使用(不使用外掛) 
每個短碼也會被匯出為獨立函式,回傳 HTML 字串:
const { fastcomments, commentCount } = require('fastcomments-11ty');
eleventyConfig.addShortcode('comments', fastcomments);
eleventyConfig.addShortcode('commentCount', commentCount);
維護狀態 
這些元件是我們核心 VanillaJS 元件的封裝層。我們可以自動更新這些元件(修復錯誤、加入功能),而無需發佈此函式庫;因此即使這個函式庫可能一段時間不會發佈,也不代表 FastComments 並未處於積極開發中!歡迎隨時查看 我們的部落格 以取得更新。除非在本函式庫中進行版本提升,否則破壞性 API 變更或新功能絕不會被推送到底層核心函式庫。
需要幫助?
如果您在使用 Eleventy (11ty) Library 時遇到任何問題或有任何疑問,請:
貢獻
歡迎貢獻!請造訪 GitHub 倉庫 以取得貢獻指南。