FastComments.com

Add Comments to Your Eleventy (11ty) Site

ื–ื•ื”ื™ ื”ืกืคืจื™ื™ื” ื”ืจืฉืžื™ืช ืฉืœ Eleventy (11ty) ืขื‘ื•ืจ FastComments.

ื”ื˜ืžืข ืชื’ื•ื‘ื•ืช ื—ื™ื•ืช, ืฆ'ืื˜ ื•ื•ื™ื“ื’'ื˜ื™ื ืœื‘ื™ืงื•ืจื•ืช ื‘ืืชืจ Eleventy (11ty) ืฉืœืš.

ืžืื’ืจ

ืฆืคื” ื‘-GitHub


ื”ื“ื’ืžื” ื—ื™ื” Internal Link


ื›ื“ื™ ืœืจืื•ืช ื›ืœ shortcode ื•-flow ืฉืจืฆื™ื ื‘ืื•ืคืŸ ืžืงื•ืžื™ ืžื•ืœ ื”ื˜ื ื ื˜ ื”ืฆื™ื‘ื•ืจื™ demo, ืฉื›ืคืœ ืืช ื”ืžืื’ืจ ื•ื”ืจืฅ:

cd example
npm install
npm start

ืœื›ืœ ืจื›ื™ื‘ ื™ืฉ ืขืžื•ื“ ืžืฉืœื• ืชื—ืช example/src/pages/ ืฉืชื•ื›ืœ ืœื”ืขืชื™ืง ื™ืฉื™ืจื•ืช ืœืืชืจ Eleventy ืฉืœืš.

ื”ืชืงื ื” Internal Link

npm install fastcomments-11ty

ื”ืชื—ืœื” ืžื”ื™ืจื” Internal Link

ื”ื•ืกืฃ ืืช ื”ืชื•ืกืฃ ืœืงื•ื‘ืฅ ื”ืชืฆื•ืจื” ืฉืœ 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" ื‘ึพtenant ID ืฉืœ FastComments ืฉืœืš.

ืฉื•ืจื˜ืงื•ื“ื™ื Internal Link

ืงื•ื“ ืžืงื•ืฆืจ ืชื™ืื•ืจ
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" } %}

ืืคืฉืจื•ื™ื•ืช ื”ืชื•ืกืฃ Internal Link

eleventyConfig.addPlugin(fastcommentsPlugin, {
    // ืจืฉื•ื ืจืง ืชืช-ืงื‘ื•ืฆื” ืฉืœ ื”-shortcodes:
    shortcodes: ['fastcomments', 'fastcommentsCommentCount'],
    // ื”ื•ืกืฃ ืงื™ื“ื•ืžืช ืœื›ืœ ืฉื shortcode ืจืฉื•ื (ืœืžืฉืœ "fc" -> "fcFastcomments"):
    prefix: 'fc'
});

ืฉื™ืžื•ืฉ ื™ื“ื ื™ (ืœืœื ื”ืชื•ืกืฃ) Internal Link

ื›ืœ shortcode ืžื™ื•ืฆื ื’ื ื›ืคื•ื ืงืฆื™ื” ืขืฆืžืื™ืช ืฉืžื—ื–ื™ืจื” ืืช ืžื—ืจื•ื–ืช ื”-HTML:

const { fastcomments, commentCount } = require('fastcomments-11ty');

eleventyConfig.addShortcode('comments', fastcomments);
eleventyConfig.addShortcode('commentCount', commentCount);

ืคืจื•ื™ืงื˜ ืœื“ื•ื’ืžื” Internal Link

ื“ืžื• ืขื•ื‘ื“ ื›ืœื•ืœ ื‘ืชื™ืงื™ื™ืช example/:

cd example && npm install && npm start


ืžืฆื‘ ืชื—ื–ื•ืงื” Internal Link

ืจื›ื™ื‘ื™ื ืืœื” ื”ื ืขื˜ื™ืคื•ืช ืกื‘ื™ื‘ ืจื›ื™ื‘ื™ ื”-VanillaJS ื”ืœื™ื‘ื” ืฉืœื ื•. ืื ื—ื ื• ื™ื›ื•ืœื™ื ืœืขื“ื›ืŸ ืื•ื˜ื•ืžื˜ื™ืช ืืช ื”ืจื›ื™ื‘ื™ื ื”ืืœื” (ืœืชืงืŸ ื‘ืื’ื™ื, ืœื”ื•ืกื™ืฃ ืชื›ื•ื ื•ืช) ืžื‘ืœื™ ืœืคืจืกื ืืช ื”ืกืคืจื™ื™ื” ื”ื–ื•, ื›ืš ืฉืœืžืจื•ืช ืฉื™ื™ืชื›ืŸ ืฉื”ื™ื ืœื ืชืคื•ืจืกื ืœืขืช ืขืชื”, ื–ื” ืœื ืื•ืžืจ ืฉ-FastComments ืื™ื ื” ื‘ืคื™ืชื•ื— ืคืขื™ืœ! ืืœ ืชื”ืกืกื• ืœื‘ื“ื•ืง ืืช ื”ื‘ืœื•ื’ ืฉืœื ื• ืœืขื“ื›ื•ื ื™ื. ืฉื™ื ื•ื™ื™ื ืžืคื™ืจื™ ืชืื™ืžื•ืช ื‘-API ืื• ืชื›ื•ื ื•ืช ืœื ื™ื™ืฉื•ืœื‘ื• ืœืขื•ืœื ื‘ืกืคืจื™ื™ืช ื”ืœื™ื‘ื” ื”ื–ื• ืžื‘ืœื™ ื”ืขืœืืช ื’ืจืกื” ื‘ืกืคืจื™ื™ื” ื–ื•.

ื–ืงื•ืงื™ื ืœืขื–ืจื”?

ืื ื ืชืงืœืชื ื‘ื‘ืขื™ื•ืช ืื• ื™ืฉ ืœื›ื ืฉืืœื•ืช ืœื’ื‘ื™ ืกืคืจื™ื™ืช Eleventy (11ty), ืื ื:

ืชืจื•ืžื•ืช

ืชืจื•ืžื•ืช ืžืชืงื‘ืœื•ืช ื‘ื‘ืจื›ื”! ืื ื ื‘ืงืจื• ื‘-ืžืื’ืจ ื”-GitHub ืœืงื‘ืœืช ื”ื ื—ื™ื•ืช ืœืชืจื•ืžื”.