- Sign up and sign in to Cloudflare https://dash.cloudflare.com/sign-up.
- In your Cloudflare dashboard, select the
Domain Registration > Register Domains
tab. - Search for your favorite domain and purchase it. In my case, I purchased the domain https://nivethan.me/ for my portfolio.
- Sign in to Vercel and go to your dashboard, where you can see all your projects in the
Overview
tab. - Click on a project and on the top right, select
Domains
. - Type your domain in the text box, e.g.,
nivethan.me
, and clickAdd
. - Select the recommended option:
Add www.nivethan.me and redirect nivethan.me to it
. - Vercel will show an invalid configuration under your domains and display the relevant A record IP under
nivethan.me
and a CNAME IP underwww.nivethan.me
. These need to be set up on Cloudflare to make it work.
-
Create a fresh new Next js project. https://nextjs.org/docs/getting-started#automatic-setup
pnpm create next-app --typescript
-
install prettier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Writen for a Chrome extension. It checks for a specific element on the page and calls a callback when it's found. | |
// Returns an element and all its child elements. | |
const getAllElements = (node: Node): Element[] => { | |
if (!(node instanceof Element)) { | |
return []; | |
} | |
const nodes = [node]; | |
if (node.childNodes) { | |
nodes.push(...[...node.childNodes].flatMap(getAllElements)); |