javascript

Posts

Inject HTML content into an Astro component

While working on a project within the Astro framework, I encountered a scenario where I needed to fill HTML content within a script tag.

Formatting Big Numbers in JavaScript

When working with large numerical values in JavaScript, it can be challenging to display them in a way that's easy to read and understand. In this blog post, we'll explore techniques for formatting big numbers in JavaScript with built-in methods.

Changing Document Field Types with MongoDB

This article explains how to convert document field types during query execution and how to use MongoDB's built-in aggregation operators $convert. The article also provides practical examples and code snippets to demonstrate how to change field types in MongoDB.

How to use Chakra UI Button and Link components with NextJS Link

There is some glue to add to make Chakra UI and NextJS work together. The Chakra UI components do not generate the "a" tag by default for a link. Let's see how to use the Chakra button to generate links between pages.

Extends Express session SessionData type

Express Session allows to store a lot of different data. There is a Typescript type named `SessionData` which allow to know what contains a session but not the data you will defined after without defining them.

Keep the same Node.js version between local environment and Github Actions

It can be complicated to have the same Node version between the local environment and the CI/CD. The latest Node.js version or the latest lts is released recently and if you want to upgrade to the Node version, usually you can forget to configure one environment.

Convert a JavaScript object to queryparams string

This post describes two very simple ways to convert a JavaScript object to a querystring both in a browser environment or server environment.

ESLint Global Variables

When we use some global variables defined elsewhere, eslint throws an error saying the variable is not defined. Here is how to configure eslint to ignore those.

Extend Window type with Typescript

Some of the object properties or functions are not available in the Typescript Window type. Let see a way to extend the Window type with the missing properties.

Gatsby + Netlify CMS + TailwindCSS Starter

Just created a new starter coming from some of my website development and powered with Gatsby.

How to render a React element to an HTML string?

What happens when you want to render a React string to HTML? For some reasons, you may want to have the generated HTML string from your React component instead of a mounted component and render it on the page.

How to manage Internationalization with NextJS SSG

Staticaly generating a website with the NextJS framework in different languages is not so obvious.

How to render emojis with JavaScript

For the content of your posts, emojis add some fun to your pages. This short post explains how to make that possible in JavaScript.

Update NodeJS with npm

New NodeJS releases are done often, so you need to keep your installation up to date. To do so, you can use your Linux distribution package manager (apt, dnf, ...) or brew for OSX. Another way is to use npm..

Snippets

Create layout with HandlebarsJS

Layout template is a good practice to not repeat ourselves (DRY). Handlebars templates engine does not provide a layout feature out of the box but it still is possible to create a layout. principle. Handlebars template engine, there is no out-of-the-box layout feature but it is possible to create a layout.

Create layout with HandlebarsJS

NestJS Project Dockerfile

A Dockerfile to build production-ready NestJS app docker image.

NestJS Project Dockerfile

Node Typescript Project Dockerfile

A Dockerfile to build production-ready Node Typescript docker image.

Node Typescript Project Dockerfile

Rename the extension of multiple files with bash script on Mac and Linux

A bash script snippet to rename recursively multiples files extension from the current directory.

Rename the extension of multiple files with bash script on Mac and Linux