npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@washingtonpost/talk-plugin-comment-count

v0.0.6-beta

Published

This plugin enables a simple little embed that can live alongside any given Talk install

Downloads

65

Maintainers

jondavenportwapojondavenportwapomarcostarafwashpostmarcostarafwashposttab00tab00alvaror2walvaror2wclau8aclau8ajosevazqueznpmjosevazqueznpmvithalanisvithalanistomkaz-wapotomkaz-wapogiomarwizegiomarwizeflaviopsantannawapoflaviopsantannawapovladimirjvvladimirjvjmiguelfloresgjmiguelfloresgkarklislkarklislallidinatallidinatalvarovalinoalvarovalinotawaddytawaddyfernandowzfernandowznikki.brimmernikki.brimmermoodypmoodypdiegodisantdiegodisanthrechthrechtmalocuevimalocuevialbertcastanedalbertcastanedchen-joshchen-joshericlauericlaumaimaimai-bitmaimaimai-bitlmnalandlmnalandmballenwp1mballenwp1hannah.goodhannah.goodgregmanifoldgregmanifolddnparmardnparmarcatherine1234catherine1234mfernanda-sosamfernanda-sosadev-javudev-javuvviswavviswanetolm-wpnetolm-wpharmanwapoharmanwapolpadillac4slpadillac4scashackcashackjoshhoegenjoshhoegenalefkowalefkowysmildeysmildeshrddhawashpostshrddhawashpostkarenwangkarenwangcarsonologycarsonologyyuyanleiyuyanleidbnappdbnappcolemanc4colemanc4stevethedevstevethedevdkaodkaoelenalaceyelenalaceyzhoyoyozhoyoyodwuandjunedwuandjunefransandifransandiashendrukashendrukmichaeldominemichaeldominemark-a-wapomark-a-waposabrinamochisabrinamochijorgemhc-devjorgemhc-devcarlyncarlyndgreen19dgreen19josephjamesjosephjamesniko_komniko_komnicrocsnicrocsavalbuenaavalbuenasotojlsotojlhaileyhaymondhaileyhaymondlukaskeelwapolukaskeelwapotimborisenkotimborisenkokt-prrykt-prryjesse.post.washpojesse.post.washpothreeteaspoonsthreeteaspoonsluciovillaluciovillatam.stephtam.stephagillespieagillespieani512ani512vonoehsenevonoehseneemmakumeremmakumeraggyjleeaggyjleelavanderoilavanderoiemily.engemily.englmelgarlmelgarsadbumblebeesadbumblebeejanicekchenjanicekchenjamelhendricksjamelhendrickscrunchwrap78crunchwrap78welchkwelchkval-l-hoslerval-l-hoslernick.mourtoupalasnick.mourtoupalasbenjakibenjakibattandbattandjon.rosadojon.rosadojacknugent27jacknugent27asamireissaasamireissacourthcourthmahigmahigjchaskelljchaskelllorenzoglorenzogln-washpostln-washpoststericsonstericsontalpert022talpert022gengelgengeltuckabelletuckabellenauticaharvinnauticaharvinaadittambeaadittambenatalievinebergnatalievinebergkrbrookskrbrookskatty-huertaskatty-huertasmariaalconadabrooksmariaalconadabrooksjuniorh28juniorh28atomictangerineatomictangerinehelmschelmsctriticotriticopranavganorepranavganoredanacasidydanacasidyterrywpterrywpksemanur8ksemanur8dreyvitserdreyvitsermvoneshmvoneshchelseaconradchelseaconradarnolda-wparnolda-wphermionewyhermionewywp-abergwp-abergsheamus-heisheamus-heihaysstephaniehaysstephaniebroadwaternebroadwaterneandrevincandrevinckat-alokat-alodaniellersauldaniellersaulstevefuenteswpstevefuenteswprekha26rekha26marcnahedmarcnahedamiemunozamiemunozmartinezymartinezyseanwaposeanwapoducroquetducroquetjakekarajakekarajtotoolejtotoolemjperalesmjperalesarturgalochaarturgalochaebgrangerebgrangerramyalamatiramyalamatiadamsrobwadamsrobwluke.connorsluke.connorswrneffwrneffmcdohmcdohfloresafloresataliatrackimtaliatrackimlennybronnerlennybronnerbitsoglassbitsoglassit_procurementit_procurementdavidchaiwapodavidchaiwapomaddoxnelsonmaddoxnelsonstephanie.clarkstephanie.clarkjasonvuongjasonvuongjkoo87jkoo87kankelcrkankelcrgregoryauld2014gregoryauld2014uncompileduncompiledjbrown4jbrown4scarothersscarotherskhan.salauddinkhan.salauddinrowhawnrowhawnsubs-npm-buildersubs-npm-buildernealhumphreywaponealhumphreywapoashlynstillashlynstillptnielsenptnielsenleslie-sleslie-scourtney-kancourtney-kankevin.schaulkevin.schauljakecrumpjakecrumpmacallahmacallahjmuyskensjmuyskensmadisonwallsmadisonwallsbrianaabrianaadsantamarinadsantamarinaartmsilvaartmsilvaashtolashtolsberhanusberhanujjalcantarajjalcantaraalyssa.fowersalyssa.fowersjoemfoxjoemfoxreubenfbreubenfbcalcantaracalcantaraadrianblancoadrianblancochiquiestebanchiquiestebaniuraizeeiuraizeebdgrossbdgrossulmonicaulmonicabmferrillbmferrilldankeatingdankeatingtimmekotimmekokevinuhrmacherkevinuhrmachershellytanshellytanharrystevensharrystevenschrisrukanchrisrukanallisonnmannallisonnmannaaronsteckelbergaaronsteckelbergshruthagandlashruthagandlabrafordabrafordaadityajain15adityajain15linorabolinilinorabolinianthonyjpesceanthonyjpesce1313davidlee1313davidleekate.rabinowitzkate.rabinowitzfontcfontccecepascualcecepascualvsingarayarvsingarayararamzsaramzsruxkruxknader_heidarinader_heidarithompsond3thompsond3tylerremmeltylerremmeltmac0201tmac0201joemoore-postjoemoore-postealvarez79ealvarez79hdormidohdormidosgpottssgpottsyutaochenyutaochennwalker_wpnwalker_wpapbestapbestbriannaschroerbriannaschroershikha-subshikha-subnaemanaemachloemeisterchloemeisterjulia.ledurjulia.ledursolomonsscottsolomonsscottbetchavarriabetchavarriaeewrighteewrightnickkirkpatricknickkirkpatricktrann_wapotrann_wapotobefrankhjtobefrankhjessiekimessiekimsergio.pecanhasergio.pecanhameganwaltermeganwalteralyssabartuchalyssabartuchalexisbarnesalexisbarnesdmoriarty6dmoriarty6mokhtar.alimokhtar.alidpham5dpham5klimenkovdklimenkovddavisshaverdavisshaveraaronbrezelaaronbrezelkastningjkastningj

