Features

Comment counts

Display the number of comments next to each post on your homepage and listing pages.

A "5 comments" link under each post title tells readers there is a conversation worth joining. Connect exposes a public endpoint that returns comment counts for up to 100 pages in one request, so a listing page costs a single call.

The endpoint

GET https://api.hakanai.io/api/connect/widget/counts?key=YOUR_SITE_KEY&identifiers=ID1,ID2,ID3
  • key: your site's public key, the same one as in the widget snippet.
  • identifiers: comma-separated list of page identities, up to 100 per request.

Each identifier is either a page id (if your widget uses data-page-id) or a full page URL (if you use the default URL identity). Use exactly what identifies your threads, see page identity; an identifier that matches no thread simply returns 0.

The response echoes your identifiers as keys:

{
  "counts": {
    "https://myblog.com/first-post": 5,
    "https://myblog.com/other-post": 0
  }
}

Only approved comments are counted.

Wiring it up

Add an element per post in your listing template, carrying its identifier:

<span data-connect-count="https://myblog.com/first-post"></span>

Then one script, at the end of the page, collects the identifiers, makes the request, and fills the elements in:

<script>
(function () {
  var els = document.querySelectorAll('[data-connect-count]')
  if (els.length === 0) return
  var ids = Array.prototype.map.call(els, function (el) {
    return el.getAttribute('data-connect-count')
  })
  var url = 'https://api.hakanai.io/api/connect/widget/counts'
    + '?key=YOUR_SITE_KEY'
    + '&identifiers=' + encodeURIComponent(ids.join(','))
  fetch(url)
    .then(function (r) { return r.json() })
    .then(function (data) {
      els.forEach(function (el) {
        var count = data.counts[el.getAttribute('data-connect-count')] || 0
        el.textContent = count === 1 ? '1 comment' : count + ' comments'
      })
    })
})()
</script>

Adapt the label logic to your language and taste; some sites prefer hiding the element entirely at zero rather than advertising an empty thread.

The per-SSG guides show how to emit the data-connect-count elements from your templates: Hugo, Astro, Jekyll, Eleventy, Nuxt.

Limits

The endpoint is rate limited per visitor IP, generously enough for normal browsing. If a listing page has more than 100 posts, batch the identifiers into several requests, or reconsider showing counts that far down the archive.

Hakanai • © 2026