FastComments.com


FastComments는 특정 페이지나 게시물의 댓글 수를 표시할 수 있는 가볍고 독립적인 댓글 수 위젯을 제공합니다. 이러한 위젯은 메인 댓글 위젯과 분리되어 있으며 전체 댓글 인터페이스 없이 댓글 수를 표시하려는 곳 어디에나 사용하도록 설계되었습니다.

사용 가능한 댓글 수 위젯은 두 가지 유형이 있습니다:

  1. Comment Count Widget - 단일 페이지의 댓글 수를 표시하기 위해
  2. Bulk Comment Count Widget - 동일한 페이지에서 여러 페이지의 댓글 수를 효율적으로 표시하기 위해

이 문서에서는 VanillaJS 위젯을 다룹니다. 당사의 React/Angular/etc 라이브러리에도 자체 위젯이 있습니다.

댓글 수 위젯 설치 Internal Link

댓글 수 위젯은 단일 페이지의 댓글 수를 표시하도록 설계되었습니다. 가볍고 구성하면 실시간 업데이트를 제공합니다.

기본 설치

Comment Count Widget Installation
Copy CopyRun External Link
1
2<script src="https://cdn.fastcomments.com/js/widget-comment-count.min.js"></script>
3<div id="comment-count"></div>
4<script>
5 window.FastCommentsCommentCount(document.getElementById('comment-count'), {
6 tenantId: 'demo'
7 });
8</script>
9

구성 옵션

FastCommentsCommentCount 함수는 다음 구성 옵션을 허용합니다:

  • tenantId (필수): FastComments 테넌트 ID
  • urlId (선택사항): 페이지 식별자. 지정하지 않으면 window.location.href가 기본값
  • numberOnly (선택사항): true이면 텍스트 없이 숫자만 표시. 기본값은 false
  • isLive (선택사항): true이면 카운트가 자동으로 업데이트됨. 기본값은 false

고급 예제

사용자 정의 URL ID

Comment Count with Custom URL ID
Copy CopyRun External Link
1
2<script src="https://cdn.fastcomments.com/js/widget-comment-count.min.js"></script>
3<div id="comment-count-custom"></div>
4<script>
5 window.FastCommentsCommentCount(document.getElementById('comment-count-custom'), {
6 tenantId: 'demo',
7 urlId: 'my-custom-page-id'
8 });
9</script>
10

숫자만 표시

Comment Count Number Only
Copy CopyRun External Link
1
2<script src="https://cdn.fastcomments.com/js/widget-comment-count.min.js"></script>
3<div id="comment-count-number"></div>
4<script>
5 window.FastCommentsCommentCount(document.getElementById('comment-count-number'), {
6 tenantId: 'demo',
7 numberOnly: true
8 });
9</script>
10

실시간 업데이트

Live Comment Count Updates
Copy CopyRun External Link
1
2<script src="https://cdn.fastcomments.com/js/widget-comment-count.min.js"></script>
3<div id="comment-count-live"></div>
4<script>
5 window.FastCommentsCommentCount(document.getElementById('comment-count-live'), {
6 tenantId: 'demo',
7 isLive: true
8 });
9</script>
10

위젯 메서드

위젯은 다음 메서드를 가진 객체를 반환합니다:

  • destroy(): 위젯을 제거하고 모든 타이머를 정리
  • update(config): 새 구성으로 위젯을 업데이트

사용 예제

Widget Methods Example
Copy CopyRun External Link
1
2<script src="https://cdn.fastcomments.com/js/widget-comment-count.min.js"></script>
3<div id="comment-count-methods"></div>
4<script>
5 const widget = window.FastCommentsCommentCount(document.getElementById('comment-count-methods'), {
6 tenantId: 'demo'
7 });
8
9 // Update the widget to show a different page's count
10 setTimeout(() => {
11 widget.update({
12 tenantId: 'demo',
13 urlId: 'different-page-id'
14 });
15 }, 5000);
16
17 // Destroy the widget after 10 seconds
18 setTimeout(() => {
19 widget.destroy();
20 }, 10000);
21</script>
22

스타일링

위젯은 댓글 수가 포함된 일반 HTML을 렌더링하며 최소한의 스타일링이 제공됩니다. CSS로 외관을 사용자 정의할 수 있습니다:

Custom Styling
Copy CopyRun External Link
1
2<style>
3 .comment-count-styled {
4 background: #f0f0f0;
5 padding: 5px 10px;
6 border-radius: 15px;
7 font-size: 14px;
8 color: #666;
9 display: inline-block;
10 }
11</style>
12<script src="https://cdn.fastcomments.com/js/widget-comment-count.min.js"></script>
13<div id="comment-count-styled" class="comment-count-styled"></div>
14<script>
15 window.FastCommentsCommentCount(document.getElementById('comment-count-styled'), {
16 tenantId: 'demo'
17 });
18</script>
19

댓글 수 위젯 일괄 설치 Internal Link

벌크 댓글 수 위젯은 동일한 페이지에서 여러 페이지의 댓글 수를 효율적으로 표시하도록 설계되었습니다. 각 댓글 수에 대해 개별 API 호출을 하는 대신, 이 위젯은 최적의 성능을 위해 요청을 일괄 처리합니다.

기본 설치

Bulk Comment Count Widget Installation
Copy CopyRun External Link
1
2<script src="https://cdn.fastcomments.com/js/embed-widget-comment-count-bulk.min.js"></script>
3
4<!-- Multiple elements with comment counts -->
5<div class="fast-comments-count" data-fast-comments-url-id="page-1"></div>
6<div class="fast-comments-count" data-fast-comments-url-id="page-2"></div>
7<div class="fast-comments-count" data-fast-comments-url-id="page-3"></div>
8
9<script>
10 window.FastCommentsBulkCountConfig = {
11 tenantId: 'demo'
12 };
13</script>
14