Keywords

Readme

talk-plugin-comment-count

This plugin enables a simple little embed that can live alongside any given Talk install:

<!-- By default, the /static/embed/count.js will replace the contents of the element targeted by the .talk_comment_count selector. Adding the href="#talk_embed" will allow when you click the comment count, it will jump to the comments! -->
<a href="#talk_embed" class="talk_comment_count">Comments</a>
<script src="{{ TALK_URL }}/static/embed/count.js"></script>

<!-- ... -->

<div id="talk_embed"></div> <!-- The div where the Talk embed will load. -->
<script src="{{ TALK_URL }}/static/embed.js" onload="
  Coral.Talk.render(document.getElementById('talk_embed'), {
    talk: '{{ TALK_URL }}'
  })
"></script>

Which will add the comment count to the page on the selected element! It'll even be translated!

Installing

Currently in beta!

Modify/create your plugins.json file to include the plugin:

{
  "server": [
    // ...
    {"@washingtonpost/talk-plugin-comment-count": "^0.0.6-beta"},
    // ...
  ],
  "client": [
    // ...
  ]
}

Which will enable it. You then need to add the /static/embed/count.js file on your HTML page, which will allow the file to be generated that will add the comment count.

URL Options

The reference to the /static/embed/count.js accepts query parameters which you may combine in any order you choose:

  • id (optional, but highly recommended) - if provided it will lookup the counts for the asset directly, possibly without even hitting MongoDB.
  • url (optional) - if provided, it will lookup the asset referenced by the url and return the count, this should be the same URL that you provide the Talk widget directly.
  • selector (optional, defaults to .talk_comment_count) - if provided, you can specify a selector where all matching elements will have their innerText replaced by the comment count.
  • notext (optional) - when specified, it will not add the Comment(s) text to the element, and will only replace the count. By default, it will include the translated text version of Comment(s).

Note that these parameters are required to be URI encoded, you can utilize the encodeURIComponent method to encode each parameter.

Examples

Get the comment count for a specific Asset by ID:

/static/embed/count.js?id=a-specific-asset-id

Get the comment count for a specific Asset by URL:

/static/embed/count.js?url=https%3A%2F%2Fcoralproject.net%2Fblog%2Fhappy-hacktoberfest%2F

Configuration

You can specify the following environment variables that can customize how the comment count files that are generated are cached:

  • TALK_COMMENT_COUNT_CACHE_DURATION (default 2m) - a string representing the duration of time that a given count will have it's file cached for. Formatted via ms.
  • TALK_COMMENT_DETECT_COUNT_CACHE_DURATION (default 1h) - a string representing the detection script will have it's file cached for. Formatted via ms.

These will be manifested when the /static/embed/count.js file is served with the appropriate query parameters via the Cache-Control header.

Example

TALK_COMMENT_COUNT_CACHE_DURATION=1m
TALK_COMMENT_DETECT_COUNT_CACHE_DURATION=10m

GET /static/embed/count.js?id=123
Cache-Control: public, max-age=60

GET /static/embed/count.js
Cache-Control: public, max-age=600

Loading Strategies

In order to facilitate easy loading, the /static/embed/count.js script will try various strategies to determine which Asset is being referenced.

  1. If the id is specified, then return the count for the asset with that ID.
  2. If the url is specified, then return the count for the asset referenced by that URL.
  3. If the element targeted by the selector contains a data-talk-id= parameter, it will be used in step 1.
  4. If the element targeted by the selector contains a data-talk-url= parameter, it will be used in step 2.
  5. If the page contains a canonical url tag, the URL will be inferred from that, and will be used in step 2.
  6. The URL of the page will be inferred from the current page url, and will be used in step 2.

License

Released under the Apache License, v2.0.