alanplotko / alanplotko.github.io

Personal website.
https://alanplotko.com
0 stars 0 forks source link

Add comments and likes to posts #45

Open alanplotko opened 2 years ago

alanplotko commented 2 years ago

Reviewing the Options

Comments

Likes

Self-hosting

External Hosting

Brainstorming

Heroku allows running a free web dyno for 1000 hours a month if the account is verified. Given 31 days * 24 hours = 744 hours in a month at most, you can run 24/7 with pinging services like New Relic to keep the dyno from sleeping. That still leaves enough for one-off dynos on the side if needed.

There aren't many options that handle both likes and comments in one dyno, so either:

  1. Extend likes into an existing node option, e.g. Staticman is basically just running a bunch of routes, and more can be added for counting likes and then deployed altogether on a dyno.
  2. Separate likes and comments into Heroku and something else.

Approach

Let's go with option 2.

Staticman can be hosted with Heroku and is the most lightweight to embed into the Jekyll blog (it's static!). Testing can be done with create sample data files with comments. Staticman can also be deployed via netlify as a serverless function.

The Cloudflare KV store offering is sufficient to track likes and caching can be implemented at edge. The like counter is a simple increment, following Medium system of up to 50 points per user. The browser's local storage can track capacity up to 50 point allotment.

alanplotko commented 2 years ago

Upgraded from Cloudflare KV to Mongo Atlas + Realm. Backups can be done with tools like docker-mongodump for a M0 free instance. While 512mb < 1gb with Cloudflare, there are much higher limits in requests.

alanplotko commented 2 years ago

~- TODO: Move to custom claps JS on frontend.~ Overhaul of claps completed in ddccfba03b5f2e545e12e52875baff6034d1b66a.