FastComments.com

Add Comments to Your Eleventy (11ty) Site

์ด๊ฒƒ์€ FastComments์šฉ ๊ณต์‹ Eleventy (11ty) ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž…๋‹ˆ๋‹ค.

๊ท€ํ•˜์˜ Eleventy (11ty) ์‚ฌ์ดํŠธ์— ์‹ค์‹œ๊ฐ„ ๋Œ“๊ธ€, ์ฑ„ํŒ… ๋ฐ ๋ฆฌ๋ทฐ ์œ„์ ฏ์„ ์ž„๋ฒ ๋“œํ•˜์„ธ์š”.

์ €์žฅ์†Œ

GitHub์—์„œ ๋ณด๊ธฐ


๋ผ์ด๋ธŒ ์‡ผ์ผ€์ด์Šค Internal Link

๋ชจ๋“  ์ˆ์ฝ”๋“œ์™€ ํ”Œ๋กœ์šฐ๊ฐ€ ๊ณต์šฉ demo ํ…Œ๋„ŒํŠธ์— ๋Œ€ํ•ด ๋กœ์ปฌ์—์„œ ์‹คํ–‰๋˜๋Š” ๋ชจ์Šต์„ ๋ณด๋ ค๋ฉด, ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ํด๋ก ํ•˜๊ณ  ๋‹ค์Œ์„ ์‹คํ–‰ํ•˜์„ธ์š”:

cd example
npm install
npm start

๊ฐ ์ปดํฌ๋„ŒํŠธ๋Š” example/src/pages/ ์•„๋ž˜์— ์ž์ฒด ํŽ˜์ด์ง€๊ฐ€ ์žˆ์œผ๋ฉฐ, ์ด๋ฅผ ๊ทธ๋Œ€๋กœ ๋ณต์‚ฌํ•˜์—ฌ ์ž์‹ ์˜ Eleventy ์‚ฌ์ดํŠธ์— ๋ถ™์—ฌ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์„ค์น˜ Internal Link

npm install fastcomments-11ty

๋น ๋ฅธ ์‹œ์ž‘ Internal Link

Eleventy ๊ตฌ์„ฑ ํŒŒ์ผ(.eleventy.js or 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๋กœ ๋ณ€๊ฒฝํ•˜์„ธ์š”.

์ˆ์ฝ”๋“œ 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: ['fastcomments', 'fastcommentsCommentCount'],
    // ๋“ฑ๋ก๋œ ๋ชจ๋“  ๋‹จ์ถ• ์ฝ”๋“œ ์ด๋ฆ„์— ์ ‘๋‘์‚ฌ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค (์˜ˆ: "fc" -> "fcFastcomments"):
    prefix: 'fc'
});

์ˆ˜๋™ ์‚ฌ์šฉ(ํ”Œ๋Ÿฌ๊ทธ์ธ ์—†์ด) Internal Link

๊ฐ ์ˆ์ฝ”๋“œ๋Š” 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 ์ €์žฅ์†Œ๋ฅผ ๋ฐฉ๋ฌธํ•˜์„ธ์š”.