Simple implementation of zola-theme-serene's anonymous reaction api endpoint.
Follow the instructions below to deploy your own endpoint. All you need is a Cloudflare account. The free tier is good enough for low-traffic sites, such as a personal blog.
- Server Framework: Hono
- Server Environment: Cloudflare Workers
- Database: Cloudflare D1
- A Cloudflare account
- Have
node
(alone withnpm
andnpx
) installed - Have
pnpm
installed, you can install it by runningnpm install -g pnpm
-
Use this template to create a new repository of your own
-
Clone your repository to your local machine
-
Run
pnpm install
-
Setup database
- Run
npx wrangler d1 create reaction
to create the database - Then paste the output to
wrangler.toml
:[[d1_databases]] binding = "DB" database_name = "reaction" database_id = "<unique-ID-for-your-database>"
- Run
npx wrangler d1 execute reaction --remote --file=./schema.sql
to initialize the database
- Run
-
Config the environment variables in
wrangler.toml
:[vars] ORIGINS = ["https://<your-username>.github.io"] # Your site's origins, can be more than one EMOJIS = ["👍", "👀", "😠"] # Default emojis for each post SLUGS = [ # Slugs of your every post "first-post", # For `https://<your-username>.github.io/blog/first-post/`, the slug is `first-post` "second-post", ["third-post", ["👍", "🥳", "😅", "😡"]], # You can also specify the emojis for each post ]
-
Deploy the worker
- Run
pnpm run deploy
- Your deployed endpoint will be available at
https://reaction.<your-cloudflare-username>.workers.dev
- Run
-
In your zola site's
config.toml
:reaction = false reaction_align = "right" reaction_endpoint = "https://reaction.<your-cloudflare-username>.workers.dev"