작동 방식

벌크 위젯은 다음과 같이 작동합니다:

  1. fast-comments-count 클래스를 가진 요소를 페이지에서 스캔
  2. 각 요소에서 data-fast-comments-url-id 속성 읽기
  3. 여러 댓글 수를 효율적으로 가져오기 위해 API 요청 일괄 처리
  4. 각 요소를 적절한 댓글 수로 업데이트

구성 옵션

FastCommentsCommentCountBulk 함수는 다음 구성 옵션을 허용합니다:

  • tenantId (필수): FastComments 테넌트 ID
  • apiHost (선택사항): 자체 호스팅 인스턴스를 사용하는 경우 사용자 정의 API 호스트

실제 예제

블로그 게시물 목록에서 벌크 위젯을 사용하는 방법을 보여주는 실용적인 예제:

Blog Post Listing with Comment Counts
Copy CopyRun External Link
1
2<script src="https://cdn.fastcomments.com/js/embed-widget-comment-count-bulk.min.js"></script>
3
4<style>
5 .blog-post {
6 border: 1px solid #ddd;
7 margin: 10px 0;
8 padding: 15px;
9 border-radius: 5px;
10 }
11 .post-meta {
12 color: #666;
13 font-size: 14px;
14 margin-top: 10px;
15 }
16 .comment-count {
17 background: #e7f3ff;
18 padding: 2px 8px;
19 border-radius: 12px;
20 font-size: 12px;
21 display: inline-block;
22 }
23</style>
24
25<div class="blog-post">
26 <h3>How to Install FastComments</h3>
27 <p>Learn how to add FastComments to your website in just a few minutes...</p>
28 <div class="post-meta">
29 Published: March 15, 2024 |
30 <span class="fast-comments-count comment-count" data-fast-comments-url-id="how-to-install-fastcomments"></span>
31 </div>
32</div>
33
34<div class="blog-post">
35 <h3>Advanced FastComments Configuration</h3>
36 <p>Dive deep into the advanced configuration options for FastComments...</p>
37 <div class="post-meta">
38 Published: March 10, 2024 |
39 <span class="fast-comments-count comment-count" data-fast-comments-url-id="advanced-fastcomments-config"></span>
40 </div>
41</div>
42
43<div class="blog-post">
44 <h3>FastComments vs Other Solutions</h3>
45 <p>See how FastComments compares to other commenting solutions...</p>
46 <div class="post-meta">
47 Published: March 5, 2024 |
48 <span class="fast-comments-count comment-count" data-fast-comments-url-id="fastcomments-comparison"></span>
49 </div>
50</div>
51
52<script>
53 window.FastCommentsBulkCountConfig = {
54 tenantId: 'demo'
55 };
56</script>
57

성능 고려사항

벌크 위젯은 다음을 통해 자동으로 성능을 최적화합니다:

  • 요청 일괄 처리: 단일 API 호출로 여러 댓글 수를 가져옴
  • 요청 크기 제한: URL 목록이 너무 길어지면(1,000자 초과) 요청이 자동으로 분할됨
  • 중복 제거: 동일한 data-fast-comments-url-id를 가진 여러 요소가 동일한 수를 공유

동일한 URL ID를 가진 여러 요소

동일한 data-fast-comments-url-id를 가진 여러 요소를 페이지에 배치할 수 있습니다. 모두 동일한 수로 업데이트됩니다:

Multiple Elements Same URL ID
Copy CopyRun External Link
1
2<script src="https://cdn.fastcomments.com/js/embed-widget-comment-count-bulk.min.js"></script>
3
4<style>
5 .count-example {
6 margin: 10px 0;
7 padding: 10px;
8 background: #f9f9f9;
9 border-radius: 5px;
10 }
11</style>
12
13<div class="count-example">
14 Header Count: <span class="fast-comments-count" data-fast-comments-url-id="shared-article"></span>
15</div>
16
17<div class="count-example">
18 Sidebar Count: <span class="fast-comments-count" data-fast-comments-url-id="shared-article"></span>
19</div>
20
21<div class="count-example">
22 Footer Count: <span class="fast-comments-count" data-fast-comments-url-id="shared-article"></span>
23</div>
24
25<script>
26 window.FastCommentsBulkCountConfig = {
27 tenantId: 'demo'
28 };
29</script>
30

로컬라이제이션

벌크 위젯은 FastComments 언어 설정에 따라 자동으로 댓글 수를 포맷합니다. 다음에 대한 적절한 텍스트를 제공합니다:

  • 댓글 없음
  • 댓글 1개
  • 여러 댓글

벌크 vs 싱글 위젯 사용 시점

벌크 위젯 사용 시:

  • 동일한 페이지에 여러 댓글 수가 있는 경우
  • 댓글 수가 있는 게시물/기사 목록을 표시하는 경우
  • 성능이 중요한 경우 (API 호출 감소)

싱글 위젯 사용 시:

  • 페이지에 댓글 수가 하나만 필요한 경우
  • 실시간 업데이트가 필요한 경우 (싱글 위젯은 실시간 업데이트 지원)
  • 개별 위젯 동작을 더 세밀하게 제어하고 싶은 경우

FastComments 댓글 수 위젯은 사이트 전반에 걸쳐 댓글 수를 표시하는 간단하고 효율적인 방법을 제공합니다.

이 문서가 도움이 되었기를 바랍니다.