Count tag
The <comentario-count>
tag inserts a widget displaying the number of comments on a page
The <comentario-count>
tag represents an optional widget that displays the number of comments on the current or any other specified page.
Like the “main” comments tag, it also requires a script tag being added to the same page, and it’s also a web component.
This tag marks the location for the displayed comment count. After Comentario engine is initialised, the comment count will appear inside the corresponding HTML element.
Customising the element
You can further customise this element by adding attributes to the <comentario-count>
tag. Available attributes are summarised in the table below.
Attribute | Description | Default value |
---|---|---|
error-text | Text to display if fetching the count fails for any reason | "?" |
path | Path (URL) of the page to display comment count for | Current page’s path |
placeholder | Text to display before the count becomes available | "" |
prefix | Text that prefixes a successfully fetched, non-zero count | "" |
suffix | Text that suffixes a successfully fetched, non-zero count | "" |
zero-text | Text to display if count is zero | prefix + "0" + suffix |
Here’s an example of a customised <comentario-count>
tag:
<comentario-count path="/blog/post/123"
placeholder="..."
error-text="ERR"
zero-text=""
prefix="("
suffix=")"></comentario-count>
The error-text
attribute of the count tag can be used to override the text displayed in the element whenever it encounters a problem with retrieving the data from the server.
The path
attribute of the count tag can be used to specify a different page to display the number of comments for.
The placeholder
attribute of the count tag can be used to specify the text initially displayed in the element.
The prefix
attribute of the count tag can be used to prepend the displayed number with a custom string.
The suffix
attribute of the count tag can be used to append a custom string to the displayed number.
The zero-text
attribute of the count tag can be used to override the text displayed in the element when its value is 0
.