Hi all – We’ve had a lot of discussion and deep sadness over the lack of a good commenting system for static sites (or just sites).
Kenton Varda does a good job of introducing Cloudflare Workers in this post.
What I’m thinking is that clicking on a button to comment could trigger a Worker. And that a Worker could update the page with the new comment by sending JSON over. That would require that the web server append the data to the page, and probably also to a backup comment flat file or database. Is this making sense?
What do you think? I don’t know JS very well – does it sound feasible?
Cloudflare Workers are a great product! I happily use them on a few websites now, primarily for speed and security.
clicking on a button to comment could trigger a Worker.
This is possible by having the Worker monitor the URLs, and kick into action when a certain URL is requested. You could for instance have that button link to example.com/my-post/submit-comment.
I’m not sure how you’d send information from a page into a Worker, but perhaps by submitting a form?
And that a Worker could update the page with the new comment by sending JSON over.
Workers can read the content from a page that they are going to send over to the user requesting the page, so you could insert comments dynamically that way too. Or of course bundle the comments as a JSON file and have the user’s client-side code show the comments.
That would require that the web server append the data to the page, and probably also to a backup comment flat file or database.
Well the Worker can append the data to the page, so the static website doesn’t have to run on an actual server and something like S3 can do.
The Worker will then later need to fetch those comments.
So that other data can be on an actual server. But you can go serverless as well, I think. If an AWS Lambda or Azure Function monitors a URL, you can have the Worker submit a request for that URL and have the serverless function fetch the comment data, and then return it to the Worker as a JSON file. And you could use another URL that a Lambda/Function runs on to act as the ‘data updater’ when a URL request is make to that Lambda/Function.
(This latter is in theory, I haven’t build that. Just thinking along here.)
However, note that Cloudflare workers are not free. At $5 per month minimum, you are on your way to a low-cost VPS.
As @Jura say’s, you’d still need something like Lambda functions to process the comments and a database to store them.
If you are doing that without any kind of authentication, you are asking for loads of spam trouble. If you are asking for authentication, you need to manage the identities (and to deal with the GDPR and other local laws) or hand that off to a 3rd party which puts you right back at the heart of the problem people seem to be having with Disqus in the first place.