VirtusLab-Open-Source / strapi-plugin-comments

A plugin for Strapi Headless CMS that provides end to end comments feature with their moderation panel, bad words filtering, abuse reporting and more.
MIT License
407 stars 63 forks source link

Adding comments to a static-generated website #42

Closed davestewart closed 2 years ago

davestewart commented 3 years ago

Hi there,

Sorry this is more of a use-case question rather than a bug report, but I'm wondering if this plugin could be used to create a commenting system that could be used in conjunction with a static site like Hugo, Jekyll, VuePress, etc.

Obviously with those sites, there would not be a parent article in any database, but maybe there are ways round this?

One idea might be some kind of build script for the static site that could generate "placeholder" articles in the strapi database, then on the flip side, when a comment is left, perhaps a webhook could be fired used to re-generate the static site?

I'm not yet a Strapi user (but recently discovered the project and am trying to learn about it) so sorry if any of this is missing the fundamentals, but I wanted to start a conversation and take it from there.

Thanks, Dave

cyp3rius commented 3 years ago

Hi @davestewart by design comments require related to be present. Based on what you wrote that seems script with "placeholder" article might be an option. If you connect it with Strapi webhook enabled for Comment create / update action that might work. It just need to call a Lambda or any other endpoint that will generate your static content again.

debatz commented 3 years ago

@cyp3rius There shouldn't be a problem doing this with 11ty. You can easily use Strapi as a CMS for Eleventy by having 11ty ask Strapi what's in store for each rebuild. 11ty asks and stores all of it on its Global Data "_data" folder and that's it. You can then dinamically display them using Nunjucks and filters.

I wouldn't recommend rebuilding the whole site every time a comment is posted (although you could), but to just display a notice like "Your comment has been posted. Check back in a while. Please note we don't post comments live." or something along those lines. That way you can schedule X amount of rebuilds a day and be more efficient.

Hope this helps.