FastComments.com

FastComments biedt lichtgewicht, zelfstandige widgets die het aantal reacties voor specifieke pagina's of berichten kunnen weergeven. Deze widgets zijn losstaand van de hoofdcommentaarwidget en zijn ontworpen voor gebruik op elke plek waar je het aantal reacties wilt tonen zonder de volledige commentaarinterface.

Er zijn twee soorten widgets voor het aantal reacties beschikbaar:

  1. Widget voor aantal reacties - Voor het weergeven van het aantal reacties van een enkele pagina
  2. Bulk-widget voor aantal reacties - Voor het efficiënt weergeven van aantallen reacties van meerdere pagina's op dezelfde pagina

Dit artikel behandelt de VanillaJS-widgets. Onze React/Angular/etc bibliotheken hebben ook hun eigen widgets.


Installatie van de widget voor reactietelling Internal Link

De Comment Count Widget is ontworpen om het aantal reacties van een enkele pagina weer te geven. Het is lichtgewicht en biedt realtime updates indien geconfigureerd.

Basis Installatie

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

Configuratie Opties

De FastCommentsCommentCount functie accepteert de volgende configuratieopties:

  • tenantId (vereist): Uw FastComments tenant ID
  • urlId (optioneel): De pagina-identifier. Standaard is window.location.href indien niet gespecificeerd
  • numberOnly (optioneel): Indien true, wordt alleen het nummer zonder tekst weergegeven. Standaard is false
  • isLive (optioneel): Indien true, wordt de telling automatisch bijgewerkt. Standaard is false

Geavanceerde Voorbeelden

Aangepaste 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

Alleen Nummer Weergave

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 Updates

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

Widget Methodes

De widget retourneert een object met de volgende methodes:

  • destroy(): Verwijdert de widget en ruimt alle timers op
  • update(config): Werkt de widget bij met een nieuwe configuratie

Voorbeeld Gebruik

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

Styling

De widget rendert gewone HTML met het aantal reacties en komt met minimale styling. U kunt het uiterlijk aanpassen met 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

Bulkinstallatie van widgets voor reactietelling Internal Link

De Bulk Comment Count Widget is ontworpen voor het efficient weergeven van commentaartellingen voor meerdere pagina's op dezelfde pagina. In plaats van individuele API-aanroepen te maken voor elke commentaartelling, bundelt deze widget verzoeken voor optimale prestaties.

Basis Installatie

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

Hoe Het Werkt

De bulk widget werkt door:

  1. De pagina te scannen naar elementen met de klasse fast-comments-count
  2. Het data-fast-comments-url-id attribuut van elk element te lezen
  3. API-verzoeken te bundelen om meerdere commentaartellingen efficient op te halen
  4. Elk element bij te werken met de juiste commentaartelling

Configuratie Opties

De FastCommentsCommentCountBulk functie accepteert de volgende configuratieopties:

  • tenantId (vereist): Uw FastComments tenant ID
  • apiHost (optioneel): Aangepaste API-host als u een zelf-gehoste instantie gebruikt

Praktijkvoorbeeld

Hier is een praktisch voorbeeld dat laat zien hoe u de bulk widget kunt gebruiken in een blogpost-overzicht:

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

Prestatie Overwegingen

De bulk widget optimaliseert automatisch de prestaties door:

  • Verzoeken bundelen: Meerdere commentaartellingen worden opgehaald in een enkele API-aanroep
  • Verzoekgrootte limieten: Verzoeken worden automatisch opgesplitst als de URL-lijst te groot wordt (meer dan 1.000 tekens)
  • Deduplicatie: Meerdere elementen met dezelfde data-fast-comments-url-id delen dezelfde telling

Meerdere Elementen met Dezelfde URL ID

U kunt meerdere elementen op de pagina hebben met dezelfde data-fast-comments-url-id. Ze worden allemaal bijgewerkt met dezelfde telling:

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

Lokalisatie

De bulk widget formatteert automatisch commentaartellingen op basis van uw FastComments taalinstellingen. Het biedt passende tekst voor:

  • Nul reacties
  • Een reactie
  • Meerdere reacties

Wanneer Bulk vs Single Widget Gebruiken

Gebruik de Bulk Widget wanneer:

  • U meerdere commentaartellingen op dezelfde pagina heeft
  • U een lijst van berichten/artikelen met commentaartellingen weergeeft
  • Prestaties belangrijk zijn (vermindert API-aanroepen)

Gebruik de Single Widget wanneer:

  • U slechts een commentaartelling op de pagina nodig heeft
  • U live updates nodig heeft (de single widget ondersteunt realtime updates)
  • U meer controle wilt over het gedrag van individuele widgets

De FastComments-widgets voor reactietellingen bieden een eenvoudige en efficiënte manier om het aantal reacties op uw site weer te geven.

We hopen dat u deze documentatie nuttig vond.