
语言 🇨🇳 简体中文
🇺🇸
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) 站点中嵌入实时评论、聊天和审核小部件。
仓库
在线展示 
要在本地查看针对公共 demo 租户运行的所有 shortcode 和 flow,请克隆该仓库并运行:
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。
短代码 
| Shortcode | Description |
|---|---|
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) 库时遇到任何问题或有疑问,请:
贡献
欢迎贡献!请访问 GitHub 仓库 以获取贡献指南。