June 22nd, 2024

Adding view count and like button to 11ty

The article explains adding view count and like button to an 11ty blog using Express and Vercel serverless functions. It details challenges, solutions, code snippets, and suggests Next.js for easier integration.

Read original articleLink Icon
Adding view count and like button to 11ty

This article discusses the process of adding a view count and like button to an 11ty blog using Express and Vercel serverless functions. The author describes the challenges faced due to limitations on Vercel, which led to the need for a serverless approach. By combining 11ty with Express and Vercel KV for storage, the author outlines the steps to create APIs for handling likes and views. The article provides code snippets for implementing these features and highlights the importance of setting up proper APIs in the server.js file. The author also shares insights into the difficulties encountered during the implementation process and suggests alternatives like Next.js for easier feature integration. Overall, the article serves as a guide for developers looking to enhance their 11ty blogs with interactive elements like view counts and like buttons.

Related

AdonisJS

AdonisJS

AdonisJS is a TypeScript-first web framework for Node.js, emphasizing type-safety, intellisense, and performance. It offers testing support, official packages like Lucid for SQL ORM, Auth for authentication, and a vibrant community.

Farm: Fast vite compatible build tool written in Rust

Farm: Fast vite compatible build tool written in Rust

Farm is a Rust-based web building engine for efficient web programming. It accelerates React/Vue projects with fast updates, incremental building, module-level caching, and support for popular technologies like Sass, Less, Vue, and React.

Exposition of Front End Build Systems

Exposition of Front End Build Systems

Frontend build systems are crucial in web development, involving transpilation, bundling, and minification steps. Tools like Babel and Webpack optimize code for performance and developer experience. Various bundlers like Webpack, Rollup, Parcel, esbuild, and Turbopack are compared for features and performance.

My weekend project turned into a 3 years journey

My weekend project turned into a 3 years journey

Anthony's note-taking app journey spans 3 years, evolving from a secure Markdown tool to a complex Electron/React project with code execution capabilities. Facing challenges in store publishing, he prioritizes user feedback and simplicity, opting for a custom online deployment solution.

Microfeatures I love in blogs and personal websites

Microfeatures I love in blogs and personal websites

The article explores microfeatures for blogs and websites inspired by programming concepts. It highlights sidenotes, navigation tools, progress indicators, and interactive elements to improve user experience subtly. Examples demonstrate practical implementations.

Link Icon 3 comments
By @bastawhiz - 5 months
The HSET calls are not just unnecessary, they're a bug. It introduces the possibility of a race condition where a view or like happens between the HGET and HSET. HSETing the values to zero doesn't actually make anything faster or more correct, it just introduces the possibility of overwriting a value that came in moments ago.
By @jsheard - 5 months
There doesn't seem to be a limit to how many times a reader can smash that like button, which brings a new degree of expression to smashing that like. You can smash that like 10 times the article was good, 100 times if it was amazing, or 100 million times if you hated it and want the author to be bankrupted by their Vercel bill.
By @d3v1an7 - 5 months
Only semi-related, I have also found the 11ty docs lacking from time to time, but don’t really have a great idea in my head about what good docs look like vs bad ones.

If you have a moment, I’d love to hear why you think these are exceptionally bad docs, and some examples or thoughts on what you feel are excellent docs!

We use and financially support 11ty at work, so if it’s something I can manage, I’d like to help make the docs better over time.