<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Dev Diary RSS Feed]]></title><description><![CDATA[I’m Mark and I write tutorials about JavaScript, React, typography, performance, and many more.]]></description><link>https://markoskon.com</link><generator>GatsbyJS</generator><lastBuildDate>Fri, 27 Mar 2026 07:17:06 GMT</lastBuildDate><item><title><![CDATA[Exclude directories (and avoid traversing) with find ]]></title><description><![CDATA[Exclude directories (and avoid traversing) with find ]]></description><link>https://markoskon.com/find-prune-directories/</link><guid isPermaLink="false">https://markoskon.com/find-prune-directories/</guid><pubDate>Tue, 06 Jan 2026 11:00:00 GMT</pubDate><content:encoded>&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ find &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -name &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;node_modules&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    -or -name &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.git&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -prune \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  -or -type f -print&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And this for directories:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ find &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -name &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;node_modules&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    -or -name &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.git&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -prune \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  -or -type d -print&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So, if you want to ignore directories, a good rule of thumb is to put the prune stuff first, and then specify what you want to print. Additionally, don’t forget to put an explicit print at the end. See the questions below for more.&lt;/p&gt;&lt;p&gt;If you have many paths you can use regex:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ find &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    -regextype posix-extended \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    -type d \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    -regex &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.*\/\.?(node_modules|git|public|cache|next|coverage).*&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -prune \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  -or \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    -type d -print&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ find &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    -regextype posix-extended \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    -type d \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    -regex &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.*\/\.?(node_modules|git|public|cache|next|coverage).*&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -prune \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  -or \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    -type f -print&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Note that you can put more filters after &lt;code&gt;-type&lt;/code&gt; and before the ending &lt;code&gt;-print&lt;/code&gt;.&lt;/p&gt;&lt;h2 id=&quot;some-things-to-keep-in-mind&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#some-things-to-keep-in-mind&quot;&gt;Some things to keep in mind&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;The find expressions are evaluated from &lt;em&gt;left to right&lt;/em&gt;: “GNU find searches the directory tree rooted at each given starting-point by evaluating the given expression from left to right”&lt;/li&gt;&lt;li&gt;If we have 2 expressions separated by &lt;code&gt;-or&lt;/code&gt; and the 1st one is true, find won’t evaluate the 2nd expression.&lt;/li&gt;&lt;li&gt;If you don’t specify a command, find appends a &lt;code&gt;-print&lt;/code&gt; at the end.&lt;/li&gt;&lt;li&gt;&lt;code&gt;-prune&lt;/code&gt; all it does is to skip traversing the directory tree.&lt;/li&gt;&lt;li&gt;An expression that contains &lt;code&gt;-prune&lt;/code&gt; at the end, returns true if it prunes and false if it doesn’t prune.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;question-1-why-find----name-node_modules--or--name-git---prune-still-prints-the-node_modules-and-git-top-level-directories&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#question-1-why-find----name-node_modules--or--name-git---prune-still-prints-the-node_modules-and-git-top-level-directories&quot;&gt;Question 1: Why &lt;code&gt;find . \( -name &amp;quot;node_modules&amp;quot; -or -name &amp;quot;.git&amp;quot; \) -prune&lt;/code&gt; still prints the &lt;code&gt;node_modules&lt;/code&gt; and &lt;code&gt;.git&lt;/code&gt; top-level directories?&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ find &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -name &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;node_modules&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  -or -name &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.git&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -prune&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The man page of find states about &lt;code&gt;-prune&lt;/code&gt; that “if the file is a directory, do not descend into it”, that’s what it does, nothing more. Also, If the only action is -prune, find still appends a &lt;code&gt;-print&lt;/code&gt; that will print the pruned directory name (and avoid descending further into it off course, as a side-effect).&lt;/p&gt;&lt;p&gt;So, if you don’t want to print the pruned top-level directory, append at the end &lt;code&gt;-or expression -print&lt;/code&gt; where expression is what you want to print. This way find won’t automatically append a print at the end.&lt;/p&gt;&lt;h2 id=&quot;question-2-why-find---type-f--print--o---name-node_modules--o--name-git---prune-gives-the-same-output-as-the-canonical-form-find----name-node_modules--o--name-git---prune--o--type-f--print&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#question-2-why-find---type-f--print--o---name-node_modules--o--name-git---prune-gives-the-same-output-as-the-canonical-form-find----name-node_modules--o--name-git---prune--o--type-f--print&quot;&gt;Question 2: Why &lt;code&gt;find . -type f -print -o \( -name node_modules -o -name .git \) -prune&lt;/code&gt; gives the same output as the “canonical form” &lt;code&gt;find . \( -name node_modules -o -name .git \) -prune -o -type f -print&lt;/code&gt;?&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ find &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -type f -print -o \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -name node_modules -o -name .git &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -prune&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ find &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -name node_modules -o -name .git &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -prune \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  -o -type f -print&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The above commands give the same result and it might seem strange at first.&lt;/p&gt;&lt;p&gt;The 2nd expression, aka the “canonical form” (&lt;code&gt;find . \( -name node_modules -o -name .git \) -prune -o -type f -print&lt;/code&gt;), behaves the way it does, because, if the item is a regular file it will skip the 1st part, it will go to the 2nd and will print it (for the case when it’s a file and it’s inside a prune directory, keep reading, I explain it further down). If the item is a directory and it’s on the prune directories, it will stop descending further. If it’s a directory and it’s not on the prune directories, it will do nothing.&lt;/p&gt;&lt;p&gt;Now, I want to focus on the 1st expression, and explain how it works.&lt;/p&gt;&lt;p&gt;This question can also take the following form: Why the 1st part of the 1st expression, &lt;code&gt;-type f -print -o&lt;/code&gt; doesn’t first print all the files, even those inside the pruned directories? The reason is probably because the find expression is evaluated on each file, and the files are sorted lexicographically ascending by name. Say, for example, you have an &lt;code&gt;index.js&lt;/code&gt; file, that starts from &lt;code&gt;i&lt;/code&gt;, and a node_modules folder, that starts from &lt;code&gt;n&lt;/code&gt;, with ton of sub-folders and files. One of those enclosed files might be a &lt;code&gt;node_modules/some-package/index.js&lt;/code&gt; file, which is after &lt;code&gt;node_modules&lt;/code&gt; in order. &lt;code&gt;i&lt;/code&gt; is before &lt;code&gt;n&lt;/code&gt; in the sorting order, so the &lt;code&gt;index.js&lt;/code&gt; file will be evaluated first. It’s file, so , because of the 1st part, it’s printed. We then proceed with the top level folder &lt;code&gt;node_modules&lt;/code&gt;, that’s not a file, but a directory, so we don’t print it. It matches the 2nd part of the find expression, and it also has a prune command, so we won’t descend into it’s subdirectories and files. It doesn’t have a print command, we won’t print &lt;code&gt;node_modules&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;So that’s why we won’t print &lt;code&gt;node_modules/some-package/index.js&lt;/code&gt;, we first run the expression on the parent folder &lt;code&gt;node_modules&lt;/code&gt; that’s pruned and we don’t descend further down.&lt;/p&gt;&lt;h2 id=&quot;question-3-why-find---type-d--print--o---name-node_modules--o--name-git---prune-output-is-not-the-same-as-find----name-node_modules--o--name-git---prune--o--type-d--print-the-2-corresponding-commands-were-equivalent-for-files--type-f&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#question-3-why-find---type-d--print--o---name-node_modules--o--name-git---prune-output-is-not-the-same-as-find----name-node_modules--o--name-git---prune--o--type-d--print-the-2-corresponding-commands-were-equivalent-for-files--type-f&quot;&gt;Question 3: Why &lt;code&gt;find . -type d -print -o \( -name node_modules -o -name .git \) -prune&lt;/code&gt; output is not the same as &lt;code&gt;find . \( -name node_modules -o -name .git \) -prune -o -type d -print&lt;/code&gt;? The 2 corresponding commands were equivalent for files (-type f).&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ find &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -type d -print -o \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -name node_modules -o -name .git &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -prune&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ find &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -name node_modules -o -name .git &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -prune \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  -o -type d -print&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let’s start by stating that both of the above commands won’t print any files, they will print only directories, so we don’t have to worry about that.&lt;/p&gt;&lt;h3 id=&quot;2nd-expression&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#2nd-expression&quot;&gt;2nd expression&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;In the 2nd expression, the “canonical form” (&lt;code&gt;find . \( -name node_modules -o -name .git \) -prune -o -type d -print&lt;/code&gt;), in the 1st part of the expression, if the directory is in the prune list, find won’t further traverse it. Also, &lt;code&gt;-prune&lt;/code&gt; returns true in this case, so we won’t evaluate the 2nd part of the expression (short-circuits due to &lt;code&gt;-or&lt;/code&gt;). We didn’t have to make a note about the fact that &lt;code&gt;-prune&lt;/code&gt; returns true in the corresponding case in Q2, about the files, because it was self-evident. We were printing files, not directories, so even if &lt;code&gt;-prune&lt;/code&gt; returned false (which is not the case) and the 2nd part of the expression was evaluated, we would not have printed the directory anyway.&lt;/p&gt;&lt;p&gt;If the directory is not in the prune list, the 1st part of the expression (the &lt;code&gt;-prune&lt;/code&gt;) returns false, and, because we have an &lt;code&gt;-or&lt;/code&gt;, we also evaluate the 2nd part of the expression, and we print the directory.&lt;/p&gt;&lt;h3 id=&quot;1st-expression&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#1st-expression&quot;&gt;1st expression&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;In the 1st expression (&lt;code&gt;find . -type d -print -o \( -name node_modules -o -name .git \) -prune&lt;/code&gt;), if the directory is in the prune list, the 1st part will print it (incorrectly), it will return true and it won’t evaluate the 2nd part.&lt;/p&gt;&lt;p&gt;If the directory is not in the prune list, again, the 1st part of the expression will print it (correctly this time), it will return true and it won’t evaluate the 2nd part.&lt;/p&gt;&lt;p&gt;So, the 1st expression just prints all the directories and doesn’t prune anything. You can test that it prints all the directories with the following command: &lt;code&gt;diff &amp;lt;(find . -type d -print -o \( -name node_modules -o -name .git \) -prune) &amp;lt;(find . -type d)&lt;/code&gt;, the diff will be empty, so the 2 commands are the same.&lt;/p&gt;&lt;h2 id=&quot;question-4-why-use--prune-and-not--not--path-pathname&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#question-4-why-use--prune-and-not--not--path-pathname&quot;&gt;Question 4: Why use &lt;code&gt;-prune&lt;/code&gt; and not &lt;code&gt;-not -path &amp;quot;pathname&amp;quot;&lt;/code&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The man page of find suggests to use &lt;code&gt;-prune&lt;/code&gt; if you want to exclude directories. If you use something like &lt;code&gt;-not -path &amp;quot;pathname&amp;quot;&lt;/code&gt;, you will exclude the directory, but you will still traverse it, and, as a result, the search will be slow for big directories like &lt;code&gt;node_modules&lt;/code&gt;.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Array decay to pointers, and address of operator (dereference) behavior.]]></title><description><![CDATA[Array decay to pointers, and address of operator (dereference) behavior.]]></description><link>https://markoskon.com/array-decay-address-of-operator/</link><guid isPermaLink="false">https://markoskon.com/array-decay-address-of-operator/</guid><pubDate>Mon, 05 Jan 2026 14:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;address-of-operator&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#address-of-operator&quot;&gt;Address of operator&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The address of operator (&amp;amp;) creates a pointer of the underlying type. For example:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;cpp&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; number &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;number;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;what&amp;quot; is an `int *`, a pointer to the underlying int&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; number&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;what&amp;quot; is an `int`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;array-decay-to-pointer&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#array-decay-to-pointer&quot;&gt;Array decay to pointer&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;cpp&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; numbers&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;what&amp;quot; is not an int[10] because array decay to pointers&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// when evaluated in an expression. So &amp;quot;what&amp;quot; decays&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// from `int[10]` to `int *`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;numbers;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;what&amp;quot; is `int (*)[10]`, a pointer to an array of 10&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// ints. Here, the address of operator prevents the decay&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// and creates a pointer to the underlying type, which is&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// an array of 10 ints.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;what&amp;quot; is an int&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;multi-dimensional-array&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#multi-dimensional-array&quot;&gt;Multi-dimensional array&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;cpp&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { {&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;}, {&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;} };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; matrix;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// matrix is an array that holds 2 arrays that, in turn,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// hold 3 ints. When you have an array, of any type, in an&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// expression, that array decays to a pointer.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// So, &amp;quot;what&amp;quot; is now `int (*) [3]` a pointer to an array of 3 ints.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Goodbye to the array of 2, now it&amp;#x27;s a pointer.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;matrix;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// This time, the address-of operator prevents the decay&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// and &amp;quot;what&amp;quot; is a pointer to the original type, which&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// is int[2][3], or an array that holds 2 arrays that hold 3 ints.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// So, technically, &amp;quot;what&amp;quot; is an `int (*) [2][3]`.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// matrix [0] is an int[3] array and we know that array&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// decay to pointers in expressions.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// So, &amp;quot;what&amp;quot; is an `int *` here.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Again, matrix[0] is of type `int[3]`. The address-of&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// operator prevents the decay of the `int[3]` to `int *`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// and, in addition,  it gives us a pointer to the `int [3]`.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// So, &amp;quot;what&amp;quot; is of type `int (*) [3]`, Or a pointer to an&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// array of 3 ints.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;what&amp;quot; is `int` here.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// `matrix[0][0]` is an int, so `&amp;amp;matrix[0][0]` is a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// pointer to int (`int *`).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;decltype&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#decltype&quot;&gt;decltype&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Btw, in C++, expressions in &lt;code&gt;decltype&lt;/code&gt; don’t decay the same way arrays decay to pointers in expressions&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;cpp&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { {&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;}, {&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;} };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;decltype&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(matrix);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;what&amp;quot; is a reference to an `int matrix[2][3]`, or a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// `int (&amp;amp;) [2][3]`.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;decltype&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// what is a `int (&amp;amp;) [3]`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;decltype&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// what is a `int &amp;amp;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; number &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;using&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; what &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;decltype&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(number);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// what is `int`. Don&amp;#x27;t ask me why it&amp;#x27;s different from the&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// above.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Something to run to observe the above:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;cpp&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { { &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }, { &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; } };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; pi &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ppi &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;pi;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; number &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;           pi: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; pi &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;          *pi: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;pi &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;          &amp;amp;pi: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;pi &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;       pi + 1: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; pi &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;    *(pi + 1): &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(pi &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;          ppi: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ppi &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;         *ppi: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;ppi &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;         &amp;amp;ppi: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;ppi &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;      ppi + 1: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ppi &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;   *(ppi + 1): &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(ppi &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;       number: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; number &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;      &amp;amp;number: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;number &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;       matrix: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; matrix &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;      &amp;amp;matrix: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;matrix &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;   &amp;amp;matrix[0]: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;&amp;amp;matrix[0][0]: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;&amp;amp;matrix[0][1]: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;&amp;amp;matrix[0][2]: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;   &amp;amp;matrix[1]: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;&amp;amp;matrix[1][0]: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;&amp;amp;matrix[1][1]: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;&amp;amp;matrix[1][2]: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;matrix&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The naming of the &lt;em&gt;what&lt;/em&gt; variable was probably poor, I had to enclose it in parentheses to make it clear I was referring to the variable. I always thought of “So What” by Anti-Nowhere League/Metallica.&lt;/p&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;See IBM address-of operator: &lt;a href=&quot;https://www.ibm.com/docs/en/i/7.2?topic=expressions-address-operator&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.ibm.com/docs/en/i/7.2?topic=expressions-address-operator&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[C++ Why we add parenthesis around assignments in if statements]]></title><description><![CDATA[C++ Why we add parenthesis around assignments in if statements ]]></description><link>https://markoskon.com/c-parenthesis-in-if-statements/</link><guid isPermaLink="false">https://markoskon.com/c-parenthesis-in-if-statements/</guid><pubDate>Mon, 05 Jan 2026 13:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I made a note for the question in the title back in 2022, but I always forget the answer.&lt;/p&gt;&lt;p&gt;From C++ Primer, 5th edition 2013, 4.4 “Assignment Operators” (p.146):&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Because assignment (&lt;code&gt;=&lt;/code&gt;) has lower precedence than the relational operators (&lt;code&gt;&amp;lt;&amp;gt;&amp;lt;=&lt;/code&gt;, etc.), parentheses are usually needed around assignments in conditions.&lt;/p&gt;&lt;/blockquote&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;cpp&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; i;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ((i &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;get_value&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;  // do something . . .&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can verify it with man pages:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ apropos associativity&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;associativity: nothing appropriate.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ apropos preced&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;operator (7)         - C operator precedence and order of evaluation&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;precedence (7)       - C operator precedence and order of evaluation&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ man 7 operator&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;NAME&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       operator - C operator precedence and order of evaluation&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;DESCRIPTION&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       This manual page lists C operators and their precedence &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;in&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; evaluation.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       Operator                            Associativity   Notes&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       [] () &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ++ --                    left to right   [1]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       ++ -- &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; + - &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; sizeof            right to left   [2]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       (type)                              right to left&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; / %                               left to right&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       + -                                 left to right&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &amp;lt;&amp;lt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;                               left to right&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;= &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;=                           left to right&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       == &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;=                               left to right&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;                                   left to right&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       ^                                   left to right&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;                                   left to right&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;                                  left to right&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;                                  left to right&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;:                                  right to left&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;= /= %= += -= &amp;lt;&amp;lt;= &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;= &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;= ^= &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;=   right to left&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       ,                                   left to right&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Also an extra bit from C++ Primer p.145&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;The result of an assignment is its left-hand operand, which is an lvalue. The
type of the result is the type of the left-hand operand. If the types of the left and right operands differ, the right-hand operand is converted to the type of the left.&lt;/p&gt;&lt;/blockquote&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Expressions become statements if you add a semicolon at the end of them (K&R C book)]]></title><description><![CDATA[Two things I found interesting and wrote down while reading the K&R C book (The C Programming Language by Ritchie & Kernighan), back in May 2024.]]></description><link>https://markoskon.com/c-expressions-statements-braces/</link><guid isPermaLink="false">https://markoskon.com/c-expressions-statements-braces/</guid><pubDate>Mon, 05 Jan 2026 12:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Two things I found interesting and wrote down while reading the K&amp;amp;R C book (The C Programming Language by Ritchie &amp;amp; Kernighan), back in May 2024. I revisited again the note in 2026, and to be honest, I had forgot the 1st.&lt;/p&gt;&lt;h2 id=&quot;1-expressions-vs-statements&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#1-expressions-vs-statements&quot;&gt;1. expressions vs statements&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Expressions become statements if you add a semicolon at the end of them, K&amp;amp;R C book, Chapter 3.1, “Statements and Blocks”:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;An expression such as &lt;code&gt;x = 0&lt;/code&gt; or &lt;code&gt;i++&lt;/code&gt; or &lt;code&gt;printf(...)&lt;/code&gt; becomes a &lt;em&gt;statement&lt;/em&gt; when it is followed by a semicolon, as in:&lt;/p&gt;&lt;/blockquote&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;c&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; x &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; i&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(...);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;blockquote&gt;&lt;p&gt;In C, the semicolon is a statement terminator, rather than a separator as it is in languages like Pascal.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;For more types of statements in C++ (we saw expression statements here), see &lt;a href=&quot;https://en.cppreference.com/w/cpp/language/statements&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://en.cppreference.com/w/cpp/language/statements&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;2-braces&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#2-braces&quot;&gt;2. braces&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Also braces {} combine multiple statements into compound statements, which is another statement type.&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Braces &lt;code&gt;{&lt;/code&gt; and &lt;code&gt;}&lt;/code&gt; are used to group declarations and statements together into a &lt;em&gt;compound statement&lt;/em&gt;, or &lt;em&gt;block&lt;/em&gt;, so that they are syntactically equivalent to a single statement. The braces that surround the statements of a function are one obvious example; braces around multiple statements after an &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;else&lt;/code&gt;, &lt;code&gt;while&lt;/code&gt;, or &lt;code&gt;for&lt;/code&gt; are another. (Variables can be declared inside any block; we will talk about this in Chapter 4.) There is no semicolon after the right brace that ends a block.&lt;/p&gt;&lt;/blockquote&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Work with binary option flags (flipping bits)]]></title><description><![CDATA[How to set, unset binary option flags and see check if they are set.]]></description><link>https://markoskon.com/work-with-binary-options/</link><guid isPermaLink="false">https://markoskon.com/work-with-binary-options/</guid><pubDate>Sat, 03 Jan 2026 12:00:00 GMT</pubDate><content:encoded>&lt;ul&gt;&lt;li&gt;&lt;code&gt;|&lt;/code&gt; = bitwise or&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;amp;&lt;/code&gt; = bitwise and&lt;/li&gt;&lt;li&gt;&lt;code&gt;~&lt;/code&gt; = not, negation&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;lt;=&amp;gt;&lt;/code&gt; = “if and only if”, aka left and right are both true under same conditions.&lt;/li&gt;&lt;li&gt;&lt;code&gt;set&lt;/code&gt; or &lt;code&gt;setting a flag&lt;/code&gt; means we want the flag to be 1.&lt;/li&gt;&lt;li&gt;&lt;code&gt;unset&lt;/code&gt;/&lt;code&gt;clear&lt;/code&gt; or &lt;code&gt;clearing a flag&lt;/code&gt; means we want it to be 0.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;1-set-options&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#1-set-options&quot;&gt;1) Set options&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Set all 3 options: OPTION_1 | OPTION_2 | OPTION_3.&lt;/p&gt;&lt;p&gt;For example: 001 | 010 | 100 = 111, so all 3 options are set.&lt;/p&gt;&lt;p&gt;Or, set a new option and add it to the current options: CURRENT_OPTIONS | NEW_OPTION.&lt;/p&gt;&lt;p&gt;For example, if the 1st/2nd bit options are already set and we want to also set the 3rd bit option: 011 | 100 = 111.&lt;/p&gt;&lt;h2 id=&quot;2-unset-options&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#2-unset-options&quot;&gt;2) Unset options&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;CURRENT_OPTIONS &amp;amp; ~OPTION_1.&lt;/p&gt;&lt;p&gt;For example: 101 &amp;amp; ~001 &amp;lt;=&amp;gt; 101 &amp;amp; 100 = 100.&lt;/p&gt;&lt;p&gt;We get he same result even if OPTION_1 is not already set. For example, 100 &amp;amp; ~001 &amp;lt;=&amp;gt; 100 &amp;amp; 100 = 100.&lt;/p&gt;&lt;h2 id=&quot;3-check-if-an-option-is-set&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#3-check-if-an-option-is-set&quot;&gt;3) Check if an option is set&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;See if OPTION_2 is set: CURRENT_OPTIONS &amp;amp; OPTION_2.&lt;/p&gt;&lt;p&gt;For example: 101 &amp;amp; 010 = 000 (falsey, not set), or 110 &amp;amp; 010 = 010 (OPTION_2, truthy and set).&lt;/p&gt;&lt;p&gt;The above means that you can use it inside an if control flow: &lt;code&gt;if (CURRENT_OPTIONS &amp;amp; OPTION_1) {}&lt;/code&gt;. If it’s not set, it will be 0, if it’s not set it will be truthy and equal to OPTION_1.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[vcpkg list dependencies from the manifest (vcpkg.json), not global dependencies.]]></title><description><![CDATA[How to list vcpkg dependencies from the vcpkg.json manifest.]]></description><link>https://markoskon.com/vcpkg-list-dependencies-from-manifest/</link><guid isPermaLink="false">https://markoskon.com/vcpkg-list-dependencies-from-manifest/</guid><pubDate>Sat, 03 Jan 2026 11:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I installed vcpkg at &lt;code&gt;/c/src/vcpkg/vcpkg.exe&lt;/code&gt;, change the command accordingly.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ /c/src/vcpkg/vcpkg.exe list \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    --x-wait-for-lock \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    --triplet &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;x64-windows&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    --vcpkg-root=/c/src/vcpkg \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    --x-manifest-root=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.\MyProject\&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    --x-install-root=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.\MyProject\vcpkg_installed\x64-windows\&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or save yourself some time from typing by going first to the folder where &lt;code&gt;vcpkg.json&lt;/code&gt; lives:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; .&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\M&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;yProject\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ /c/src/vcpkg/vcpkg.exe list \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    --x-wait-for-lock \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    --triplet &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;x64-windows&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    --x-install-root=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.\vcpkg_installed\x64-windows\&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Edit binary files with dd: replacing, deleting, and copying bytes]]></title><description><![CDATA[3 useful things you can do with the dd utility: replace, remove, and copy specific byte ranges within files.]]></description><link>https://markoskon.com/replace-delete-copy-bytes-with-dd/</link><guid isPermaLink="false">https://markoskon.com/replace-delete-copy-bytes-with-dd/</guid><pubDate>Thu, 01 Jan 2026 12:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;replace-bytes-with-dd-hex-editor-edit-bytes&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#replace-bytes-with-dd-hex-editor-edit-bytes&quot;&gt;Replace bytes with dd (hex editor, edit bytes)&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# The file you want to edit:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;My name is dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; file.txt&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat file.txt&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;My name is dark&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Replace 1 byte:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -n &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  dd \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    of=file.txt  \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    bs=1 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    seek=11 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    count=1 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    conv=notrunc&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1+0 records &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;in&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1+0 records out&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1 byte copied, 5.1489e-05 s, 19.4 kB/s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Inpect file:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat file.txt&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;My name is Mark&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ xxd file.txt&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;00000000: 4d79 206e 616d 6520 6973 204d 6172 6b0a  My name is Mark.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Notes:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;stdin = input file = ‘if’, in other words, what you want to add to the new file&lt;/li&gt;&lt;li&gt;of is the file you want to edit.&lt;/li&gt;&lt;li&gt;bs, read and write up to BYTES bytes at a time (default: 512); overrides ibs and obs&lt;/li&gt;&lt;li&gt;seek, The decimal address you want to start replacing. If you want to add a hex address, wrap in double quotes and use arithmetic substitution&lt;code&gt;$((0x30))&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;count, how many bytes from the ‘if’ you want to add to the ‘of’.&lt;/li&gt;&lt;li&gt;conv=notrunc, do not truncate the file, which is the default.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;delete-bytes-with-dd&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#delete-bytes-with-dd&quot;&gt;Delete bytes with dd&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;It seems that you can’t remove individual bytes. If you think about it, there isn’t a system call that does this.&lt;/p&gt;&lt;p&gt;What you can do though is to write the whole file again, without those bytes:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; $ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;helllo doge world &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  { dd bs=1 count=4 &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; dd skip=1 bs=1 count=2 &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; dd skip=5 bs=1 &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;2&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;/dev/null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Explanation:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;ol&gt;&lt;li&gt;print hell&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;li&gt;&lt;ol start=&quot;2&quot;&gt;&lt;li&gt;skip 3rd l, print ‘o’ and space.&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;li&gt;&lt;ol start=&quot;3&quot;&gt;&lt;li&gt;delete doge and space and print world.&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;See &lt;a href=&quot;https://unix.stackexchange.com/questions/128871/dd-remove-range-of-bytes&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://unix.stackexchange.com/questions/128871/dd-remove-range-of-bytes&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;copy-a-part-of-a-file-with-dd&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#copy-a-part-of-a-file-with-dd&quot;&gt;Copy a part of a file with dd&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ dd if=input.txt iflag=skip_bytes,count_bytes skip=5 count=3 of=part.txt&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# or&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ dd if=input.txt bs=1 skip=5 count=3 of=part.txt&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There are 2 versions because if you use the skip/count combo without a block size (bs) &lt;code&gt;skip=N&lt;/code&gt; and &lt;code&gt;count=N&lt;/code&gt;, the &lt;code&gt;N&lt;/code&gt; is a block and not bytes. So, if you want to skip bytes, and you don’t want to change the block size, use the 1st option (set the block size to 1 byte). Otherwise, you can use the second option.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Download git submodules]]></title><description><![CDATA[Some commands to start working with git submodules.]]></description><link>https://markoskon.com/download-git-submodules/</link><guid isPermaLink="false">https://markoskon.com/download-git-submodules/</guid><pubDate>Sun, 28 Dec 2025 14:00:00 GMT</pubDate><content:encoded>&lt;p&gt;To see the git submodules of the project:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ git submodule status&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Add a submodule from git:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ git submodule add git@github.com:oatpp/oatpp.git modules/oatpp&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you already have cloned the project:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ git submodule update --init&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can also break it up in two steps:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ git submodule init&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ git submodule update&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or to clone and download submodules:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ git clone --recursive https://github.com/obsproject/obs-studio.git&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For more see: &lt;a href=&quot;https://www.git-scm.com/book/en/v2/Git-Tools-Submodules&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.git-scm.com/book/en/v2/Git-Tools-Submodules&lt;/a&gt;&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Git rebase and create new timestamps (dates)]]></title><description><![CDATA[Git rebase and create new timestamps (dates)]]></description><link>https://markoskon.com/git-rebase-with-new-timestamps/</link><guid isPermaLink="false">https://markoskon.com/git-rebase-with-new-timestamps/</guid><pubDate>Sun, 28 Dec 2025 13:00:00 GMT</pubDate><content:encoded>&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ git checkout development&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ git rebase --ignore-date origin/development&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;what &lt;code&gt;--ignore-date&lt;/code&gt; does:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Instead of using the author date of the original commit, use the current time as the author date of the rebased commit.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;The opposite is the &lt;code&gt;--committer-date-is-author-date&lt;/code&gt; option, which is the default, in my system:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Instead of using the current time as the committer date, use the author date of the commit being rebased as the committer date.&lt;/p&gt;&lt;/blockquote&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Parsing JSON/XML/YML in the command line with jq/yq/xq]]></title><description><![CDATA[Learn how to parse, filter, and transform JSON, XML, and YAML directly from the command line using jq, yq, and xq, with practical examples.]]></description><link>https://markoskon.com/jq-examples/</link><guid isPermaLink="false">https://markoskon.com/jq-examples/</guid><pubDate>Sun, 28 Dec 2025 12:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;install&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#install&quot;&gt;Install&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Install jq with a package manager. For example, in Ubuntu with apt:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ sudo apt install jq&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The xq/yq executables are part the python package yq &lt;a href=&quot;https://github.com/kislyuk/yq&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://github.com/kislyuk/yq&lt;/a&gt; that transforms the XML/YML files to JSON and calls jq with the filter you provide. Install it with&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# You need to install python3 first that includes the pip package manager.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ pip3 install yq&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;xq/yq call jq, so the filters will be the same.&lt;/p&gt;&lt;p&gt;See &lt;a href=&quot;https://stedolan.github.io/jq/manual/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://stedolan.github.io/jq/manual/&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;get-the-first-item-of-the-array&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-the-first-item-of-the-array&quot;&gt;Get the first item of the array&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ curl https://jsonplaceholder.typicode.com/users &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; jq .[0]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;get-only-a-specific-field-from-the-array-items&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-only-a-specific-field-from-the-array-items&quot;&gt;Get only a specific field from the array items&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Also count the unique&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ curl https://jsonplaceholder.typicode.com/users &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; jq .[].address.city &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; sort &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; uniq -c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;get-the-length&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-the-length&quot;&gt;Get the length&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Get the length of an array.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat facebook.xml &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; xq  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.rss.channel.item | length&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Get the length of nested fields. Be careful, though, because if the field is a string, instead of an array, you’ll get the string length.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat facebook.xml &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; xq  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.rss.channel.item[].&amp;quot;g:additional_image_link&amp;quot; | length&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;filter-entries-with-select&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#filter-entries-with-select&quot;&gt;Filter entries with select&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ curl https://jsonplaceholder.typicode.com/users &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.[] | select(.username == &amp;quot;Bret&amp;quot;)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Use and/or:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ curl https://jsonplaceholder.typicode.com/users &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.[] | select(.username == &amp;quot;Bret&amp;quot; and .address.city == &amp;quot;Gwenborough&amp;quot;)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;unescape-character-from-json-string-with-fromjson-filter-parse&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#unescape-character-from-json-string-with-fromjson-filter-parse&quot;&gt;Unescape character from JSON string with fromjson filter (parse)&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;. | fromjson&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;:[{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;battery.current&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;:0,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;vehicle.mileage&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;:437.974}]}&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;prints:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;battery.current&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: 0,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;vehicle.mileage&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: 437.974&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; ]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Or decode JSON strings in your programming language.&lt;/p&gt;&lt;h2 id=&quot;return-specific-fields-in-a-row-with-string-interpolation&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#return-specific-fields-in-a-row-with-string-interpolation&quot;&gt;Return specific fields in a row with string interpolation&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ curl https://jsonplaceholder.typicode.com/users &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.[] | select(.username == &amp;quot;Bret&amp;quot;) | &amp;quot;\(.id) \(.name) \(.company.name)&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;pick-specific-fields-from-an-object&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#pick-specific-fields-from-an-object&quot;&gt;Pick specific fields from an object&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.urlset.url[] | { loc, lastmod }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; kids-shop-123-sitemap.json &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; head&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://kids-shop-123.gr/kathisma-daxtilidi-baniou-panda-prasino-lorelli&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;lastmod&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;2023-04-27T21:54:05+00:00&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://kids-shop-123.gr/kathisma-daxtilidi-baniou-panda-roz-lorelli&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;lastmod&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;2023-02-28T13:52:06+00:00&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://kids-shop-123.gr/1022057-Lorelli-pipila-silikonis-MY-FRIEND-me-kallyma1022057-blue&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;select-with-pipes-and-match&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#select-with-pipes-and-match&quot;&gt;Select with pipes and match&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Note the pipe inside &lt;code&gt;select(..)&lt;/code&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat facebook.xml &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; xq  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.rss.channel.item[] | select(.&amp;quot;g:link&amp;quot; | match(&amp;quot;https:\/\/kids-shop-123.gr\/.*\/&amp;quot;)).&amp;quot;g:link&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; grep -ivE route&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;select-with-pipes-and-contains-includes&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#select-with-pipes-and-contains-includes&quot;&gt;Select with pipes and contains (includes)&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat facebook.xml &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; xq  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.rss.channel.item[] | select(.&amp;quot;g:link&amp;quot; | contains(&amp;quot;Lorelli&amp;quot;)) | .&amp;quot;g:link&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;get-all-the-possible-properties-keys&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-all-the-possible-properties-keys&quot;&gt;Get all the possible properties (keys)&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;From an array of objects with &lt;code&gt;keys&lt;/code&gt; built-in function.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat facebook.xml &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; xq  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.rss.channel.item[] | keys&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; sort &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; uniq&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can also use &lt;code&gt;keys[]&lt;/code&gt;, I don’t know atm what’s the difference.&lt;/p&gt;&lt;h2 id=&quot;get-all-the-possible-values-values&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-all-the-possible-values-values&quot;&gt;Get all the possible values (values)&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;From an array of objects with &lt;code&gt;values[]&lt;/code&gt; built-in function.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;15&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.[][1].ips | values[]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ./x64/Debug/user-stats.json&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# From input:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   667204,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;ips&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;122.127.33.1&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: 1685028929&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   675978,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;ips&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;10.26.218.58&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: 1685028929&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Output:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1685028929&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1685028929&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1685028976&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;get-the-items-that-their-value-is-an-array&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-the-items-that-their-value-is-an-array&quot;&gt;Get the items that their value is an array&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Use the &lt;code&gt;type&lt;/code&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;16&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat shop-2023-06-17.json &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.products.product[] | select( .manufacturer == &amp;quot;CRISTIANA MASI&amp;quot;) | select( values[] | type == &amp;quot;array&amp;quot; )&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;find-which-items-have-a-value-that-is-an-array-and-get-the-items-keys-and-counts&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#find-which-items-have-a-value-that-is-an-array-and-get-the-items-keys-and-counts&quot;&gt;Find which items have a value that is an array, and get the items’ keys and counts&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;to_entries&lt;/code&gt; transforms an object to an array of key/value objects. It’s usefull if you want to do stuff with one of the key/value and then reference the other.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;17&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;/Desktop/shop/shop-2024-02-10.json &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; jq -r &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.data.post[] | to_entries | .[] | select(.value | type == &amp;quot;array&amp;quot;) | &amp;quot;\(.key) \(.value | length)&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; sort &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; uniq -c &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; sort &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; awk &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;BEGIN{print &amp;quot;count, key, array_length&amp;quot;} {print $0}&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# prints&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;count, key, array_length&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     1 ImageFilename 3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     1 ImageFilename 8&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     1 ImageURL 3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     1 ImageURL 8&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     1 ΠροϊόνΣύνθεση 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     2 ΠροϊόνΔιαστάσεις 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     2 ΠροϊόνΧρώμα 4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     3 Κατηγορίεςπροϊόντων 3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    12 ΠροϊόνΧρώμα 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    21 ImageFilename 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    21 ImageURL 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    55 Κατηγορίεςπροϊόντων 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The use case here is to see which objects from an array have array properties. At the same time, print the key and the length of the array. Useful if I want to use wpallimport for a feed to see how many max additional images or attributes to account for (and not lose existing data).&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;18&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat kids-shop-123-facebook-2023-06-19.json &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; jq -c &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.rss.channel.item[] | to_entries[] | if .value | type == &amp;quot;array&amp;quot; then { key, length: .value | length } else null end&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; grep -v null &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; head&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;drop-exclude-delete-remove-a-property-field-from-an-object-path&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#drop-exclude-delete-remove-a-property-field-from-an-object-path&quot;&gt;Drop (exclude, delete, remove) a property (field) from an object path&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Use the &lt;code&gt;del(path_expression)&lt;/code&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;19&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;[&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt; { &amp;quot;name&amp;quot;: &amp;quot;Mark&amp;quot;, &amp;quot;age&amp;quot;: 12, &amp;quot;password&amp;quot;: &amp;quot;123456&amp;quot; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt; { &amp;quot;name&amp;quot;: &amp;quot;John&amp;quot;, &amp;quot;age&amp;quot;: 21, &amp;quot;password&amp;quot;: &amp;quot;123&amp;quot; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;del(.[].password)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# prints&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: 12&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;John&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: 21&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;add-a-property-field-to-an-object&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#add-a-property-field-to-an-object&quot;&gt;Add a property (field) to an object&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Add the profit_target_sent property to all objects, with a default value of 0.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;20&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.records[][1] += { &amp;quot;profit_target_sent&amp;quot;: 0.0 }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; my_file.json &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; my_file.json.ready&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;sort-results&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#sort-results&quot;&gt;Sort results&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Notice that it’s &lt;code&gt;item&lt;/code&gt;, not &lt;code&gt;item[]&lt;/code&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;21&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat facebook.xml &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; xq  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.rss.channel.item | sort_by(.&amp;quot;g:quantity&amp;quot;) | .[].&amp;quot;g:quantity&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;sort-results-and-keep-the-initial-structure&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#sort-results-and-keep-the-initial-structure&quot;&gt;Sort results and keep the initial structure&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Use &lt;code&gt;|=&lt;/code&gt; vs &lt;code&gt;|&lt;/code&gt;: See &lt;a href=&quot;https://stackoverflow.com/a/30332672&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://stackoverflow.com/a/30332672&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;22&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.urlset.url |= sort_by (.loc)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; kids-shop-123-sitemap-real.json &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; head&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;urlset&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@xmlns&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;http://www.sitemaps.org/schemas/sitemap/0.9&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@xmlns:image&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;http://www.google.com/schemas/sitemap-image/1.1&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://kids-shop-123.gr/10010060003-marsipo-lorelli-prasino&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;changefreq&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;weekly&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;lastmod&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;2021-11-03T13:49:11+00:00&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;priority&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Explanation:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;23&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;{ &amp;quot;numbers&amp;quot;: [{ &amp;quot;value&amp;quot;: 2 }, { &amp;quot;value&amp;quot;: 3 }, { &amp;quot;value&amp;quot;: 1 }] }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.numbers | sort_by ( .value )&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# | (pipe) did not keep numbers property.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: 3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;{ &amp;quot;numbers&amp;quot;: [{ &amp;quot;value&amp;quot;: 2 }, { &amp;quot;value&amp;quot;: 3 }, { &amp;quot;value&amp;quot;: 1 }] }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.numbers |= sort_by ( .value )&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# |= kept numbers property.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: 3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; ]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;how-to-remove-items-from-a-nested-array-based-on-a-filter-and-keep-the-rest-structure-unchanged&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#how-to-remove-items-from-a-nested-array-based-on-a-filter-and-keep-the-rest-structure-unchanged&quot;&gt;How to remove items from a nested array based on a filter and keep the rest structure unchanged&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Again, use the assignment operator (|=)&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;24&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;{&amp;quot;message&amp;quot;:&amp;quot;Hi&amp;quot;,&amp;quot;items&amp;quot;:[1,2,3]}&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; jq -c &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.items[] |= select(. &amp;gt;2)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hi&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;:[3]}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Note this works for jq version &amp;gt;= 1.7&lt;/p&gt;&lt;h2 id=&quot;update-with-pipe-assignment-operator--multiple-properties-at-once-maybe-even-on-different-levels-of-nesting&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#update-with-pipe-assignment-operator--multiple-properties-at-once-maybe-even-on-different-levels-of-nesting&quot;&gt;Update with pipe assignment operator |= multiple properties at once, maybe even on different levels of nesting.&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You do what you did above, but you then use regular pipe to update the second property.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;25&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;{&amp;quot;message&amp;quot;:&amp;quot;Hi&amp;quot;,&amp;quot;items&amp;quot;:[1,2,3],&amp;quot;hello&amp;quot;:{&amp;quot;items&amp;quot;:[1,4,5]}}&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; jq -c &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.items[] |= select(. &amp;gt;2) | .hello.items[] |= select(. &amp;gt;2)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hi&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;:[3],&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hello&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;:{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;:[4,5]}}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;unique-field&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#unique-field&quot;&gt;Unique field&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;It’s not a filter, the same as &lt;code&gt;sort_by&lt;/code&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;26&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;cat facebook.xml &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; xq  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.rss.channel.item | unique_by(.&amp;quot;g:quantity&amp;quot;) | .[].&amp;quot;g:quantity&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;how-to-minify-a-json-file&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#how-to-minify-a-json-file&quot;&gt;How to minify a JSON file&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Use the &lt;code&gt;-c&lt;/code&gt; (compact) option:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;27&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  &amp;quot;message&amp;quot;: &amp;quot;Hello World&amp;quot;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  &amp;quot;number&amp;quot;: 123&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; jq -c &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# prints:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello World&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;:123}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;count-objects-if-the-output-is-an-object-stream--instead-of-an-array-with---compact--c-option-keywords-minify-minified-minimize-compress&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#count-objects-if-the-output-is-an-object-stream--instead-of-an-array-with---compact--c-option-keywords-minify-minified-minimize-compress&quot;&gt;Count objects if the output is an object stream (?) instead of an array with –compact, -c option (keywords: minify, minified, minimize, compress)&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The length works if the output is an array:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;28&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat input/current-shop-export-22-09-2022.xml &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; xq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.data.post | length&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Prints 761.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But if the output consists of individual objects, the length is applied as a filter on each object:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;29&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat input/current-shop-export-22-09-2022.xml &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; xq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.data.post[] | length&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Prints:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# 25&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# 25&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# ...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This comes up when you already filtered the array and you want to count how many items satisfy the filter. In this case, you can use the -c (compact) option to print each item in a single line and pipe the output to wc to count the number of lines&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;30&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat input/current-shop-export-22-09-2022.xml &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; xq -c  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.data.post[] | select(.&amp;quot;Ετικέτεςπροϊόντος&amp;quot; | type == &amp;quot;array&amp;quot;)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; wc -l&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Prints 208&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;convert-json-to-csv-with-jq&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#convert-json-to-csv-with-jq&quot;&gt;Convert JSON to csv with jq&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;See &lt;a href=&quot;https://stackoverflow.com/questions/32960857/how-to-convert-arbitrary-simple-json-to-csv-using-jq&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://stackoverflow.com/questions/32960857/how-to-convert-arbitrary-simple-json-to-csv-using-jq&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;31&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ jq -r &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; input.json &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; output.csv&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;get-the-results-as-raw-strings-without-quotes&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-the-results-as-raw-strings-without-quotes&quot;&gt;Get the results as raw strings (without quotes)&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Say you don’t want the string quotes:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;32&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;[&amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.[]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;C&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Use the -r option:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;33&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;[&amp;quot;A&amp;quot;, &amp;quot;B&amp;quot;, &amp;quot;C&amp;quot;]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; jq -r &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.[]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;txt&quot; data-index=&quot;34&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;-r               output raw strings, not JSON texts;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;multiple-expresssions-search-keyword-conditions-in-select&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#multiple-expresssions-search-keyword-conditions-in-select&quot;&gt;Multiple expresssions (search keyword: conditions) in select&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;I want to select the tags from Woocommerce products that are arrays (they can also be a single string) and their length is equal to 8:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;35&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat input/current-shop-export-22-09-2022.xml &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; xq  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.data.post[] | select(.&amp;quot;Ετικέτεςπροϊόντος&amp;quot; | (type == &amp;quot;array&amp;quot;) and length == 8)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Enclose the first expression in parenthesis and use the and keyword for the second expression, see &lt;a href=&quot;https://stackoverflow.com/questions/33057420/jq-select-multiple-conditions&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://stackoverflow.com/questions/33057420/jq-select-multiple-conditions&lt;/a&gt;, &lt;a href=&quot;https://stedolan.github.io/jq/manual/#select(boolean_expression)&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://stedolan.github.io/jq/manual/#select(boolean_expression)&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;jq-ternary-if-then-else-elseif-conditions&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#jq-ternary-if-then-else-elseif-conditions&quot;&gt;jq ternary if then else elseif conditions&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;My product categories are either a single category (string) or an array of categories (strings). I want to return the single category string, but I want to flatten the category arrays. For that reason, I will use if-then-else, see &lt;a href=&quot;https://stedolan.github.io/jq/manual/#if-then-else&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://stedolan.github.io/jq/manual/#if-then-else&lt;/a&gt; and the example below:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;36&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ cat input/current-shop-export-22-09-2022.xml &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; xq -r &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.data.post[].&amp;quot;Κατηγορίεςπροϊόντων&amp;quot; | if type == &amp;quot;array&amp;quot; then .[] else . end&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; sort &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; uniq -c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;sql-like-operators-in-check-if-the-value-of-a-property-is-in-an-array-of-known-values&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#sql-like-operators-in-check-if-the-value-of-a-property-is-in-an-array-of-known-values&quot;&gt;SQL-like operators, IN: check if the value of a property is in an array of known values&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;37&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.records[] | select(.[0] | IN(20008,20009,20010))&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; profits.json&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;get-a-range-from-an-array&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-a-range-from-an-array&quot;&gt;Get a range from an array&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Use the &lt;code&gt;[start_index:end_endex]&lt;/code&gt; syntax:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;38&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# get the first 2 million elements from the array:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.[0:2000000]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; results-1705071239.json &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; results-1705071239-first-2m.json&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can also query items from the end of the array by adding negative indices.&lt;/p&gt;&lt;p&gt;You can also omit the end index if you from the first element until the last element of the array.&lt;/p&gt;&lt;p&gt;See “jq: Select range” &lt;a href=&quot;https://stackoverflow.com/questions/45548604/jq-select-range&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://stackoverflow.com/questions/45548604/jq-select-range&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;combine-arrays-with-jq-with-the-slurp-option&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#combine-arrays-with-jq-with-the-slurp-option&quot;&gt;Combine arrays with jq with the slurp option&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;39&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# inputs is&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# [] length 200&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# [] length 50&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# [] length 550&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# that resulted from multiple files&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;transform-stuff&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;json &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; jq -s &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; input.json&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# prints&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[each object merge here] length 800&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;-s option =&amp;gt; &lt;code&gt;-s               read (slurp) all inputs into an array; apply filter to it;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;The filter in this case is &lt;code&gt;add&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;More examples to understand what’s happening:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;40&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# this works but our data is not in this form&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;[[1,2],[3,4]]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; 1,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; 2,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; 3,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; 4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# our data is in this form and the output is not what we want...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# it applies the filter on each individual array.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;[1,2][3,4]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; jq &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;7&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# jq slurp to the rescue:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;[1,2][3,4]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; jq -s &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; 1,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; 2,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; 3,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; 4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# just jq -s also doesn&amp;#x27;t work in case you&amp;#x27;re wondering&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;[1,2][3,4]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; jq -s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   1,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   3,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;   4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt; ]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;See &lt;a href=&quot;https://stedolan.github.io/jq/manual/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://stedolan.github.io/jq/manual/&lt;/a&gt; and &lt;a href=&quot;https://remysharp.com/drafts/jq-recipes&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://remysharp.com/drafts/jq-recipes&lt;/a&gt;&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[C++ constructor/destructor order]]></title><description><![CDATA[Explains the order in which constructors and destructors are called for base classes, derived classes, and member variables.]]></description><link>https://markoskon.com/cpp-constructor-destructor-order/</link><guid isPermaLink="false">https://markoskon.com/cpp-constructor-destructor-order/</guid><pubDate>Sat, 27 Dec 2025 12:00:00 GMT</pubDate><content:encoded>&lt;p&gt;The following C++ code prints when run:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;txt&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;Base::Base&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;A::A&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;B::B&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;Derived::Derived&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;Derived::~&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;B::~&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;A::~&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;Base::~&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The code:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;cpp&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;struct&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Base&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Base&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;() { std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Base::Base&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; std::endl; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;virtual&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;~Base&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;() { std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Base::~&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; std::endl; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;struct&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;() { std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A::A&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; std::endl; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;~A&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;() { std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A::~&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; std::endl; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;struct&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;() { std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;B::B&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; std::endl; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;~B&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;() { std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;B::~&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; std::endl; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;struct&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Derived &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;final&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;public&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Base&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    A a;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    B b;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Derived&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;() { std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Derived::Derived&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; std::endl; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;~Derived&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;() { std::cout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Derived::~&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; std::endl; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    Derived derived;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;From C++20 standard draft:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;In a non-delegating constructor, initialization proceeds in the following order:
(13.1) — First, and only for the constructor of the most derived class (6.7.2), virtual base classes are initialized in the order they appear on a depth-first left-to-right traversal of the directed acyclic graph of base classes, where “left-to-right” is the order of appearance of the base classes in the derived class base-specifier-list.
(13.2) — Then, direct base classes are initialized in declaration order as they appear in the base-specifier-list (regardless of the order of the mem-initializers).
(13.3) — Then, non-static data members are initialized in the order they were declared in the class definition (again regardless of the order of the mem-initializers).
(13.4) — Finally, the compound-statement of the constructor body is executed.
[Note: The declaration order is mandated to ensure that base and member subobjects are destroyed in the reverse order of initialization. —end note]&lt;/p&gt;&lt;/blockquote&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Invert any boolean condition]]></title><description><![CDATA[Invert any boolean condition with De Morgan's laws.]]></description><link>https://markoskon.com/invert-any-boolean-condition/</link><guid isPermaLink="false">https://markoskon.com/invert-any-boolean-condition/</guid><pubDate>Sat, 27 Dec 2025 12:00:00 GMT</pubDate><content:encoded>&lt;ul&gt;&lt;li&gt;The negation of &lt;code&gt;A || B&lt;/code&gt; is &lt;code&gt;!A &amp;amp;&amp;amp; !B&lt;/code&gt;&lt;/li&gt;&lt;li&gt;The negation of &lt;code&gt;A &amp;amp;&amp;amp; B&lt;/code&gt; is &lt;code&gt;!A || !B&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;See Boolean algebra, “De Morgan’s laws”: &lt;a href=&quot;https://en.wikipedia.org/wiki/De_Morgan%27s_laws&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://en.wikipedia.org/wiki/De_Morgan%27s_laws&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;an-example&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#an-example&quot;&gt;An example&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;An example in C++ from the &lt;a href=&quot;https://github.com/gabime/spdlog/blob/32dd298dc2d60fe0454e70b818d64941392c5b41/include/spdlog/sinks/stdout_sinks-inl.h#L45&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;spdlog library, stdout_sinks-inl.h&lt;/a&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;cpp&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;  // don&amp;#x27;t throw to support cases where no console is attached,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;  // and let the log method to do nothing if (handle_ == INVALID_HANDLE_VALUE).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;  // throw only if non stdout/stderr target is requested (probably regular file and not console).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (handle_ &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; INVALID_HANDLE_VALUE &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; file &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; stdout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; file &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; stderr) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;throw_spdlog_ex&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;spdlog::stdout_sink_base: _get_osfhandle() failed&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, errno);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We group the 2nd and 3rd conditions into a new one:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;cpp&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (handle_ &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; INVALID_HANDLE_VALUE &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (file &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; stdout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; file &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; stderr)) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;we apply the rule:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;cpp&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (handle_ &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; INVALID_HANDLE_VALUE &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(file &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; stdout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; file &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; stderr)) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;then apply the rule again on the 2nd part to get the inverted condition:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;cpp&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;file &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; stdout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; file &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; stderr&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;finally, we substitute it above:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;cpp&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (handle_ &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; INVALID_HANDLE_VALUE &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; file &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; stdout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; file &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; stderr) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So the opposite of “if file is an invalid file and no console is attached” is “if file is a valid file or a console is attached”:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;cpp&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  # highlight&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;start&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;  // throw if handle_ is valid or a console is attached.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (handle_ &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; INVALID_HANDLE_VALUE &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; file &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; stdout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; file &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; stderr) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  # highlight&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;throw_spdlog_ex&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;spdlog::stdout_sink_base: _get_osfhandle() failed&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, errno);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Get windows error description from exception codes]]></title><description><![CDATA[Find out what the Windows exception codes mean in the event manager.]]></description><link>https://markoskon.com/windows-error-descriptions/</link><guid isPermaLink="false">https://markoskon.com/windows-error-descriptions/</guid><pubDate>Sat, 27 Dec 2025 12:00:00 GMT</pubDate><content:encoded>&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;powershell&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ certutil &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;error &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0x5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk8&quot;&gt;0x5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (WIN32: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ERROR_ACCESS_DENIED) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;Error message text: Access is denied.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;CertUtil: &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;error command completed successfully.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can also use decimal numbers, for example, the following are equivalent:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;powershell&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ certutil &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;error &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;50&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ certutil &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;error &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0x32&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk8&quot;&gt;0x32&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (WIN32: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ERROR_NOT_SUPPORTED) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;50&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;Error message text: The request is not supported.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To view multiple possible error meanings from multiple header files, see the error lookup tool &lt;a href=&quot;https://learn.microsoft.com/en-us/windows/win32/debug/system-error-code-lookup-tool&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://learn.microsoft.com/en-us/windows/win32/debug/system-error-code-lookup-tool&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;powershell&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk13&quot;&gt;Err_6.4.5.exe&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; c000021a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# for hex 0xc000021a / decimal -1073741286&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;STATUS_SYSTEM_PROCESS_TERMINATED                ntstatus.h​&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# {Fatal System Error}​&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# The %hs system process terminated unexpectedly with a​&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# status of 0x%08x (0x%08x 0x%08x).​&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# The system has been shut down.​&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# as an HRESULT: Severity: FAILURE (1), FACILITY_NULL (0x0), Code 0x21a​&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# for hex 0x21a / decimal 538​&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;ERROR_ABIOS_ERROR                               winerror.h​&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# An error occurred in the ABIOS subsystem.​&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# 2 matches found for &amp;quot;c000021a&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;ThioJoe - “Never Wonder About Windows Errors Again”: &lt;a href=&quot;https://www.youtube.com/watch?v=88a-cW9vNxY&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.youtube.com/watch?v=88a-cW9vNxY&lt;/a&gt;&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk13 { color: #7FDBCAFF; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Get a list of all shell built-ins]]></title><description><![CDATA[Get information about all the shell built-in commands with the help built-in command.]]></description><link>https://markoskon.com/get-info-about-shell-builtins/</link><guid isPermaLink="false">https://markoskon.com/get-info-about-shell-builtins/</guid><pubDate>Wed, 05 Jul 2023 22:00:00 GMT</pubDate><content:encoded>&lt;p&gt;The &lt;code&gt;help&lt;/code&gt; built-in command explains what a particular shell built-in does. The help menu of &lt;code&gt;help&lt;/code&gt; says:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;help&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; --help&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# or $ help help :)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;help: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;help&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [-dms] [pattern ...]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    Display information about &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;builtin&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; commands.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    Displays brief summaries of &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;builtin&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; commands.  If PATTERN is&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    specified, gives detailed &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;help&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; on all commands matching PATTERN,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    otherwise the list of &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;help&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; topics is printed.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    Options:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      -d        output short description &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; each topic&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So, if you use the &lt;code&gt;-d&lt;/code&gt; option to get a short description, and pass the &lt;code&gt;&amp;#x27;*&amp;#x27;&lt;/code&gt; as a pattern to get information for all topics, you get a list with all the shell built-in commands and what they do:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;help&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -d &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;Shell commands matching keyword &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;% - Resume job in foreground.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;(( ... )) - Evaluate arithmetic expression.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;. - Execute commands from a file in the current shell.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;: - Null command.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;[ - Evaluate conditional expression.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;[[ ... ]] - Execute conditional command.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;alias - Define or display aliases.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;bg - Move jobs to the background.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;bind - Set Readline key bindings and variables.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;break - Exit for, while, or until loops.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;builtin - Execute shell builtins.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;caller - Return the context of the current subroutine call.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;case - Execute commands based on pattern matching.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;cd - Change the shell working directory.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;until - Execute commands as long as a test does not succeed.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;variables - Common shell variable names and usage.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;wait - Wait for job completion and return exit status.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;while - Execute commands as long as a test succeeds.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;{ ... } - Group commands as a unit.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;How do you know if a command is a shell built-in?&lt;/p&gt;&lt;p&gt;You can use the &lt;code&gt;type&lt;/code&gt; shell built-in:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;cd&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; is a shell &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;builtin&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; cp&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;cp is /usr/bin/cp&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# cp is not a shell built-in&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;What are &lt;a href=&quot;https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;shell built-in commands&lt;/a&gt; anyway?&lt;/p&gt;&lt;p&gt;TL;DR:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Builtin commands are contained within the shell itself.&lt;/p&gt;&lt;/blockquote&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Bash Guide for Beginners&lt;/em&gt; from The Linux Documentation Project&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tldp.org/LDP/abs/html/abs-guide.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Advanced Bash-Scripting Guide&lt;/em&gt; from The Linux Documentation Project&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Inspect text that contains control characters in bash]]></title><description><![CDATA[Inspect text that contains control characters with the xxd command. xxd can also be useful when you want to see the bytes of UTF-8 (Unicode) encoded files.]]></description><link>https://markoskon.com/inspect-text-that-contains-control-characters/</link><guid isPermaLink="false">https://markoskon.com/inspect-text-that-contains-control-characters/</guid><pubDate>Wed, 05 Jul 2023 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;My use case: See what the &lt;code&gt;IFS&lt;/code&gt; environment variable contains.&lt;/p&gt;&lt;p&gt;Some context: The &lt;code&gt;IFS&lt;/code&gt; is the &lt;em&gt;input field separator&lt;/em&gt; environment variable and it’s used by programs such as &lt;code&gt;awk&lt;/code&gt; to separate the fields (columns) of a line.&lt;/p&gt;&lt;p&gt;For example, if a line contains the text &lt;code&gt;1 2 3&lt;/code&gt; and &lt;code&gt;${IFS}&lt;/code&gt; is set to the space character, awk will give you 3 columns &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt;, and &lt;code&gt;3&lt;/code&gt;. If &lt;code&gt;IFS&lt;/code&gt; is set to tab, though, &lt;code&gt;awk&lt;/code&gt; will give you only 1 column, a column that contains all the numbers &lt;code&gt;1 2 3&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;It’s also used by the &lt;code&gt;read&lt;/code&gt; shell built-in, a utility that’s used to read lines and fields from files and from the standard input (see &lt;code&gt;help read&lt;/code&gt;).&lt;/p&gt;&lt;p&gt;It’s also worth noting that &lt;code&gt;IFS&lt;/code&gt; can contain a list of characters, not only one character.&lt;/p&gt;&lt;p&gt;See &lt;a href=&quot;https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html#table_03_01&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Bourne shell reserved variables&lt;/a&gt; if want to know learn more environment variables.&lt;/p&gt;&lt;p&gt;So, let’s see what the &lt;code&gt;IFS&lt;/code&gt; variable contains in my terminal:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;${IFS}&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# no visible out&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I get no visible output, but if I pipe the result to the &lt;code&gt;xxd&lt;/code&gt; command:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;${IFS}&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; xxd&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;00000000: 2009 0a0a                                 ...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# xxd output explanation:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# line address: | hex bytes in pairs of 2 by default | textual representation&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I get 4 characters. There’s an extra new line character there &lt;code&gt;0a&lt;/code&gt; because echo adds an extra new line at the end of the output.&lt;/p&gt;&lt;p&gt;We can use the &lt;code&gt;-n&lt;/code&gt; option of &lt;code&gt;echo&lt;/code&gt; to &lt;em&gt;not append a newline&lt;/em&gt; (type &lt;code&gt;help echo&lt;/code&gt; for more options).&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -n &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;${IFS}&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; xxd&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;00000000: 2009 0a                                   ..&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It seems that my &lt;code&gt;IFS&lt;/code&gt; environment variable consists of 3 characters:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;0x20&lt;/code&gt; the space&lt;/li&gt;&lt;li&gt;&lt;code&gt;0x09&lt;/code&gt; the tab (horizontal)&lt;/li&gt;&lt;li&gt;&lt;code&gt;0x0a&lt;/code&gt; the line feed, aka new line, or &lt;code&gt;\n&lt;/code&gt;, or &lt;code&gt;LF&lt;/code&gt;.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;The Wikipedia page &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_Unicode_characters&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;List of Unicode characters&lt;/a&gt; will probably serve you well if you want to translate hex codes to Unicode characters.&lt;/p&gt;&lt;h2 id=&quot;text-to-utf-8-bytes&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#text-to-utf-8-bytes&quot;&gt;Text to UTF-8 bytes&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You can also use &lt;code&gt;xxd&lt;/code&gt; to see the UTF-8 encoding (Unicode) of some text.&lt;/p&gt;&lt;p&gt;In the following example, I print my name (Mark) in English:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -n &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; xxd&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;00000000: 4d61 726b                                Mark&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Not too exciting, I gave it 4 characters, I got back 4 bytes.&lt;/p&gt;&lt;p&gt;But if I type my name in Greek:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -n &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Μάρκος&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; xxd&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;00000000: ce9c ceac cf81 ceba cebf cf82            ............&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I get the UTF-8 encoding; how the text in stored in the file as bytes. I gave it “6” characters, I got back 12 bytes.&lt;/p&gt;&lt;p&gt;A “quick” way to verify this is with JavaScript’s &lt;code&gt;encodeURIComponent&lt;/code&gt; method:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;Welcome&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;Node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;vx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.help&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;more&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;information&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;encodeURIComponent&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Μάρκος&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toLowerCase&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; ce 9c ce ac cf 81 ce ba ce bf cf 82&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;bash-default-encoding&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#bash-default-encoding&quot;&gt;Bash default encoding&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you want to see what’s the default encoding in your shell, search for environment variables that start with &lt;code&gt;LC*&lt;/code&gt; (stands for locale) or &lt;code&gt;LANG*&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ printenv &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; grep -iE &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;LC|LANG&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;LANG=en_US.UTF-8&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;printenv&lt;/code&gt; command above retrieves the values of all environment variables. The &lt;code&gt;|&lt;/code&gt; (pipe) symbol redirects the &lt;code&gt;printenv&lt;/code&gt; output to the &lt;code&gt;grep&lt;/code&gt; command.&lt;/p&gt;&lt;p&gt;The &lt;code&gt;grep&lt;/code&gt; command is used to search for patterns in text. The options used are:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;-i&lt;/code&gt;: Performs a case-insensitive search.&lt;/li&gt;&lt;li&gt;&lt;code&gt;-E&lt;/code&gt;: Enables extended regular expressions for pattern matching.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The pattern ‘LC|LANG’ specifies the search criteria. It looks for lines that contain either “LC” or “LANG”.&lt;/p&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_Unicode_characters&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;List of Unicode characters&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html#table_03_01&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Bourne shell reserved variables&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://explainshell.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Explain shell web application&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Bash Guide for Beginners&lt;/em&gt; from The Linux Documentation Project&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tldp.org/LDP/abs/html/abs-guide.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Advanced Bash-Scripting Guide&lt;/em&gt; from The Linux Documentation Project&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Join the lines of two files based on a common column]]></title><description><![CDATA[See how to join the lines of two files in bash, based on a common column with the join command. You'll also see how to perform SQL-like joins on files.]]></description><link>https://markoskon.com/join-files-based-on-common-column/</link><guid isPermaLink="false">https://markoskon.com/join-files-based-on-common-column/</guid><pubDate>Tue, 04 Jul 2023 16:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Consider the following files:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# file 1:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A    1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B    3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C    9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;D    4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# file 2:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;E    twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B    three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C    nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A    one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Column 1 contains the key in both files, which is a capital letter.&lt;/li&gt;&lt;li&gt;Column 2 in file 1 contains a number&lt;/li&gt;&lt;li&gt;Column 2 in file 2 contains the same number in text format this time.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;If we want a new file with:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;the key in column 1,&lt;/li&gt;&lt;li&gt;the number in column 2 (from file 1),&lt;/li&gt;&lt;li&gt;and the number in text in column 3 (from file 2),&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;we can use the following join command:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ join &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A    1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;D    4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;E    twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;A    one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A 1 one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B 3 three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C 9 nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Note that the inputs of join should be sorted, you’ll get an error by default. Also, the &lt;code&gt;&amp;lt;( COMMAND )&lt;/code&gt; syntax is called &lt;a href=&quot;https://tldp.org/LDP/abs/html/process-sub.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;process substitution&lt;/a&gt;, and you can see it as a temporary file that’s not saved anywhere.&lt;/p&gt;&lt;p&gt;I would like to join on specific columns, though. When I typed &lt;code&gt;join --help&lt;/code&gt; I noticed the following:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;The default join field (i.e column) is the first, delimited by blanks.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;You can specify on which column you want to join each of the two files with the &lt;code&gt;-1&lt;/code&gt; and &lt;code&gt;-2&lt;/code&gt; options. With &lt;code&gt;-1&lt;/code&gt; you specify the column number that contains the key from file 1, and, with &lt;code&gt;-2&lt;/code&gt;, unsurprisingly, you specify the column number that contains the key from file 2.&lt;/p&gt;&lt;p&gt;For example, if the 2nd file had it’s columns in a different order, and the key was in the 2nd column:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# file 2:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;twelve E&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;three B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;nine C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;one A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We could still join the lines of the 2 files based on the letters (key), but based on the second column for file 2 this time, with the following command:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ join -2 2 &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;D    4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;twelve E&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;three B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;nine C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;one A&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort -k 2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A 1 one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B 3 three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C 9 nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;-2 2&lt;/code&gt; means that the 2nd column from file 2 contains our key.&lt;/p&gt;&lt;p&gt;Note that &lt;code&gt;sort -k 2&lt;/code&gt; means “sort by the second column”.&lt;/p&gt;&lt;h2 id=&quot;sql-joins&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#sql-joins&quot;&gt;SQL joins&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You may wonder if you can join files with the &lt;code&gt;join&lt;/code&gt; command, and get a similar behavior to SQL joins. In SQL, some common types of joins are the &lt;em&gt;inner join&lt;/em&gt;, the &lt;em&gt;left join&lt;/em&gt;, the &lt;em&gt;right join&lt;/em&gt;, and the &lt;em&gt;full join&lt;/em&gt;. It seems that you can perform all those joins with the &lt;code&gt;join&lt;/code&gt; command!&lt;/p&gt;&lt;p&gt;For a TL;DR see &lt;a href=&quot;#full-join&quot;&gt;the code blocks at the end of full join&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Also, if you need to refresh your SQL joins (I did), see the YouTube video &lt;a href=&quot;https://www.youtube.com/watch?v=9yeOJ0ZMUYw&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;SQL Joins Explained&lt;/a&gt;.&lt;/p&gt;&lt;h3 id=&quot;inner-join&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#inner-join&quot;&gt;Inner join&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;By default, and in the previous examples, we got an inner join. Let’s review the 1st example again:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# file 1:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A    1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B    3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C    9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;D    4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# file 2:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;E    twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B    three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C    nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A    one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# command&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ join &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A    1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;D    4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;E    twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;A    one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# result&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A 1 one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B 3 three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C 9 nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The result is an &lt;em&gt;inner join&lt;/em&gt; by default, because the row with key &lt;code&gt;D&lt;/code&gt; from file 1 doesn’t have a matching row in file 2, and it’s not in the final result. Additionally, the row with key &lt;code&gt;E&lt;/code&gt; from file 2 does not have a matching row in file 1, and it’s also omitted from the final result.&lt;/p&gt;&lt;h3 id=&quot;left-join&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#left-join&quot;&gt;Left join&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;If we want to perform a &lt;em&gt;left join&lt;/em&gt;, meaning that we want all the rows from file 1, and for those rows from file 1 that don’t have a matching row from file 2 (the one with key &lt;code&gt;D&lt;/code&gt;), we will show &lt;code&gt;null&lt;/code&gt;, we can use the &lt;code&gt;-a FILE_NUMBER&lt;/code&gt; option.&lt;/p&gt;&lt;p&gt;The &lt;code&gt;join --help&lt;/code&gt; says about the &lt;code&gt;-a&lt;/code&gt; option:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  -a FILENUM&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    also print unpairable lines from file FILENUM, where&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    FILENUM is 1 or 2, corresponding to FILE1 or FILE2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So, we can use &lt;code&gt;-a 1&lt;/code&gt; to perform a &lt;em&gt;left join&lt;/em&gt; (and include the unpairable lines from file 1 in the output):&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ join -a 1 &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A    1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;D    4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;E    twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;A    one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# result&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A 1 one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B 3 three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C 9 nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;D 4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The result can be improved though. I would like an output like the following:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A 1 one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B 3 three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C 9 nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;D 4 null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can achieve the above with 2 extra &lt;code&gt;join&lt;/code&gt; options (output from &lt;code&gt;man join&lt;/code&gt; follows):&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;-e &amp;lt;EMPTY&amp;gt;&lt;/code&gt;, &lt;em&gt;replace missing input fields with EMPTY.&lt;/em&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;-o &amp;lt;FORMAT&amp;gt;&lt;/code&gt;, &lt;em&gt;obey FORMAT while constructing output line. FORMAT is one or more comma or blank separated specifications, each being &lt;code&gt;FILENUM.FIELD&lt;/code&gt;&lt;/em&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;code&gt;FILENUM&lt;/code&gt; can be 1 or 2, and &lt;code&gt;FIELD&lt;/code&gt; is the column number (again 1 or 2, we have 2 columns in each file).&lt;/p&gt;&lt;p&gt;So, to improve the output of the &lt;em&gt;left join&lt;/em&gt;, we can use the following command:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ join -a 1 -e null -o &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1.1,1.2,2.2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A    1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;D    4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;E    twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;A    one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A 1 one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B 3 three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C 9 nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;D 4 null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That’s better!&lt;/p&gt;&lt;h3 id=&quot;right-join&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#right-join&quot;&gt;Right join&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;And if we want to perform a &lt;em&gt;right join&lt;/em&gt;, where we won’t have the row with key &lt;code&gt;D&lt;/code&gt;, because it’s not present in file 2 at all, and the row with key &lt;code&gt;E&lt;/code&gt; won’t have a number (from file 1) because it’s not present in file 1, we can use the following command:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ join -a 2 -e null -o &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;2.1,1.2,2.2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A    1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;D    4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;E    twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;A    one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A 1 one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B 3 three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C 9 nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;E null twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Note that the above is a right join this time (on file 2), so we want the &lt;code&gt;2.1&lt;/code&gt; instead of the &lt;code&gt;1.1&lt;/code&gt; as the key in the &lt;code&gt;-o&lt;/code&gt; option.&lt;/p&gt;&lt;h3 id=&quot;full-join&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#full-join&quot;&gt;Full join&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;In a full (outer) join, you want all the keys from both files, and wherever you don’t have a value, you print null.&lt;/p&gt;&lt;p&gt;This is the closest we can get with a custom output format:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ join -a 1 -a 2 -e null -o &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1.2,2.1,1.2,2.2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A    1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;D    4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;E    twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;A    one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1 A 1 one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3 B 3 three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;9 C 9 nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;4 null 4 null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;null E null twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Not so pretty… But then I noticed the following:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;If FORMAT is the keyword ‘auto’, then the first line of each file determines the number of fields output for each line.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;I don’t fully get it right now, but if you use &lt;code&gt;-o auto&lt;/code&gt; it does what we want (in this simple example…):&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ join -a 1 -a 2 -e null -o &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A    1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;D    4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;E    twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;A    one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A 1 one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B 3 three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C 9 nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;D 4 null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;E null twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In fact, you can use &lt;code&gt;-o auto&lt;/code&gt; for &lt;em&gt;left join&lt;/em&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ join -a 1 -e null -o auto &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A    1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;D    4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;E    twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;A    one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A 1 one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B 3 three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C 9 nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;D 4 null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and for &lt;em&gt;right join&lt;/em&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ join -a 2 -e null -o auto &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A    1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;D    4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;E    twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;A    one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A 1 one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B 3 three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C 9 nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;E null twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And, in order to have all the joins in one place, this is again the command for the &lt;em&gt;inner join&lt;/em&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ join &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A    1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;D    4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;E    twelve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B    three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C    nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;A    one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; sort&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A 1 one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B 3 three&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C 9 nine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://www.gnu.org/software/coreutils/join&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.gnu.org/software/coreutils/join&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/52862/find-common-elements-in-a-given-column-from-two-files-and-output-the-column-valu&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Find common elements in a given column from two files and output the column values from each file&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=9yeOJ0ZMUYw&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;SQL Joins Explained - Socratica - Youtube Video&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://explainshell.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Explain shell web application&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Bash Guide for Beginners&lt;/em&gt; from The Linux Documentation Project&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tldp.org/LDP/abs/html/abs-guide.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Advanced Bash-Scripting Guide&lt;/em&gt; from The Linux Documentation Project&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Get specific rows from a file]]></title><description><![CDATA[User awk's NR built-in variable to print only specific rows from a file.]]></description><link>https://markoskon.com/get-specific-rows-from-a-file/</link><guid isPermaLink="false">https://markoskon.com/get-specific-rows-from-a-file/</guid><pubDate>Thu, 29 Jun 2023 18:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I wanted to update some python dependencies with &lt;code&gt;pip&lt;/code&gt;, and I got this output when I run &lt;code&gt;pip list --outdated&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ pip list --outdated&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;Package    Version Latest Type&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;---------- ------- ------ -----&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;fonttools  4.33.3  4.40.0 wheel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pip        22.1    23.1.2 wheel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;setuptools 58.1.0  68.0.0 wheel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And I thought: “Hm, it would be nice if I could print from the 3rd line and below, I don’t want the table header and separator in my output. This way, I can grab the package names with ease”.&lt;/p&gt;&lt;p&gt;You can print specific lines with &lt;code&gt;awk&lt;/code&gt; and the &lt;code&gt;NR&lt;/code&gt; built-in variable. &lt;code&gt;NR&lt;/code&gt; contains the row number (aka line), which is an index that starts from 1:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ pip list --outdated &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  awk &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;{ if (NR &amp;gt; 2) print $0 }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;fonttools  4.33.3  4.40.0 wheel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pip        22.1    23.1.2 wheel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;setuptools 58.1.0  68.0.0 wheel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;print $0&lt;/code&gt; means print all the fields (columns) in the row. &lt;code&gt;$1&lt;/code&gt; refers to the first field, &lt;code&gt;$2&lt;/code&gt; to the second, and so on. &lt;code&gt;awk&lt;/code&gt; is build for that kind of stuff.&lt;/p&gt;&lt;p&gt;And the complete command, where I upgrade the dependencies (use it at you own risk, check first which dependencies you really want to upgrade!):&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ pip list --outdated &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  awk &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;{ if (NR &amp;gt; 2) print $0 }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  grep -v pip &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  cut --delimiter &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;  --field 1 &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  xargs pip install --upgrade&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;grep -v pip&lt;/code&gt; removes &lt;code&gt;pip&lt;/code&gt; from the results ( &lt;code&gt;-v&lt;/code&gt;, &lt;code&gt;--invert-match&lt;/code&gt; select non-matching lines) because I didn’t want to upgrade pip this way (I got an error when I did &lt;code&gt;ERROR: To modify pip, please run the following command:..&lt;/code&gt;).&lt;/li&gt;&lt;li&gt;With &lt;code&gt;cut --delimiter &amp;#x27; &amp;#x27; --field 1&lt;/code&gt; I get the 1st column from the output which is the package name. The default delimiter for &lt;code&gt;cut&lt;/code&gt; I believe is the tab character, that’s why I use a space as a delimiter.&lt;/li&gt;&lt;li&gt;With &lt;code&gt;command | xargs other-command&lt;/code&gt;, if the command output is, for example:&lt;/li&gt;&lt;/ol&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# output of &amp;quot;command&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You transform it to:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ other-command 1 2 3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In other words, you pass each line from the output of the previous command as a positional argument to the next command (the one that &lt;code&gt;xargs&lt;/code&gt; calls), and execute the next command (&lt;code&gt;other-command&lt;/code&gt; in this example).&lt;/p&gt;&lt;p&gt;And if you want only a specific row, for example the 2nd row:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;3\n6\n1&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; awk &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;{ if (NR == 2) print $0 }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;6&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;echo -e&lt;/code&gt; means &lt;em&gt;enable interpretation of backslash escapes&lt;/em&gt;, if you don’t use it, it will print:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;3\n6\n1&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;use-the-paste-command-if-youre-feeling-adventurous&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#use-the-paste-command-if-youre-feeling-adventurous&quot;&gt;Use the paste command if you’re feeling adventurous&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A less robust way would be to use the &lt;code&gt;paste&lt;/code&gt; command with the &lt;code&gt;--serial&lt;/code&gt; option and then the &lt;code&gt;cut&lt;/code&gt; command:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# doesn&amp;#x27;t work pip list -o, only with echo for some reason&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# probably pip list -o has some funny characters?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Package    Version Latest Type&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;---------- ------- ------ -----&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;fonttools  4.33.3  4.40.0 wheel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;pip        22.1    23.1.2 wheel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;setuptools 58.1.0  68.0.0 wheel&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  paste --serial --delimiters &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  cut -d &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -f 3-  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  tr &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# result&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;fonttools  4.33.3  4.40.0 wheel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pip        22.1    23.1.2 wheel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;setuptools 58.1.0  68.0.0 wheel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the example above, I print the text directly into the console with &lt;code&gt;echo&lt;/code&gt; because &lt;code&gt;pip list --outdated&lt;/code&gt; doesn’t really work here with this method, for some reason I don’t care to investigate.&lt;/p&gt;&lt;p&gt;To understand how &lt;code&gt;paste&lt;/code&gt; works, see a note of mine on &lt;a href=&quot;/paste-split-lines-even-odd/&quot;&gt;how to split even and odd lines into two columns with paste&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&lt;code&gt;cut -f 3-&lt;/code&gt; means get from the 3 column until the last column (see &lt;code&gt;man cut&lt;/code&gt; for more stuff the &lt;code&gt;-f&lt;/code&gt; option can do). And, if you want a specific row, for example the 3rd:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ pip list -o &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  paste --serial --delimiters &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  cut -d &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; -f 3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I’m using ’*’ as delimiter; find a char that is not part of your data/output/files.&lt;/p&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://explainshell.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Explain shell web application&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Bash Guide for Beginners&lt;/em&gt; from The Linux Documentation Project&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tldp.org/LDP/abs/html/abs-guide.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Advanced Bash-Scripting Guide&lt;/em&gt; from The Linux Documentation Project&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Split the even and the odd lines of one column into two separate columns]]></title><description><![CDATA[See how the paste command works by splitting the even and the odd lines of one column into two separate columns]]></description><link>https://markoskon.com/paste-split-lines-even-odd/</link><guid isPermaLink="false">https://markoskon.com/paste-split-lines-even-odd/</guid><pubDate>Tue, 27 Jun 2023 16:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Let’s start with the requirement in the title. You have this:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# file 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And you want this:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1 A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2 B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3 C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In other words, you want odd rows (#1, #3, #5, etc) in column 1 and even rows (#2, #4, #6, etc) in column 2.&lt;/p&gt;&lt;p&gt;You can use the &lt;code&gt;paste&lt;/code&gt; command like this:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ paste --serial --delimiters &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;\t\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1       A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2       B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3       C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That seemed like a hack to me. Let’s break down the command above step by step:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;&amp;lt;( command_to_run )&lt;/code&gt;: This is called &lt;a href=&quot;https://tldp.org/LDP/abs/html/process-sub.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;process substitution&lt;/a&gt;. It allows the output of a command to be treated as a file-like object. In this case, the output of the &lt;code&gt;echo&lt;/code&gt; command will be used as input “file” for the &lt;code&gt;paste&lt;/code&gt; command.&lt;/li&gt;&lt;li&gt;&lt;code&gt;paste&lt;/code&gt;: This is a command that merges lines from multiple files. In this case, it will merge lines from the file-like object provided by the process substitution, we have only 1 file.&lt;/li&gt;&lt;li&gt;&lt;code&gt;--delimiters &amp;#x27;\t\n&amp;#x27;&lt;/code&gt;: This option specifies the delimiters to be used between merged lines. In this case, it alternates between a tab character (&lt;code&gt;\t&lt;/code&gt;) and a newline character (&lt;code&gt;\n&lt;/code&gt;) as delimiters.&lt;/li&gt;&lt;li&gt;&lt;code&gt;--serial&lt;/code&gt;: I left this option last because it’s a bit tricky. It tells &lt;code&gt;paste&lt;/code&gt; to &lt;em&gt;paste one file at a time instead of in parallel&lt;/em&gt;. Lets see some examples first.&lt;/li&gt;&lt;/ol&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# file 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# file 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Default paste:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ paste &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1\n2\n3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a\nb\nc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1       a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2       b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3       c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With serial option:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ paste --serial &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1\n2\n3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a\nb\nc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1       2       3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;a       b       c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# or with even more rows for file 1:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ paste --serial &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1\n2\n3\n4\n5&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a\nb\nc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1       2       3       4       5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;a       b       c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Also, an example if the files had 2 columns:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# file 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1 Name1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2 Name2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3 Name3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# file 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;a 10&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;b 20&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;c 39&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ paste  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Name1\n2 Name2\n3 Name3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a 10\nb 20\nc 39&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1 Name1 a 10&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2 Name2 b 20&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3 Name3 c 39&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And with 2 columns and &lt;code&gt;--serial&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ paste --serial &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Name1\n2 Name2\n3 Name3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a\nb\nc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1 Name1 2 Name2 3 Name3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;a       b       c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So, when you run &lt;code&gt;paste&lt;/code&gt;, by default:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;It will go to the 1st line of the resulting file, and it will print the whole 1st line from file 1.&lt;/li&gt;&lt;li&gt;In the same line, it will add a delimiter and it will print the whole 1st line from file 2.&lt;/li&gt;&lt;li&gt;In the same line, it will add a delimiter and it will print the whole 1st line from file 3, and so on, for each file.&lt;/li&gt;&lt;li&gt;It will go the 2nd line of the resulting file, and it will print the whole 2nd line from file 1.&lt;/li&gt;&lt;li&gt;In the same line, it will add a delimiter and it will print the whole 2nd line from file 2.&lt;/li&gt;&lt;li&gt;In the same line, it will add a delimiter and it will print the whole 2nd line from file 3, and so on, for each file.&lt;/li&gt;&lt;li&gt;And so on, for each line.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Hence the &lt;em&gt;merges lines from multiple files&lt;/em&gt; you saw before.&lt;/p&gt;&lt;p&gt;If you run paste with the &lt;code&gt;--serial&lt;/code&gt; option, it will do the following:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;It will go to the 1st line of the resulting file, and it will print the whole 1st line from file 1.&lt;/li&gt;&lt;li&gt;In the same line, it will add a delimiter and it will print the whole 2nd line from file 1.&lt;/li&gt;&lt;li&gt;In the same line, it will add a delimiter and it will print the whole 3rd line from file 1, and so on, for each line of file 1.&lt;/li&gt;&lt;li&gt;It will go the 2nd line of the resulting file, and it will print the whole 1st line from file 2.&lt;/li&gt;&lt;li&gt;In the same line, it will add a delimiter and it will print the whole 2nd line from file 2.&lt;/li&gt;&lt;li&gt;In the same line, it will add a delimiter and it will print the whole 3rd line from file 2, and so on, for each line of file 2.&lt;/li&gt;&lt;li&gt;And so on, for each file.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;In other words, with the &lt;code&gt;--serial&lt;/code&gt; option, the &lt;code&gt;paste&lt;/code&gt; command will print all the lines of each file, separated by the delimiter, in the same line. And each file will be in a different line.&lt;/p&gt;&lt;p&gt;Without the &lt;code&gt;--serial&lt;/code&gt; option, the &lt;code&gt;paste&lt;/code&gt; command will print each line of each file in order, separated by the delimiter, in the same line. And each line of the input files will be in a different line.&lt;/p&gt;&lt;p&gt;Let’s see some examples with the &lt;code&gt;--delimiters&lt;/code&gt; option to understand what’s going on:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ paste --delimiters &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1\n2\n3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a\nb\nc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1^a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2^b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3^c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Ok, it replaces the default tab delimiter with the &lt;code&gt;^&lt;/code&gt; character, this makes sense.&lt;/p&gt;&lt;p&gt;What if we add another character in the &lt;code&gt;--delimiters&lt;/code&gt; because &lt;code&gt;man curl&lt;/code&gt; says that: &lt;em&gt;&lt;code&gt;-d&lt;/code&gt;, &lt;code&gt;--delimiters=LIST&lt;/code&gt;, reuse characters from LIST instead of TABs&lt;/em&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ paste --delimiters &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;^#&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1\n2\n3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a\nb\nc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1^a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2^b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3^c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So, nothing changed here. That is because it did not have the need for an additional delimiter, the files were only two.&lt;/p&gt;&lt;p&gt;But if you use the &lt;code&gt;--serial&lt;/code&gt; option, there is room for 2 delimiters because each file has 3 lines:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ paste --delimiters &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;^#&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; --serial &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1\n2\n3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a\nb\nc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1^2#3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;a^b#c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And now let’s add again the tab and the new line as delimiters, the same as the original solution:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ paste --delimiters &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;\t\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; --serial &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1\n2\n3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a\nb\nc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1       2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;a       b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Not the result we wanted to achieve in the title, but, in our defense, the input is different! And I also hope that the original solution makes more sense now.&lt;/p&gt;&lt;p&gt;If you use serial, and you limit the input to 1 file, you’ll get the same result:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;paste --delimiters &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;\t\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; --serial &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1\na\n2\nb\n3\nc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1       a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2       b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3       c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;quiz&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#quiz&quot;&gt;Quiz&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You have the following file:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;b&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;How do you transform it to:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;15&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1 a A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2 b B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3 c C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;details class=&quot;DisclosureNative__Details-sc-163yhq5-0 vHCRo&quot;&gt;&lt;summary&gt;Solution:&lt;/summary&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;16&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# notice the x2 spaces in the delimiters&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;paste --delimiters &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;  \n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; --serial \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; -e &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1\na\nA\n2\nb\nB\n3\nc\nC&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1 a A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2 b B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3 c C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/details&gt;&lt;h2 id=&quot;use-awk-if-you-want-more-flexibility&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#use-awk-if-you-want-more-flexibility&quot;&gt;Use awk if you want more flexibility&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You can achieve the same result with awk and the &lt;code&gt;NR&lt;/code&gt; built-in variable (it stores the row number):&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;17&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ awk &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;{ if (NR % 2) { printf &amp;quot;%s&amp;quot;, $1 } else { printf &amp;quot;\t%s\n&amp;quot;, $1}}&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;C&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;1       A&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;2       B&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;3       C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The above says, if the row number is odd, print the first column, else (the row number is even), print a tab character, the first column, and a newline character (change the line). Repeat this for every line in the file.&lt;/p&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://explainshell.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Explain shell web application&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Bash Guide for Beginners&lt;/em&gt; from The Linux Documentation Project&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tldp.org/LDP/abs/html/abs-guide.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Advanced Bash-Scripting Guide&lt;/em&gt; from The Linux Documentation Project&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Get specific columns from multiple files and paste (combine) them into  a new file]]></title><description><![CDATA[Use the cut or awk commands to extract specific columns from files and create a new file that has all the previous columns with the paste command.]]></description><link>https://markoskon.com/cut-or-awk-and-paste-commands/</link><guid isPermaLink="false">https://markoskon.com/cut-or-awk-and-paste-commands/</guid><pubDate>Sun, 25 Jun 2023 16:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Assuming that the first file shows the block size of a file in column 1 and the file path in column 2:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# file 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ du -sh &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;/bin/&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;0       /c/Users/asdf/bin/abswin&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;0       /c/Users/asdf/bin/abwin&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;37M     /c/Users/asdf/bin/BrowserStackLocal.exe&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;0       /c/Users/asdf/bin/cloc&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;0       /c/Users/asdf/bin/curltime&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;960K    /c/Users/asdf/bin/cvdump.exe&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And file 2 has the file size in column 5:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# &amp;quot;file&amp;quot; 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ ls -lha &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;/bin/&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; awk &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;{print $5}&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;lrwxrwxrwx 1 asdf 197121   27 Nov 21  2022 /c/Users/asdf/bin/abswin -&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; /c/abs-from-laragon/abs.exe&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;lrwxrwxrwx 1 asdf 197121   56 Nov 20  2022 /c/Users/asdf/bin/abwin -&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; /c/laragon/bin/apache/httpd-2.4.47-win64-VS16/bin/ab.exe&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;-rwxr-xr-x 1 asdf 197121  37M Dec 16  2022 /c/Users/asdf/bin/BrowserStackLocal.exe&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;lrwxrwxrwx 1 asdf 197121   66 Oct 28  2022 /c/Users/asdf/bin/cloc -&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; /c/Users/asdf/Desktop/dev/personal-projects/shell-scripts/clock.sh&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;lrwxrwxrwx 1 asdf 197121   69 Nov  2  2022 /c/Users/asdf/bin/curltime -&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; /c/Users/asdf/Desktop/dev/personal-projects/shell-scripts/curltime.sh&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;-rwxr-xr-x 1 asdf 197121 957K May  3 14:40 /c/Users/asdf/bin/cvdump.exe&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;note&quot;&gt;If you don&amp;#x27;t have files in your &lt;code&gt;~/bin&lt;/code&gt; directory, you can grab some files from the &lt;code&gt;/bin&lt;/code&gt; directory. For example, replace &lt;code&gt;du -sh ~/bin/*&lt;/code&gt; with &lt;code&gt;du -sh /bin/* | head -n 5&lt;/code&gt;. The &lt;code&gt;bin&lt;/code&gt; folder of your home directory (the &lt;code&gt;~&lt;/code&gt; character means home directory), is in the &lt;code&gt;PATH&lt;/code&gt; variable, so you can refer and execute them from any folder.&lt;/div&gt;&lt;p&gt;Let’s assume that I want the following output. First, the column 2 of file 1 (name), second, the column 1 of file 1 (size), and finally, column 5 of file 2 (size):&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;/c/Users/asdf/bin/abswin        27      0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;/c/Users/asdf/bin/abwin 56      0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;/c/Users/asdf/bin/BrowserStackLocal.exe 37M     37M&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;/c/Users/asdf/bin/cloc  66      0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;/c/Users/asdf/bin/curltime      69      0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;/c/Users/asdf/bin/cvdump.exe    957K    960K&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Use the &lt;code&gt;cut --fields LIST&lt;/code&gt; or &lt;code&gt;awk &amp;#x27;{print $5}&amp;#x27;&lt;/code&gt; command to print specific columns from a file, and use the &lt;code&gt;paste&lt;/code&gt; utility to combine them into a new file. See the following command for example:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;$ paste \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;du -sh &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/bin/&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; cut -f 2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;ls -lha &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/bin/&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; awk &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;{print $5}&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;lt;(&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;du -sh &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/bin/&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; cut -f 1&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;/c/Users/asdf/bin/abswin        27      0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;/c/Users/asdf/bin/abwin 56      0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;/c/Users/asdf/bin/BrowserStackLocal.exe 37M     37M&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;/c/Users/asdf/bin/cloc  66      0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;/c/Users/asdf/bin/curltime      69      0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;/c/Users/asdf/bin/cvdump.exe    957K    960K&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the command above, I use &lt;a href=&quot;https://tldp.org/LDP/abs/html/process-sub.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;process substitution&lt;/a&gt; &lt;code&gt;&amp;lt;(...)&lt;/code&gt; to generate the output of the &lt;code&gt;du&lt;/code&gt;, &lt;code&gt;cut&lt;/code&gt;, and &lt;code&gt;awk&lt;/code&gt; commands as input to the paste utility. See the process substitution as something that creates a temporary file that doesn’t get saved anywhere. The &lt;code&gt;du&lt;/code&gt; command retrieves the disk usage of files, the &lt;code&gt;cut&lt;/code&gt; command extracts specific fields, and the &lt;code&gt;awk&lt;/code&gt; command prints the fifth field.&lt;/p&gt;&lt;p&gt;I also use &lt;a href=&quot;https://tldp.org/LDP/lpg/node10.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;linux pipes&lt;/a&gt;, we combine single letter options, e.g. &lt;code&gt;-sh&lt;/code&gt; = &lt;code&gt;-s&lt;/code&gt; + &lt;code&gt;-h&lt;/code&gt;, the &lt;code&gt;-h&lt;/code&gt; option in all the previous commands means &lt;em&gt;human readable&lt;/em&gt;, the &lt;code&gt;-f&lt;/code&gt; option means field (or column). If you don’t understand a command, copy and paste it in the &lt;a href=&quot;https://explainshell.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Explain shell web application&lt;/a&gt;.&lt;/p&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://unix.stackexchange.com/questions/158408/select-certain-column-of-each-file-paste-to-a-new-file&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Select certain column of each file, paste to a new file&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://explainshell.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Explain shell web application&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Bash Guide for Beginners&lt;/em&gt; from The Linux Documentation Project&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://tldp.org/LDP/abs/html/abs-guide.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Advanced Bash-Scripting Guide&lt;/em&gt; from The Linux Documentation Project&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Web scraping in the console]]></title><description><![CDATA[A collection of code snippets you can paste in the browser’s console to get useful data back.]]></description><link>https://markoskon.com/web-scraping-from-the-browsers-console/</link><guid isPermaLink="false">https://markoskon.com/web-scraping-from-the-browsers-console/</guid><pubDate>Mon, 02 Nov 2020 15:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This post contains a collection of code snippets you can paste into the browser’s console and get useful data back. It’s like scraping a web page, but instead of doing it inside a Node script, you do it in the browser’s console. Because you shouldn’t run code that you don’t understand in your console, I explain how most of the snippets work. As a result, you may learn some JavaScript tricks you haven’t seen before, learn how to accomplish basic tasks without using a framework/library (not optimized for performance though), and extract some useful data from the pages you visit. Before we see the code, I want to explain some syntax you’ll encounter throughout the snippets.&lt;/p&gt;&lt;p&gt;In the browser, the &lt;code&gt;$&lt;/code&gt; function &lt;a href=&quot;https://developers.google.com/web/tools/chrome-devtools/console/utilities#queryselector&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;is an alias&lt;/a&gt; for &lt;code&gt;document.querySelector&lt;/code&gt;. For example, if you run &lt;code&gt;$(&amp;#x27;body&amp;#x27;)&lt;/code&gt; in the console, you’ll get back the body element which is the same as running &lt;code&gt;document.querySelector(&amp;#x27;body&amp;#x27;)&lt;/code&gt;. The &lt;code&gt;$$&lt;/code&gt; is the equivalent for &lt;code&gt;document.querySelectorAll&lt;/code&gt;. I use both of those aliases to save some space in the code snippets.&lt;/p&gt;&lt;p&gt;The &lt;code&gt;$$&lt;/code&gt; returns a &lt;code&gt;NodeList&lt;/code&gt; that lacks many of the useful array methods such as &lt;code&gt;map&lt;/code&gt; and &lt;code&gt;filter&lt;/code&gt;. For that reason, I use the &lt;code&gt;Array.from(notAnArray)&lt;/code&gt; method to transform it into an array.&lt;/p&gt;&lt;p&gt;I also use the &lt;code&gt;Set&lt;/code&gt; constructor &lt;code&gt;new Set(array)&lt;/code&gt; that returns a &lt;code&gt;Set&lt;/code&gt; object that contains all the unique values inside an array. Here, we face the same issue with the &lt;code&gt;$$&lt;/code&gt; alias, so I transform the &lt;code&gt;Set&lt;/code&gt; to an array with the &lt;code&gt;Array.from&lt;/code&gt; method.&lt;/p&gt;&lt;h2 id=&quot;show-outlines-to-find-overflows&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#show-outlines-to-find-overflows&quot;&gt;Show outlines to find overflows&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Find which elements cause overflows by adding a red outline to all the body elements. This can also help you understand &lt;a href=&quot;https://iamvdo.me/en/blog/css-font-metrics-line-height-and-vertical-align&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;how inline elements work&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body *&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;outline&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1px solid red&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;get-all-the-different-tags-used-in-a-page&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-all-the-different-tags-used-in-a-page&quot;&gt;Get all the different tags used in a page&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;It’s not the most exciting one, but you may discover new elements to use or at least see what elements other sites use.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body *&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;tagName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You get all the elements inside the &lt;code&gt;body&lt;/code&gt; element with &lt;code&gt;$$(&amp;quot;body *&amp;quot;)&lt;/code&gt; call that returns a &lt;code&gt;NodeList&lt;/code&gt;, you make it an array, you transform that element array to an array with the tag names (strings), you keep only the unique tags with the &lt;code&gt;Set&lt;/code&gt; constructor, and finally, you transform the Set to an array. The &lt;code&gt;sort()&lt;/code&gt; call at the end sorts the array in alphabetical order.&lt;/p&gt;&lt;h2 id=&quot;typography&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#typography&quot;&gt;Typography&lt;/a&gt;&lt;/h2&gt;&lt;h3 id=&quot;print-a-table-with-all-the-characters&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#print-a-table-with-all-the-characters&quot;&gt;Print a table with all the characters&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;See what characters a website uses. Use this if you want to &lt;a href=&quot;/creating-font-subsets/&quot;&gt;adjust the font files by creating subsets&lt;/a&gt; to make sure they cover those characters. The final result is the end of the section.&lt;/p&gt;&lt;p&gt;You start by getting all the elements inside the body and filter out those elements that don’t contain human-readable text, for example, scripts, styles, iframes, etc.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body *&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;tagName&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;defs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;STYLE&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;IFRAME&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;svg&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;SCRIPT&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;NOSCRIPT&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    ]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;tagName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You transform the elements (with &lt;code&gt;map&lt;/code&gt;) to an array that contains their inner texts, you keep only the values that are &lt;em&gt;truthy&lt;/em&gt; with &lt;code&gt;filter(Boolean)&lt;/code&gt;—this will remove empty strings (&lt;code&gt;&amp;quot;&amp;quot;&lt;/code&gt;), &lt;code&gt;undefined&lt;/code&gt;, and more—and you transform it into an array of characters with the &lt;code&gt;join(&amp;quot;&amp;quot;)&lt;/code&gt; &lt;a href=&quot;/array-prototype-methods/&quot;&gt;array method&lt;/a&gt;. The final stage is to pass the output to &lt;code&gt;Array.from(new set(output)).sort()&lt;/code&gt; that will return a sorted array with unique characters.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body *&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;tagName&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;defs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;STYLE&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;IFRAME&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;svg&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;SCRIPT&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;NOSCRIPT&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          ]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;tagName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;innerText&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Boolean&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;note&quot;&gt;Why do this instead of splitting the joined string with &lt;code&gt;split(&amp;quot;&amp;quot;)&lt;/code&gt;? Because, this way, you preserve characters like emojis (and many more). &lt;code&gt;split&lt;/code&gt;, on the other hand, breaks those characters apart and returns jibberish.&lt;/div&gt;&lt;p&gt;Transform the characters to code points and sort them, and finally, print the result. The result is an array with the characters, along with their Unicode hex numbers.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body *&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;tagName&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;defs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;STYLE&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;IFRAME&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;svg&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;SCRIPT&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;NOSCRIPT&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            ]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;tagName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;innerText&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Boolean&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;codePointAt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;())&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;codePoint&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      unicode: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;codePoint&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toUpperCase&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      character: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;fromCodePoint&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;codePoint&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;see-what-fonts-a-website-uses&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#see-what-fonts-a-website-uses&quot;&gt;See what fonts a website uses&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Or, more specifically, get the different values of the &lt;code&gt;font-family&lt;/code&gt; &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; attributes of all body elements. You accomplish that with the help of the &lt;code&gt;getComputedStyle&lt;/code&gt; method:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body *&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getComputedStyle&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;fontFamily&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In case you’re wondering, you &lt;em&gt;cannot&lt;/em&gt; do the same with &lt;code&gt;el.style&lt;/code&gt; because the &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; properties of that object are not populated from the stylesheets. &lt;code&gt;el.style&lt;/code&gt; is used for &lt;em&gt;setting&lt;/em&gt; properties with JavaScript. See all the differences between &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle#Description&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;getComputedStyle&lt;/code&gt; and &lt;code&gt;el.style&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;Firefox developer tools do a much better job at this task with the &lt;em&gt;Fonts&lt;/em&gt; tab, that’s inside the &lt;em&gt;Inspector&lt;/em&gt; tab.&lt;/div&gt;&lt;h3 id=&quot;more-typographic-data&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#more-typographic-data&quot;&gt;More typographic data&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Get the font &lt;em&gt;families&lt;/em&gt; and the different font &lt;em&gt;sizes&lt;/em&gt; that are used in:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body *&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;fontFamily&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;fontSize&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getComputedStyle&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;fontFamily&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;fontSize&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      })&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;uniqueKey&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;uniqueKey&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;fontFamily&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toUpperCase&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;codePointAt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;() &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;fontFamily&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toUpperCase&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;codePointAt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;Set&lt;/code&gt; constructor finds the unique values from arrays that contain primitive values. In this case, we want both the family and the size of an element, so the first thought might be to create an object for each element and store that information there. If you do that, &lt;code&gt;Set&lt;/code&gt; will not work because it will compare the objects by reference, not by the inner value to find if they are unique. For this reason, you serialize the object to a string with &lt;code&gt;JSON.stringify&lt;/code&gt; and later transform it back to an object with &lt;code&gt;JSON.parse&lt;/code&gt; (see the highlighted lines).&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;I have a post that tackles a similar issue which is &lt;a href=&quot;/deep-copy-vs-shallow-copy-vs-assignment/&quot;&gt;the difference between deep/shallow copy and the assignment operator&lt;/a&gt;. It contains useful references to other resources to learn more about the subject.&lt;/div&gt;&lt;h3 id=&quot;highlight-characters-from-a-specific-script&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#highlight-characters-from-a-specific-script&quot;&gt;Highlight characters from a specific script&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A use case for me is that some Greek characters are identical to Latin, for example, &lt;code&gt;Τ&lt;/code&gt;/&lt;code&gt;T&lt;/code&gt; or &lt;code&gt;O&lt;/code&gt;/&lt;code&gt;Ο&lt;/code&gt;. This code helps me find these small mistakes I make while writing text.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;regEx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\p&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;{Script_Extensions=Latin}&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;gu&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;h1, h2, h3, h4, p&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;regEx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;innerHTML&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;innerText&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;innerText&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;regEx&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;$&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\u&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;0332&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Regular expressions are not the most readable code in the world, but they have some cool features. One of them is the &lt;a href=&quot;https://github.com/mathiasbynens/regexpu-core/blob/main/property-escapes.md&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Unicode property escapes&lt;/a&gt; (e.g: &lt;code&gt;/\p{property}/u&lt;/code&gt;). You can use them in regular expressions to find characters from a specific script, emojis, punctuation marks, and more—see the link for more properties. Don’t forget to add the Unicode flag (&lt;code&gt;u&lt;/code&gt;) when you use Unicode property escapes. I’m also using &lt;code&gt;$&amp;amp;&lt;/code&gt; in the string &lt;code&gt;replace&lt;/code&gt; method to refer to the matched string.&lt;/p&gt;&lt;p&gt;I mark the characters with the mark Unicode character (&lt;em&gt;combining low line&lt;/em&gt; &lt;code&gt;u+0332&lt;/code&gt;). I initially thought to parse the &lt;abbr title=&quot;Hypertext Markup&quot;&gt;HTML&lt;/abbr&gt; of the elements (not the innerText) with regular expressions and wrap the characters with &lt;code&gt;&amp;lt;mark&amp;gt;&lt;/code&gt; elements, but, as it turns out, &lt;a href=&quot;https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;parsing &lt;abbr title=&quot;Hypertext Markup&quot;&gt;HTML&lt;/abbr&gt; with regular expressions is probably a bad idea&lt;/a&gt;.&lt;/p&gt;&lt;h3 id=&quot;test-a-font&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#test-a-font&quot;&gt;Test a font&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;See how a Google Font looks on a page. To do that, you create a style element, you add it inside the head element, and you use it.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;ibmSans&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;assign&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  href: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,700;1,400;1,700&amp;amp;display=swap&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  rel: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;stylesheet&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;ibmSans&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Use the font&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body, h1, h2, h3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;fontFamily&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;&amp;#x27;IBM Plex Sans&amp;#x27;, sans-serif&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the previous example, I use a “trick” with &lt;code&gt;Object.assign&lt;/code&gt; to create an element that looks like the React &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; for creating elements, for example:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// This&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;redDiv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;assign&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  style: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;background-color: red; width: 100px; height: 100px;&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Looks similar to this React.createElement(tag, props, children)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;redDiv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    style: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      backgroundColor: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;red&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      width: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;100px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      height: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;100px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;add-an-external-library&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#add-an-external-library&quot;&gt;Add an external library&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Vanilla JavaScript is cool, but sometimes you wish you had access to an external library to help you do the job. In the following example, you can add &lt;code&gt;lodash&lt;/code&gt; with an external script from &lt;code&gt;unpkg&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://unpkg.com/lodash@4.17.20/lodash.js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;onload&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// prints [2, 4, 6] when the script loads&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The code above shows how to add an external script to a page with JavaScript. To add a different library from &lt;abbr title=&quot;Node Package Manager&quot;&gt;NPM&lt;/abbr&gt;, replace the &lt;code&gt;:package&lt;/code&gt; from the following snippet with the package name, enter the &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt; in the browser, and &lt;code&gt;unpkg&lt;/code&gt; will redirect you to the correct file. If not, you’ll have to browse the directory to find the file yourself, and in this case, don’t forget to remove the &lt;code&gt;/browse/&lt;/code&gt; from the &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;unpkg.com/:package@latest&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# And the original sample from unpkg:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;unpkg.com/:package@:version/:file&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;extract-more-css-properties-from-a-page&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#extract-more-css-properties-from-a-page&quot;&gt;Extract more &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; properties from a page&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;With the following snippet, you get all the different box shadows, but you can use it for any other &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; property you’re interested in.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body *&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getComputedStyle&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;boxShadow&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Or create an object with the box shadows, colors, borders, and background images.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;entries&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body *&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getComputedStyle&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;boxShadows&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;boxShadow&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;colors&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;colors&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;backgroundColor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;borders&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;borders&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;borderTop&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;borders&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;borderRight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;borders&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;borderBottom&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;borders&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;borderLeft&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;backgroundImages&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;backgroundImage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      boxShadows: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      colors: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      borders: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      backgroundImages: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  [&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cssVal&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cssVal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cssVal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;show-me-the-code&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#show-me-the-code&quot;&gt;Show me the code&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Show all the elements that are usually hidden. More specifically, this snippet shows all the head elements, and from the body, it shows the scripts, styles, and &lt;code&gt;noscript&lt;/code&gt; elements.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;head &amp;gt; *, body script, body style, body noscript&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;backgroundColor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1em&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;marginBottom&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1.5em&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;overflowX&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;zIndex&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;9999&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;backgroundColor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;inherit&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;inherit&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cloneNode&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;insertAdjacentElement&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;afterend&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;innerText&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;innerHTML&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the previous snippet, you create a &lt;code&gt;pre&lt;/code&gt; and a nested &lt;code&gt;code&lt;/code&gt; element, and you style them. You also add the code in plain text inside the code element (see below how). The plan is to use them like this:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;html&quot; data-index=&quot;15&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  // How to greet from the console.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  console.log(&amp;quot;Hello world&amp;quot;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You use the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentElement&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;insertAdjacentElement&lt;/code&gt;&lt;/a&gt; method to insert the &lt;code&gt;&amp;lt;pre&amp;gt;&lt;/code&gt; right after the original element. The alternative is to get the parent node of the element with &lt;code&gt;el.parentNode&lt;/code&gt; and append a child with the &lt;code&gt;appendChild&lt;/code&gt; method. You set the code element’s inner text to its inner &lt;abbr title=&quot;Hypertext Markup&quot;&gt;HTML&lt;/abbr&gt; which is the original (cloned) element’s &lt;abbr title=&quot;Hypertext Markup&quot;&gt;HTML&lt;/abbr&gt;. If you don’t use the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;cloneNode()&lt;/code&gt;&lt;/a&gt; method to create copies of the original elements, the scripts and the styles will be rendered useless, and the page will not work as before.&lt;/p&gt;&lt;p&gt;Infinite scrollers, default styles on &lt;code&gt;&amp;lt;pre&amp;gt;&lt;/code&gt; elements, and fixed elements can mess-up the result.&lt;/p&gt;&lt;h3 id=&quot;get-comments-from-inline-scripts-and-styles&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-comments-from-inline-scripts-and-styles&quot;&gt;Get comments from inline scripts and styles&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;I’m not sure why you’d want to use this; maybe to read the licenses and the inner thoughts of your fellow developers? My favorite comments are the &lt;em&gt;DO NOT CHANGE&lt;/em&gt;, all in caps of course.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;16&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;script, style&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;textContent&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Boolean&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;weirdRegEx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;(?&amp;lt;!:)(?&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;comment&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\/&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{2}&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*?&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;(?&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;commentMulti&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\/&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;[*\s]&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\*&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;[\s\S]&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;+?&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\*&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;[*\s]&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;comments&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;of&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;code&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;matchAll&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;weirdRegEx&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;comment&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;groups&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;comment&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; || &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;groups&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;commentMulti&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;comments&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;comment&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;comments&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }, []);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The regular expression for single-line comments gives many false positives though. For example, it may return base64 encoded data that match.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;You could use either of &lt;code&gt;textContent&lt;/code&gt; and &lt;code&gt;innerText&lt;/code&gt; to get the text of styles and scripts, so it doesn’t matter which one you choose in this case. See all &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent#Differences_from_innerText&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;the differences between &lt;code&gt;textContent&lt;/code&gt; and &lt;code&gt;innerText&lt;/code&gt;&lt;/a&gt;.&lt;/div&gt;&lt;p&gt;This is a visualization of the regular expression for single-line comments created by the &lt;a href=&quot;https://jex.im/regulex/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Regulex app&lt;/a&gt;. The &lt;code&gt;(?&amp;lt;name&amp;gt;thing to name)&lt;/code&gt; creates a &lt;em&gt;named capturing group&lt;/em&gt; that is easier to access via &lt;code&gt;match.groups.name&lt;/code&gt; instead of &lt;code&gt;match[1]&lt;/code&gt;.&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:1085px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/806f6661dbddf3fd58d4f7062321ef30/f99dd/comment-single.png&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:26.041666666666668%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAA7DAAAOwwHHb6hkAAABVUlEQVQY012QO0/CUBiG+yN1MsFLQtSYqINR4w9w0MVJjDZO+gMYDKsMGBMullu59QKFtjScc9pygILD9xqJk8ObPMkzPa9Sr9fwns+j2e6SM3Sp2WzCsm3qNBrUb7cxsgyybQdCcGKMgXFGf1uz4AKMc3DO8euVScBg6S14NY24ZcIduSTYhCaeR4HvI+YhyXCORC4pkUskMqGFTGg5W2EhFySEwDwOIeMIUkooFaeK4aiLRtWBVncoDjx8WD5qwwkcx6Tb7DV2HzZxqG4j/bhFB2oKR897SN1v0OXLCVqGjlxnjIJuQisXoZTsCuxhB3Xdh9bywdwB5fJFyn9+kW+aULN3OM6kcPaYxmlmB+dP+3ShHtJxZhs3r1c0MHp46/go6Aa0cgmKjCSiKMZUMEjB13+4fRu20YMQIZLpAnMxQxSE4B5DGAiMHR+STfEtVwj/Jf8AF4ZcKjNnCg0AAAAASUVORK5CYII=&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Regular expression visualization for single-line comments&quot; title=&quot;Regular expression visualization for single-line comments&quot; src=&quot;/static/806f6661dbddf3fd58d4f7062321ef30/f99dd/comment-single.png&quot; srcSet=&quot;/static/806f6661dbddf3fd58d4f7062321ef30/3166f/comment-single.png 480w,/static/806f6661dbddf3fd58d4f7062321ef30/fde0f/comment-single.png 960w,/static/806f6661dbddf3fd58d4f7062321ef30/f99dd/comment-single.png 1085w&quot; sizes=&quot;(max-width: 1085px) 100vw, 1085px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Regular expression visualization for single-line comments&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;17&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Single-line comment&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And this is a visualization of the regular expression for multiline comments:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:1529px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/4b4ed300e02139ceed11fb0426765613/675e0/comment-multi.png&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:25.416666666666664%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAAsTAAALEwEAmpwYAAABVElEQVQY0yXIv4rUQADA4TyPhU8gooIg4guoaGOpNjZ2PoBge6BbeXAIyjY2Byrin8NiObl1J9nNZiaZZHYzG7OZzCT7AD8Lv/KLhBAshKDe7iiUxWiLUpY8K6m0QeeWpm4J/kDwI871dM7huh7fD3gXcJ37f84Redfjuz3GaEQ6Y56csZIX2O2WQwjUTU5RLSg3MXUjGYOnbRqyQjBPfpJkM3SlGL1nHEeieJNwXvzlPP7Ms+lN7h1f5dXpff6s1yRmx8vTB9x+fYk7by7zfHqLuNQIWTH5+pS7b6/w+P01vv1+x4V2zMWCKLc5wuyp1S8qfcT35Uf2+ohM5ZR1y6fZCx6d3ODh8XU+/HiCtZalMvTlhLPVFFlM2KkvxKYnU4po8IHDEGi2G6osxcgUnS5xbcvQO5pNRZWv0XKFKSSD6/Bdh5EZRq7RaUJdlhyCZxgC/wAadlkuRdNjewAAAABJRU5ErkJggg==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Regular expression visualization for multi-line comments&quot; title=&quot;Regular expression visualization for multi-line comments&quot; src=&quot;/static/4b4ed300e02139ceed11fb0426765613/675e0/comment-multi.png&quot; srcSet=&quot;/static/4b4ed300e02139ceed11fb0426765613/3166f/comment-multi.png 480w,/static/4b4ed300e02139ceed11fb0426765613/fde0f/comment-multi.png 960w,/static/4b4ed300e02139ceed11fb0426765613/675e0/comment-multi.png 1529w&quot; sizes=&quot;(max-width: 1529px) 100vw, 1529px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Regular expression visualization for multi-line comments&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;18&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/*&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;  Multiline&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;  comment&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The dot special character &lt;code&gt;.&lt;/code&gt; in regular expressions matches all characters except newlines. To match all characters including newlines, you can use &lt;code&gt;[\s\S]&lt;/code&gt;.&lt;/p&gt;&lt;h2 id=&quot;get-all-the-links-from-a-page&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-all-the-links-from-a-page&quot;&gt;Get all the links from a page&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Print the &lt;abbr title=&quot;Uniform Resource Locators&quot;&gt;URLs&lt;/abbr&gt; and the text of the links in a table. Screen readers offer something similar with the &lt;em&gt;rotor&lt;/em&gt; function:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;19&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;href&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                url: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                text: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;innerText&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              })&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Boolean&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;serialized&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;serialized&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you don’t like the table from &lt;code&gt;console.table&lt;/code&gt;, you can use a regular &lt;code&gt;console.log&lt;/code&gt;. In Chrome’s console, you can resize the columns of the table and sort the data by column.&lt;/p&gt;&lt;h2 id=&quot;images&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#images&quot;&gt;Images&lt;/a&gt;&lt;/h2&gt;&lt;h3 id=&quot;display-only-the-images&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#display-only-the-images&quot;&gt;Display only the images&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Display only the image elements inside the page’s body—it removes the body content.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;20&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;images&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;innerHTML&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;overflow&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;images&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;wrapper&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;wrapper&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;wrapper&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;show-background-images-too-and-change-styling&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#show-background-images-too-and-change-styling&quot;&gt;Show background images too and change styling&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;I have a more elaborate solution because the images many times have some default styling, such as absolute positions or weird widths. If you want a more consistent result, it’s better to create new image elements. This also creates image elements for the background images:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;21&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;images&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;backgroundImages&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body *&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getComputedStyle&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;backgroundImage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// The .*? in the middle will match zero or more characters,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// but as few as possible (non-greedy, greedy is the default).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// If you use .* it will consume the ending quote and the URL&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;//  will be invalid.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    src: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;css&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;[&amp;quot;&amp;#x27;]&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*?&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;[&amp;quot;&amp;#x27;]&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    alt: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;innerHTML&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;overflow&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;images&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;backgroundImages&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;newImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;newImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;newImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;newImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;newImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;newImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;outline&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1px dashed red&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newImage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I use &lt;code&gt;append&lt;/code&gt; because I want to add multiple elements at once—see all the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/append&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;differences between &lt;code&gt;append&lt;/code&gt; and &lt;code&gt;appendChild&lt;/code&gt;&lt;/a&gt;. You can render the images in a mosaic layout (kind of) if you add some flex styles to the body element:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;22&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;flex&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;flexWrap&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;wrap&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;alignItems&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;flex-start&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:1382px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/43afb9a69faefd1f54255ff410d0a899/aa36a/url.png&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:24.375000000000004%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAAsTAAALEwEAmpwYAAABOUlEQVQY0yWQy0rDQABF88UiKGihoAsVN678hvpaCPoBLtVWUURbbZrJjHlZk3kkMcVqhSPGxeXexd2c4133+0gVIUNFIBRBEJOpBBWmhEISRzF5kbcpdIHWBdZYrDUUWqO1xliLNgZjDN40TZk5TZZmCP+FKAxI0zescczrLz6rOS4vqYqa79kPX803zjniJCEOfaJXhdUFTV1RVhXerVKcP08RUtJ/vudyMiKRksGoT/dwhc7BMp3eMt2jVdZ6S2werzORAUqMuRg98BSMeBAxN74k8Md4AyE4G2bEWcYwmnCrAsz7lMfhHXsnG2z11tg+6LB72G33/ukOr6Ekf0+4kj4ikYyTnJtxiJj4eE1ZMq9di1E7Q1P+Oymt46dZMDMzGt1QFx9tL5pF68o6134rZ6n+dlW2yL9yv2P+XWFlwQAAAABJRU5ErkJggg==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Regular expression visualization for background images URLs.&quot; title=&quot;Regular expression visualization for background images URLs.&quot; src=&quot;/static/43afb9a69faefd1f54255ff410d0a899/aa36a/url.png&quot; srcSet=&quot;/static/43afb9a69faefd1f54255ff410d0a899/3166f/url.png 480w,/static/43afb9a69faefd1f54255ff410d0a899/fde0f/url.png 960w,/static/43afb9a69faefd1f54255ff410d0a899/aa36a/url.png 1382w&quot; sizes=&quot;(max-width: 1382px) 100vw, 1382px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Regular expression visualization for background images URLs.&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;h2 id=&quot;dark-mode-diy&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#dark-mode-diy&quot;&gt;Dark mode DIY&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;This trick uses the &lt;code&gt;invert&lt;/code&gt; &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; filter to create a dark mode if the site doesn’t offer the option. I first saw it in a post on &lt;a href=&quot;https://inclusive-components.design/a-theme-switcher/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;how to create a theme switcher by Heydon Pickering&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;23&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;invert(1)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;backgroundColor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;allElements&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body *&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;allElements&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;backgroundColor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;inherit&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;media&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;img:not([src*=&amp;quot;.svg&amp;quot;]), video&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;media&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;show-duplicated-ids&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#show-duplicated-ids&quot;&gt;Show duplicated ids&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Ids on a page should be unique and it may be hard to notice if you don’t test with a tool like &lt;code&gt;axe&lt;/code&gt; or Lighthouse. Duplicate ids are not always the result of your code; external libraries can cause them too. This snippet will help you identify this issue.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;24&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;elementsWithIds&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;[id]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;ids&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;elementsWithIds&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getAttribute&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Boolean&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;elementsWithIds&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  uniqueIds: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;ids&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  duplicateIds: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;ids&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;ids&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk12 { color: #FFCB8B; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk28 { color: #5CA7E4; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[React’s useState hook details]]></title><description><![CDATA[Learn the difference between lazy initialization and passing a value as the initial state, the functional and the regular form of setState, and more.]]></description><link>https://markoskon.com/react-usestate-details/</link><guid isPermaLink="false">https://markoskon.com/react-usestate-details/</guid><pubDate>Sun, 02 Aug 2020 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In this post, you’ll see some details with the &lt;code&gt;useState&lt;/code&gt; hook. More specifically, you’ll learn about:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The difference between lazy initialization and passing an initial value.&lt;/li&gt;&lt;li&gt;The difference between the functional and the regular &lt;code&gt;setState&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;The fact that the &lt;code&gt;setState&lt;/code&gt; function remains the same during renders.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;whats-the-difference-between-lazy-initialization-and-passing-an-initial-value-to-usestate-hook&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#whats-the-difference-between-lazy-initialization-and-passing-an-initial-value-to-usestate-hook&quot;&gt;What’s the difference between lazy initialization and passing an initial value to &lt;code&gt;useState&lt;/code&gt; hook?&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Consider a typical &lt;code&gt;useState&lt;/code&gt; hook (the &lt;code&gt;initialValue&lt;/code&gt; represents a number or a string value):&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setValue&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;initialValue&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you declare a &lt;code&gt;useState&lt;/code&gt; hook this way, React will use the &lt;code&gt;initialValue&lt;/code&gt; for the first render and ignore it for subsequent renders. Ignoring the initial value on subsequent renders makes sense because you want to be able to change the state in your code.&lt;/p&gt;&lt;p&gt;If you calculate the initial value with an expensive function, though, React will still run the expensive function on every render. It will just discard the result. An example of what I’m talking about:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setValue&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;someExpensiveComputation&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This behavior isn’t specific to React. In the example above, you invoke a function that returns your initial state, so the JavaScript engine itself has to evaluate that function call to get the resulting value. If you don’t want to evaluate the expensive function on every render, you can use &lt;em&gt;lazy initialization&lt;/em&gt; and pass a function as the first argument to the &lt;code&gt;useState&lt;/code&gt;, as shown below:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setValue&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;someExpensiveComputation&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is different because you pass a function, not the result of a function call. You can also pass a function reference if your expensive function doesn’t need a parameter to make the code less verbose:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setValue&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;someExpensiveComputation&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can &lt;a href=&quot;https://codesandbox.io/s/youthful-euclid-e3gcy?file=/src/App.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;observe this useState behavior in this CodeSanbox&lt;/a&gt; (comment / uncomment the lines).&lt;/p&gt;&lt;h2 id=&quot;whats-the-difference-between-the-functional-and-the-regular-setstate&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#whats-the-difference-between-the-functional-and-the-regular-setstate&quot;&gt;What’s the difference between the functional and the regular &lt;code&gt;setState&lt;/code&gt;?&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;In the following snippet, I use the &lt;code&gt;useState&lt;/code&gt; hook to store and update a counter:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setCounter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The most straightforward way to update your counter state is to pass a value or an expression to the &lt;code&gt;setState&lt;/code&gt; function (I call this regular form):&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setCounter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// somewhere inside an event listener&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;setCounter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The alternative is to pass a function (aka updater function) that has the previous state as a parameter and returns the new state (I call this functional form):&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setCounter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// somewhere inside an event listener&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;setCounter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Most of the times, these two forms of &lt;code&gt;setState&lt;/code&gt; do the same thing. They start to differ if you call them inside an asynchronous function or multiple times inside the same function.&lt;/p&gt;&lt;p&gt;Let’s explain what happens when you call them inside an asynchronous function. That function can be a &lt;code&gt;setTimeout&lt;/code&gt;, a &lt;code&gt;promise.then&lt;/code&gt; block, or a &lt;code&gt;requestAnimationFrame&lt;/code&gt;. For example:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setCounter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// somewhere inside an event listener&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;setTimeout&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setCounter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you use the regular form to increase the counter inside the &lt;code&gt;setTimeout&lt;/code&gt;, and then you increase the counter again by 1 in a synchronous function (or if you update 2 times quickly with the asynchronous function), the counter will remain at 1. This happens because the &lt;code&gt;setTimeout&lt;/code&gt; callback captures the value of the counter at the time you create it. So it sees &lt;code&gt;setCounter(0 + 1)&lt;/code&gt; and not &lt;code&gt;setCounter(currentValue + 1)&lt;/code&gt;. An important detail to remember here is that we get a new &lt;code&gt;counter&lt;/code&gt; and function on every render. The asynchronous function closes over the &lt;code&gt;counter&lt;/code&gt; value the time you create it. If you update the state with the asynchronous function, and then you update it again with a synchronous function, the asynchronous function won’t see the update. This is because the &lt;code&gt;counter&lt;/code&gt; variable that was updated is not the same variable the asynchronous function sees.&lt;/p&gt;&lt;p&gt;On the other hand, if you use the functional form, the counter will increase 2 times and you’ll get a 2 as a result. The functional form doesn’t capture a specific value for the state but gets the previous value when it’s time to update the state.&lt;/p&gt;&lt;p&gt;The same thing happens if you &lt;a href=&quot;https://overreacted.io/react-as-a-ui-runtime/#batching&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;call the &lt;code&gt;setState&lt;/code&gt; multiple times inside the same method&lt;/a&gt; (see at the end of the chapter in the previous link). The functional form will update the state multiple times but the regular form only once. See also &lt;a href=&quot;https://stackoverflow.com/questions/56404819/usestate-hook-setstate-function-accessing-previous-state-value&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;a relevant StackOverflow question&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Check a &lt;a href=&quot;https://codesandbox.io/s/functional-vs-regular-setstate-mvlcf?file=/src/App.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;CodeSanbox that shows the difference between the functional and the regular &lt;code&gt;setState&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&lt;h2 id=&quot;the-setstate-function-from-usestate-doesnt-change-during-renders&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#the-setstate-function-from-usestate-doesnt-change-during-renders&quot;&gt;The &lt;code&gt;setState&lt;/code&gt; function from &lt;code&gt;useState&lt;/code&gt; doesn’t change during renders&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You saw in the previous section that the first variable &lt;code&gt;useState&lt;/code&gt; returns (the &lt;code&gt;counter&lt;/code&gt;) is different on every render. This is not true for the updater function (e.g. &lt;code&gt;setCounter&lt;/code&gt;) which remains the same between renders. We can validate this with the following quote that comes from the &lt;a href=&quot;https://reactjs.org/docs/hooks-reference.html#usestate&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Hooks reference&lt;/a&gt; in the React docs:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;React guarantees that &lt;code&gt;setState&lt;/code&gt; function identity is stable and won’t change on re-renders. This is why it’s safe to omit from the &lt;code&gt;useEffect&lt;/code&gt; or &lt;code&gt;useCallback&lt;/code&gt; dependency list.&lt;/p&gt;&lt;/blockquote&gt;&lt;div class=&quot;note&quot;&gt;The same is true for the &lt;code&gt;dispatch&lt;/code&gt; function from the &lt;a href=&quot;https://reactjs.org/docs/hooks-reference.html#usereducer&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;useReducer&lt;/code&gt;&lt;/a&gt; hook.&lt;/div&gt;&lt;p&gt;In addition to the dependency list part, this also means that you don’t have to wrap this function in a &lt;code&gt;useCallback&lt;/code&gt; hook when you pass it down from a parent to a child component (to prevent the child from re-rendering if the parent component renders).&lt;/p&gt;&lt;p&gt;In other words, you don’t have to worry that the identity of the function will change between renders, as it changes when you pass to a child component a function you create inside the render method of the parent component.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[What’s the difference between using a ref and a variable to keep track of a value in React?]]></title><description><![CDATA[Learn what’s the difference between using a ref (for example, with the useRef hook) and regular variables (outside of a functional component) to keep track of a changing value.]]></description><link>https://markoskon.com/the-difference-between-refs-and-variables/</link><guid isPermaLink="false">https://markoskon.com/the-difference-between-refs-and-variables/</guid><pubDate>Wed, 10 Jun 2020 20:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Sometimes, you want to keep track of a value in React, but you don’t want to store it in the state because it will cause extra renders when it changes. The recommended method (for a functional component) is to use the &lt;code&gt;useRef&lt;/code&gt; hook to store the value there.&lt;/p&gt;&lt;p&gt;In the following example, I want to run the effect when the &lt;code&gt;state&lt;/code&gt; changes, but not the first time the component mounts. For this reason, I use a &lt;code&gt;firstTime&lt;/code&gt; &lt;code&gt;ref&lt;/code&gt; that initially is set to &lt;code&gt;true&lt;/code&gt; and run the effect only when the &lt;code&gt;firstTime.current&lt;/code&gt; is &lt;code&gt;false&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { useState, useEffect, useRef } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Component&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setState&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;firstTime&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useRef&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    if &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;firstTime&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Run the effect.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    } else {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;firstTime&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Component&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The syntax is a bit ugly because you have to use the &lt;code&gt;.current&lt;/code&gt; property, and you might be tempted to use a regular variable instead of the &lt;code&gt;useRef&lt;/code&gt; hook, as shown in the next example.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { useState, useEffect } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;firstTime&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Component&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setState&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    if &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;firstTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Run the effect.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    } else {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;firstTime&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Component&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;differences&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#differences&quot;&gt;Differences&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;As long as the component is a singleton—meaning that you use only one instance of the component in your application—both methods do the same thing. Multiple instances, though, which is really common, share the same variable! As a result, you should avoid using a regular variable because it can get pretty bad. The following example illustrates the problem:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/Counter.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { useState } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;counterOutside&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setCounter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;counterOutside&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      The counter is &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;button&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setCounter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;counterOutside&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;counterOutside&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        +&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/App.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// ....&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you press the button inside one counter, it prints “1 1” where it should print “1 0”, “2, 2” where it should print “2 0”, and so on.&lt;/p&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;Hooks &lt;abbr title=&quot;Frequently Asked Questions&quot;&gt;FAQ&lt;/abbr&gt;: &lt;em&gt;&lt;a href=&quot;https://reactjs.org/docs/hooks-faq.html#is-there-something-like-instance-variables&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Is there something like instance variables?&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://reactjs.org/docs/hooks-reference.html#useref&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;useRef&lt;/code&gt;&lt;/a&gt; in Hooks &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt;.&lt;/li&gt;&lt;li&gt;The same question in a &lt;a href=&quot;https://github.com/facebook/react/issues/15276&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub issue.&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Creating font subsets]]></title><description><![CDATA[Improve the typography and the performance of your site by creating custom font subsets.]]></description><link>https://markoskon.com/creating-font-subsets/</link><guid isPermaLink="false">https://markoskon.com/creating-font-subsets/</guid><pubDate>Wed, 06 May 2020 23:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Two of the most important parts of a web font are the &lt;em&gt;characters&lt;/em&gt; and the &lt;em&gt;OpenType features&lt;/em&gt;. Characters are the letters of the English alphabet (A-Z, a-z), Arabic numbers (0-9), punctuation (comma, spaces, etc). The Unicode standard organizes the characters in blocks based on their functionality and the language they support. Each character in Unicode is mapped to a hex number.&lt;/p&gt;&lt;p&gt;The OpenType features, on the other hand, may include variations of those characters (aka glyphs) that are useful in different contexts. If we take the numbers, for example, they can be superscripts (x&lt;sup&gt;&lt;mark class=&quot;red-mark&quot;&gt;2&lt;/mark&gt;&lt;/sup&gt;), fractions (&lt;span class=&quot;fraction&quot;&gt;1/2&lt;/span&gt;), &lt;a href=&quot;https://docs.microsoft.com/en-us/typography/opentype/spec/features_uz#tag-zero&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;slashed zeros&lt;/a&gt; to separate them from the capital O, or old-style numbers (123456789) that are used to blend numbers inside text.&lt;/p&gt;&lt;h2 id=&quot;why-bother-with-font-subsets&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#why-bother-with-font-subsets&quot;&gt;Why bother with font subsets.&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Subsetting fonts is the process of taking a large font file as input and creating other smaller files, with fewer characters or OpenType features. There are several reasons you may want to subset a font file:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You want to use &lt;em&gt;advanced typographic features&lt;/em&gt; or characters that are not included in the Google fonts subsets—see &lt;a href=&quot;#what-the-google-font-subsets-include&quot;&gt;what the Google fonts subsets include&lt;/a&gt; in a later section. On the other hand, you may want to use fewer features or characters from the original font file.&lt;/li&gt;&lt;li&gt;You want to create small subsets for &lt;a href=&quot;https://www.zachleat.com/web/comprehensive-webfonts/#foft&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;two-stage font loading&lt;/em&gt;&lt;/a&gt; to improve the performance of your application. The goal of this method is to reduce or eliminate the time the browser shows the fallback fonts or the invisible fonts. You can achieve that by loading a small file first, and, at some later point, by swapping it with a richer font file.&lt;/li&gt;&lt;li&gt;You want to split a large font file into script (or language) specific subsets to improve performance without getting overly technical with two-stage font loading. Google already does this, but you may want to create your own, custom subsets, or create subsets for a font that’s not on Google Fonts.&lt;/li&gt;&lt;li&gt;You want to use the latest version of a typeface, and you don’t want to wait until Google updates it.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;note&quot;&gt;Subsetting is probably more useful for &lt;em&gt;free fonts&lt;/em&gt; because paid fonts may require to embed them in a specific way in your site (through a &lt;abbr title=&quot;Content Delivery Network&quot;&gt;CDN&lt;/abbr&gt;), or the license you purchase may not permit subsetting.&lt;/div&gt;&lt;p&gt;In the next section, you’ll see what tools you can use to subset your fonts.&lt;/p&gt;&lt;h2 id=&quot;available-tools&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#available-tools&quot;&gt;Available Tools&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;To create subsets, you can use online tools like the &lt;a href=&quot;https://www.fontsquirrel.com/tools/webfont-generator&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;web font generator&lt;/a&gt; from Font Squirrel, but here I’ll show you how to use &lt;code&gt;pyftsubset&lt;/code&gt;. &lt;code&gt;pyftsubset&lt;/code&gt; is a popular command-line tool written in Python that is part of the &lt;a href=&quot;https://github.com/fonttools/fonttools&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;fonttools&lt;/a&gt;. Apparently, &lt;a href=&quot;https://github.com/googlefonts/gftools/tree/master/Lib/gftools/encodings&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Google Fonts use this tool&lt;/a&gt; to create their subsets, but, because I’m not familiar with Python, I don’t know if this is still true. Another useful tool is &lt;code&gt;glyphhanger&lt;/code&gt; (it uses &lt;code&gt;pyftsubset&lt;/code&gt; under the hood) that has a really cool feature that can crawl your site and show you what characters you use. You can use &lt;code&gt;glyphhanger&lt;/code&gt; to subset your fonts, but I prefer &lt;code&gt;pyftsubset&lt;/code&gt; because you can select what OpenType features you want.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;To use &lt;code&gt;glyphhanger&lt;/code&gt; —which is an &lt;abbr title=&quot;Node Package Manager&quot;&gt;NPM&lt;/abbr&gt; package by the way— check the &lt;a href=&quot;https://github.com/filamentgroup/glyphhanger&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;project’s README&lt;/a&gt; on GitHub or a &lt;a href=&quot;https://www.filamentgroup.com/lab/glyphhanger/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;post&lt;/a&gt; by Zach Leatherman. I will use &lt;code&gt;glyphhanger&lt;/code&gt; in one of the following examples.&lt;/div&gt;&lt;p&gt;Let’s see now how you can install the &lt;code&gt;fontools&lt;/code&gt; and &lt;code&gt;pyftsubset&lt;/code&gt;:&lt;/p&gt;&lt;h2 id=&quot;install-fonttools&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#install-fonttools&quot;&gt;Install fonttools&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;To use &lt;code&gt;pyftsubset&lt;/code&gt;, you need Python and the Python package manager (&lt;code&gt;pip&lt;/code&gt;). &lt;a href=&quot;https://pip.pypa.io/en/stable/installing/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Later versions&lt;/a&gt; of Python include &lt;code&gt;pip&lt;/code&gt;, so you don’t have to install them separately. When you install Python, don’t forget to add it to the path (Windows installer gives you this option) because you want to use &lt;code&gt;pip&lt;/code&gt; from the command line to install the required packages. To check if you installed them, run &lt;code&gt;python --version&lt;/code&gt; and &lt;code&gt;pip --version&lt;/code&gt; in your command line; both tools should print their versions.&lt;/p&gt;&lt;p&gt;Having installed Python and &lt;code&gt;pip&lt;/code&gt;, you’ll use pip to install the following Python packages:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pip install fonttools brotli zopfli&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let’s see what those packages do:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You install the &lt;code&gt;fonttools&lt;/code&gt; because you want to use the &lt;code&gt;pyftsubset&lt;/code&gt; tool to subset your fonts.&lt;/li&gt;&lt;li&gt;You want &lt;code&gt;Brotli&lt;/code&gt; to compress &lt;code&gt;.woff2&lt;/code&gt; files, which is the format used by modern browsers. You don’t have to run &lt;code&gt;Brotli&lt;/code&gt; separately; it’s used by &lt;code&gt;pyftsubset&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;zopfli&lt;/code&gt; is used to compress &lt;code&gt;.woff&lt;/code&gt; files, which is a format used by older browsers. &lt;code&gt;zopfli&lt;/code&gt; is &lt;em&gt;not&lt;/em&gt; the default option for compressing &lt;code&gt;woff&lt;/code&gt; files, and, as a result, it’s &lt;em&gt;optional&lt;/em&gt;. If you want to use it, you add the &lt;code&gt;--with-zopfli&lt;/code&gt; option in your &lt;code&gt;pyftsubset&lt;/code&gt; commands.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;To subsets your fonts, you’ll want to know what characters and OpenType features they contain. Luckily, there’s an excellent online tool that can help you with that.&lt;/p&gt;&lt;h2 id=&quot;what-the-google-font-subsets-include&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#what-the-google-font-subsets-include&quot;&gt;What the Google font subsets include&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let’s now see what the subsets from Google fonts include. You’ll use an online tool by &lt;a href=&quot;https://twitter.com/PixelAmbacht&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Roel Nieskens&lt;/a&gt; called &lt;a href=&quot;https://wakamaifondue.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;wakamaifondue&lt;/a&gt; (What can my font do). Go to the Google fonts interface and select the regular version of &lt;a href=&quot;https://fonts.google.com/specimen/Work+Sans?query=work&amp;amp;sidebar.open&amp;amp;selection.family=Work+Sans&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Work Sans&lt;/a&gt;. To download the font file, go to the embed code that Google gives you, copy the &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt; from the &lt;code&gt;href&lt;/code&gt; attribute of the &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt;, and open it in your browser. To save you some time, this is the &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt; I’m talking about:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;https://fonts.googleapis.com/css2?family=Work+Sans&amp;amp;display=swap&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt; contains a &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; file that has the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;font faces&lt;/a&gt; for the subsets. If you open the Latin subset (the &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt; from the &lt;code&gt;src&lt;/code&gt; descriptor) in your browser, you’ll start downloading that file. This is the &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt; of the font file at the time of writing:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;https://fonts.gstatic.com/s/worksans/v7/QGY_z_wNahGAdqQ43RhVcIgYT2Xz5u32K0nXBi8Jpg.woff2&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Download the file above and drop it in &lt;a href=&quot;https://wakamaifondue.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;wakamaifondue&lt;/a&gt;. The app tells me that the Latin subset has 225 characters and 9 layout features.&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:1409px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/6a9f624edf8f2c76d9ff04dcef434407/1dfc6/wakamaifontdue-summary.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:56.25%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAALABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAECAwX/xAAVAQEBAAAAAAAAAAAAAAAAAAABAP/aAAwDAQACEAMQAAAB3VGwQZH/xAAYEAADAQEAAAAAAAAAAAAAAAAAAREQMf/aAAgBAQABBQKIhEPuf//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABURAQEAAAAAAAAAAAAAAAAAAAAR/9oACAECAQE/AUf/xAAWEAADAAAAAAAAAAAAAAAAAAAQIDH/2gAIAQEABj8CET//xAAcEAACAgIDAAAAAAAAAAAAAAAAARGREDFBUWH/2gAIAQEAAT8hfQqIzxR5KHZWsf/aAAwDAQACAAMAAAAQc+//xAAWEQEBAQAAAAAAAAAAAAAAAAABABH/2gAIAQMBAT8QRLb/xAAXEQADAQAAAAAAAAAAAAAAAAAAARFR/9oACAECAQE/EIsIP//EABwQAQABBAMAAAAAAAAAAAAAAAEAEBEhcUFh8f/aAAgBAQABPxDJLTpA8hdWTwUMgeCEs1T/2Q==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;The Work Sans in the wakamaifondue interface&quot; title=&quot;The Work Sans in the wakamaifondue interface&quot; src=&quot;/static/6a9f624edf8f2c76d9ff04dcef434407/1dfc6/wakamaifontdue-summary.jpg&quot; srcSet=&quot;/static/6a9f624edf8f2c76d9ff04dcef434407/a5e48/wakamaifontdue-summary.jpg 480w,/static/6a9f624edf8f2c76d9ff04dcef434407/1fe05/wakamaifontdue-summary.jpg 960w,/static/6a9f624edf8f2c76d9ff04dcef434407/1dfc6/wakamaifontdue-summary.jpg 1409w&quot; sizes=&quot;(max-width: 1409px) 100vw, 1409px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;The Work Sans in the wakamaifondue interface&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;h3 id=&quot;opentype-features&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#opentype-features&quot;&gt;OpenType features&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/typography/opentype/spec/features_ko#tag-kern&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;kern&lt;/a&gt;, &lt;a href=&quot;https://docs.microsoft.com/en-us/typography/opentype/spec/features_ko#tag-liga&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;liga&lt;/a&gt;, &lt;a href=&quot;https://docs.microsoft.com/en-us/typography/opentype/spec/features_ae#tag-calt&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;calt&lt;/a&gt;, &lt;a href=&quot;https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#tag-rvrn&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;rvrn&lt;/a&gt;, &lt;a href=&quot;https://docs.microsoft.com/en-us/typography/opentype/spec/features_ko#tag-locl&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;locl&lt;/a&gt;: Browsers enable those features by default. &lt;code&gt;kern&lt;/code&gt; adjusts the distance between glyphs, &lt;code&gt;liga&lt;/code&gt; and &lt;code&gt;calt&lt;/code&gt; transform some glyph combinations to single glyphs, &lt;code&gt;rvrn&lt;/code&gt; is specific to variable fonts, and &lt;code&gt;locl&lt;/code&gt; is script related.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/typography/opentype/spec/features_ae#tag-cswh&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;cswh&lt;/a&gt;: Contextual swashes (&lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;Reality&lt;/span&gt; → &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;cswh&amp;#x27;&quot;&gt;Reality&lt;/span&gt;&lt;/span&gt;) are used for decoration.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/typography/opentype/spec/features_fj#tag-frac&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;frac&lt;/a&gt; (fractions: &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;tnum&amp;#x27;, &amp;#x27;lnum&amp;#x27;;font-variant-numeric:tabular-nums lining-nums&quot;&gt;5/8&lt;/span&gt;&lt;/span&gt; → &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;frac&amp;#x27;, &amp;#x27;tnum&amp;#x27;, &amp;#x27;lnum&amp;#x27;&quot;&gt;5/8&lt;/span&gt;&lt;/span&gt;), &lt;a href=&quot;https://docs.microsoft.com/en-us/typography/opentype/spec/features_ko#tag-numr&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;numr&lt;/a&gt; (numerators: &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;tnum&amp;#x27;, &amp;#x27;lnum&amp;#x27;;font-variant-numeric:tabular-nums lining-nums&quot;&gt;123&lt;/span&gt;&lt;/span&gt; → &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;numr&amp;#x27;&quot;&gt;123&lt;/span&gt;&lt;/span&gt;), and &lt;a href=&quot;https://docs.microsoft.com/en-us/typography/opentype/spec/features_ae#tag-dnom&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;dnom&lt;/a&gt; (denominators: &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;tnum&amp;#x27;, &amp;#x27;lnum&amp;#x27;;font-variant-numeric:tabular-nums lining-nums&quot;&gt;123&lt;/span&gt;&lt;/span&gt; → &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;dnom&amp;#x27;&quot;&gt;123&lt;/span&gt;&lt;/span&gt;) are all different ways to display numbers.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;A Google font subset with 9 OpenType features is not that usual; most times you’ll see subsets with 4 features.&lt;/p&gt;&lt;p&gt;Now do the same thing for the &lt;a href=&quot;https://github.com/weiweihuanghuang/Work-Sans/blob/dcdcfac3782757f5077f1897c2df4e9667021036/fonts/static/TTF/WorkSans-Regular.ttf&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;complete font file&lt;/a&gt; that you can find in the GitHub page of Work Sans. The app tells me that this file has 750 characters and 38 layout features. Although 750 compared to 225 characters seems a big difference, most of the characters the Latin subset is missing will be inside the other subsets (see the &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; file with the font faces). So let’s focus first on the OpenType features, and name some important that are not in the subsets:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;onum&lt;/code&gt;, &lt;code&gt;pnum&lt;/code&gt;: &lt;em&gt;Old-style&lt;/em&gt; and &lt;em&gt;proportional&lt;/em&gt; numbers are used to blend numbers inside text: &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;tnum&amp;#x27;, &amp;#x27;lnum&amp;#x27;;font-variant-numeric:tabular-nums lining-nums&quot;&gt;365&lt;/span&gt; days&lt;/span&gt; → &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;365 days&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;smcp&lt;/code&gt;, &lt;code&gt;c2sc&lt;/code&gt;: &lt;em&gt;Small caps&lt;/em&gt; are used for abbreviations and acronyms, and have the same purpose as old-style numbers which is to blend capital letters inside text: &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;&lt;abbr title=&quot;Cascading Style Sheets&quot; style=&quot;font-feature-settings:&amp;#x27;kern&amp;#x27;, &amp;#x27;liga&amp;#x27;, &amp;#x27;clig&amp;#x27;, &amp;#x27;calt&amp;#x27;;font-variant-caps:normal&quot;&gt;HTML&lt;/abbr&gt; document&lt;/span&gt; → &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;&lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;HTML&lt;/abbr&gt; document&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;subs&lt;/code&gt;, &lt;code&gt;sups&lt;/code&gt;: &lt;em&gt;Superscripts&lt;/em&gt; and &lt;em&gt;subscripts&lt;/em&gt; for numbers.&lt;/li&gt;&lt;li&gt;&lt;code&gt;dlig&lt;/code&gt;: &lt;em&gt;Discretionary ligatures&lt;/em&gt; are used for decoration. You can use them together with contextual swashes to create an interesting logo for example: &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;station&lt;/span&gt; → &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr dlig&quot;&gt;station&lt;/span&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;salt&lt;/code&gt; or &lt;code&gt;ss01&lt;/code&gt; to &lt;code&gt;ss05&lt;/code&gt;: Stylistic alternates that are variations of existing characters: &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;R&lt;/span&gt; → &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;kern&amp;#x27;, &amp;#x27;liga&amp;#x27;, &amp;#x27;calt&amp;#x27;, &amp;#x27;clig&amp;#x27;, &amp;#x27;ss03&amp;#x27;&quot;&gt;R&lt;/span&gt;&lt;/span&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;For more information about the OpenType features and how to use them in your code, check an interactive post by Tim Brown called &lt;a href=&quot;https://practice.typekit.com/lesson/caring-about-opentype-features/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Caring about OpenType features&lt;/a&gt;. I use &lt;a href=&quot;https://github.com/MarkosKon/theme-playground/tree/master/packages/opentype&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;a &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; package&lt;/a&gt; I made for that reason.&lt;/p&gt;&lt;h3 id=&quot;characters&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#characters&quot;&gt;Characters&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;You saw what OpenType features the Google fonts subsets include and what features they’re missing; let’s now focus on the characters. Open again the &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; file that contains the font faces, and, this time, pay attention to the &lt;code&gt;unicode-range&lt;/code&gt; descriptor:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* latin */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0000-00FF&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0131&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0152-0153&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+02BB-02BC&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+02C6&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+02DA&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+02DC&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2000-206F&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2074&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+20AC&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2122&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2191&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2193&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2212&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2215&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+FEFF&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+FFFD&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let’s now see what characters this Unicode range contains:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;U+0000-00FF&lt;/code&gt; (I’m ommiting the control characters because they don’t render a character):&lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;20&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;!&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;21&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;22&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;#&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;23&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;24&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;%&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;25&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;26&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;27&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;28&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;29&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;*&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;+&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;-&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;.&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;/&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;0&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;30&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;1&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;31&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;2&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;32&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;3&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;33&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;4&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;34&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;5&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;35&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;6&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;36&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;7&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;37&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;8&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;38&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;9&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;39&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;:&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;3A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;3B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;3C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;3D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;3E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;?&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;3F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;@&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;40&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;A&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;41&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;B&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;42&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;C&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;43&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;D&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;44&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;E&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;45&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;F&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;46&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;G&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;47&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;H&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;48&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;I&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;49&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;J&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;4A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;K&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;4B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;L&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;4C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;M&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;4D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;N&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;4E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;O&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;4F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;P&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;50&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Q&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;51&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;R&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;52&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;S&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;53&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;T&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;54&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;U&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;55&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;V&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;56&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;W&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;57&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;X&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;58&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Y&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;59&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Z&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;5A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;5B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;\&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;5C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;5D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;^&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;5E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;_&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;5F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;`&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;60&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;a&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;61&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;b&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;62&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;c&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;63&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;d&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;64&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;e&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;65&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;f&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;66&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;g&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;67&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;h&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;68&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;i&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;69&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;j&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;6A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;k&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;6B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;l&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;6C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;m&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;6D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;n&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;6E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;o&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;6F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;p&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;70&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;q&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;71&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;r&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;72&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;s&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;73&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;t&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;74&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;u&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;75&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;v&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;76&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;w&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;77&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;x&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;78&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;y&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;79&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;z&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;7A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;7B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;|&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;7C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;7D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;~&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;7E&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¡&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A1&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¢&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A2&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;£&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A3&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¤&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A4&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¥&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¦&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A6&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;§&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A7&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¨&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A8&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;©&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A9&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ª&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;AA&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;«&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;AB&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¬&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;AC&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;­&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;AD&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;®&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;AE&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¯&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;AF&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;°&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;±&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B1&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;²&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B2&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;³&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B3&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;´&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B4&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;µ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¶&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B6&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;·&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B7&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¸&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B8&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¹&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B9&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;º&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;BA&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;»&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;BB&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¼&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;BC&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;½&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;BD&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¾&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;BE&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¿&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;BF&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;À&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Á&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C1&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Â&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C2&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ã&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C3&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ä&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C4&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Å&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Æ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C6&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ç&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C7&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;È&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C8&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;É&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C9&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ê&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;CA&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ë&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;CB&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ì&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;CC&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Í&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;CD&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Î&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;CE&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ï&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;CF&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ð&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ñ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D1&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ò&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D2&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ó&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D3&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ô&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D4&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Õ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ö&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D6&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;×&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D7&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ø&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D8&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ù&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D9&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ú&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;DA&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Û&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;DB&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ü&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;DC&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ý&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;DD&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Þ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;DE&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ß&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;DF&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;à&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;á&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E1&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;â&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E2&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ã&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E3&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ä&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E4&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;å&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;æ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E6&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ç&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E7&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;è&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E8&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;é&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E9&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ê&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;EA&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ë&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;EB&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ì&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;EC&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;í&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;ED&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;î&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;EE&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ï&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;EF&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ð&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ñ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F1&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ò&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F2&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ó&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F3&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ô&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F4&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;õ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ö&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F6&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;÷&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F7&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ø&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F8&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ù&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F9&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ú&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FA&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;û&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FB&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ü&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FC&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ý&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FD&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;þ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FE&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ÿ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FF&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+0131&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ı&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;131&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+0152-0153&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Œ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;152&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;œ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;153&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+02BB-02BC&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ʻ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2BB&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ʼ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2BC&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+02C6&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ˆ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2C6&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+02DA&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;˚&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2DA&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+02DC&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;˜&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2DC&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+2000-206F&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2000&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2001&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2002&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2003&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2004&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2005&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2006&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2007&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2008&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2009&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;200A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;​&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;200B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‌&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;200C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‍&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;200D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‎&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;200E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‏&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;200F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‐&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2010&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‑&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2011&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‒&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2012&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;–&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2013&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;—&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2014&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;―&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2015&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‖&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2016&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‗&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2017&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‘&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2018&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;’&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2019&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‚&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;201A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‛&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;201B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;“&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;201C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;”&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;201D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;„&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;201E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‟&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;201F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;†&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2020&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‡&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2021&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;•&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2022&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‣&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2023&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;․&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2024&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‥&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2025&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;…&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2026&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‧&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2027&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2028&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2029&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‪&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;202A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‫&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;202B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‬&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;202C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‭&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;202D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‮&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;202E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;202F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‰&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2030&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‱&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2031&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;′&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2032&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;″&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2033&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‴&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2034&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‵&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2035&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‶&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2036&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‷&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2037&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‸&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2038&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‹&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2039&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;›&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;203A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;※&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;203B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‼&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;203C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‽&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;203D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‾&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;203E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;‿&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;203F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁀&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2040&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁁&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2041&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁂&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2042&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁃&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2043&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁄&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2044&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁅&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2045&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁆&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2046&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁇&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2047&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁈&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2048&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁉&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2049&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁊&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;204A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁋&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;204B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁌&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;204C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁍&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;204D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁎&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;204E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁏&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;204F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁐&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2050&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁑&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2051&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁒&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2052&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁓&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2053&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁔&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2054&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁕&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2055&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁖&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2056&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁗&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2057&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁘&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2058&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁙&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2059&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁚&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;205A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁛&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;205B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁜&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;205C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁝&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;205D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁞&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;205E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;205F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁠&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2060&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁡&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2061&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁢&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2062&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁣&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2063&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁤&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2064&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁥&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2065&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁦&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2066&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁧&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2067&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁨&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2068&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁩&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2069&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁪&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;206A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁫&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;206B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁬&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;206C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁭&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;206D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁮&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;206E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁯&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;206F&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+2074&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;⁴&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2074&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+20AC&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;€&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;20AC&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+2122&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;™&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2122&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+2191&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;↑&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2191&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+2193&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;↓&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2193&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+2212&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;−&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2212&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+2215&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;∕&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2215&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+FEFF&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;﻿&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FEFF&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;U+FFFD&lt;/code&gt;: &lt;span class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;�&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FFFD&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;As you can see, the Latin subset from Google Fonts contains a lot of characters, that your font may not even support. Furthermore, there’s a chance that you don’t need all these characters, or that you need some characters not listed above. In the following examples, you’ll see how to address these issues by creating your own subsets.&lt;/p&gt;&lt;h2 id=&quot;examples&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#examples&quot;&gt;Examples&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;It’s time to use the &lt;code&gt;pyftsubset&lt;/code&gt; to create some subsets. This is the list with the subsets you’ll create:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;#keep-all-opentype-features-and-characters&quot;&gt;Keep all OpenType features and characters&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#latin-subset&quot;&gt;Latin subset&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#english-subset&quot;&gt;English subset&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#minimal-english-subset&quot;&gt;Minimal English subset&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#multiple-subsets-by-script&quot;&gt;Multiple subsets by script&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;note&quot;&gt;Before we begin, I want to point out that I&amp;#x27;m running the examples on a Windows machine with the Git Bash command line.&lt;/div&gt;&lt;h3 id=&quot;keep-all-opentype-features-and-characters&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#keep-all-opentype-features-and-characters&quot;&gt;Keep all OpenType features and characters&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The first thing you’ll do is to convert a TrueType (&lt;code&gt;.ttf&lt;/code&gt;) file to a compressed TrueType file that’s optimized for the web (&lt;code&gt;.woff2&lt;/code&gt;). You’ll keep all the characters and OpenType features from the original file. The file you’re working with is the &lt;a href=&quot;https://github.com/weiweihuanghuang/Work-Sans/blob/dcdcfac3782757f5077f1897c2df4e9667021036/fonts/static/TTF/WorkSans-Regular.ttf&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;regular version of Work Sans&lt;/a&gt; because it has many OpenType features and characters. Download the font file, open your command line in the downloads folder, and paste the following command:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;           --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-all.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;           --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;           --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;           --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The first parameter is the original font name (WorkSans-Regular.ttf). With the &lt;em&gt;&lt;code&gt;output-file&lt;/code&gt;&lt;/em&gt; option, you pass the name of the file you’ll create and with the &lt;em&gt;&lt;code&gt;flavor&lt;/code&gt;&lt;/em&gt; option the format of that file. You specify what OpenType features you want with the &lt;em&gt;&lt;code&gt;layout-features&lt;/code&gt;&lt;/em&gt; option—the asterisk means that you want them all. The &lt;em&gt;&lt;code&gt;unicodes&lt;/code&gt;&lt;/em&gt; option is for the Unicode characters you want, with the asterisk meaning that you want all the characters from the original file. If you specify more characters than the font file has, the program doesn’t throw an error by default. Instead of passing Unicode character codes, you can directly pass characters with the &lt;code&gt;text&lt;/code&gt; or &lt;code&gt;text-file&lt;/code&gt; options. I don’t prefer the &lt;code&gt;text&lt;/code&gt; option because it seems error-prone.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;I’m using the backslash (&lt;code&gt;\&lt;/code&gt;) to span the command over multiple lines and make it more readable. The alternative is to remove the backslashes and write the command in a single line.&lt;/div&gt;&lt;div class=&quot;note&quot;&gt;I suggest opening a text editor to paste the examples there so you can easily change them if you want. For example, the command above doesn’t work on the Windows &lt;abbr title=&quot;Command prompt&quot;&gt;CMD&lt;/abbr&gt;. To run multiline commands on the Windows command line, you’ll have to replace the backslash with a &lt;em&gt;circumflex accent&lt;/em&gt; (`^`, `Shift + 6` in your keyboard).&lt;/div&gt;&lt;p&gt;You can also use the &lt;code&gt;--verbose&lt;/code&gt; option to view information while the tool creates the file. With &lt;code&gt;pyftsubset --help&lt;/code&gt;, you get a list of all the available options. Alternatively, check the &lt;code&gt;pyftsubset&lt;/code&gt; &lt;a href=&quot;https://fonttools.readthedocs.io/en/latest/subset/index.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;documentation page&lt;/a&gt; that explains all the options.&lt;/p&gt;&lt;p&gt;The new font file is around 62kb and the original was 207kb. Along with the characters and the OpenType features, the font files also include &lt;em&gt;hinting tables&lt;/em&gt;. These are instructions on how to render the fonts well on screens with small resolution (or more specifically, with low pixels per inch or ppi). If you want to remove the hinting, use the &lt;code&gt;--no-hinting&lt;/code&gt; option along with the &lt;code&gt;--desubroutinize&lt;/code&gt; option as shown in the following command:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;           --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-all-no-hinting.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;           --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;           --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;           --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;           --no-hinting \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;           --desubroutinize&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After removing the hinting, the file size goes down to 47kb, which means that hinting was taking up 30% of the file size. While testing hinting in a Windows machine, with a screen that has a 23″ diagonal and 1920 × 1080 resolution, I was able to see some &lt;em&gt;minor&lt;/em&gt; differences between the hinted and the unhinted version of Work Sans. In mobile phones (they have high ppi) and Macs it shouldn’t matter much. As a result, I suggest to keep hinting, unless you really want to save some space.&lt;/p&gt;&lt;h3 id=&quot;latin-subset&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#latin-subset&quot;&gt;Latin subset&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Now, you’ll create a subset based on the Google font Latin subset you saw earlier. This subset includes a ton of useful characters, so it’s a good starting point if you want to cover text in English, French, Spanish, or German. This is the command you’ll run:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-google-fonts.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The new file has a file size of 35kb with hinting and 26kb without hinting. For comparison, the Latin Google font subset is around 23kb &lt;em&gt;with&lt;/em&gt; hinting but with a limited number of layout features. To reduce the file size, you can limit the layout features too:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-google-fonts-2.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let’s explain what the layout features do first (you already saw most of them):&lt;/p&gt;&lt;ul&gt;&lt;li&gt;In the first line, &lt;code&gt;kern&lt;/code&gt;, &lt;code&gt;liga&lt;/code&gt;, &lt;code&gt;calt&lt;/code&gt;, &lt;code&gt;clig&lt;/code&gt; are important features and they are on by default in &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;. &lt;code&gt;ccmp&lt;/code&gt;, &lt;code&gt;locl&lt;/code&gt;, &lt;code&gt;mark&lt;/code&gt;, and &lt;code&gt;mkmk&lt;/code&gt; are also always turned on by the browser, but their difference is that you can’t turn them off with &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;.&lt;/li&gt;&lt;li&gt;In the second line, we have some essential features for body text like the &lt;code&gt;onum&lt;/code&gt;, &lt;code&gt;pnum&lt;/code&gt;, &lt;code&gt;smcp&lt;/code&gt;, and &lt;code&gt;c2sc&lt;/code&gt; that you saw in a previous section, and for representing numbers we have &lt;code&gt;frac&lt;/code&gt;, &lt;code&gt;lnum&lt;/code&gt;, &lt;code&gt;tnum&lt;/code&gt;, &lt;code&gt;sups&lt;/code&gt;, and &lt;code&gt;subs&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;In the third line, we have some decoration features like &lt;code&gt;cswh&lt;/code&gt;, &lt;code&gt;dlig&lt;/code&gt;, &lt;code&gt;ss01&lt;/code&gt;, &lt;code&gt;ss03&lt;/code&gt;, and &lt;code&gt;zero&lt;/code&gt;. If you don’t plan to use these features, you can remove them because some take a lot of space (&lt;code&gt;cswh&lt;/code&gt;).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;By including only these features, we save 4kb and we go down to 31kb. We were not able to reduce the size much because small caps and contextual swashes add a lot of extra glyphs to the file.&lt;/p&gt;&lt;p&gt;If you open the new file in &lt;a href=&quot;https://wakamaifondue.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;wakamaifondue&lt;/a&gt;, you’ll notice that only the &lt;code&gt;locl&lt;/code&gt; feature is kept from the features that you can’t change in &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;, and &lt;code&gt;mark&lt;/code&gt;, &lt;code&gt;ccmp&lt;/code&gt;, &lt;code&gt;mkmk&lt;/code&gt; were thrown away. You can find an explanation for that in wakamaifondue:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;These are the required layout features: features that are always turned on by the system that renders the font. You can’t turn them off in &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;. They may be applicable &lt;strong&gt;only to certain language scripts or specific languages, or in certain writing modes.&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Because this process can get messy, If you don’t want to remove essential features from the original file by specifying the layout features &lt;em&gt;explicitly&lt;/em&gt; with the &lt;code&gt;=&lt;/code&gt; operator, you can instead add to the &lt;em&gt;default features&lt;/em&gt; with &lt;code&gt;+=&lt;/code&gt; or remove with &lt;code&gt;-=&lt;/code&gt;. The default features are &lt;code&gt;calt&lt;/code&gt;, &lt;code&gt;ccmp&lt;/code&gt;, &lt;code&gt;clig&lt;/code&gt;, &lt;code&gt;curs&lt;/code&gt;, &lt;code&gt;dnom&lt;/code&gt;, &lt;code&gt;frac&lt;/code&gt;, &lt;code&gt;kern&lt;/code&gt;, &lt;code&gt;liga&lt;/code&gt;, &lt;code&gt;locl&lt;/code&gt;, &lt;code&gt;mark&lt;/code&gt;, &lt;code&gt;mkmk&lt;/code&gt;, &lt;code&gt;numr&lt;/code&gt;, &lt;code&gt;rclt&lt;/code&gt;, &lt;code&gt;rlig&lt;/code&gt;, &lt;code&gt;rvrn&lt;/code&gt;, and all features required for script shaping. Type &lt;code&gt;pyftsubset --layout-features=?&lt;/code&gt; to see all the defaults features. So a safer alternative to the previous command is the following:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-google-fonts-2.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features+=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;onum,pnum,smcp,c2sc,lnum,tnum,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  subs,sups,cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features-=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dnom,numr&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Looking at the character table of the original file in wakamaifondue, I can see some cool characters we don’t have in the subset. I want to add all the arrows &lt;code&gt;U+2190-21BB&lt;/code&gt; &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;(← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↩ ↪ ↺ ↻)&lt;/span&gt; and a hedgehog symbol &lt;span class=&quot;WorkSansSnippet-sc-1l1boyp-0 foVttr&quot;&gt;()&lt;/span&gt; that’s on &lt;code&gt;U+F8FF&lt;/code&gt;. To add those characters, change the &lt;code&gt;unicodes&lt;/code&gt; option to the following:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-google-fonts-3.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+2122,U+2190-21BB,U+2212,U+2215,U+F8FF,U+FEFF,U+FFFD&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This increases the file size to 32kb but you now have some cool characters to work with.&lt;/p&gt;&lt;p&gt;You saw how to create a Latin subset with fewer characters and OpenType features. In the next section, you’ll remove even more characters to create an English-only subset.&lt;/p&gt;&lt;h3 id=&quot;english-subset&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#english-subset&quot;&gt;English subset&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Let’s now assume that you display only English on your site. If that’s the case, you’ll want to remove the characters used by other languages. &lt;a href=&quot;https://www.bramstein.com/writing/web-font-anti-patterns-subsetting.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Don’t overdo it though&lt;/a&gt; because you may display names or places from other languages. In the next section, you’ll verify what characters you use with &lt;code&gt;glyphhanger&lt;/code&gt; so stay tuned.&lt;/p&gt;&lt;p&gt;We want to remove a big chunk from the &lt;em&gt;Latin-1 supplement&lt;/em&gt; (&lt;code&gt;U+0080-00FF&lt;/code&gt;), but we want to keep punctuation characters, symbols, and a couple of math characters: &lt;code&gt;U+00D7&lt;/code&gt; (×) and &lt;code&gt;U+00F7&lt;/code&gt; (÷). Long story short, from the following table, you’ll &lt;em&gt;remove&lt;/em&gt; the highlighted characters:&lt;/p&gt;&lt;div class=&quot;RangesToCharacters__Container-sc-i3j11l-0 ieDqpa&quot;&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;20&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;!&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;21&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;22&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;#&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;23&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;$&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;24&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;%&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;25&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;26&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;27&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;28&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;)&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;29&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;*&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;+&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;-&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;.&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;/&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;2F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;0&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;30&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;1&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;31&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;2&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;32&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;3&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;33&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;4&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;34&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;5&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;35&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;6&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;36&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;7&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;37&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;8&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;38&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;9&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;39&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;:&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;3A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;3B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;3C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;=&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;3D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;3E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;?&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;3F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;@&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;40&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;A&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;41&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;B&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;42&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;C&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;43&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;D&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;44&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;E&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;45&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;F&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;46&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;G&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;47&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;H&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;48&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;I&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;49&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;J&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;4A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;K&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;4B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;L&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;4C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;M&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;4D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;N&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;4E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;O&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;4F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;P&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;50&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Q&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;51&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;R&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;52&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;S&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;53&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;T&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;54&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;U&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;55&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;V&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;56&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;W&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;57&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;X&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;58&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Y&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;59&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Z&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;5A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;[&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;5B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;\&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;5C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;]&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;5D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;^&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;5E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;_&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;5F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;`&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;60&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;a&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;61&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;b&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;62&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;c&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;63&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;d&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;64&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;e&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;65&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;f&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;66&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;g&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;67&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;h&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;68&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;i&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;69&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;j&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;6A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;k&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;6B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;l&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;6C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;m&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;6D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;n&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;6E&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;o&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;6F&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;p&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;70&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;q&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;71&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;r&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;72&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;s&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;73&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;t&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;74&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;u&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;75&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;v&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;76&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;w&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;77&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;x&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;78&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;y&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;79&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;z&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;7A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;7B&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;|&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;7C&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;7D&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;~&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;7E&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt; &lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 kQgKoo&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¡&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¢&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A2&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;£&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A3&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¤&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A4&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¥&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¦&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A6&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;§&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A7&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¨&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A8&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;©&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;A9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 kQgKoo&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ª&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;AA&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;«&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;AB&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¬&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;AC&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;­&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;AD&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;®&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;AE&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 kQgKoo&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¯&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;AF&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;°&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;±&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B1&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;²&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B2&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;³&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B3&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;´&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B4&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;µ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¶&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B6&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;·&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B7&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 kQgKoo&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¸&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B8&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¹&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;B9&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;º&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;BA&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 kQgKoo&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;»&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;BB&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¼&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;BC&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;½&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;BD&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¾&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;BE&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 kQgKoo&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;¿&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;BF&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;À&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Á&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C1&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Â&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C2&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ã&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C3&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ä&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C4&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Å&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Æ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C6&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ç&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C7&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;È&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C8&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;É&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;C9&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ê&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;CA&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ë&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;CB&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ì&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;CC&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Í&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;CD&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Î&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;CE&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ï&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;CF&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ð&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ñ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D1&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ò&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D2&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ó&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D3&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ô&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D4&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Õ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ö&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D6&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;×&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D7&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 kQgKoo&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ø&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D8&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ù&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;D9&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ú&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;DA&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Û&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;DB&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ü&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;DC&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Ý&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;DD&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;Þ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;DE&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ß&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;DF&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;à&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;á&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E1&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;â&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E2&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ã&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E3&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ä&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E4&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;å&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;æ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E6&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ç&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E7&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;è&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E8&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;é&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;E9&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ê&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;EA&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ë&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;EB&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ì&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;EC&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;í&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;ED&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;î&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;EE&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ï&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;EF&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ð&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ñ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F1&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ò&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F2&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ó&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F3&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ô&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F4&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;õ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ö&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F6&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 hFBqPr&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;÷&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F7&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Range-sc-i3j11l-1 kQgKoo&quot;&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ø&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F8&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ù&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;F9&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ú&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FA&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;û&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FB&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ü&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FC&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ý&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FD&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;þ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FE&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__Character-sc-i3j11l-2 ilhCDS&quot;&gt;&lt;span&gt;ÿ&lt;/span&gt;&lt;span class=&quot;RangesToCharacters__HexCode-sc-i3j11l-3 jzjFIj&quot;&gt;FF&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;Outside of the Latin-1 supplement, you’ll also remove &lt;code&gt;U+0131&lt;/code&gt; (ı), &lt;code&gt;U+0152-0153&lt;/code&gt; (Œ œ), and the &lt;em&gt;spacing modifier letters&lt;/em&gt; &lt;code&gt;U+02B0-02FF&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;This is the command that creates an English-only subset:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-english.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+0000-00A0,U+00A2-00A9,U+00AC-00AE,U+00B0-00B7,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+00B9-00BA,U+00BC-00BE,U+00D7,U+00F7,U+2000-206F,U+2074,U+20AC,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+2122,U+2190-21BB,U+2212,U+2215,U+F8FF,U+FEFF,U+FFFD&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With those changes, the file size goes from 31kb to 27kb. In the next section, you see how to create a performance focused subset.&lt;/p&gt;&lt;h3 id=&quot;minimal-english-subset&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#minimal-english-subset&quot;&gt;Minimal English subset&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The goal here is to create a tiny subset that you can use for &lt;a href=&quot;https://www.zachleat.com/web/comprehensive-webfonts/#foft&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;two-stage font loading&lt;/a&gt;. As a result, you’ll want to keep the file size as small as possible—under 10kb would be ideal. The English subset in the previous section won’t do because it still has a lot of characters you probably won’t use. Instead, I suggest to install &lt;code&gt;glyphhanger&lt;/code&gt; and use it to crawl your website to see what characters you use. If you want something more generic, but with fewer characters than in the previous section, crawl a popular English website with good typography.&lt;/p&gt;&lt;p&gt;First, you want to install &lt;code&gt;glyphhanger&lt;/code&gt; globally:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;npm install -g glyphhanger&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can also install it as a dev dependency in your project with &lt;code&gt;yarn add -D glyphhanger&lt;/code&gt; and run it from there with &lt;code&gt;yarn glyphhanger&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;Then, crawl your development server (or your production site), after adding the correct port:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;glyphhanger http://localhost:3000 --spider --spider-limit=5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I will now crawl my website to see what characters I’m using:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;glyphhanger https://markoskon.com --spider --spider-limit=5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;These are the Unicode ranges I get back after running the command above:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;U+A,U+20,U+22,U+25-29,U+2B-3E,U+41-59,U+61-7A,U+F3,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;U+3A4,U+2014,U+2019,U+201C,U+201D,U+2020,U+2021,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;U+2026,U+20AC,U+2190,U+F8FF,U+1F426,U+1F4D7,U+1F4F0,U+1F525&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;note&quot;&gt;&lt;ul style=&quot;margin-bottom:0&quot;&gt;&lt;li&gt;&lt;p&gt;To be sure you get all the characters back, you can crawl all your pages with &lt;code&gt;--spider-limit=0&lt;/code&gt;, but this will take some time.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;You can get the characters a specific font uses with the &lt;code&gt;family&lt;/code&gt; option (e.g. &lt;code&gt;--family=&amp;quot;monospace&amp;quot;&lt;/code&gt;) or specify multiple families with &lt;code&gt;--family=&amp;quot;Georgia,Consolas&amp;quot;&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;p&gt;I will now pass the string I got in the &lt;code&gt;--unicodes&lt;/code&gt; option (after removing the 4 emojis at the end) to create an English subset:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;15&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-glyphhanger.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+A,U+20,U+22,U+25-29,U+2B-3E,U+41-59,U+61-7A,U+F3,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;U+3A4,U+2014,U+2019,U+201C,U+201D,U+2020,U+2021,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;U+2026,U+20AC,U+2190&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This results in a font file at around 20kb. This is still way over the 10kb goal. Let’s remove the hinting first because, in this case, size is more important:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;16&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-minimal.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+A,U+20,U+22,U+25-29,U+2B-3E,U+41-59,U+61-7A,U+F3,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;U+3A4,U+2014,U+2019,U+201C,U+201D,U+2020,U+2021,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;U+2026,U+20AC,U+2190&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --no-hinting\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --desubroutinize&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The font file without hinting is around 14kb which is still not good enough.&lt;/p&gt;&lt;p&gt;The goal of two-stage font loading is to reduce or eliminate the time the browser displays the invisible or the fallback font. To be more precise, we have 3 fonts: the fallback (e.g. sans-serif), the small fake (e.g. Work Sans Minimal), and the real font (e.g. Work Sans). We also have 2 transitions: from the fallback to the fake and from the fake to the real font. Here, we’re not concerned with the first transition, so we’ll focus on the second. In this transition, you’ll want to reduce the moving of the text, and, to do that, you’ll want to keep all the layout features that affect spacing. All the features we have here affect spacing in some way, so if you plan to use them all, you can’t reduce the size any further.&lt;/p&gt;&lt;p&gt;But there’s a good chance that you won’t use all of them, or that you’ll use them sparingly, and, as a result, they won’t cause a lot of text reflow. So if you keep only the default features (minus the swashes) along with &lt;code&gt;lnum&lt;/code&gt;, &lt;code&gt;tnum&lt;/code&gt; (which are the default number forms):&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;17&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-minimal-super-minimal.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features+=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;lnum,tnum&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features-=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cswh&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+A,U+20,U+22,U+25-29,U+2B-3E,U+41-59,U+61-7A,U+F3,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;U+3A4,U+2014,U+2019,U+201C,U+201D,U+2020,U+2021,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;U+2026,U+20AC,U+2190&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --no-hinting\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --desubroutinize&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The command above creates a file that’s 8kb in size which is under the 10kb goal.&lt;/p&gt;&lt;h4 id=&quot;extra-find-what-characters-a-language-uses&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#extra-find-what-characters-a-language-uses&quot;&gt;Extra: Find what characters a language uses&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;This is what you can do when you want to cover a language, but you are not sure what characters to add in your subsets.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;There is the Unicode Common Locale Data Repository (&lt;abbr title=&quot;Unicode Common Locale Data Repository&quot;&gt;CLDR&lt;/abbr&gt;) that shows, among other things, what &lt;a href=&quot;https://github.com/unicode-cldr/cldr-misc-modern/tree/master/main&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;characters a language uses&lt;/a&gt;. For example, these are the &lt;a href=&quot;https://github.com/unicode-cldr/cldr-misc-modern/blob/master/main/fr/characters.json&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;characters for the French language&lt;/a&gt;. I also made an app a while ago that &lt;a href=&quot;https://character-table.netlify.app/french/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;shows that data in a table&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;You can crawl a popular website that uses that language with &lt;code&gt;glyphhanger&lt;/code&gt;, as you saw in this section.&lt;/li&gt;&lt;li&gt;After you create your subsets, you can see if you cover all the characters with the Firefox developer tools. Open the dev tools, go to the inspector tab, and, at the top right, select the &lt;em&gt;Fonts&lt;/em&gt; tab that’s sitting next to &lt;em&gt;Layout&lt;/em&gt;/&lt;em&gt;Computed&lt;/em&gt;/&lt;em&gt;Changes&lt;/em&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;multiple-subsets-by-script&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#multiple-subsets-by-script&quot;&gt;Multiple subsets by script&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/MarkosKon/unicode-range&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;A repo with the examples of this section&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Instead of creating a single subset and throwing away the rest of the characters, you can keep them all by chunking the initial file into multiple files. You can then take advantage of the &lt;code&gt;unicode-range&lt;/code&gt; descriptor—that you can use inside your &lt;code&gt;@font-face&lt;/code&gt;—to instruct the browser to download only the chunk it needs to render the text. The easiest way to chunk the file is follow the Unicode blocks; for example, you can create the following subsets:&lt;/p&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th align=&quot;left&quot;&gt;Set&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Range&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0000-00FF&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin-extended-a&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0100-017F&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin-extended-b&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0180-024F&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Rest middle&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0259-03C0&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin-extended-additional&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+1E00-1EFF&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Rest&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+2000-FB02&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;In this case, the &lt;code&gt;pyftsubset&lt;/code&gt; commands will be:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;18&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-latin.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+0000-00FF&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-latin-extended-a.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+0100-017F&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-latin-extended-b.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+0180-024F&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-rest-middle.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+0259-03C0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-latin-extended-additional.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+1E00-1EFF&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-rest.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+2000-FB02&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And this is the &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; code that uses the files, assuming you serve them from a &lt;code&gt;fonts&lt;/code&gt; folder:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;19&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* Regular */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Work Sans&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-display&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-style&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;normal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/fonts/WorkSans-Regular-latin.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0000-00FF&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Work Sans&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-display&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-style&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;normal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/fonts/WorkSans-Regular-latin-extended-a.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0100-017F&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Work Sans&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-display&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-style&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;normal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/fonts/WorkSans-Regular-latin-extended-b.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0180-024F&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Work Sans&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-display&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-style&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;normal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/fonts/WorkSans-Regular-rest-middle.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0259-03C0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Work Sans&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-display&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-style&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;normal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/fonts/WorkSans-Regular-latin-extended-additional.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+1E00-1EFF&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Work Sans&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-display&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-style&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;normal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/fonts/WorkSans-Regular-rest.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2000-FB02&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You’ll want to do the same thing for the rest of the weights you want to support and for the italics. This method doesn’t work on Internet Explorer because it downloads all the files. The site is still usable but it’s kind of a disaster performance-wise.&lt;/p&gt;&lt;p&gt;The following table shows the sizes of the subsets after running the commands:&lt;/p&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th align=&quot;left&quot;&gt;Filename&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Size&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;WorkSans-Regular-latin.woff2&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;29kb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;WorkSans-Regular-latin-extended-a.woff2&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;15kb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;WorkSans-Regular-latin-extended-b.woff2&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;10kb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;WorkSans-Regular-rest-middle.woff2&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;5kb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;WorkSans-Regular-latin-extended-additional.woff2&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;13kb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;WorkSans-Regular-rest.woff2&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;12kb&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;This means that, for English content, the browser will download the Latin version (29kb) and maybe the rest (12kb) which is 41kb in total for the regular normal weight. If you have italics and a bold version, the browser will download 123kb (41 × 3) in total, which is not ideal.&lt;/p&gt;&lt;p&gt;A different way to chunk the initial file is to use the subset you created earlier—that has the English characters, the punctuation, and the symbols—and create subsets for the rest blocks. See the following list for an example:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;English/punctuation/symbols: &lt;code&gt;U+0000-00A0, U+00A2-00A9, U+00AC-00AE, U+00B0-00B7, U+00B9-00BA, U+00BC-00BE, U+00D7, U+00F7, U+2000-206F, U+2074, U+20AC, U+2122, U+2190-21BB, U+2212, U+2215, U+F8FF, U+FEFF, U+FFFD&lt;/code&gt;&lt;/li&gt;&lt;li&gt;French/German/etc.: &lt;code&gt;U+00A1, U+00AA-00AB, U+00AF, U+00B8, U+00BB, U+00BF-00D6, U+00D8-00F6, U+00F8-00FF, U+0131, U+0152-0153, U+02B0-02FF&lt;/code&gt;&lt;/li&gt;&lt;li&gt;Latin-extended-a: &lt;code&gt;U+0100-0130, U+0132-0151, U+0154-017F&lt;/code&gt;&lt;/li&gt;&lt;li&gt;Latin-extended-b: &lt;code&gt;U+0180-024F&lt;/code&gt;&lt;/li&gt;&lt;li&gt;Latin-extended-additional: &lt;code&gt;U+1E00-1EFF&lt;/code&gt;&lt;/li&gt;&lt;li&gt;The rest: &lt;code&gt;U+0259, U+0300-03C0, U+2070-2073, U+2075-20AB, U+20AD-2121, U+2123-218F, U+21BC-2211, U+2213-2214, U+2216-F8FE, U+FB01-FB02&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;These are the new commands:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;20&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-english.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+0000-00A0,U+00A2-00A9,U+00AC-00AE,U+00B0-00B7,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+00B9-00BA,U+00BC-00BE,U+00D7,U+00F7,U+2000-206F,U+2074,U+20AC,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+2122,U+2190-21BB,U+2212,U+2215,U+F8FF,U+FEFF,U+FFFD&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-rest-latin.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+00A1,U+00AA-00AB,U+00AF,U+00B8,U+00BB,U+00BF-00D6,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+00D8-00F6,U+00F8-00FF,U+0131,U+0152-0153,U+02B0-02FF&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-latin-extended-a.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+0100-0130,U+0132-0151,U+0154-017F&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-latin-extended-b.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+0180-024F&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-latin-extended-additional.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+1E00-1EFF&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;pyftsubset\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  WorkSans-Regular.ttf \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --output-file=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;WorkSans-Regular-rest.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --flavor=woff2 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --layout-features=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;kern,liga,clig,calt,ccmp,locl,mark,mkmk,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  onum,pnum,smcp,c2sc,frac,lnum,tnum,subs,sups,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  cswh,dlig,ss01,ss03,zero&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  --unicodes=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+0259,U+0300-03C0,U+2070-2073,U+2075-20AB,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+20AD-2121,U+2123-218F,U+21BC-2211,U+2213-2214,U+2216-F8FE,&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  U+FB01-FB02&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And these are the file sizes:&lt;/p&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th align=&quot;left&quot;&gt;Filename&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Size&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;WorkSans-Regular-english.woff2&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;27kb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;WorkSans-Regular-rest-latin.woff2&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;10kb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;WorkSans-Regular-latin-extended-a.woff2&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;14kb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;WorkSans-Regular-latin-extended-b.woff2&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;10kb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;WorkSans-Regular-latin-extended-additional.woff2&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;13kb&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;WorkSans-Regular-rest.woff2&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;11kb&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;Now the browser will download 27kb for English content and 81kb in total for regular, italic, and bold.&lt;/p&gt;&lt;h4 id=&quot;a-note-for-overlaps-when-using-the-unicode-range&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#a-note-for-overlaps-when-using-the-unicode-range&quot;&gt;A note for overlaps when using the unicode-range&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;Because the process of figuring out which characters go to which file is time-consuming and error-prone, you can use Unicode ranges that overlap. The following is a quote from the &lt;a href=&quot;https://www.w3.org/TR/css-fonts-4/#unicode-range-desc&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;unicode-range descriptor&lt;/a&gt; in the &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; Font Module specification.&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;If the Unicode ranges overlap for a set of &lt;code&gt;@font-face&lt;/code&gt; rules with the same family and style descriptor values, the rules are ordered in the reverse order they were defined; the last rule defined is the first to be checked for a given character.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;In other words, if you have overlaps in the Unicode ranges, put the frequently used subset &lt;em&gt;last&lt;/em&gt;, the one that is most likely to be downloaded (e.g. English/punctuation/symbols), and the rest of the files above it. So you can create a complex English subset, and for the rest of the characters, create a subset for each Unicode block:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;21&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* Regular */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Work Sans&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-display&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-style&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;normal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/fonts/WorkSans-Regular-latin.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0000-00FF&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* … */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/fonts/WorkSans-Regular-latin-extended-a.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0100-017F&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* … */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/fonts/WorkSans-Regular-latin-extended-b.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0180-024F&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* … */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/fonts/WorkSans-Regular-latin-extended-additional.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+1E00-1EFF&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* … */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/fonts/WorkSans-Regular-rest.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0259-03C0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2000-FB02&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* Place the English subset last */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Work Sans&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-display&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-style&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;normal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/fonts/WorkSans-Regular-english.woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0000-00A0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+00A2-00A9&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+00AC-00AE&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+00B0-00B7&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+00B9-00BA&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+00BC-00BE&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+00D7&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+00F7&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2000-206F&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2074&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+20AC&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2122&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2190-21BB&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2212&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2215&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+F8FF&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+FEFF&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+FFFD&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;note&quot;&gt;Raph Levien and Jason Pamental made a really good note in the &lt;a href=&quot;https://almanac.httparchive.org/en/2020/fonts#home-on-the-unicode-range&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;2020 Web almanac about fonts&lt;/a&gt; that if you organize your subsets by Unicode blocks, you may end up dropping kerning pairs. For example, if you create a subset for the basic Latin (&lt;code&gt;U+00-FF&lt;/code&gt;), the kerning between letter W and À (WÀ) will be fine. But if you create one for basic Latin (&lt;code&gt;U+00-7F&lt;/code&gt; W lives here) and one for Latin-1 supplement (&lt;code&gt;U+80-FF&lt;/code&gt; À lives here), you &lt;em&gt;will&lt;/em&gt; drop that kerning pair. This is probably true for more OpenType features.&lt;/div&gt;&lt;h2 id=&quot;recap&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#recap&quot;&gt;Recap&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let’s now make a quick recap of the key points of this post:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You saw why you may want to subset your fonts.&lt;/li&gt;&lt;li&gt;Characters and OpenType features are two of the most important things font files include. You also saw what some OpenType features do.&lt;/li&gt;&lt;li&gt;wakamaifondue is an online tool that can help you analyze font files. You used it to see what the Google font files contain.&lt;/li&gt;&lt;li&gt;You saw how to install and use &lt;code&gt;pyftsubset&lt;/code&gt; to create custom font subsets. More specifically:&lt;ul&gt;&lt;li&gt;How to create a web font file with all the characters and features from the original.&lt;/li&gt;&lt;li&gt;How to create a Latin subset based on the Google fonts character list but with more layout features.&lt;/li&gt;&lt;li&gt;How to create an English only subset.&lt;/li&gt;&lt;li&gt;How to use &lt;code&gt;glyphhanger&lt;/code&gt; to create a tiny subset for two-stage font loading.&lt;/li&gt;&lt;li&gt;Finally, how to keep all the characters by breaking up the initial file into chunks based on the Unicode block they belong to.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Feedback is welcome. This includes corrections, suggestions, and things to explain further.&lt;/p&gt;&lt;h2 id=&quot;appendix&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#appendix&quot;&gt;Appendix&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;This section contains information that’s useful when working with subsets. You definitely don’t have to read it.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;#conversions-in-javascript&quot;&gt;Conversions in JavaScript&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#manual-conversions&quot;&gt;Manual conversions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#unicode-ranges-to-characters&quot;&gt;Unicode ranges to characters&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#unicode-blocks--explanations&quot;&gt;Unicode blocks &amp;amp; explanations&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#other-notes&quot;&gt;Other Notes&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;conversions-in-javascript&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#conversions-in-javascript&quot;&gt;Conversions in JavaScript&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;See the character behind a Unicode hex number.&lt;ol&gt;&lt;li&gt;Convert a hex string to a decimal (base-ten) number:&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;22&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A9&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 169&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;Convert that decimal number (or that code point) to a character:&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;23&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;fromCharCode&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;169&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// prints the copyright symbol: ©&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// or fromCodePoint()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;li&gt;Get the Unicode hex number for a character&lt;ol&gt;&lt;li&gt;And the other way around, get the char code for the copyright symbol:&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;24&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;©&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;charCodeAt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 169&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// or codePointAt()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;Convert the char code to a hex string:&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;25&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;169&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// A9 or U+00A9&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;manual-conversions&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#manual-conversions&quot;&gt;Manual conversions&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Convert a hex number to a decimal with pen and paper. The available digits are from &lt;code&gt;0&lt;/code&gt; to &lt;code&gt;F&lt;/code&gt;; &lt;code&gt;A&lt;/code&gt; is equal to &lt;code&gt;10&lt;/code&gt;; &lt;code&gt;F&lt;/code&gt; is equal to &lt;code&gt;15&lt;/code&gt;.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;&quot; data-index=&quot;26&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;FF = 15×16¹ + 15×16⁰&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;   = 240    + 15&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;   = 255&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;&quot; data-index=&quot;27&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;BB8 = 11×16² + 11×16¹ + 8×16⁰&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;    = 2816   + 176    + 8&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;    = 3000&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;&quot; data-index=&quot;28&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;FFEF = 15×16³ + 15×16² + 14×16¹ + 15×16⁰&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;     = 61440  + 3840   + 224    + 15&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;     = 65519&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;unicode-ranges-to-characters&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#unicode-ranges-to-characters&quot;&gt;Unicode ranges to characters&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;JavaScript code that takes as input a bunch of Unicode ranges and outputs the characters. 100% &lt;em&gt;not&lt;/em&gt; tested.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;29&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+20,U+27-29,U+2C-2E,U+30-3B,U+41-49,U+4B-50,U+52-56,U+59,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;U+5A,U+61-70,U+72-7A,U+7C,U+A0,U+A9,U+107,U+10C,U+10D,U+111,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;U+161,U+17E&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;U&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\+&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;last&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;last&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;fromCharCode&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, { range: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, characters: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) }];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;res&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          range: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          characters: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;fromCharCode&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      ];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }, []);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;create-a-unicode-table&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#create-a-unicode-table&quot;&gt;Create a Unicode table&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Display the Unicode Basic Multilingual Plane (&lt;abbr title=&quot;Basic Multilingual Plane&quot;&gt;BMP&lt;/abbr&gt;) characters (&lt;code&gt;U+0000-FFFF&lt;/code&gt;) in a few lines of code:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;30&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// FFFF is 65535 in decimal&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;65536&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;one&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;one&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;codePoint&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;fromCodePoint&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;codePoint&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// or with code points embeded:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;65536&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;one&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;one&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;codePoint&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    character: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;fromCodePoint&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;codePoint&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;codePoint&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    unicode: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;codePoint&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;padStart&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;U+000&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toUpperCase&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;unicode-blocks--explanations&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#unicode-blocks--explanations&quot;&gt;Unicode blocks &amp;amp; explanations&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;See also the Unicode &lt;a href=&quot;https://www.unicode.org/charts/nameslist/index.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Names List Charts&lt;/a&gt;. It presents the Unicode blocks in tables with information for each character.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U+0000-00FF&lt;/code&gt; (256 characters). Includes &lt;em&gt;control characters&lt;/em&gt; (&lt;code&gt;U+0000-001F&lt;/code&gt;, 32 characters), &lt;a href=&quot;https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;basic Latin&lt;/em&gt;&lt;/a&gt; (&lt;code&gt;U+0020-007F&lt;/code&gt;, 96 characters; includes English and general punctuation), the &lt;a href=&quot;https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Latin-1 supplement&lt;/em&gt;&lt;/a&gt; (&lt;code&gt;U+0080-00FF&lt;/code&gt;, 128 characters for French, Italian, Spanish, German, and Icelandic).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U+0100-017F&lt;/code&gt; (&lt;a href=&quot;https://en.wikipedia.org/wiki/Latin_Extended-A&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Latin Extended-A&lt;/em&gt;&lt;/a&gt;, 128 characters). Supports Maltese, Polish, Czech, Hungarian, Serbo-Croatian, Turkish, and more.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U+0180-024F&lt;/code&gt; (&lt;a href=&quot;https://en.wikipedia.org/wiki/Latin_Extended-B&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Latin Extended-B&lt;/em&gt;&lt;/a&gt;, 208 characters). Supports African, historic, additions for Romanian, Croatian, Slovenian.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U+0250-02FF&lt;/code&gt; = 174: Phonetic stuff, and more specifically: &lt;abbr title=&quot;International Phonetic Alphabet&quot;&gt;IPA&lt;/abbr&gt; Extensions (&lt;code&gt;U+0250-02AF&lt;/code&gt; = 96) and spacing modifier letters (&lt;code&gt;U+02B0-02FF&lt;/code&gt; = 80). &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_Unicode_characters#IPA_Extensions&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Some languages use characters&lt;/a&gt; from these sets.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U+0300-036F&lt;/code&gt; = 112. Combining diacritical marks. Some languages use characters from this set—see the Unicode &lt;abbr title=&quot;Portable Document Format&quot;&gt;PDF&lt;/abbr&gt;. As I understand this, you use them to type text in many languages, including polytonic Greek. When you render text, though, these characters merge to form characters from the script Unicode blocks.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U+0370-03FF&lt;/code&gt; (Greek and Coptic = 144, neohellenic monotonic)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U+0400-04FF&lt;/code&gt; (Cyrillic = 256).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U+0500-052F&lt;/code&gt; (Cyrillic Supplement = 48).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U+1D00-1D7F&lt;/code&gt; (Phonetic Extensions = 128).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U+1D80-1DBF&lt;/code&gt; (Phonetic Extensions Supplement = 64).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U+1DC0-01DFF&lt;/code&gt; (Combing Diacritical Marks Supplement = 64).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U+1E00-1EFF&lt;/code&gt; (Latin Extended Additional = 256).&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U+1F00-1FFF&lt;/code&gt; (Greek extended = 256, polytonic Greek)&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;U2000-FEFF&lt;/code&gt; Rest goodies. This includes:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;general punctuation (&lt;code&gt;U+2000-206F&lt;/code&gt;).&lt;/li&gt;&lt;li&gt;superscripts/subscripts (&lt;code&gt;U+2070-209F&lt;/code&gt;).&lt;/li&gt;&lt;li&gt;currency symbols (&lt;code&gt;U+20A0-20CF&lt;/code&gt;, or just the euro 20AC).&lt;/li&gt;&lt;li&gt;Letter-like symbols (&lt;code&gt;U+2100-214F&lt;/code&gt;, includes TM, Tel. No symbols).&lt;/li&gt;&lt;li&gt;Arrows (&lt;code&gt;U+2190-21FF&lt;/code&gt;),&lt;/li&gt;&lt;li&gt;Mathematical operators (&lt;code&gt;U+2200-22FF&lt;/code&gt;, minus, division signs)&lt;/li&gt;&lt;li&gt;and many more.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;other-notes&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#other-notes&quot;&gt;Other Notes&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://mathiasbynens.be/notes/es-unicode-property-escapes&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Unicode property escapes&lt;/a&gt; in JavaScript regular expressions seem very useful, and more specifically: &lt;a href=&quot;http://unicode.org/reports/tr44/#GC_Values_Table&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;General_Category&lt;/a&gt;, &lt;a href=&quot;http://unicode.org/reports/tr24/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Script&lt;/a&gt;, and &lt;a href=&quot;http://unicode.org/reports/tr24/#Script_Extensions&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Script_Extensions&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;There are &lt;a href=&quot;https://en.wikipedia.org/wiki/Unicode#Standardized_subsets&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;standardized subsets&lt;/a&gt; for Unicode but they are big.&lt;/li&gt;&lt;li&gt;There are other Latin sets later in the Unicode table, such as the Latin Extended Additional, and the Latin Extended-C/D/E.&lt;/li&gt;&lt;li&gt;You can find punctuation in ASCII, Latin-1 supplement, general punctuation, and supplemental punctuation (&lt;code&gt;U+2E00-2E7F&lt;/code&gt;).&lt;/li&gt;&lt;li&gt;The “ugly” quote lives in ASCII, the triangle (Italian) in Latin-1 supplement, and the curly quotes in general punctuation.&lt;/li&gt;&lt;li&gt;Unicode has small caps in &lt;abbr title=&quot;International Phonetic Alphabet&quot;&gt;IPA&lt;/abbr&gt; Extensions, Phonetic Extensions, and Latin Extended-D, but &lt;a href=&quot;https://en.wikipedia.org/wiki/Small_caps#Unicode&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;they are meant for use in the phonetic alphabet&lt;/a&gt; (?). Use OpenType small caps instead.&lt;/li&gt;&lt;li&gt;Some typefaces have superscripts and subscripts in Unicode while others have them in OpenType features. Prefer OpenType because they may also include letters. &lt;a href=&quot;https://en.wikipedia.org/wiki/Subscript_and_superscript&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Subscripts and superscripts in Wikipedia&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;There are blocks for ancient Greek numbers, linear A, and linear B.&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://home.unicode.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Unicode home page&lt;/a&gt; and the &lt;a href=&quot;http://unicode.org/main.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Unicode Technical Site&lt;/a&gt;. They are not super helpful or user friendly.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://unicode.org/charts/index.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Unicode Character Code Charts (&lt;abbr title=&quot;Portable Document Format&quot;&gt;PDF&lt;/abbr&gt;)&lt;/a&gt; and the &lt;a href=&quot;https://www.unicode.org/charts/nameslist/index.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Unicode Names List Charts&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Unicode &lt;a href=&quot;https://cldr.unicode.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Common Locale Data Repository&lt;/a&gt; (&lt;abbr title=&quot;Unicode Common Locale Data Repository&quot;&gt;CLDR&lt;/abbr&gt;).&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://unicode-table.com/en/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Unicode table&lt;/a&gt;. Use it to visualize the Unicode blocks.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_Unicode_characters&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;List of Unicode characters&lt;/a&gt; Wikipedia page.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/webfont-optimization&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Web Font Optimization&lt;/a&gt; a post by Ilya Grigorik on Google developers site.&lt;/li&gt;&lt;li&gt;Mathias Bynens: &lt;a href=&quot;https://mathiasbynens.be/notes/javascript-unicode&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;JavaScript has a Unicode problem&lt;/a&gt; and the other posts under the &lt;a href=&quot;https://mathiasbynens.be/notes#unicode&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Unicode tag&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/typography/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Microsoft Typography documentation&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/typography/opentype/spec/features_ae&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;OpenType Registered features - definitions and implementations&lt;/a&gt; from Microsoft.&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk15 { color: #80CBC4; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk16 { color: #FF6363; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk28 { color: #5CA7E4; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk12 { color: #FFCB8B; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Reforma typeface notes]]></title><description><![CDATA[My notes for the Reforma typeface designed by Alejandro Lo Celso.]]></description><link>https://markoskon.com/reforma-typeface-notes/</link><guid isPermaLink="false">https://markoskon.com/reforma-typeface-notes/</guid><pubDate>Fri, 20 Mar 2020 19:00:00 GMT</pubDate><content:encoded>&lt;p&gt;You can find here my notes for the Reforma typeface. Reforma was designed by Alejandro Lo Celso and programmed by Guido Ferreyra as part of a commission to the PampaType foundry by the Universidad Nacional de Córdoba, Argentina. It is published under the &lt;a href=&quot;https://creativecommons.org/licenses/by-nd/4.0/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Creative Commons &lt;abbr title=&quot;Creative Commons License with Attribution No Derivative Works&quot;&gt;CC BY-ND&lt;/abbr&gt; 4.0&lt;/a&gt; and you can use it for free with attribution. It consists of 3 subfamilies: the Reforma 1918, the Reforma 1969, and the Reforma 2018.&lt;/p&gt;&lt;h2 id=&quot;opinions--notes&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#opinions--notes&quot;&gt;Opinions &amp;amp; notes&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The following quotes are from a &lt;a href=&quot;https://pampatype.com/blog/reforma&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;blog post&lt;/a&gt; written by the designer that explains the story of the typeface, and from the &lt;abbr title=&quot;Portable Document Format&quot;&gt;PDF&lt;/abbr&gt; files that come with the font files.&lt;/p&gt;&lt;blockquote style=&quot;font-style:italic&quot;&gt;&lt;div style=&quot;margin-bottom:calc(var(--rhythm) / 2)&quot;&gt;&amp;quot;The Reforma type family is divided into 3 subfamilies:&lt;/div&gt;&lt;ul style=&quot;margin-bottom:0&quot;&gt;&lt;li&gt;Reforma 1918, the classic version (humanist serif).&lt;/li&gt;&lt;li&gt;Reforma 2018, the modern version (humanist sans-serif).&lt;/li&gt;&lt;li&gt;Reforma 1969, a hybrid version (incise, flare serif)&amp;quot;.&lt;/li&gt;&lt;/ul&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;p&gt;Reforma is a multi-form humanist typeface that combines the virtues of Roman epigraphic tradition, such as dignity and sobriety, with a sense of modern friendliness.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;The following quote is from a &lt;a href=&quot;https://typographica.org/typeface-reviews/reforma/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Typographica review&lt;/a&gt; by Luara Meseguer.&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;…Reforma explores versatility by way of a common skeleton wearing different outfits.&lt;/p&gt;&lt;/blockquote&gt;&lt;h3 id=&quot;my-notes&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#my-notes&quot;&gt;My notes&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;Reforma 1918 looks good in large sizes, but I prefer the other two for body text.&lt;/li&gt;&lt;li&gt;Reforma 2018 (the sans-serif) version gives me a “calculator vibe”. This happens due to the extreme modulated strokes of the bold versions, near the joining strokes. For example:&lt;div style=&quot;font-size:4.2em;line-height:1.07;font-weight:700;font-family:Reforma2018;margin:calc(var(--rhythm) / 2) 0&quot;&gt;n h p&lt;/div&gt;&lt;/li&gt;&lt;li&gt;When you download the font files, you get a specimen &lt;abbr title=&quot;Portable Document Format&quot;&gt;PDF&lt;/abbr&gt; and a &lt;abbr title=&quot;Portable Document Format&quot;&gt;PDF&lt;/abbr&gt; with usage instructions.&lt;/li&gt;&lt;li&gt;It doesn’t have a regular weight, but you can use the Gris version (500) with lighter colors.&lt;/li&gt;&lt;li&gt;The zip includes &lt;code&gt;woff/woff2&lt;/code&gt; files, and because they are small, there’s no need for Unicode subsets.&lt;/li&gt;&lt;li&gt;It has a black 900 version, but it’s used exclusively by the university.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;The project is not available on GitHub but there is a &lt;a href=&quot;https://pampatype.com/blog/reforma&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;blog post&lt;/a&gt; on the foundry’s site with a lot of useful information.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://pampatype.com/reforma&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Download link&lt;/a&gt; for Reforma.&lt;/li&gt;&lt;li&gt;Typewolf doesn’t have a review, but Reforma was part of the list: ”&lt;a href=&quot;https://www.typewolf.com/not-on-google-fonts&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;The 10 Best Free Fonts That Aren’t Available on Google Fonts&lt;/a&gt;.”&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://typographica.org/typeface-reviews/reforma/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Typographica review&lt;/a&gt; for Reforma.&lt;/li&gt;&lt;li&gt;Fontsinuse entries for the Reforma family: &lt;a href=&quot;https://fontsinuse.com/typefaces/85912/reforma-1918&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Reforma 1918&lt;/a&gt; and &lt;a href=&quot;https://fontsinuse.com/typefaces/85914/reforma-2018&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Reforma 2018&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;An &lt;a href=&quot;https://github.com/MarkosKon/checking-typefaces/tree/reforma&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;example repo&lt;/a&gt; that uses Reforma.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;playground&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#playground&quot;&gt;Playground&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;All notes are for the following version:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;Version 1.001; ttfautohint (v1.6)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;sc-aXZVg Primitives__Box-sc-12p0hgy-0 knHXor ccOBqu&quot;&gt;&lt;div class=&quot;Components__ControlContainer-sc-uj3ksg-0 ixEsga&quot;&gt;&lt;label for=&quot;select-sub-family&quot;&gt;&lt;strong&gt;Sub-family: &lt;/strong&gt;&lt;select id=&quot;select-sub-family&quot; name=&quot;select-sub-family&quot;&gt;&lt;option value=&quot;Reforma1918&quot; selected=&quot;&quot;&gt;Reforma1918&lt;/option&gt;&lt;option value=&quot;Reforma1969&quot;&gt;Reforma1969&lt;/option&gt;&lt;option value=&quot;Reforma2018&quot;&gt;Reforma2018&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&lt;label for=&quot;select-weight&quot;&gt;&lt;strong&gt;Weight: &lt;/strong&gt;&lt;select id=&quot;select-weight&quot; name=&quot;select-weight&quot;&gt;&lt;option value=&quot;300&quot;&gt;300&lt;/option&gt;&lt;option value=&quot;500&quot;&gt;500&lt;/option&gt;&lt;option value=&quot;700&quot;&gt;700&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&lt;label for=&quot;select-style&quot;&gt;&lt;strong&gt;Style: &lt;/strong&gt;&lt;select id=&quot;select-style&quot; name=&quot;select-style&quot;&gt;&lt;option value=&quot;normal&quot; selected=&quot;&quot;&gt;normal&lt;/option&gt;&lt;option value=&quot;italic&quot;&gt;italic&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&lt;label for=&quot;select-width&quot;&gt;&lt;strong&gt;Width: &lt;/strong&gt;&lt;select id=&quot;select-width&quot; name=&quot;select-width&quot;&gt;&lt;option value=&quot;normal&quot; selected=&quot;&quot;&gt;normal&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&lt;label for=&quot;input-size&quot;&gt;&lt;strong&gt;Size: &lt;/strong&gt;&lt;input id=&quot;input-size&quot; name=&quot;input-size&quot; type=&quot;range&quot; min=&quot;8&quot; max=&quot;150&quot; value=&quot;20&quot;/&gt;&lt;span style=&quot;min-width:54px;text-align:right&quot;&gt;20px&lt;/span&gt;&lt;/label&gt;&lt;label for=&quot;input-line-height&quot;&gt;&lt;strong&gt;Line height: &lt;/strong&gt;&lt;input id=&quot;input-line-height&quot; name=&quot;input-line-height&quot; type=&quot;range&quot; min=&quot;1&quot; max=&quot;2&quot; step=&quot;0.05&quot; value=&quot;1.5&quot;/&gt;&lt;span&gt;1.50em&lt;/span&gt;&lt;/label&gt;&lt;label for=&quot;input-letter-spacing&quot;&gt;&lt;strong&gt;Letter spacing: &lt;/strong&gt;&lt;input id=&quot;input-letter-spacing&quot; name=&quot;input-letter-spacing&quot; type=&quot;range&quot; min=&quot;0&quot; max=&quot;1&quot; step=&quot;0.01&quot; value=&quot;0&quot;/&gt;&lt;span&gt;0.00em&lt;/span&gt;&lt;/label&gt;&lt;/div&gt;&lt;p contenteditable=&quot;true&quot; spellcheck=&quot;false&quot; aria-label=&quot;Sample text&quot; class=&quot;Components__Editable-sc-uj3ksg-1 dAKiXS&quot;&gt;A peep at some distant orb has power to raise and purify our thoughts like a strain of sacred music, or a noble picture, or a passage from the grander poets. It always does one good.&lt;/p&gt;&lt;/div&gt;&lt;h2 id=&quot;opentype-features&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#opentype-features&quot;&gt;OpenType features&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;All the Reforma subfamilies support 22 layout features in roman and 25 in italics. They support all types of figures (&lt;code&gt;onum&lt;/code&gt;, &lt;code&gt;pnum&lt;/code&gt;, &lt;code&gt;tnum&lt;/code&gt;, &lt;code&gt;lnum&lt;/code&gt;), but they doesn’t have small caps. Reforma has many interesting stylistic sets, and the italic versions have discretionary ligatures. There are also some uppercase ligatures but they are exclusively used by the University. The following table shows some of the most interesting features:&lt;/p&gt;&lt;div font-family=&quot;Reforma1918&quot; font-weight=&quot;500&quot; class=&quot;ReformaFeatures__Container-sc-tugj0v-0 llKTEQ&quot;&gt;&lt;div class=&quot;ReformaFeatures__LabelContainer-sc-tugj0v-1 gxIJwr&quot;&gt;&lt;label for=&quot;sub-family&quot;&gt;&lt;strong&gt;Sub-family:&lt;/strong&gt; &lt;select id=&quot;sub-family&quot; name=&quot;sub-family&quot;&gt;&lt;option value=&quot;Reforma1918&quot; selected=&quot;&quot;&gt;Reforma 1918&lt;/option&gt;&lt;option value=&quot;Reforma1969&quot;&gt;Reforma 1969&lt;/option&gt;&lt;option value=&quot;Reforma2018&quot;&gt;Reforma 2018&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&lt;label for=&quot;weight&quot;&gt;&lt;strong&gt;Weight:&lt;/strong&gt; &lt;select id=&quot;weight&quot; name=&quot;weight&quot;&gt;&lt;option value=&quot;300&quot;&gt;Blanca 300&lt;/option&gt;&lt;option value=&quot;500&quot; selected=&quot;&quot;&gt;Gris 500&lt;/option&gt;&lt;option value=&quot;700&quot;&gt;Negra 700&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&lt;/div&gt;&lt;div tabindex=&quot;0&quot; class=&quot;TableWrapper__Wrapper-sc-48voiu-0 bGmsWm&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th align=&quot;left&quot;&gt;Feature code&lt;/th&gt;&lt;th align=&quot;center&quot;&gt;On&lt;/th&gt;&lt;th align=&quot;center&quot;&gt;Off&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Notes&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;salt or ss01&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;salt&amp;#x27;&quot;&gt;J K R Q&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;J K R Q&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;All stylistic alternates.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss02&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss02&amp;#x27;&quot;&gt;Jupiter&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;Jupiter&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Capital J without a descender.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss03&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss03&amp;#x27;&quot;&gt;ROCK&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;ROCK&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Long leg in capital K &amp;amp; R.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss04&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss04&amp;#x27;&quot;&gt;Quality&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;Quality&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Capital Q with a long tail.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss05 (italic)&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss05&amp;#x27;;font-style:italic&quot;&gt;Quality&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-style:italic&quot;&gt;Quality&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Italic capital Q with an extra-long tail.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss06&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss06&amp;#x27;&quot;&gt;Tome&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;Tome&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Taller capital T.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss07 (italic)&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss07&amp;#x27;;font-style:italic&quot;&gt;Ysera&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-style:italic&quot;&gt;Ysera&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Alternate italic capital Y.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;dlig (italic)&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;dlig&amp;#x27;;font-style:italic&quot;&gt;effect station&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-style:italic&quot;&gt;effect station&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Italic discretionary ligatures.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss05 + dlig + italic&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss05&amp;#x27;, &amp;#x27;dlig&amp;#x27;;font-style:italic&quot;&gt;Question&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-style:italic&quot;&gt;Question&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Combination.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 id=&quot;interesting-characters&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#interesting-characters&quot;&gt;Interesting characters&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;For more interesting characters see the OpenType features above, check the &lt;a href=&quot;#playground&quot;&gt;playground&lt;/a&gt;, or get a &lt;a href=&quot;https://pampatype.com/reforma&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;copy from Pampatype’s site&lt;/a&gt; and drop it in the &lt;a href=&quot;https://wakamaifondue.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Wakamai Fondue&lt;/a&gt; app to discover them yourself.&lt;/p&gt;&lt;ul font-family=&quot;Reforma1918&quot; class=&quot;InterestingCharacters__List-sc-1c3igsl-0 hUiUOG&quot;&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;C&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;H&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;J&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;M&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;Q&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;R&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;a&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;f&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;n&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;r&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;9&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hnMguF&quot;&gt;&amp;amp;&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;€&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;“”&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;†&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;‡&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;character-support&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#character-support&quot;&gt;Character support&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;According to &lt;a href=&quot;https://wakamaifondue.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Wakamai Fondue&lt;/a&gt;, it has 276 characters and 359 glyphs. The font files cover the majority, if not all, of the following Unicode sets.&lt;/p&gt;&lt;div tabindex=&quot;0&quot; class=&quot;TableWrapper__Wrapper-sc-48voiu-0 bGmsWm&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th align=&quot;left&quot;&gt;Set&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Range&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0000-00FF&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Rest&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+2000-FB01&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;h3 id=&quot;not-complete-sets-below-50&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#not-complete-sets-below-50&quot;&gt;Not complete sets (below 50%)&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Total characters = 42. This means that the typeface supports only specific languages/characters from these Unicode blocks.&lt;/p&gt;&lt;div tabindex=&quot;0&quot; class=&quot;TableWrapper__Wrapper-sc-48voiu-0 bGmsWm&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th align=&quot;left&quot;&gt;Set&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Range&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Notes&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin Extended-A&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0100-017F&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;14 chars&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin Extended-B&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0180-024F&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;1 char&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Spacing Modifier Letters&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+02B0-02FF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;5 chars&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Combing Diacritical Marks&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0300-036F&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;11 chars&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Greek&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0370-03FF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;3 chars&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin Extended Additional&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+1E00-1EFF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;8 chars&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;h2 id=&quot;weights--styles&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#weights--styles&quot;&gt;Weights &amp;amp; styles&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Each subfamily comes in 3 weights with matching italics: light 300 (Blanca), semi 500 (Gris), and bold 700 (Negra). Italic = Italica.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Using the contenteditable attribute]]></title><description><![CDATA[Create a <textarea> that resizes while the user types with the contenteditable attribute.]]></description><link>https://markoskon.com/using-the-contenteditable-attribute/</link><guid isPermaLink="false">https://markoskon.com/using-the-contenteditable-attribute/</guid><pubDate>Tue, 17 Mar 2020 18:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Instead of using a &lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt;, you can make any &lt;abbr title=&quot;Hypertext Markup&quot;&gt;HTML&lt;/abbr&gt; element editable by setting the &lt;code&gt;contenteditable&lt;/code&gt; attribute to &lt;code&gt;true&lt;/code&gt;—see the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/contentEditable&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Mozilla Developer Network Web Docs&quot;&gt;MDN&lt;/abbr&gt; link&lt;/a&gt; and the &lt;a href=&quot;https://html.spec.whatwg.org/multipage/interaction.html#attr-contenteditable&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;specification link&lt;/a&gt; for more details on the attribute.
This way, you can have an element that behaves like a &lt;code&gt;textarea&lt;/code&gt; but it automatically &lt;em&gt;resizes&lt;/em&gt; when the user types—something not possible with a &lt;code&gt;textarea&lt;/code&gt;. This behavior can be useful for font-related applications, where you may &lt;em&gt;not care&lt;/em&gt; what’s inside the editable element.&lt;/p&gt;&lt;h2 id=&quot;uncontrolled-component&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#uncontrolled-component&quot;&gt;Uncontrolled component&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you’re using React, you can use a &lt;code&gt;contenteditable&lt;/code&gt; element as an &lt;a href=&quot;https://reactjs.org/docs/uncontrolled-components.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;uncontrolled component&lt;/a&gt;. This means you don’t keep in the state the text that’s inside the editable element. The following snippet shows an example of that:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;suppressContentEditableWarning&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;contentEditable&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;spellCheck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  Edit this text&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Instead of “Edit this text” you could render a &lt;code&gt;children&lt;/code&gt; prop. This is what the code snippet above looks like when rendered in React:&lt;/p&gt;&lt;p contenteditable=&quot;true&quot; spellcheck=&quot;false&quot; class=&quot;FirstSnippet__Paragraph-sc-6d9yc-0 cowVPi&quot;&gt;Edit this text&lt;/p&gt;&lt;p&gt;If you don’t use the &lt;code&gt;suppressContentEditableWarning&lt;/code&gt;, React will give you the following warning:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;A component is &lt;code&gt;contentEditable&lt;/code&gt; and contains &lt;code&gt;children&lt;/code&gt; managed by React. It is now your responsibility to guarantee that none of those nodes are unexpectedly modified or duplicated. This is probably not intentional.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;We are ok with the situation the warning describes because we don’t care what’s inside, so we suppress it.&lt;/p&gt;&lt;p&gt;If you want to have the resize handle at the bottom right of the element use the following &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.editable&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;both&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;overflow&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The next element has a resize handle at the bottom right. It resizes when the user types until they drag the handle. At that point, it behaves like a &lt;code&gt;textarea&lt;/code&gt;.&lt;/p&gt;&lt;p contenteditable=&quot;true&quot; spellcheck=&quot;false&quot; class=&quot;FirstSnippet__Paragraph-sc-6d9yc-0 CsDNw&quot;&gt;You can resize me&lt;/p&gt;&lt;h2 id=&quot;pasting-only-text&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#pasting-only-text&quot;&gt;Pasting only text&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you try to paste something inside that element, you’ll notice that you can paste &lt;abbr title=&quot;Hypertext Markup&quot;&gt;HTML&lt;/abbr&gt; elements, not only text. Try copying the “Pasting only text” heading into the previous editable element. If you want to paste only text, you can override the default behavior with an &lt;a href=&quot;https://reactjs.org/docs/events.html#clipboard-events&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;onPaste&lt;/code&gt;&lt;/a&gt; listener.&lt;/p&gt;&lt;p&gt;In the following snippet, I prevent the default element paste with &lt;code&gt;e.preventDefault()&lt;/code&gt;, and I take only the text from the clipboard with the &lt;code&gt;getData(&amp;quot;text&amp;quot;)&lt;/code&gt; method. Finally, I &lt;em&gt;insert&lt;/em&gt; the text at the &lt;a href=&quot;https://en.wikipedia.org/wiki/Caret_navigation&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;caret&lt;/a&gt; position with the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;document.execCommand&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;suppressContentEditableWarning&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;contentEditable&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;spellCheck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onPaste&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;preventDefault&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;clipboardData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;execCommand&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;insertText&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    Only text is allowed here.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Try pasting a heading or a code block in the following paragraph. You’ll notice that you can paste only text.&lt;/p&gt;&lt;p contenteditable=&quot;true&quot; spellcheck=&quot;false&quot; class=&quot;ExecCommandPaste__Paragraph-sc-lvbmcj-0 fZxtfO&quot;&gt;Only text is allowed here.&lt;/p&gt;&lt;p&gt;The &lt;abbr title=&quot;Mozilla Developer Network Web Docs&quot;&gt;MDN&lt;/abbr&gt; link for &lt;code&gt;execCommand&lt;/code&gt; warns us that this feature is now obsolete and could be removed at any time. You’d think that instead of using the &lt;code&gt;execCommand&lt;/code&gt;, you can use a ref and directly change the &lt;abbr title=&quot;Document Object Model&quot;&gt;DOM&lt;/abbr&gt;, as I do below:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { useRef } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;editableRef&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useRef&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;suppressContentEditableWarning&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;contentEditable&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;ref&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;editableRef&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;spellCheck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onPaste&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;preventDefault&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;clipboardData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        editableRef&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;innerText &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      Only text is allowed here.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But in this case, you &lt;em&gt;replace&lt;/em&gt; the content every time, and, as a result, you lose the caret position because the content is brand new. This is what it looks like if you do that:&lt;/p&gt;&lt;p contenteditable=&quot;true&quot; spellcheck=&quot;false&quot; class=&quot;BadPaste__Paragraph-sc-1qb31ua-0 cPoZt&quot;&gt;Probably not what you want.&lt;/p&gt;&lt;p&gt;Besides that, the undo command &lt;code&gt;Ctrl + Z&lt;/code&gt; doesn’t work. If you want to implement the functionality of the &lt;code&gt;insertText&lt;/code&gt; command, you have to re-invent the wheel—I have &lt;a href=&quot;#implementing-inserttext-without-success&quot;&gt;some code&lt;/a&gt; at the end with unsuccessful experiments. You have to account for the current &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;selection&lt;/a&gt; to paste the text in the correct position, and after that, you have to place the caret at the expected position by creating a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Range&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;range&lt;/a&gt;. As a result, sticking with the obsolete functionality or using a &lt;code&gt;&amp;lt;textarea&amp;gt;&lt;/code&gt; seems the way to go.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;The &lt;a href=&quot;https://caniuse.com/?search=clipboarddata&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;support for &lt;code&gt;e.clipboardData&lt;/code&gt; object&lt;/a&gt; doesn’t seem to be that great, at the time of writing at least. MDN warns us that &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/ClipboardEvent/clipboardData&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;it’s an experimental technology.&lt;/a&gt; I wonder if there is some error on caniuse.com, or if I can’t read the tables properly. For example, it says that’s not supported on desktop Safari 13, but I found that’s not the case when I tested. Anyway, an &lt;em&gt;alternative&lt;/em&gt; is to use the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Navigator/clipboard&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Clipboard from the Navigator API&lt;/a&gt; which &lt;a href=&quot;https://caniuse.com/mdn-api_navigator_clipboard&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;seems to have better support&lt;/a&gt;.&lt;/div&gt;&lt;h2 id=&quot;controlled-component&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#controlled-component&quot;&gt;“Controlled” component&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you want to use the text of the editable element, you’ll have to keep it in the state. To update that state, you can use the &lt;code&gt;onInput&lt;/code&gt; listener. But you’ll face the same problems I mentioned before with the &lt;code&gt;onPaste&lt;/code&gt; listener. The problem is that you don’t have a &lt;code&gt;value&lt;/code&gt; property for the editable element (as you have with inputs), nor an &lt;code&gt;event.target.value&lt;/code&gt; on the event object of the &lt;code&gt;onInput&lt;/code&gt; listener. If you replace the text content with a ref—mutate the &lt;abbr title=&quot;Document Object Model&quot;&gt;DOM&lt;/abbr&gt; directly—you lose the caret position.&lt;/p&gt;&lt;p&gt;There is a &lt;a href=&quot;https://bundlephobia.com/package/react-contenteditable@3.3.3&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;small&lt;/a&gt; &lt;abbr title=&quot;Node Package Manager&quot;&gt;NPM&lt;/abbr&gt; package called &lt;a href=&quot;https://github.com/lovasoa/react-contenteditable&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;react-contenteditable&lt;/code&gt;&lt;/a&gt; that approaches this problem in a different way. When the text content changes, you don’t replace the &lt;abbr title=&quot;Hypertext Markup&quot;&gt;HTML&lt;/abbr&gt; content, but you call the user’s &lt;code&gt;onChange&lt;/code&gt; listener and pass the current value so the user can update the state. You get that value with a ref, for example: &lt;code&gt;ref.current.innerText&lt;/code&gt;. At the same time, you store that value in a variable outside the state. Because the user value (state) changes, the component will want to re-render. You prevent this with a &lt;code&gt;shouldComponentUpdate&lt;/code&gt; method. This is the &lt;a href=&quot;https://github.com/lovasoa/react-contenteditable/blob/master/src/react-contenteditable.tsx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;source code&lt;/a&gt; of the component on GitHub, and this an example on how to use it:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { useState, useRef } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ContentEditable &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-contenteditable&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;editableRef&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useRef&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;editableText&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setEditableText&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Edit me.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;ContentEditable&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;innerRef&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;editableRef&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;tagName&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;editableText&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onPaste&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;preventDefault&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;clipboardData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;execCommand&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;insertText&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;value;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setEditableText&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you want to paste only text, you still have to implement the &lt;code&gt;onPaste&lt;/code&gt; listener.&lt;/p&gt;&lt;h2 id=&quot;final-thoughts&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#final-thoughts&quot;&gt;Final thoughts&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Depending on your requirements, working with &lt;code&gt;contentEditable&lt;/code&gt; elements in React can be challenging. Below, you can find more of my thoughts regarding the &lt;code&gt;contentEditable&lt;/code&gt; attribute. If you feel I’m wrong somewhere or there is a better way of approaching the problem, let me know in the comments.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;If your use case is to have text that when the user clicks inside, it becomes a &lt;code&gt;contenteditable&lt;/code&gt; element, a better solution from an accessibility standpoint is to use a plain old &lt;em&gt;input&lt;/em&gt;. Assuming you do this because you don&amp;#x27;t like the look of the input. If that&amp;#x27;s the case, you can use &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; to change the styling.&lt;/div&gt;&lt;div class=&quot;note&quot;&gt;&lt;code&gt;contenteditable&lt;/code&gt; elements can do much more; you can use them as rich text editors for example. Take a look at the &lt;abbr title=&quot;Mozilla Developer Network Web Docs&quot;&gt;MDN&lt;/abbr&gt; guide “&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Making Content Editable&lt;/a&gt;”.&lt;/div&gt;&lt;div class=&quot;note&quot;&gt;You have to be aware of &lt;a href=&quot;https://owasp.org/www-community/attacks/xss/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Cross-Site Scripting&lt;/a&gt; (&lt;abbr title=&quot;Cross-Site Scripting&quot;&gt;XSS&lt;/abbr&gt;) attacks. If you allow the user to add &lt;abbr title=&quot;Hypertext Markup&quot;&gt;HTML&lt;/abbr&gt; inside an element, and you then save that value in a server without sanitizing it, you &lt;em&gt;may&lt;/em&gt; be vulnerable to &lt;abbr title=&quot;Cross-Site Scripting&quot;&gt;XSS&lt;/abbr&gt; attacks. That is if you try to render again that content on another client. An example of that is comments from two different users on a post.&lt;/div&gt;&lt;h2 id=&quot;related-links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#related-links&quot;&gt;Related links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/22677931/react-js-onchange-event-for-contenteditable&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Stackoverflow thread&lt;/a&gt; from 2014; React is old I guess.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/17181396/which-elements-can-be-safely-made-contenteditable&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Which elements can be safely made contenteditable?&lt;/a&gt;&lt;/li&gt;&lt;li&gt;The &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autocapitalize&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;autocapitalize&lt;/a&gt; attribute.&lt;/li&gt;&lt;li&gt;&lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; Tricks: &lt;a href=&quot;https://css-tricks.com/show-and-edit-style-element/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Show and Edit Style Element&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.taniarascia.com/content-editable-elements-in-javascript-react/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Tania Rascia: Using Content Editable Elements in JavaScript (React)&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;implementing-inserttext-without-success&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#implementing-inserttext-without-success&quot;&gt;Implementing insertText (without success)&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;This is what I came up with while trying to implement the &lt;code&gt;insertText&lt;/code&gt; command on the &lt;code&gt;onPaste&lt;/code&gt; listener.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// onPaste listener&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;preventDefault&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;pastedText&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;clipboardData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getData&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getSelection&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;currentText&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pRef&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;innerText&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// The idea was to create a range before&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// I replace the text to keep track of&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// the caret position. I add it to the&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// selection aftewards. This doesn&amp;#x27;t work.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createRange&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setStart&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;anchorNode&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;anchorOffset&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;collapse&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// The selection is collapsed when the user&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// has not selected any of the existing text.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// This works assuming the content is a single&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// text node. If you press the enter to create&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// new lines, that&amp;#x27;s not the case anymore and it&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// doesn&amp;#x27;t work.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isCollapsed&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;beforeCursor&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;currentText&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;anchorOffset&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;afterCursor&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;currentText&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;anchorOffset&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pRef&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;innerText&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;beforeCursor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;pastedText&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;afterCursor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;} &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;selectionStart&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;currentText&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;anchorOffset&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;selectionEnd&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;currentText&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;focusOffset&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pRef&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;innerText&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;selectionStart&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;pastedText&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;selectionEnd&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;removeAllRanges&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;selection&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;addRange&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk15 { color: #80CBC4; }
  .night-owl-no-italics .mtk16 { color: #FF6363; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Add inline style elements in Gatsby]]></title><description><![CDATA[See how to add inline style elements to a specific page in your Gatsby app with react-helmet.]]></description><link>https://markoskon.com/add-inline-style-elements-in-gatsby/</link><guid isPermaLink="false">https://markoskon.com/add-inline-style-elements-in-gatsby/</guid><pubDate>Sun, 15 Mar 2020 11:00:00 GMT</pubDate><content:encoded>&lt;p&gt;I wanted to add &lt;em&gt;inline style elements&lt;/em&gt; that are &lt;em&gt;unique&lt;/em&gt; per page in this Gatsby blog. My use case was to create several posts where I would share my notes about some typefaces I like from Google Fonts. Inside those posts, I would download the font files, display an interactive component where the user can add text and change font-related &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; attributes, and, finally, show some interesting characters and OpenType features.&lt;/p&gt;&lt;p&gt;I didn’t want the font face rules to be present in all pages, something that would increase the &lt;abbr title=&quot;Hypertext Markup&quot;&gt;HTML&lt;/abbr&gt; size. If you want that, you have a ton of options. Let’s name a few:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You can import a &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; file inside your &lt;code&gt;gatsby-browser.js&lt;/code&gt; file.&lt;/li&gt;&lt;li&gt;You can import a &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; file inside any React component.&lt;/li&gt;&lt;li&gt;You can create a “global style” with a &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;-in-&lt;abbr title=&quot;JavaScript&quot;&gt;JS&lt;/abbr&gt; library like &lt;code&gt;styled-components&lt;/code&gt; or &lt;code&gt;emotion&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;You can use the Gatsby &lt;abbr title=&quot;Server-Side Rendering&quot;&gt;SSR&lt;/abbr&gt; &lt;abbr title=&quot;Application Programming Interfaces&quot;&gt;APIs&lt;/abbr&gt;. More specifically, the &lt;code&gt;onRenderBody&lt;/code&gt; and its parameters &lt;code&gt;setHeadComponents&lt;/code&gt; and &lt;code&gt;setPostBodyComponents&lt;/code&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Coming back to the initial requirement, if you want to add an inline style element that would apply &lt;em&gt;only&lt;/em&gt; to a &lt;em&gt;specific page&lt;/em&gt; in Gatsby, you can do the following:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/page-2.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Page2&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Helmet&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;text/css&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        @font-face {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          font-family: &amp;quot;Source Sans Variable&amp;quot;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          font-display: swap;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          font-weight: 200 900;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          font-style: normal;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          font-stretch: normal;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          src: url(&amp;quot;/fonts/SourceSansVariable-Roman-latin.woff2&amp;quot;) format(&amp;quot;woff2&amp;quot;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          unicode-range: U+00-FF;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        ... skipping the rest&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Helmet&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Page 1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* content */&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In my case, the pages were not &lt;abbr title=&quot;JavaScript XML&quot;&gt;JSX&lt;/abbr&gt; files but &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt;, and the above snippet didn’t work inside an &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; page. The workaround was simple—and maybe preferred from a “clean code” perspective. I created a &lt;code&gt;react-helmet&lt;/code&gt; only component with the font faces, and then I imported that component inside the &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt;. This the component I’m talking about:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;content/posts/source-sans/font-faces.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Helmet } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-helmet&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Helmet&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;text/css&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        @font-face {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          ... skipping&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Helmet&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And this is the import/render inside the &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; page:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;content/posts/source-sans/index.mdx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; FontFaces &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./font-faces&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;FontFaces&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The GitHub page for the &lt;code&gt;react-helmet&lt;/code&gt; has a &lt;a href=&quot;https://github.com/nfl/react-helmet#reference-guide&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;reference guide&lt;/a&gt; that shows how to add other types of elements in the head of the document.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;Don&amp;#x27;t forget that to use &lt;code&gt;react-helmet&lt;/code&gt; properly in Gatsby, you need the &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-plugin-react-helmet/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-plugin-react-helmet&lt;/a&gt; plugin.&lt;/div&gt;&lt;h2 id=&quot;related-links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#related-links&quot;&gt;Related links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;GitHub issue: &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/issues/3446#issuecomment-573320294&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Using different &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; file for different pages&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Work Sans typeface notes]]></title><description><![CDATA[My notes for the Work Sans typeface. Work Sans is designed by Wei Huang and is published under the SIL Open Font License.]]></description><link>https://markoskon.com/work-sans-typeface-notes/</link><guid isPermaLink="false">https://markoskon.com/work-sans-typeface-notes/</guid><pubDate>Thu, 12 Mar 2020 19:00:00 GMT</pubDate><content:encoded>&lt;p&gt;You can find here my notes for the Work Sans typeface. Work Sans is designed by Wei Huang and is published under the &lt;abbr title=&quot;Summer Institute of Linguistics&quot;&gt;SIL&lt;/abbr&gt; Open Font License Version 1.1.&lt;/p&gt;&lt;h2 id=&quot;opinions--notes&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#opinions--notes&quot;&gt;Opinions &amp;amp; notes&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Description from the creator and some personal notes in the end. The following quotes are from the &lt;a href=&quot;http://weiweihuanghuang.github.io/Work-Sans/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;project’s site.&lt;/a&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Work Sans is based loosely on early Grotesques — i.e. &lt;a href=&quot;https://www.flickr.com/photos/stewf/14444337254/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Stephenson Blake&lt;/a&gt;, &lt;a href=&quot;https://archive.org/stream/printingtypespec00millrich#page/226/mode/2up/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Miller &amp;amp; Richard&lt;/a&gt; and &lt;a href=&quot;https://archive.org/stream/hauptprobeingedr00baue#page/109/mode/1up&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Bauerschen Giesserei&lt;/a&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;p&gt;The core of the fonts are optimized for on-screen medium-sized text usage (14px-48px) – but still can be used in print well. The fonts at the extreme weights are designed more for display use.&lt;/p&gt;&lt;/blockquote&gt;&lt;h3 id=&quot;my-notes&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#my-notes&quot;&gt;My notes&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;It has a variable font.&lt;/li&gt;&lt;li&gt;It’s playful and has a ton of features for an open-source typeface.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/weiweihuanghuang/Work-Sans&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Project on GitHub&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://weiweihuanghuang.github.io/Work-Sans/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Project’s website&lt;/a&gt;. You can find a description and excerpts in supported languages.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://fonts.google.com/specimen/Work+Sans&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Google Fonts entry&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.typewolf.com/site-of-the-day/fonts/work-sans&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Typewolf review&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://fontsinuse.com/typefaces/39678/work-sans&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Work Sans entry&lt;/a&gt; in fontinuse.com.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://beautifulwebtype.com/work-sans/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Work Sans in beautiful web type&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;An &lt;abbr title=&quot;Node Package Manager&quot;&gt;NPM&lt;/abbr&gt; package I made for Work Sans with &lt;a href=&quot;https://www.npmjs.com/package/@affectionatedoor/work-sans-subsets&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Unicode subsets.&lt;/a&gt; It also includes the italic styles that, at the time of writing, are not available in Google Fonts.&lt;/li&gt;&lt;li&gt;An &lt;a href=&quot;https://github.com/MarkosKon/theme-playground/tree/master/examples/using-work-sans-subsets&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;example repo&lt;/a&gt; that uses the package.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;playground&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#playground&quot;&gt;Playground&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;I load the variable version of Work Sans. Below is the exact version of the variable fonts I use.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;Version 2.007; ttfautohint (v1.8.1.43-b0c9)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;sc-aXZVg Primitives__Box-sc-12p0hgy-0 knHXor ccOBqu&quot;&gt;&lt;div class=&quot;Components__ControlContainer-sc-uj3ksg-0 ixEsga&quot;&gt;&lt;label for=&quot;select-weight&quot;&gt;&lt;strong&gt;Weight: &lt;/strong&gt;&lt;select id=&quot;select-weight&quot; name=&quot;select-weight&quot;&gt;&lt;option value=&quot;100&quot;&gt;100&lt;/option&gt;&lt;option value=&quot;200&quot;&gt;200&lt;/option&gt;&lt;option value=&quot;300&quot;&gt;300&lt;/option&gt;&lt;option value=&quot;400&quot; selected=&quot;&quot;&gt;400&lt;/option&gt;&lt;option value=&quot;500&quot;&gt;500&lt;/option&gt;&lt;option value=&quot;600&quot;&gt;600&lt;/option&gt;&lt;option value=&quot;700&quot;&gt;700&lt;/option&gt;&lt;option value=&quot;800&quot;&gt;800&lt;/option&gt;&lt;option value=&quot;900&quot;&gt;900&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&lt;label for=&quot;select-style&quot;&gt;&lt;strong&gt;Style: &lt;/strong&gt;&lt;select id=&quot;select-style&quot; name=&quot;select-style&quot;&gt;&lt;option value=&quot;normal&quot; selected=&quot;&quot;&gt;normal&lt;/option&gt;&lt;option value=&quot;italic&quot;&gt;italic&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&lt;label for=&quot;select-width&quot;&gt;&lt;strong&gt;Width: &lt;/strong&gt;&lt;select id=&quot;select-width&quot; name=&quot;select-width&quot;&gt;&lt;option value=&quot;normal&quot; selected=&quot;&quot;&gt;normal&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&lt;label for=&quot;input-size&quot;&gt;&lt;strong&gt;Size: &lt;/strong&gt;&lt;input id=&quot;input-size&quot; name=&quot;input-size&quot; type=&quot;range&quot; min=&quot;8&quot; max=&quot;150&quot; value=&quot;20&quot;/&gt;&lt;span style=&quot;min-width:54px;text-align:right&quot;&gt;20px&lt;/span&gt;&lt;/label&gt;&lt;label for=&quot;input-line-height&quot;&gt;&lt;strong&gt;Line height: &lt;/strong&gt;&lt;input id=&quot;input-line-height&quot; name=&quot;input-line-height&quot; type=&quot;range&quot; min=&quot;1&quot; max=&quot;2&quot; step=&quot;0.05&quot; value=&quot;1.5&quot;/&gt;&lt;span&gt;1.50em&lt;/span&gt;&lt;/label&gt;&lt;label for=&quot;input-letter-spacing&quot;&gt;&lt;strong&gt;Letter spacing: &lt;/strong&gt;&lt;input id=&quot;input-letter-spacing&quot; name=&quot;input-letter-spacing&quot; type=&quot;range&quot; min=&quot;0&quot; max=&quot;1&quot; step=&quot;0.01&quot; value=&quot;0&quot;/&gt;&lt;span&gt;0.00em&lt;/span&gt;&lt;/label&gt;&lt;/div&gt;&lt;p contenteditable=&quot;true&quot; spellcheck=&quot;false&quot; aria-label=&quot;Sample text&quot; class=&quot;Components__Editable-sc-uj3ksg-1 gAZInL&quot;&gt;A peep at some distant orb has power to raise and purify our thoughts like a strain of sacred music, or a noble picture, or a passage from the grander poets. It always does one good.&lt;/p&gt;&lt;/div&gt;&lt;h2 id=&quot;opentype-features&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#opentype-features&quot;&gt;OpenType features&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Work Sans supports 39 layout features. It supports features essential for body text, such as old-style numbers (&lt;code&gt;onum&lt;/code&gt;), proportional numbers (&lt;code&gt;pnum&lt;/code&gt;), small caps, and it also has a ton of stylistic sets. It also has support for stylistic features such as swashes (&lt;code&gt;swsh&lt;/code&gt;, &lt;code&gt;cswh&lt;/code&gt;) and discretionary ligatures (&lt;code&gt;dlig&lt;/code&gt;). The following table shows some of the most interesting to me:&lt;/p&gt;&lt;div tabindex=&quot;0&quot; class=&quot;TableWrapper__Wrapper-sc-48voiu-0 bGmsWm&quot;&gt;&lt;table font-family=&quot;Work Sans Variable&quot; class=&quot;WorkSansFeatures__Table-sc-1uroe1h-0 rJkvb&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th align=&quot;left&quot;&gt;Feature code&lt;/th&gt;&lt;th align=&quot;center&quot;&gt;Result&lt;/th&gt;&lt;th align=&quot;center&quot;&gt;Default&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Notes&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;swsh&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;swsh&amp;#x27;&quot;&gt;A E F L M N R S T&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;A E F L M N R S T&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Capital swashes&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;swsh&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;swsh&amp;#x27;&quot;&gt;n r t y&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;n r t y&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Lowercase swashes&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;cswh&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;cswh&amp;#x27;&quot;&gt;Reality&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;swsh&amp;#x27;&quot;&gt;Reality&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Contextual swashes compared to swashes&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;dlig&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;dlig&amp;#x27;&quot;&gt;effect station&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;effect station&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Discretionary ligatures&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;cswh + dlig&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;dlig&amp;#x27;, &amp;#x27;cswh&amp;#x27;&quot;&gt;Rocksteady&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;Rocksteady&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Contextual swashes and discretionary ligatures combined&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ornm&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ornm&amp;#x27;&quot;&gt;• “ ” ‘ ’ ¶&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;• “ ” ‘ ’ ¶&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Ornaments&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss02&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss02&amp;#x27;&quot;&gt;l&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;l&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Lowercase l without a tail.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss03&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss03&amp;#x27;&quot;&gt;R&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;R&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Capital R alternate&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss04&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss04&amp;#x27;&quot;&gt;G&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;G&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Capital G alternate&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss06&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss06&amp;#x27;&quot;&gt;a&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;a&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Single story lowercase a&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;h2 id=&quot;interesting-characters&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#interesting-characters&quot;&gt;Interesting characters&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;For more interesting characters see the OpenType features above, check the &lt;a href=&quot;#playground&quot;&gt;playground&lt;/a&gt;, or get a &lt;a href=&quot;https://github.com/weiweihuanghuang/Work-Sans&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;copy from GitHub&lt;/a&gt; and drop it in the &lt;a href=&quot;https://wakamaifondue.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Wakamai Fondue&lt;/a&gt; app to discover them yourself.&lt;/p&gt;&lt;ul font-family=&quot;Work Sans Variable&quot; class=&quot;InterestingCharacters__List-sc-1c3igsl-0 iJBrpT&quot;&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;G&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;J&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;Q&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;a&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;e&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;g&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;l&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;m&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;§&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;←&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;↑&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;→&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;↓&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;↺&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;€&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;₤&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;$&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;❡&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;character-support&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#character-support&quot;&gt;Character support&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;According to &lt;a href=&quot;https://wakamaifondue.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Wakamai Fondue&lt;/a&gt;, it has 753 characters and 1410 glyphs. The font files cover the majority if not all of the following Unicode sets.&lt;/p&gt;&lt;div tabindex=&quot;0&quot; class=&quot;TableWrapper__Wrapper-sc-48voiu-0 bGmsWm&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th align=&quot;left&quot;&gt;Set&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Range&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0000-00FF&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin Extended-A&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0100-017F&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin Extended-B&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0180-024F&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin Extended Additional&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+1E00-1EFF&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Rest&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+2000-FB01&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;h3 id=&quot;not-complete-sets-below-50&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#not-complete-sets-below-50&quot;&gt;Not complete sets (below 50%)&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Total characters = 48. This means that the typeface supports only specific languages/characters from these Unicode blocks. See the project’s site for detailed language support.&lt;/p&gt;&lt;div tabindex=&quot;0&quot; class=&quot;TableWrapper__Wrapper-sc-48voiu-0 bGmsWm&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th align=&quot;left&quot;&gt;Set&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Range&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Notes&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;abbr title=&quot;International Phonetic Alphabet&quot;&gt;IPA&lt;/abbr&gt; Extensions&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0250-02AF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;1 char&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Spacing Modifier Letters&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+02B0-02FF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;19 chars&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Combing Diacritical Marks&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0300-036F&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;25 chars&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Greek&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0370-03FF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;3 chars&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;h2 id=&quot;weights--styles&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#weights--styles&quot;&gt;Weights &amp;amp; styles&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;It comes in 9 weights with matching italics. It’s also available in a variable font format with a &lt;code&gt;weight&lt;/code&gt; variation axis that supports weights from 100 to 900.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Source Sans Pro typeface notes]]></title><description><![CDATA[My notes for the Source Sans Pro typeface. Source Sans was designed by Paul D. Hunt and is licensed under the SIL Open Font License.]]></description><link>https://markoskon.com/source-sans-typeface-notes/</link><guid isPermaLink="false">https://markoskon.com/source-sans-typeface-notes/</guid><pubDate>Wed, 11 Mar 2020 19:00:00 GMT</pubDate><content:encoded>&lt;p&gt;You can find here my notes for the Source Sans Pro typeface. Source Sans was designed by Paul D. Hunt and is licensed under the &lt;abbr title=&quot;Summer Institute of Linguistics&quot;&gt;SIL&lt;/abbr&gt; Open Font License, Version 1.1.&lt;/p&gt;&lt;h2 id=&quot;opinions--notes&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#opinions--notes&quot;&gt;Opinions &amp;amp; notes&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Opinions from the creators and other credible sources. In the end, there are some personal notes.&lt;/p&gt;&lt;h3 id=&quot;typewolf&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#typewolf&quot;&gt;Typewolf&lt;/a&gt;&lt;/h3&gt;&lt;blockquote&gt;&lt;p&gt;The design was inspired by American gothics, however, some traits such as the tail on the lowercase l are more reminiscent of humanist typefaces.&lt;/p&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;p&gt;The slightly condensed letterforms of Source Sans Pro make it ideal for user interfaces where space is a concern.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;A note from Captain obvious: it also has the &lt;em&gt;modulated stroke&lt;/em&gt; of the humanist typefaces.&lt;/p&gt;&lt;h3 id=&quot;adobe-blog&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#adobe-blog&quot;&gt;Adobe blog&lt;/a&gt;&lt;/h3&gt;&lt;blockquote&gt;&lt;p&gt;Source Sans is a classic grotesque typeface with a simple, unassuming design.&lt;/p&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;p&gt;In &lt;abbr title=&quot;User Interface&quot;&gt;UI&lt;/abbr&gt; screenshots, Source Sans feels more classically typographic than I would expect.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;a href=&quot;https://blogs.adobe.com/typblography/2012/08/new-adobe-originals-more-adobe-web-fonts.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Source Sans on Adobe blog.&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;my-notes&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#my-notes&quot;&gt;My notes&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;Arguably the best and most complete family on Google fonts. Don’t forget that the Source family includes a serif (Source Serif Pro) and a monospace version (Source Code Pro). Additionally, there is an alternative for the monospace version called &lt;a href=&quot;https://github.com/i-tu/Hasklig.&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Hasklig&lt;/a&gt; that includes code ligatures.&lt;/li&gt;&lt;li&gt;It supports Greek and they are awesome.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/adobe-fonts/source-sans-pro&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Project on GitHub.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.typewolf.com/site-of-the-day/fonts/source-sans-pro&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Typewolf review.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://typographica.org/typeface-reviews/source-sans/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Typographica review.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://beautifulwebtype.com/source-sans-pro/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Source Sans Pro in beautiful web type&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;An &lt;abbr title=&quot;Node Package Manager&quot;&gt;NPM&lt;/abbr&gt; package I made for Source Sans Pro with &lt;a href=&quot;https://www.npmjs.com/package/@affectionatedoor/source-sans-subsets&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Unicode subsets.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;An &lt;a href=&quot;https://github.com/MarkosKon/checking-typefaces/tree/source-sans&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;example repo&lt;/a&gt; that uses the package.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;playground&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#playground&quot;&gt;Playground&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;All the notes and the interactive controls below are for the variable version of Source Sans Pro; you can see the exact version I used below.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;Version 3.006; hotconv 1.0.111; makeotfexe 2.5.65597&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;sc-aXZVg Primitives__Box-sc-12p0hgy-0 knHXor ccOBqu&quot;&gt;&lt;div class=&quot;Components__ControlContainer-sc-uj3ksg-0 ixEsga&quot;&gt;&lt;label for=&quot;select-weight&quot;&gt;&lt;strong&gt;Weight: &lt;/strong&gt;&lt;select id=&quot;select-weight&quot; name=&quot;select-weight&quot;&gt;&lt;option value=&quot;200&quot;&gt;200&lt;/option&gt;&lt;option value=&quot;300&quot;&gt;300&lt;/option&gt;&lt;option value=&quot;400&quot; selected=&quot;&quot;&gt;400&lt;/option&gt;&lt;option value=&quot;500&quot;&gt;500&lt;/option&gt;&lt;option value=&quot;600&quot;&gt;600&lt;/option&gt;&lt;option value=&quot;700&quot;&gt;700&lt;/option&gt;&lt;option value=&quot;800&quot;&gt;800&lt;/option&gt;&lt;option value=&quot;900&quot;&gt;900&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&lt;label for=&quot;select-style&quot;&gt;&lt;strong&gt;Style: &lt;/strong&gt;&lt;select id=&quot;select-style&quot; name=&quot;select-style&quot;&gt;&lt;option value=&quot;normal&quot; selected=&quot;&quot;&gt;normal&lt;/option&gt;&lt;option value=&quot;italic&quot;&gt;italic&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&lt;label for=&quot;select-width&quot;&gt;&lt;strong&gt;Width: &lt;/strong&gt;&lt;select id=&quot;select-width&quot; name=&quot;select-width&quot;&gt;&lt;option value=&quot;normal&quot; selected=&quot;&quot;&gt;normal&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&lt;label for=&quot;input-size&quot;&gt;&lt;strong&gt;Size: &lt;/strong&gt;&lt;input id=&quot;input-size&quot; name=&quot;input-size&quot; type=&quot;range&quot; min=&quot;8&quot; max=&quot;150&quot; value=&quot;20&quot;/&gt;&lt;span style=&quot;min-width:54px;text-align:right&quot;&gt;20px&lt;/span&gt;&lt;/label&gt;&lt;label for=&quot;input-line-height&quot;&gt;&lt;strong&gt;Line height: &lt;/strong&gt;&lt;input id=&quot;input-line-height&quot; name=&quot;input-line-height&quot; type=&quot;range&quot; min=&quot;1&quot; max=&quot;2&quot; step=&quot;0.05&quot; value=&quot;1.5&quot;/&gt;&lt;span&gt;1.50em&lt;/span&gt;&lt;/label&gt;&lt;label for=&quot;input-letter-spacing&quot;&gt;&lt;strong&gt;Letter spacing: &lt;/strong&gt;&lt;input id=&quot;input-letter-spacing&quot; name=&quot;input-letter-spacing&quot; type=&quot;range&quot; min=&quot;0&quot; max=&quot;1&quot; step=&quot;0.01&quot; value=&quot;0&quot;/&gt;&lt;span&gt;0.00em&lt;/span&gt;&lt;/label&gt;&lt;/div&gt;&lt;p contenteditable=&quot;true&quot; spellcheck=&quot;false&quot; aria-label=&quot;Sample text&quot; class=&quot;Components__Editable-sc-uj3ksg-1 jfBITX&quot;&gt;A peep at some distant orb has power to raise and purify our thoughts like a strain of sacred music, or a noble picture, or a passage from the grander poets. It always does one good.&lt;/p&gt;&lt;/div&gt;&lt;h2 id=&quot;opentype-features&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#opentype-features&quot;&gt;OpenType features:&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Source Sans Pro supports 52 layout features. It supports features essential for body text, such as old-style numbers (&lt;code&gt;onum&lt;/code&gt;), proportional numbers (&lt;code&gt;pnum&lt;/code&gt;), small caps, and it also has a ton of stylistic sets and character variants. The following table shows some of the most interesting to me:&lt;/p&gt;&lt;div tabindex=&quot;0&quot; class=&quot;TableWrapper__Wrapper-sc-48voiu-0 bGmsWm&quot;&gt;&lt;table font-family=&quot;Source Sans Variable&quot; class=&quot;SourceSansFeatures__Table-sc-t4o4qu-0 caeBYh&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th align=&quot;left&quot;&gt;Feature code&lt;/th&gt;&lt;th align=&quot;center&quot;&gt;Result&lt;/th&gt;&lt;th align=&quot;center&quot;&gt;Default&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Notes&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss04 or cv03&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss04&amp;#x27;&quot;&gt;g&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;g&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Single story lower case g&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss05 or cv04&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss05&amp;#x27;&quot;&gt;l&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;l&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Lower case l without a tail.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss06 or cv05&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss06&amp;#x27;&quot;&gt;a&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;a&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;Double story lower case a with a tail&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;ss02&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span style=&quot;font-feature-settings:&amp;#x27;ss02&amp;#x27;&quot;&gt;a g l&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;center&quot;&gt;&lt;span&gt;a g l&lt;/span&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;-&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;h2 id=&quot;interesting-characters&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#interesting-characters&quot;&gt;Interesting characters&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Many stylistic sets and characters variants. It has a ton of characters &lt;code&gt;U+2000&lt;/code&gt;+. For more interesting characters, check the &lt;a href=&quot;#playground&quot;&gt;playground&lt;/a&gt; or get a &lt;a href=&quot;https://github.com/adobe-fonts/source-sans-pro&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;copy from GitHub&lt;/a&gt; and drop it in the &lt;a href=&quot;https://wakamaifondue.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Wakamai Fondue&lt;/a&gt; app.&lt;/p&gt;&lt;ul font-family=&quot;Source Sans Variable&quot; class=&quot;InterestingCharacters__List-sc-1c3igsl-0 bwuMTr&quot;&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;M&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;Q&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;S&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;a&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;g&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;l&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;t&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;💩&lt;/li&gt;&lt;li class=&quot;InterestingCharacters__ListItem-sc-1c3igsl-1 hNlyig&quot;&gt;🤖&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;character-support&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#character-support&quot;&gt;Character support&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;According to &lt;a href=&quot;https://wakamaifondue.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Wakamai Fondue&lt;/a&gt;, it has 1436 characters and 2194 glyphs. The font files cover the majority if not all of the following Unicode sets.&lt;/p&gt;&lt;div tabindex=&quot;0&quot; class=&quot;TableWrapper__Wrapper-sc-48voiu-0 bGmsWm&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th align=&quot;left&quot;&gt;Set&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Range&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Notes&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0000-00FF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin Extended-A&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0100-017F&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin Extended-B&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0180-024F&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;probably below 50%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;&lt;abbr title=&quot;International Phonetic Alphabet&quot;&gt;IPA&lt;/abbr&gt; Extensions&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0250-02AF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Spacing Modifier Letters&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+02B0-02FF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Combing Diacritical Marks&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0300-036F&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Greek&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0370-03FF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Cyrillic&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+0400-04FF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Latin Extended Additional&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+1E00-1EFF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Greek Extended&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+1F00-1FFF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Rest&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+2000-1F916&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;234 chars!&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;h3 id=&quot;not-complete-sets-below-50&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#not-complete-sets-below-50&quot;&gt;Not complete sets (below 50%)&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Total characters = 17. This means that the typeface supports only specific languages/characters from these Unicode blocks.&lt;/p&gt;&lt;div tabindex=&quot;0&quot; class=&quot;TableWrapper__Wrapper-sc-48voiu-0 bGmsWm&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th align=&quot;left&quot;&gt;Set&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Range&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Notes&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Phonetic Extensions&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+1D00-1D7F&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;14 chars&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;left&quot;&gt;Phonetic Extensions Supplement:&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;U+1D80-1DBF&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;3 chars&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;h2 id=&quot;weights--styles&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#weights--styles&quot;&gt;Weights &amp;amp; styles&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;It has 6 weights with matching italics. It also comes in a variable font format with a &lt;code&gt;weight&lt;/code&gt; variation axis that supports weights from 200 to 900.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Debugging notes]]></title><description><![CDATA[Tips and tricks you can use to debug JavaScript applications.]]></description><link>https://markoskon.com/debugging-notes/</link><guid isPermaLink="false">https://markoskon.com/debugging-notes/</guid><pubDate>Wed, 13 Nov 2019 15:00:00 GMT</pubDate><content:encoded>&lt;p&gt;You can find here some notes I wrote while watching an excellent talk by Rebecca Hill: &lt;a href=&quot;https://www.youtube.com/watch?v=TtsvMRxmfGA&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Essential JavaScript debugging tools for the modern detective&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;gatsby-resp-iframe-wrapper&quot; style=&quot;padding-bottom:56.25%;position:relative;height:0;overflow:hidden;margin-bottom:32px&quot;&gt; &lt;iframe title=&quot;Essential JavaScript debugging tools for the modern detective&quot; src=&quot;https://www.youtube.com/embed/TtsvMRxmfGA&quot; frameBorder=&quot;0&quot; allow=&quot;accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen=&quot;&quot; style=&quot;position:absolute;top:0;left:0;width:100%;height:100%&quot;&gt;&lt;/iframe&gt; &lt;/div&gt;&lt;h2 id=&quot;-dollar-selector&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#-dollar-selector&quot;&gt;&lt;code&gt;$&lt;/code&gt; (dollar) selector&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The tips in this section are for the &lt;a href=&quot;https://developers.google.com/web/tools/chrome-devtools/console/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;console tab&lt;/a&gt; of Chrome DevTools.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;$&lt;/code&gt; is an &lt;a href=&quot;https://developers.google.com/web/tools/chrome-devtools/console/utilities#queryselector&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;alias&lt;/a&gt; for &lt;code&gt;document.querySelector&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// the following statements are equivalent:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#an-id&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#an-id&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;$$&lt;/code&gt; is an &lt;a href=&quot;https://developers.google.com/web/tools/chrome-devtools/console/utilities#queryselectorall&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;alias&lt;/a&gt; for &lt;code&gt;document.querySelectorAll&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// the following statements are equivalent:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;$$&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;$0&lt;/code&gt; returns the most recent &lt;abbr title=&quot;Hypertext Markup Language&quot;&gt;HTML&lt;/abbr&gt; element you inspected; &lt;code&gt;$1&lt;/code&gt; the second most recent and so forth until &lt;code&gt;$4&lt;/code&gt;. &lt;a href=&quot;https://developers.google.com/web/tools/chrome-devtools/console/utilities#dom&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Console Utilities &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; Reference: \$0-\$4&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;logging-stuff-to-the-console&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#logging-stuff-to-the-console&quot;&gt;Logging stuff to the console&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Prefer &lt;code&gt;console.log({ variable })&lt;/code&gt;—wrap the variable inside an object—instead of &lt;code&gt;console.log(variable)&lt;/code&gt; to get a little more context:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// prints: 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// prints { number: 1 }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;console.table&lt;/code&gt; makes more readable the logs for your &lt;em&gt;arrays of objects&lt;/em&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;John&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, age: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Jane&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, age: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;39&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The code above prints:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:713px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/7fb3ce4dfb66f5593f3b15df4aed6404/6085a/console-table.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:13.958333333333334%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAADABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAEF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAB3QUH/8QAFBABAAAAAAAAAAAAAAAAAAAAEP/aAAgBAQABBQJ//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAFBABAAAAAAAAAAAAAAAAAAAAEP/aAAgBAQAGPwJ//8QAFxABAAMAAAAAAAAAAAAAAAAAABFBUf/aAAgBAQABPyHVIf/aAAwDAQACAAMAAAAQ+C//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/ED//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/ED//xAAZEAEAAgMAAAAAAAAAAAAAAAABADERIXH/2gAIAQEAAT8QL6mNIhsJ/9k=&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Results from console.table&quot; title=&quot;Results from console.table&quot; src=&quot;/static/7fb3ce4dfb66f5593f3b15df4aed6404/6085a/console-table.jpg&quot; srcSet=&quot;/static/7fb3ce4dfb66f5593f3b15df4aed6404/a5e48/console-table.jpg 480w,/static/7fb3ce4dfb66f5593f3b15df4aed6404/6085a/console-table.jpg 713w&quot; sizes=&quot;(max-width: 713px) 100vw, 713px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Results from console.table&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;console.group&lt;/code&gt; creates collapsable groups of console logs:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;group&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Greetings&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;World&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;groupEnd&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The statements above prints:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:728px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/e29d9f6232446660e858eb8d8e4bda1f/5e74c/console-group-groupend.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:8.75%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAACABQDASIAAhEBAxEB/8QAFwABAAMAAAAAAAAAAAAAAAAAAAEDBf/EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAd6QqB//xAAWEAEBAQAAAAAAAAAAAAAAAAABEDH/2gAIAQEAAQUCI7//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/AT//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/AT//xAAUEAEAAAAAAAAAAAAAAAAAAAAQ/9oACAEBAAY/An//xAAUEAEAAAAAAAAAAAAAAAAAAAAQ/9oACAEBAAE/IVf/2gAMAwEAAgADAAAAEAvv/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPxA//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPxA//8QAGRABAAIDAAAAAAAAAAAAAAAAAQARITFR/9oACAEBAAE/EAU4NyjhCWn/2Q==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Results from console.group/groupEnd&quot; title=&quot;Results from console.group/groupEnd&quot; src=&quot;/static/e29d9f6232446660e858eb8d8e4bda1f/5e74c/console-group-groupend.jpg&quot; srcSet=&quot;/static/e29d9f6232446660e858eb8d8e4bda1f/a5e48/console-group-groupend.jpg 480w,/static/e29d9f6232446660e858eb8d8e4bda1f/5e74c/console-group-groupend.jpg 728w&quot; sizes=&quot;(max-width: 728px) 100vw, 728px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Results from console.group/groupEnd&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;console.trace&lt;/code&gt; to quick log the call stack.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Use &lt;code&gt;console.dir&lt;/code&gt; if you want to inspect an &lt;abbr title=&quot;Hypertext Markup Language&quot;&gt;HTML&lt;/abbr&gt; element as an &lt;em&gt;object&lt;/em&gt; instead of logging its &lt;em&gt;markup&lt;/em&gt; with &lt;code&gt;console.log&lt;/code&gt;. Consider the following examples:&lt;/p&gt;&lt;p&gt;&lt;code&gt;console.log()&lt;/code&gt; prints:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:732px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/00307c5de1050dffaa6d7f746860f005/7a3f0/console-log.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:5.833333333333333%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAABABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAIF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAB3AUD/8QAFBABAAAAAAAAAAAAAAAAAAAAEP/aAAgBAQABBQJ//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAFBABAAAAAAAAAAAAAAAAAAAAEP/aAAgBAQAGPwJ//8QAFBABAAAAAAAAAAAAAAAAAAAAEP/aAAgBAQABPyF//9oADAMBAAIAAwAAABD7z//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8QP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8QP//EABgQAAIDAAAAAAAAAAAAAAAAAAExABBx/9oACAEBAAE/EC6DOz//2Q==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Results from console.log&quot; title=&quot;Results from console.log&quot; src=&quot;/static/00307c5de1050dffaa6d7f746860f005/7a3f0/console-log.jpg&quot; srcSet=&quot;/static/00307c5de1050dffaa6d7f746860f005/a5e48/console-log.jpg 480w,/static/00307c5de1050dffaa6d7f746860f005/7a3f0/console-log.jpg 732w&quot; sizes=&quot;(max-width: 732px) 100vw, 732px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Results from console.log&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;&lt;code&gt;console.dir&lt;/code&gt; prints:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:711px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/7fa1fef71a19d4f2ac51c78dd58b32ad/e3ef6/console-dir.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:21.041666666666668%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAEABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAEF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAB3aFB/8QAFRABAQAAAAAAAAAAAAAAAAAAARD/2gAIAQEAAQUCb//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABQQAQAAAAAAAAAAAAAAAAAAABD/2gAIAQEABj8Cf//EABcQAQADAAAAAAAAAAAAAAAAAAEAECH/2gAIAQEAAT8hwkGv/9oADAMBAAIAAwAAABADz//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8QP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8QP//EABcQAAMBAAAAAAAAAAAAAAAAAAABESH/2gAIAQEAAT8QbEMpEf/Z&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Results from console.dir&quot; title=&quot;Results from console.dir&quot; src=&quot;/static/7fa1fef71a19d4f2ac51c78dd58b32ad/e3ef6/console-dir.jpg&quot; srcSet=&quot;/static/7fa1fef71a19d4f2ac51c78dd58b32ad/a5e48/console-dir.jpg 480w,/static/7fa1fef71a19d4f2ac51c78dd58b32ad/e3ef6/console-dir.jpg 711w&quot; sizes=&quot;(max-width: 711px) 100vw, 711px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Results from console.dir&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;console.dir&lt;/code&gt; is even more useful in Node because it adds colors, and you can inspect nested objects instead of only logging something like: &lt;code&gt;[Object]&lt;/code&gt;. Consider the following example:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;John&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  age: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  pets:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Azor&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, type: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dog&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, favouriteOwner: { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Sally&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; } },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Kitty&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, type: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  ]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// prints:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//   name: &amp;#x27;John&amp;#x27;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//   age: 26,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//   pets: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//     { name: &amp;#x27;Azor&amp;#x27;, type: &amp;#x27;dog&amp;#x27;, favouriteOwner: [Object] },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//     { name: &amp;#x27;Kitty&amp;#x27;, type: &amp;#x27;cat&amp;#x27; } ]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = { colors: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, depth: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// prints:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//   name: &amp;#x27;John&amp;#x27;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//   age: 26,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//   pets: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//     { name: &amp;#x27;Azor&amp;#x27;, type: &amp;#x27;dog&amp;#x27;, favouriteOwner: { name: &amp;quot;Sally&amp;quot; } },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//     { name: &amp;#x27;Kitty&amp;#x27;, type: &amp;#x27;cat&amp;#x27; } ]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;To make your life easier, find or create VS Code snippets for logging stuff into console. &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=dsznajder.es7-react-js-snippets#console&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;ECMAScript 7&quot;&gt;ES7&lt;/abbr&gt; snippets extension&lt;/a&gt; for VS Code has some console snippets:&lt;/p&gt;&lt;div tabindex=&quot;0&quot; class=&quot;TableWrapper__Wrapper-sc-48voiu-0 bGmsWm&quot;&gt;&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th align=&quot;center&quot;&gt;Prefix&lt;/th&gt;&lt;th align=&quot;left&quot;&gt;Method&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;clg→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.log(object)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;clo→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.log(&amp;quot;object&amp;quot;, object)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;ctm→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.time(&amp;quot;timeId&amp;quot;)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;cte→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.timeEnd(&amp;quot;timeId&amp;quot;)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;cas→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.assert(expression,object)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;ccl→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.clear()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;cco→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.count(label)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;cdi→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.dir&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;cer→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.error(object)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;cgr→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.group(label)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;cge→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.groupEnd()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;ctr→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.trace(object)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;cwa→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.warn&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;&lt;code&gt;cin→&lt;/code&gt;&lt;/td&gt;&lt;td align=&quot;left&quot;&gt;&lt;code&gt;console.info&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;h2 id=&quot;debugging&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#debugging&quot;&gt;Debugging&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You can debug your JavaScript applications with VS Code’s &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Debugger for Chrome&lt;/a&gt; extension.&lt;/p&gt;&lt;h3 id=&quot;cra-debug&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#cra-debug&quot;&gt;&lt;abbr title=&quot;Create React App&quot;&gt;CRA&lt;/abbr&gt; debug:&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;For &lt;abbr title=&quot;Create React App&quot;&gt;CRA&lt;/abbr&gt; app you need the following &lt;code&gt;.vscode/launch.json&lt;/code&gt; config:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.vscode/launch.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Use IntelliSense to learn about possible attributes.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Hover to view descriptions of existing attributes.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;version&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;0.2.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;configurations&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;type&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;chrome&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;request&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;launch&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;CRA Debug&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;url&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;http://localhost:3000&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;webRoot&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;${workspaceFolder}/src&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;sourceMapPathOverrides&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;webpack:///src/*&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;${webRoot}/*&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  ]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You don’t have to specify the &lt;code&gt;sourceMapPathOverrides&lt;/code&gt; explicitly because the default value includes what we specify in the above code snippet.&lt;/p&gt;&lt;h3 id=&quot;gatsby-debug&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#gatsby-debug&quot;&gt;Gatsby debug&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;If you want to debug &lt;em&gt;Gatsby’s development build&lt;/em&gt;, you need a similar &lt;code&gt;launch.json&lt;/code&gt; config, but you’ll have to change the port from &lt;code&gt;3000&lt;/code&gt; to &lt;code&gt;8000&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;You also have to override the Webpack configuration (at the time of writing at least) in &lt;a href=&quot;https://www.gatsbyjs.org/docs/add-custom-webpack-config/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;develop stage&lt;/a&gt; to include the &lt;code&gt;eval-source-map&lt;/code&gt; &lt;a href=&quot;https://webpack.js.org/configuration/devtool/#development&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;devtool&lt;/a&gt;. Otherwise, the line numbering will be messed up, and you won’t be able to add breakpoints. &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/issues/16281&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Relevant GitHub issue&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-node.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;onCreateWebpackConfig&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;stage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;stage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;develop&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setWebpackConfig&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      devtool: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;eval-source-map&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;You can add breakpoints to &lt;em&gt;&lt;abbr title=&quot;Document Object Model&quot;&gt;DOM&lt;/abbr&gt; nodes&lt;/em&gt; by right-clicking and selecting &lt;em&gt;“break on”&lt;/em&gt; under the Elements tab inside DevTools. For example, you can add breakpoints to monitor an &lt;em&gt;attribute change&lt;/em&gt; or when the &lt;abbr title=&quot;Document Object Model&quot;&gt;DOM&lt;/abbr&gt; node gets &lt;em&gt;removed&lt;/em&gt;.&lt;/li&gt;&lt;li&gt;You can add &lt;em&gt;conditional&lt;/em&gt; breakpoints (based on a known &lt;em&gt;variable&lt;/em&gt;): @ 11:47 in the video.&lt;/li&gt;&lt;li&gt;The &lt;em&gt;“pause on all/uncaught exceptions”&lt;/em&gt; can be useful.&lt;/li&gt;&lt;li&gt;Use &lt;em&gt;“Blackbox script”&lt;/em&gt; to stop stepping into certain scripts. For example, black box an external library script because the bug you’re investigating is more likely to be inside your codebase, not in the external library. You can enable that by right-clicking in a file under the Sources tab and selecting “Blackbox script”.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;devtools-snippets--1420&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#devtools-snippets--1420&quot;&gt;DevTools snippets @ 14:20&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://bgrins.github.io/devtools-snippets/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;DevTools Snippets&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk39 { color: #C789D6; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Useful Lodash utilities]]></title><description><![CDATA[You can find here a collection of the most useful lodash utilities, with simple explanations, examples on how to use them, and more.]]></description><link>https://markoskon.com/lodash-utilities/</link><guid isPermaLink="false">https://markoskon.com/lodash-utilities/</guid><pubDate>Sun, 13 Oct 2019 15:06:00 GMT</pubDate><content:encoded>&lt;p&gt;In this post, you can find a collection of the most useful &lt;a href=&quot;https://lodash.com&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;lodash&lt;/a&gt; utilities. Each method has a quick description, its signature, and examples on how to use it. It also has links to the documentation, the weekly downloads (from &lt;abbr title=&quot;Node Package Manager&quot;&gt;NPM&lt;/abbr&gt;), and the bundle size from &lt;a href=&quot;https://bundlephobia.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;bundlephobia&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;The goal here is to list as many methods as possible, in the least possible space. I tried not to include methods that are identical to their native counterparts unless they are popular. You can’t say that this post is something new or groundbreaking, but you can rather see it as a resource that will remind/introduce you to cool lodash methods quickly. To give you an idea, most of the examples are from the lodash documentation. The descriptions, on the other hand, are custom because I wanted to provide clear, non-technical explanations (at least I tried). Finally, I assume that you download the individual packages, not the whole library. As a result, you won’t see me calling the methods with the underscore e.g. &lt;code&gt;_.map()&lt;/code&gt; but directly e.g. &lt;code&gt;map()&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;* You’ll see that many functions have a parameter named &lt;a href=&quot;#identity-iteratee&quot;&gt;iteratee&lt;/a&gt; with a default value of &lt;a href=&quot;#identity-iteratee&quot;&gt;identity&lt;/a&gt;. Both of them are helper lodash functions listed under the &lt;a href=&quot;#util&quot;&gt;Utils section&lt;/a&gt;. Click the links above to learn more.&lt;/p&gt;&lt;h2 id=&quot;table-of-contents&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#table-of-contents&quot;&gt;Table of contents&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;#array&quot;&gt;Array:&lt;/a&gt; &lt;a href=&quot;#chunk&quot;&gt;chunk()&lt;/a&gt;, &lt;a href=&quot;#flatten---flattendeep---flattendepth&quot;&gt;flatten()&lt;/a&gt;, &lt;a href=&quot;#compact&quot;&gt;compact()&lt;/a&gt;, &lt;a href=&quot;#sets&quot;&gt;set methods&lt;/a&gt;, &lt;a href=&quot;#zip&quot;&gt;zip()&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#collection&quot;&gt;Collection:&lt;/a&gt; &lt;a href=&quot;#countby&quot;&gt;countBy()&lt;/a&gt;, &lt;a href=&quot;#groupby&quot;&gt;groupBy()&lt;/a&gt;, &lt;a href=&quot;#orderby&quot;&gt;orderBy()&lt;/a&gt;, &lt;a href=&quot;#partition&quot;&gt;partition()&lt;/a&gt;, &lt;a href=&quot;#popular-methods-with-es6-alternatives&quot;&gt;popular with &lt;abbr title=&quot;ECMAScript 6&quot;&gt;ES6&lt;/abbr&gt; alternatives&lt;/a&gt;, &lt;a href=&quot;#other-collection-methods&quot;&gt;other collection methods.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#math&quot;&gt;Math:&lt;/a&gt; &lt;a href=&quot;#maxby&quot;&gt;maxBy()&lt;/a&gt;, &lt;a href=&quot;#minby&quot;&gt;minBy()&lt;/a&gt;, &lt;a href=&quot;#round&quot;&gt;round().&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#string&quot;&gt;String:&lt;/a&gt; &lt;a href=&quot;#truncate&quot;&gt;truncate()&lt;/a&gt;, &lt;a href=&quot;#pad&quot;&gt;pad()&lt;/a&gt;, &lt;a href=&quot;#deburr&quot;&gt;deburr()&lt;/a&gt;, &lt;a href=&quot;#escape---unescape&quot;&gt;escape() - unescape()&lt;/a&gt;, &lt;a href=&quot;#capitalize&quot;&gt;capitalize()&lt;/a&gt;, &lt;a href=&quot;#change-letter-casing&quot;&gt;change letter casing&lt;/a&gt;, &lt;a href=&quot;#other-popular-string-methods&quot;&gt;other sting methods.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#util&quot;&gt;Util:&lt;/a&gt; &lt;a href=&quot;#identity-and-iteratee&quot;&gt;identity() - iteratee()&lt;/a&gt;, &lt;a href=&quot;#bindall&quot;&gt;bindAll()&lt;/a&gt;, &lt;a href=&quot;#flow&quot;&gt;flow()&lt;/a&gt;, &lt;a href=&quot;#times&quot;&gt;times()&lt;/a&gt;, &lt;a href=&quot;#range---rangeright&quot;&gt;range()&lt;/a&gt;, &lt;a href=&quot;#other-interesting-methods&quot;&gt;other util methods.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#lang&quot;&gt;Lang:&lt;/a&gt; &lt;a href=&quot;#clone&quot;&gt;clone()&lt;/a&gt;, &lt;a href=&quot;#clonedeep&quot;&gt;cloneDeep()&lt;/a&gt;, &lt;a href=&quot;#isequal&quot;&gt;isEqual()&lt;/a&gt;, &lt;a href=&quot;#isempty&quot;&gt;isEmpty()&lt;/a&gt;, &lt;a href=&quot;#type-checking&quot;&gt;type checking&lt;/a&gt;, &lt;a href=&quot;#other-interesting-type-checking-methods&quot;&gt;other type-checking methods&lt;/a&gt;, &lt;a href=&quot;#type-conversion-methods&quot;&gt;type conversion methods.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#seq&quot;&gt;Seq&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#object&quot;&gt;Object:&lt;/a&gt; &lt;a href=&quot;#get---set&quot;&gt;get() - set()&lt;/a&gt;, &lt;a href=&quot;#has---hasin&quot;&gt;has() - hasIn()&lt;/a&gt;, &lt;a href=&quot;#assign---assignin&quot;&gt;assign() - assignIn()&lt;/a&gt;, &lt;a href=&quot;#merge&quot;&gt;merge()&lt;/a&gt;, &lt;a href=&quot;#defaults---defaultsdeep&quot;&gt;defaults() - defaultsDeep()&lt;/a&gt;, &lt;a href=&quot;#pick---omit&quot;&gt;pick() - omit()&lt;/a&gt;, &lt;a href=&quot;#topairs---frompairs&quot;&gt;toPairs() - fromPairs()&lt;/a&gt;, &lt;a href=&quot;#keys---values&quot;&gt;keys() - values()&lt;/a&gt;, &lt;a href=&quot;#other-object-methods&quot;&gt;other object methods.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#function&quot;&gt;Function:&lt;/a&gt; &lt;a href=&quot;#debounce---throttle&quot;&gt;debounce() - throttle()&lt;/a&gt;, &lt;a href=&quot;#once&quot;&gt;once()&lt;/a&gt;, &lt;a href=&quot;#curry---partial&quot;&gt;curry() - partial()&lt;/a&gt;, &lt;a href=&quot;#bind&quot;&gt;bind()&lt;/a&gt;, &lt;a href=&quot;#other-function-methods&quot;&gt;other function methods.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;array&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#array&quot;&gt;Array&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Methods to chunk, flatten, and perform set operations on arrays.&lt;/p&gt;&lt;h3 id=&quot;chunk&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#chunk&quot;&gt;chunk&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;chunk(array, chunkSize = 1)&lt;/code&gt;: Split an array into equal chunks. &lt;a href=&quot;https://lodash.com/docs/latest#chunk&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.chunk&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.chunk@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;chunk&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [[&amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;], [&amp;quot;c&amp;quot;, &amp;quot;d&amp;quot;]]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;chunk&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [[&amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;c&amp;quot;], [&amp;quot;d&amp;quot;]]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;flatten---flattendeep---flattendepth&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#flatten---flattendeep---flattendepth&quot;&gt;flatten - flattenDeep - flattenDepth&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;flatten(array)&lt;/code&gt;: Flatten a nested array by 1 level. &lt;a href=&quot;https://lodash.com/docs/latest#flatten&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.flatten&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.flatten@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;flattenDeep(array)&lt;/code&gt;: Flatten the array recursively. &lt;a href=&quot;https://lodash.com/docs/latest#flattenDeep&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.flattendeep&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.flattendeep@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;flattenDepth(array, depth = 1)&lt;/code&gt;: Specify the levels. &lt;a href=&quot;https://lodash.com/docs/latest#flattenDepth&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.flattendepth&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.flattendepth@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;nested&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]], &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;nested&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2, [3, [4]], 5]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;flattenDeep&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;nested&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2, 3, 4, 5]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;flattenDepth&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;nested&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2, [3, [4]], 5]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;flattenDepth&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;nested&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2, 3, [4], 5]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;compact&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#compact&quot;&gt;compact&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;compact(array)&lt;/code&gt;: Remove the falsey values. &lt;a href=&quot;https://lodash.com/docs/latest#compact&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.compact&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.compact@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;compact&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;sets&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#sets&quot;&gt;Sets&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;I think it’s easier to understand what each method does in this section by looking at the pictures, rather than reading the descriptions. &lt;a href=&quot;https://en.wikipedia.org/wiki/Set_(mathematics)#Basic_operations&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Set images are from Wikipedia.&lt;/a&gt;&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:763px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/7ea8a36a47360c6c6e48642fe8b91237/b61cb/sets.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:72.70833333333334%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAPABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAIDBAX/xAAWAQEBAQAAAAAAAAAAAAAAAAACAwT/2gAMAwEAAhADEAAAAW0FUaLRAKH/xAAaEAADAQADAAAAAAAAAAAAAAABAgMSAAQR/9oACAEBAAEFAivY3TWD5yIILqxrIFZ//8QAGREAAgMBAAAAAAAAAAAAAAAAAAIBESFB/9oACAEDAQE/AWa25hOTR//EABURAQEAAAAAAAAAAAAAAAAAABAR/9oACAECAQE/AYf/xAAeEAABAwQDAAAAAAAAAAAAAAAAAQIRECExMhIiQf/aAAgBAQAGPwL3J02o7ndZyTs2BEetz//EABsQAQACAwEBAAAAAAAAAAAAAAEAESExQWGR/9oACAEBAAE/IbBv2HEvIjImbk34Om4AY2yhqmXYvqp//9oADAMBAAIAAwAAABDI7//EABgRAQADAQAAAAAAAAAAAAAAAAEAESGh/9oACAEDAQE/EBI4YwiBup//xAAYEQEAAwEAAAAAAAAAAAAAAAABABEhQf/aAAgBAgEBPxAod2Glz//EAB4QAQABBAIDAAAAAAAAAAAAAAERACExQVGhYZHR/9oACAEBAAE/EHkuyAnjvFDKrkxG++qQ1kWGoFK6XgRYOKgoAYobwp7+VkyKC2NE1//Z&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Set methods in lodash&quot; title=&quot;Set methods in lodash&quot; src=&quot;/static/7ea8a36a47360c6c6e48642fe8b91237/b61cb/sets.jpg&quot; srcSet=&quot;/static/7ea8a36a47360c6c6e48642fe8b91237/a5e48/sets.jpg 480w,/static/7ea8a36a47360c6c6e48642fe8b91237/b61cb/sets.jpg 763w&quot; sizes=&quot;(max-width: 763px) 100vw, 763px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Set methods in lodash&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;h4 id=&quot;union&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#union&quot;&gt;union&lt;/a&gt;&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;union(arrays)&lt;/code&gt;: Create an array that holds all the unique values from both arrays. &lt;a href=&quot;https://lodash.com/docs/latest#union&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.union&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.union@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;unionBy(arrays, iteratee = identity)&lt;/code&gt;: It’s like &lt;code&gt;union&lt;/code&gt;, but you can specify the unique criterion. &lt;a href=&quot;https://lodash.com/docs/latest#unionBy&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.unionby&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.unionby@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;union&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [2, 1, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;unionBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([{ x: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }], [{ x: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }, { x: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }], &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [{ x: 1 }, { x: 2 }]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&quot;intersection&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#intersection&quot;&gt;intersection&lt;/a&gt;&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;intersection(arrays)&lt;/code&gt;: Create an array that holds only the unique values that exist in both arrays. &lt;a href=&quot;https://lodash.com/docs/latest#intersection&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.intersection&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.intersection@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;intersectionBy(arrays, iteratee = identity)&lt;/code&gt;: It’s like &lt;code&gt;intersection&lt;/code&gt;, but you can specify the unique criterion. &lt;a href=&quot;https://lodash.com/docs/latest#intersectionBy&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.intersectionby&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.intersectionby@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;intersection&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [2]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;intersectionBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([{ x: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }], [{ x: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }, { x: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }], &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [{ x: 1 }]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&quot;difference&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#difference&quot;&gt;difference&lt;/a&gt;&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;difference(arrays)&lt;/code&gt;: Create an array that holds the unique values that exist in the first array but not in the second. &lt;a href=&quot;https://lodash.com/docs/latest#difference&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.difference&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.difference@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;differenceBy(arrays, iteratee = identity)&lt;/code&gt;: It’s like &lt;code&gt;difference&lt;/code&gt;, but you can specify the unique criterion. &lt;a href=&quot;https://lodash.com/docs/latest#differenceBy&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.differenceby&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.differenceby@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;difference&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;differenceBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([{ x: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }, { x: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }], [{ x: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }], &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [{ x: 2 }]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See also &lt;a href=&quot;https://lodash.com/docs/latest#without&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;without&lt;/a&gt; if you prefer to pass values instead of a second array.&lt;/p&gt;&lt;h4 id=&quot;xor&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#xor&quot;&gt;xor&lt;/a&gt;&lt;/h4&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;xor(arrays)&lt;/code&gt;: Create an array that holds the unique values from both arrays but not those that exist in both. &lt;a href=&quot;https://lodash.com/docs/latest#xor&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.xor&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.xor@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;xorBy(arrays, iteratee = identity)&lt;/code&gt;: It’s like &lt;code&gt;xor&lt;/code&gt;, but you can specify the unique criterion. &lt;a href=&quot;https://lodash.com/docs/latest#xorBy&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.xorby&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.xorby@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;xor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;xorBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([{ x: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }], [{ x: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }, { x: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }], &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [{ x: 2 }]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;zip&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#zip&quot;&gt;zip&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;zip(arrays)&lt;/code&gt;: Group arrays, see the example. &lt;a href=&quot;https://lodash.com/docs/latest#zip&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.zip&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.zip@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], [&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [[&amp;quot;a&amp;quot;, 1, true], [&amp;quot;b&amp;quot;, 2, false]]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// edge cases:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [[&amp;quot;a&amp;quot;, 1], [&amp;quot;b&amp;quot;, 2], [undefined, 3]], different length.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [[&amp;quot;a&amp;quot;], [&amp;quot;b&amp;quot;]], single array.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;collection&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#collection&quot;&gt;Collection&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You can use these methods for array-like objects and regular objects.&lt;/p&gt;&lt;h3 id=&quot;example-users-array&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#example-users-array&quot;&gt;Example users array&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;I will reference this array in some examples.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;barney&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, age: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;36&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, active: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fred&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, age: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, active: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;pebbles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, age: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, active: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;countby&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#countby&quot;&gt;countBy&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;countBy(collection, iteratee = identity)&lt;/code&gt;: Count the different values. &lt;a href=&quot;https://lodash.com/docs/latest#countBy&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.countby&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.countby@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;countBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { &amp;quot;1&amp;quot;: 2, &amp;quot;2&amp;quot;: 1 }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;countBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;6.1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4.2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;6.3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;floor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { &amp;quot;4&amp;quot;: 1, &amp;quot;6&amp;quot;: 2 }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;countBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;two&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;three&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { &amp;quot;3&amp;quot;: 2, &amp;quot;5&amp;quot;: 1 }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// 2 items with length 3, 1 item with length 5.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;countBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { false: 2, true: 1 }, by an object property.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;groupby&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#groupby&quot;&gt;groupBy&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;groupBy(collection, iteratee = identity)&lt;/code&gt;: Group the different values. &lt;a href=&quot;#example-users-array&quot;&gt;Example users array&lt;/a&gt; - &lt;a href=&quot;https://lodash.com/docs/latest#groupBy&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.groupby&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.groupby@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;groupBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;6.1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4.2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;6.3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;floor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { &amp;quot;4&amp;quot;: [4.2], &amp;quot;6&amp;quot;: [6.1, 6.3] }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;groupBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;two&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;three&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { &amp;quot;3&amp;quot;: [&amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;], &amp;quot;5&amp;quot;: [&amp;quot;three&amp;quot;] }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;groupBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { &amp;quot;false&amp;quot;: [barney, pebbles], &amp;quot;true&amp;quot;: [fred] }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;orderby&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#orderby&quot;&gt;orderBy&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;orderBy(collection, iteratees = identity, [order])&lt;/code&gt;: Sort the collection by a property. It’s like &lt;a href=&quot;https://lodash.com/docs/latest#sortBy&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;sortBy&lt;/a&gt;, but you can also set the order (asc/desc). &lt;a href=&quot;#example-users-array&quot;&gt;Example users array&lt;/a&gt; - &lt;a href=&quot;https://lodash.com/docs/latest#orderBy&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.orderby&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.orderby@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;orderBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;desc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [fred (40), barney (36)], pebbles (1)]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;orderBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;asc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;desc&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// by name and then (if equal) by age.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// [barney(&amp;quot;b&amp;quot;,36), fred(&amp;quot;f&amp;quot;,40), pebbles(&amp;quot;p&amp;quot;,1)]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;partition&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#partition&quot;&gt;partition&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;partition(collection, predicate = identity)&lt;/code&gt;: Split the collection into two groups. &lt;a href=&quot;#example-users-array&quot;&gt;Example users array&lt;/a&gt; - &lt;a href=&quot;https://lodash.com/docs/latest#partition&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.partition&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.partition@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;partition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [[fred(true)], [barney(false), pebbles(false)]], func.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;partition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, { age: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, active: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [[pebbles], [barney, fred]], object.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;partition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [[barney, pebbles], [fred]], array.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;partition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [[fred], [barney, pebbles]], string.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;popular-methods-with-es6-alternatives&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#popular-methods-with-es6-alternatives&quot;&gt;Popular methods with &lt;abbr title=&quot;ECMAScript 6&quot;&gt;ES6&lt;/abbr&gt; alternatives&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;These methods are useful if you &lt;a href=&quot;https://www.youtube.com/watch?v=EyuuKn19gKQ&amp;amp;t=580s&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;want to support Internet Explorer&lt;/a&gt;—instead of relying on polyfills and native methods—or if you want to use the &lt;a href=&quot;http://shzhangji.com/blog/2017/03/13/why-use-lodash-when-es6-is-available/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;iteratee shorthand&lt;/a&gt;. It has been also reported in the past that they are more performant than the native methods, but I can’t find a definitive resource for that.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;includes(collection, value, fromIndex = 0)&lt;/code&gt; &lt;a href=&quot;https://lodash.com/docs/latest#includes&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.includes&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.includes@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;each/foreach(collection, iteratee = identity)&lt;/code&gt; &lt;a href=&quot;https://lodash.com/docs/latest#forEach&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.foreach&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.foreach@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;map(collection, iteratee = identity)&lt;/code&gt; &lt;a href=&quot;https://lodash.com/docs/latest#map&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.map&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.map@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;filter(collection, predicate= identity)&lt;/code&gt; &lt;a href=&quot;https://lodash.com/docs/latest#filter&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.filter&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.filter@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;find(collection, predicate = identity, fromIndex = 0)&lt;/code&gt; &lt;a href=&quot;https://lodash.com/docs/latest#find&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.find&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.find@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;reduce(collection, iteratee = identity, accumulator)&lt;/code&gt; &lt;a href=&quot;https://lodash.com/docs/latest#reduce&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.reduce&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.reduce@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;a href=&quot;#example-users-array&quot;&gt;Example users array&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 1 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 2 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Logs 1 then 2.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 3 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [8, 16]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 3 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;barney&amp;quot;, &amp;quot;fred&amp;quot;, &amp;quot;pebbles&amp;quot;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 4 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, { age: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;36&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, active: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [barney]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 4 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [barney, pebbles]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 5 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [barney], the first it finds.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 6 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;), &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 6&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;other-collection-methods&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#other-collection-methods&quot;&gt;Other collection methods&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;shuffle(collection)&lt;/code&gt; Shuffle the elements. &lt;a href=&quot;https://lodash.com/docs/latest#shuffle&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.shuffle&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.shuffle@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;sample(collection)&lt;/code&gt; Get a random element. &lt;a href=&quot;https://lodash.com/docs/latest#sample&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.sample&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.sample@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;shuffle&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [4, 1, 3, 2]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 2, get a random element.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;math&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#math&quot;&gt;Math&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;These are three of the most interesting &lt;a href=&quot;https://lodash.com/docs/4.17.15#add&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;lodash math methods.&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;maxby&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#maxby&quot;&gt;maxBy&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;maxBy(array, iteratee = identity)&lt;/code&gt;: Find the max in an array. &lt;a href=&quot;#example-users-array&quot;&gt;Example users array&lt;/a&gt; - &lt;a href=&quot;https://lodash.com/docs/latest#maxBy&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.maxby&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.maxby@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;15&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;maxBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// fred object, function&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;maxBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// fred object, shorthand&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;minby&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#minby&quot;&gt;minBy&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;minBy(array, iteratee = identity)&lt;/code&gt;: Find the min in an array. &lt;a href=&quot;#example-users-array&quot;&gt;Example users array&lt;/a&gt; - &lt;a href=&quot;https://lodash.com/docs/latest#minBy&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.minby&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.minby@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;16&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;minBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// pebbles object, function&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;minBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// pebbles object, shorthand&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;round&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#round&quot;&gt;round&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;round(number, precision = 0)&lt;/code&gt;: It’s like &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Math.round&lt;/a&gt; but with precision. &lt;a href=&quot;https://lodash.com/docs/latest#round&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.round&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.round@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;17&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4.006&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4.006&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 4.01&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4.004&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4060&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 4100, 60 &amp;gt; 50 (middle with 2 precision)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4060&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 4000, 60 &amp;lt; 500 (middle with 3 precision)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;string&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#string&quot;&gt;String&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Methods to truncate, pad, escape characters, and change the casing of a string.&lt;/p&gt;&lt;h3 id=&quot;truncate&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#truncate&quot;&gt;truncate&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Shorten a string to a certain length: &lt;a href=&quot;https://lodash.com/docs/latest#truncate&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.truncate&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.truncate@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;&quot; data-index=&quot;18&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;truncate(string, { length = 30, omission = &amp;quot;...&amp;quot;, [separator] });&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;19&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hi-diddly-ho there, neighborino&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;truncate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;hi-diddly-ho there, neighbo...&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;truncate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, { length: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, separator: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;hi-diddly-ho there,...&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;truncate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, { length: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, separator:&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;hi-diddly-ho there...&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;truncate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, { omission: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; [...]&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;hi-diddly-ho there, neig [...]&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;pad&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#pad&quot;&gt;pad&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;pad(string, length = 0, padCharacters)&lt;/code&gt;: Adds a character before and after the string. See also &lt;a href=&quot;https://lodash.com/docs/latest#padStart&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;padStart&lt;/a&gt; and &lt;a href=&quot;https://lodash.com/docs/latest#padEnd&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;padEnd.&lt;/a&gt; &lt;a href=&quot;https://lodash.com/docs/latest#pad&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.pad&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.pad@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;20&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;pad&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hello&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;  hello   &amp;quot;, 2 spaces at the start, 3 at the end.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;pad&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;mark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;___mark___&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;padStart&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;342&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;.......342&amp;quot;, useful in CLI tools.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;padStart&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;//  &amp;quot;........12&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;deburr&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#deburr&quot;&gt;deburr&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;deburr(string)&lt;/code&gt;: Removes &lt;a href=&quot;https://en.wikipedia.org/wiki/Combining_Diacritical_Marks&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;combining diacritical marks&lt;/a&gt;, and converts &lt;a href=&quot;https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Latin-1 Supplement&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Latin_Extended-A&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Latin Extended-A&lt;/a&gt; letters to basic Latin letters. &lt;a href=&quot;https://lodash.com/docs/latest#deburr&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.deburr&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.deburr@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;21&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;deburr&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;déjà vu&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;deja vu&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;escape---unescape&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#escape---unescape&quot;&gt;escape - unescape&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;escape(string)&lt;/code&gt;: Convert &lt;code&gt;&amp;amp; &amp;lt; &amp;gt; &amp;#x27;&amp;#x27; &amp;#x27;&lt;/code&gt; to &lt;code&gt;&amp;amp;amp; &amp;amp;lt; &amp;amp;gt; &amp;amp;quot; &amp;amp;#39;&lt;/code&gt;. In other words, convert characters to &lt;abbr title=&quot;Hypertext Markup Language&quot;&gt;HTML&lt;/abbr&gt; entities. &lt;a href=&quot;https://lodash.com/docs/latest#escape&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.escape&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.escape@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;unescape(string)&lt;/code&gt;: The opposite of escape, convert &lt;abbr title=&quot;Hypertext Markup Language&quot;&gt;HTML&lt;/abbr&gt; entities to characters. &lt;a href=&quot;https://lodash.com/docs/latest#unescape&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.unescape&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.unescape@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;22&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;escape&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fred, barney, &amp;amp; pebbles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;fred, barney, &amp;amp;amp; pebbles&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;unescape&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fred, barney, &amp;amp;amp; pebbles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;fred, barney, &amp;amp; pebbles&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See also &lt;a href=&quot;https://lodash.com/docs/latest#escapeRegExp&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;escapeRegExp&lt;/a&gt;.&lt;/p&gt;&lt;h3 id=&quot;capitalize&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#capitalize&quot;&gt;capitalize&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;capitalize(string)&lt;/code&gt;: Capitalize a string. &lt;a href=&quot;https://lodash.com/docs/latest#capitalize&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.capitalize&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.capitalize@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;23&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;capitalize&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;mark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Mark&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;capitalize&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;MARK&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Mark&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;capitalize&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;mArK&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Mark&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;change-letter-casing&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#change-letter-casing&quot;&gt;Change letter casing&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;cameCase(string)&lt;/code&gt;: &lt;a href=&quot;https://lodash.com/docs/latest#camelCase&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.camelcase&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.camelcase@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;kebabCase(string)&lt;/code&gt;: &lt;a href=&quot;https://lodash.com/docs/latest#kebabCase&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.kebabcase&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.kebabcase@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;snakeCase(string)&lt;/code&gt;: &lt;a href=&quot;https://lodash.com/docs/latest#snakeCase&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.snakecase&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.snakecase@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;startCase(string)&lt;/code&gt;: &lt;a href=&quot;https://lodash.com/docs/latest#startCase&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.startcase&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.startcase@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;24&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;camelCase&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;--foo-bar--&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;fooBar&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;camelCase&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;__FOO_BAR__&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;fooBar&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;camelCase&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Foo Bar&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;kebabCase&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Foo Bar&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;snakeCase&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Foo Bar&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;startCase&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Foo Bar&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;other-popular-string-methods&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#other-popular-string-methods&quot;&gt;Other popular string methods&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;template&lt;/code&gt;: It’s popular but not really relevant now that we have &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;template literals&lt;/a&gt;. &lt;a href=&quot;https://lodash.com/docs/latest#template&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.template&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.template@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;util&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#util&quot;&gt;Util&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;General functional programming utilities.&lt;/p&gt;&lt;h3 id=&quot;identity-and-iteratee&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#identity-and-iteratee&quot;&gt;identity and iteratee&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;identity(value)&lt;/code&gt;: A helper utility that returns the first value it receives. It’s used as a default value for the &lt;code&gt;iteratee&lt;/code&gt; in many methods. It’s like the &lt;a href=&quot;https://lodash.com/docs/latest#constant&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;constant&lt;/a&gt; method. &lt;a href=&quot;https://lodash.com/docs/latest#identity&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.identity&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.identity@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;iteratee(func = identity)&lt;/code&gt;: Creates a new function. If the &lt;code&gt;func&lt;/code&gt; argument is a &lt;strong&gt;function&lt;/strong&gt;, the new function calls &lt;code&gt;func&lt;/code&gt; with the arguments it receives—doesn’t sound really useful. When &lt;code&gt;func&lt;/code&gt; is a &lt;strong&gt;property name&lt;/strong&gt; (e.g. &lt;code&gt;user.age&lt;/code&gt;), though, the new function returns the value for that property. Finally, if &lt;code&gt;func&lt;/code&gt; is an &lt;strong&gt;array or object&lt;/strong&gt;, it returns true for elements that have those properties, or false otherwise. Consider the examples below. &lt;a href=&quot;https://lodash.com/docs/latest#iteratee&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.iteratee&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.iteratee@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;25&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;barney&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, age: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;36&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, active: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fred&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, age: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, active: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;identity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]; &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;iteratee&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;barney&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; })); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [barney], `matches` shorthand.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;iteratee&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fred&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;])); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [fred], `matchesProperty` shorthand.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;iteratee&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;barney&amp;quot;, &amp;quot;fred&amp;quot;], `property` shorthand.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See also &lt;a href=&quot;https://lodash.com/docs/latest#matches&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;matches&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#matchesProperty&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;matchesProperty&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#property&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;property&lt;/a&gt;, and &lt;a href=&quot;https://lodash.com/docs/latest#method&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;method&lt;/a&gt;.&lt;/p&gt;&lt;h3 id=&quot;bindall&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#bindall&quot;&gt;bindAll&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;bindAll(object, methodNames)&lt;/code&gt;: For the object methods you choose, &lt;code&gt;this&lt;/code&gt; inside them points to the object, no matter &lt;a href=&quot;https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/this-object-prototypes/ch2.md#determining-this&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;how they’re called&lt;/a&gt;. &lt;a href=&quot;https://lodash.com/docs/latest#bindAll&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.bindall&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.bindall@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;26&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  label: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;docs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;click&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: function &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;clicked &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; + &lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;bindAll&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;click&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;click&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;click&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;clicked docs&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;flow&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#flow&quot;&gt;flow&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;flow(funcs)&lt;/code&gt;: Chain functions from left to right. See also &lt;a href=&quot;https://lodash.com/docs/latest#flowRight&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;flowRight.&lt;/a&gt; &lt;a href=&quot;https://lodash.com/docs/latest#flow&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.flow&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.flow@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;27&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; + &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;square&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; * &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;addSquare&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;flow&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;square&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// or flow(add, square) if you prefer.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;addSquare&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// returns 9. Returns 3 after `add` and 9 after `square`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/lodash/lodash/wiki/FP-Guide&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Lodash &lt;abbr title=&quot;Functional Programming&quot;&gt;FP&lt;/abbr&gt;&lt;/a&gt; and currying &lt;a href=&quot;https://simonsmith.io/dipping-a-toe-into-functional-js-with-lodash-fp#how-does-currying-help&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;can make flow even more interesting.&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;times&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#times&quot;&gt;times&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;times(n, iteratee = identity)&lt;/code&gt;: Call the &lt;code&gt;iteratee&lt;/code&gt; &lt;code&gt;n&lt;/code&gt; times—passing the current index each time—and return an array with the results. &lt;a href=&quot;https://lodash.com/docs/latest#times&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.times&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.times@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;28&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;times&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [0, 1, 2]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;times&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;0&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;times&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;constant&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [0, 0, 0, 0]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;range---rangeright&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#range---rangeright&quot;&gt;range - rangeRight&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Create an array where you specify the start, end, and the step. The start number is optional.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;range(start = 0, end, step = 1)&lt;/code&gt;: &lt;a href=&quot;https://lodash.com/docs/latest#range&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.range&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.range@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;rangeRight(start = 0, end, step = 1)&lt;/code&gt;: &lt;a href=&quot;https://lodash.com/docs/latest#rangeRight&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.rangeright&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.rangeright@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;29&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [0, 1, 2, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [0, -1, -2, -3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [0, 5, 10, 15]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 1, 1]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// []&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;rangeRight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [3, 2, 1, 0]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;rangeRight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [-3, -2, -1, 0]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;other-interesting-methods&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#other-interesting-methods&quot;&gt;Other interesting methods&lt;/a&gt;&lt;/h3&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;cond(pairs)&lt;/code&gt; Ιt’s like a &lt;code&gt;switch&lt;/code&gt; statement, but you create it on the fly by composing functions. See also &lt;a href=&quot;#topairs-frompairs&quot;&gt;toPairs&lt;/a&gt;. &lt;a href=&quot;https://lodash.com/docs/latest#cond&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.cond&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.cond@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;conforms(source)&lt;/code&gt; Similar to the object shorthand of the &lt;a href=&quot;#identity-iteratee&quot;&gt;iteratee&lt;/a&gt; but you can specify the operation. &lt;a href=&quot;https://lodash.com/docs/latest#conforms&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.conforms&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.conforms@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;noop()&lt;/code&gt; A method that returns &lt;code&gt;undefined&lt;/code&gt;. Useful when you want to call a method no matter what, without getting an error. See the example. &lt;a href=&quot;https://lodash.com/docs/latest#noop&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.noop&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.noop@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;uniqueId(prefix = &amp;#x27;&amp;#x27;)&lt;/code&gt; Generate a unique ID with an optional prefix. &lt;a href=&quot;https://lodash.com/docs/latest#uniqueId&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.uniqueid&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.uniqueid@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;over(iteratees = identity)&lt;/code&gt; &lt;a href=&quot;https://lodash.com/docs/latest#over&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.over&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.over@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;a href=&quot;#example-users-array&quot;&gt;Example users array&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;30&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cond&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;matches&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }), &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* . */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;constant&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;matches A&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;conforms&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ b: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isNumber&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }), &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;constant&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;matches B&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  [&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;stubTrue&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* .......... */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;constant&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;no match&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;]);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 1 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;matches A&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 1 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;matches B&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 1 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ a: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, b: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;no match&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 2 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;conforms&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; })&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [fred]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 3 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;times&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;noop&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [undefined, undefined]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 3 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;callbackThatMustBeCalled&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;userCallback&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; || &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;noop&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 4 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;uniqueId&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;105&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 4 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;uniqueId&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;contact_&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;contact_104&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 5 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;over&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 5 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [4, 1]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;lang&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#lang&quot;&gt;Lang&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Utilities that simplify cloning objects, type checking, and type conversions.&lt;/p&gt;&lt;h3 id=&quot;clone&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#clone&quot;&gt;clone&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;clone(value)&lt;/code&gt;: Create a shallow copy of a value. &lt;a href=&quot;https://lodash.com/docs/latest#clone&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.clone&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.clone@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;31&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [{ a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }, { b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;shallow&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;clone&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;shallow&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]; &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;clonedeep&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#clonedeep&quot;&gt;cloneDeep&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;cloneDeep(value)&lt;/code&gt;: Create a deep copy of a value. &lt;a href=&quot;https://lodash.com/docs/latest#cloneDeep&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.clonedeep&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.clonedeep@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;32&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [{ a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }, { b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;deep&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cloneDeep&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;deep&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;objects&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]; &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;isequal&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#isequal&quot;&gt;isEqual&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;isEqual(value, other)&lt;/code&gt;: Deep comparison between two values. &lt;a href=&quot;https://lodash.com/docs/latest#isEqual&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.isequal&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.isequal@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;33&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = { a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;other&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = { a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isEqual&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;other&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;other&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;; &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;isempty&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#isempty&quot;&gt;isEmpty&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;isEmpty(value)&lt;/code&gt;: Check if a value is empty. For array-like: length is 0; for objects: no own properties; for maps/sets: size is 0. &lt;a href=&quot;https://lodash.com/docs/latest#isEmpty&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.isempty&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.isempty@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;34&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;type-checking&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#type-checking&quot;&gt;Type-checking&lt;/a&gt;&lt;/h3&gt;&lt;h4 id=&quot;isnumber&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#isnumber&quot;&gt;isNumber&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;&lt;code&gt;isNumber(value)&lt;/code&gt;: Check if the value is a &lt;code&gt;Number&lt;/code&gt; primitive or object. &lt;a href=&quot;https://lodash.com/docs/latest#isNumber&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.isnumber&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.isnumber@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;35&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isNumber&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isNumber&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;MIN_VALUE); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isNumber&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Infinity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isNumber&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&quot;isinteger&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#isinteger&quot;&gt;isInteger&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;&lt;code&gt;isInteger(value)&lt;/code&gt;: &lt;a href=&quot;https://lodash.com/docs/latest#isInteger&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.isinteger&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.isinteger@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;36&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isInteger&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isInteger&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;MIN_VALUE); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isInteger&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Infinity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isInteger&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isInteger&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3.2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&quot;isplainobject&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#isplainobject&quot;&gt;isPlainObject&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;&lt;code&gt;isPlainObject(value)&lt;/code&gt;: Checks if value is a plain object, that is, an object created by the &lt;code&gt;Object&lt;/code&gt; constructor or one with a &lt;code&gt;[[Prototype]]&lt;/code&gt; of &lt;code&gt;null&lt;/code&gt;. &lt;a href=&quot;https://lodash.com/docs/latest#isPlainObject&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.isplainobject&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.isplainobject@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;37&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isPlainObject&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isPlainObject&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isPlainObject&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ x: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, y: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isPlainObject&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id=&quot;ismatch&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#ismatch&quot;&gt;isMatch&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;&lt;code&gt;isMatch(object, source)&lt;/code&gt;: See if the object has a property with that value. If you partially apply the source, it’s the same as &lt;a href=&quot;https://lodash.com/docs/latest#matches&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;matches&lt;/a&gt;. &lt;a href=&quot;https://lodash.com/docs/latest#isMatch&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.ismatch&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.ismatch@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;38&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = { a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isMatch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, { b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;isMatch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, { b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;other-interesting-type-checking-methods&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#other-interesting-type-checking-methods&quot;&gt;Other interesting type-checking methods&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://lodash.com/docs/latest#isArray&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isArray&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isArrayLike&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isArrayLike&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isBoolean&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isBoolean&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isDate&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isDate&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isElement&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isElement&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isError&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isError&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isFinite&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isFinite&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isFunction&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isFunction&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isNative&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isNative&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isObject&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isObject&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isObjectLike&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isObjectLike&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isRegExp&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isRegExp&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isSafeInteger&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isSafeInteger&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isString&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isString&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#isTypedArray&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isTypedArray&lt;/a&gt;, and &lt;a href=&quot;https://lodash.com/docs/latest#isUndefined&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;isUndefined&lt;/a&gt;.&lt;/p&gt;&lt;h3 id=&quot;type-conversion-methods&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#type-conversion-methods&quot;&gt;Type conversion methods&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;a href=&quot;https://lodash.com/docs/latest#toArray&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;toArray&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#toFinite&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;toFinite&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#toInteger&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;toInteger&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#toLength&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;toLength&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#toNumber&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;toNumber&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#toPlainObject&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;toPlainObject&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#toSafeInteger&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;toSafeInteger&lt;/a&gt;, and &lt;a href=&quot;https://lodash.com/docs/latest#toString&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;toString&lt;/a&gt;.&lt;/p&gt;&lt;h2 id=&quot;seq&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#seq&quot;&gt;Seq&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Chain lodash methods with the &lt;a href=&quot;https://lodash.com/docs/4.17.15#lodash&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Sequence methods&lt;/a&gt;. An alternative is the &lt;a href=&quot;#flow&quot;&gt;flow&lt;/a&gt; method.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;#example-users-array&quot;&gt;Example users array&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;39&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;youngest&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;chain&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// start the chain by passing a value.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;sortBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; `&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; is &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;() &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// get the first element from the array.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;pebbles is 1&amp;quot;, get the value.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See also &lt;a href=&quot;https://lodash.com/docs/latest#tap&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;tap&lt;/a&gt;, &lt;a href=&quot;https://lodash.com/docs/latest#thru&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;thru&lt;/a&gt;. They both intercept the chain and can modify the value, but &lt;code&gt;thru&lt;/code&gt; returns the value.&lt;/p&gt;&lt;h2 id=&quot;object&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#object&quot;&gt;Object&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Methods that simplify object creation, validation, getting/setting properties, and more.&lt;/p&gt;&lt;h3 id=&quot;get---set&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get---set&quot;&gt;get - set&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;get(object, property, [defaultValue])&lt;/code&gt;: Get the object property, without throwing reference errors if it doesn’t exist. &lt;a href=&quot;https://lodash.com/docs/latest#get&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.get&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.get@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;set(object, property, value)&lt;/code&gt;: Set an object property. &lt;a href=&quot;https://lodash.com/docs/latest#set&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.set&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.set@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;40&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = { a:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [{ b: { c: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; } }]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a[0].b.c&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a.b.c&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;#x27;default&amp;#x27;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a[0].b.c&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { a: [{ b: { c: 4 } }] }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;z&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { a: [{ b: { c: 4 } }], x: [{ y: { z: 5 } }] }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See also &lt;a href=&quot;https://lodash.com/docs/latest#unset&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;unset&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;has---hasin&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#has---hasin&quot;&gt;has - hasIn&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;has(object, property)&lt;/code&gt;: Check if the object &lt;strong&gt;directly&lt;/strong&gt; has the property, excluding inherited methods. &lt;a href=&quot;https://lodash.com/docs/latest#has&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.has&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.has@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;hasIn(object, property)&lt;/code&gt;: Check if the object has the property, &lt;strong&gt;directly&lt;/strong&gt; or by &lt;strong&gt;inheritance&lt;/strong&gt;. &lt;a href=&quot;https://lodash.com/docs/latest#hasIn&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.hasin&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.hasin@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;41&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = { a: { b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;other&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ a: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// inheritance&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;has&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;has&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a.b&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;has&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;has&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;other&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false, a is not a direct property of other.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;hasIn&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;other&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;assign---assignin&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#assign---assignin&quot;&gt;assign - assignIn&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;assign(object, otherObjects)&lt;/code&gt;: Assign the own properties of the &lt;code&gt;otherObjects&lt;/code&gt; to the &lt;code&gt;object&lt;/code&gt;. &lt;a href=&quot;https://lodash.com/docs/latest#assign&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.assign&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.assign@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;assignIn(object, otherObjects)&lt;/code&gt;: Assign the own and inherited properties of the &lt;code&gt;otherObjects&lt;/code&gt; to the &lt;code&gt;object&lt;/code&gt;. &lt;a href=&quot;https://lodash.com/docs/latest#assignIn&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.assignin&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.assignin@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;42&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Bar&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;Bar&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;assign&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(), &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Bar&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { a: 1, c: 3 }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;assignIn&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(), &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Bar&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { a: 1, b: 2, c: 3, d: 4 }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;merge&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#merge&quot;&gt;merge&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;merge(object, otherObjects)&lt;/code&gt;: It’s like &lt;code&gt;assignIn&lt;/code&gt; but can merge nested object properties too. See also &lt;a href=&quot;https://lodash.com/docs/latest#mergeWith&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;mergeWith.&lt;/a&gt; &lt;a href=&quot;https://lodash.com/docs/latest#merge&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.merge&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.merge@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;43&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = { a:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [{ b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }, { d: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;otherr&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = { a:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [{ c: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }, { e: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;merge&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;otherr&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;//    { a: [{ b: 2, c: 3 }, { d: 4, e: 5 }] }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;assignIn&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;otherr&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { a: [{ c: 3 }, { e: 5 }] }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;assign&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;otherr&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;//   { a: [{ c: 3 }, { e: 5 }] }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;defaults---defaultsdeep&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#defaults---defaultsdeep&quot;&gt;defaults - defaultsDeep&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;defaults(object, defaultProperties)&lt;/code&gt;: If the object doesn’t already have the default properties, add them. &lt;a href=&quot;https://lodash.com/docs/latest#defaults&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.defaults&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.defaults@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;defaultsDeep(object, defaultProperties)&lt;/code&gt;: Same as &lt;code&gt;defaults&lt;/code&gt; but recursively for nested properties too. &lt;a href=&quot;https://lodash.com/docs/latest#defaultsDeep&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.defaultsdeep&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.defaultsdeep@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;44&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;defaults&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }, { b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }, { a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { a: 1, b: 2 }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;defaultsDeep&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ a: { b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; } }, { a: { b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, c: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; } }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { a: { b: 2, c: 3 } }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;pick---omit&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#pick---omit&quot;&gt;pick - omit&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;pick(object, properties)&lt;/code&gt;: Create an object and choose the properties you want. &lt;a href=&quot;https://lodash.com/docs/latest#pick&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.pick&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.pick@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;omit(object, properties)&lt;/code&gt;: Create an object and choose what properties you don’t want. (It’s slower than &lt;code&gt;pick&lt;/code&gt;) &lt;a href=&quot;https://lodash.com/docs/latest#omit&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.omit&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.omit@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;45&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = { a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, b: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, c: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;pick&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { a: 1, c: 3 }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;omit&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { b: &amp;quot;2&amp;quot; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;topairs---frompairs&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#topairs---frompairs&quot;&gt;toPairs - fromPairs&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;toPairs(object)&lt;/code&gt;: Put the object’s own key-value pairs in an array. Each entry (pair) is also an array. &lt;a href=&quot;https://lodash.com/docs/latest#toPairs&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.topairs&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.topairs@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;fromPairs(pairs)&lt;/code&gt;: The opposite from &lt;code&gt;toPairs&lt;/code&gt; (this is an Array method by the way). &lt;a href=&quot;https://lodash.com/docs/latest#fromPairs&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.frompairs&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.frompairs@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;46&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;toPairs&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [[&amp;quot;a&amp;quot;, 1], [&amp;quot;b&amp;quot;, 2]]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;fromPairs&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { a: 1, b: 2 }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;keys---values&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#keys---values&quot;&gt;keys - values&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;keys(object)&lt;/code&gt;: Create an array with the object’s own keys. For inherited properties see &lt;a href=&quot;https://lodash.com/docs/latest#keysIn&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;keysIn.&lt;/a&gt; &lt;a href=&quot;https://lodash.com/docs/latest#keys&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.keys&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.keys@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;values(object)&lt;/code&gt;: Create an array with the object’s own values. For inherited values see &lt;a href=&quot;https://lodash.com/docs/latest#valuesIn&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;valuesIn.&lt;/a&gt; &lt;a href=&quot;https://lodash.com/docs/latest#values&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.values&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.values@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;47&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;prototype&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;keys&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;keys&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hi&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;0&amp;quot;, &amp;quot;1&amp;quot;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;keysIn&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;c&amp;quot;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hi&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;h&amp;quot;, &amp;quot;i&amp;quot;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;valuesIn&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Foo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;//  [1, 2, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;other-object-methods&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#other-object-methods&quot;&gt;Other object methods&lt;/a&gt;&lt;/h3&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;create(prototype, optionalProperties)&lt;/code&gt; Create an object that inherits from (is linked to) the prototype object (first parameter). &lt;a href=&quot;https://lodash.com/docs/latest#create&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.create&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.create@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;invert(object)&lt;/code&gt; Invert the object’s key-value pairs. &lt;a href=&quot;https://lodash.com/docs/latest#invert&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.invert&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.invert@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;invoke(object, property, [args])&lt;/code&gt; Invoke an object’s method. You can also pass arguments. &lt;a href=&quot;https://lodash.com/docs/latest#invoke&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.invoke&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.invoke@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;mapValues(object, iteratee = identity)&lt;/code&gt; &lt;a href=&quot;https://lodash.com/docs/latest#mapValues&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.mapvalues&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.mapvalues@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;transform&lt;/code&gt; Similar to &lt;code&gt;reduce&lt;/code&gt; but you can stop the iteration by returning &lt;code&gt;false&lt;/code&gt;. &lt;a href=&quot;https://lodash.com/docs/latest#transform&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.transform&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.transform@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;a href=&quot;#example-users-array&quot;&gt;Example users array&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;48&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 2 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = { a: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, b: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, c: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 2 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;invert&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { 1: &amp;quot;c&amp;quot;, 2: &amp;quot;b&amp;quot; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 3 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = { a:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [{ b: { c: [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] } }]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 3 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;invoke&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;a[0].b.c.slice&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [2, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 4 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;mapValues&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;users&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;age&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// { &amp;#x27;0&amp;#x27;: 36, &amp;#x27;1&amp;#x27;: 40, &amp;#x27;2&amp;#x27;: 1 }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 5 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;*=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  []&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;//  [4, 9]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;function&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#function&quot;&gt;Function&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Methods that &lt;strong&gt;moderate&lt;/strong&gt; the execution of functions and some that help with functional programming like &lt;strong&gt;currying/partial application.&lt;/strong&gt;&lt;/p&gt;&lt;h3 id=&quot;debounce---throttle&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#debounce---throttle&quot;&gt;debounce - throttle&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;debounce(func, wait = 0, options={ leading = false, trailing = true })&lt;/code&gt;: &lt;strong&gt;Groups&lt;/strong&gt; the &lt;code&gt;func&lt;/code&gt; calls if they happen in less than &lt;code&gt;wait&lt;/code&gt; ms &lt;a href=&quot;https://css-tricks.com/debouncing-throttling-explained-examples/#article-header-id-4&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;(imagine the calls as a sudden burst of events).&lt;/a&gt; By “group” I mean it &lt;strong&gt;doesn’t allow&lt;/strong&gt; the &lt;code&gt;func&lt;/code&gt; to &lt;strong&gt;execute&lt;/strong&gt;. &lt;a href=&quot;https://lodash.com/docs/latest#debounce&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.debounce&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.debounce@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;throttle(func, wait = 0, options={ leading = true, trailing = true })&lt;/code&gt;: Calls the &lt;code&gt;func&lt;/code&gt; &lt;strong&gt;at most&lt;/strong&gt; every &lt;code&gt;wait&lt;/code&gt; ms. Unlike &lt;code&gt;debounce&lt;/code&gt;, &lt;code&gt;throttle&lt;/code&gt; guarantees the execution of the &lt;code&gt;func&lt;/code&gt; at least every &lt;code&gt;wait&lt;/code&gt; ms. &lt;a href=&quot;https://lodash.com/docs/latest#throttle&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.throttle&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.throttle@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;True for both of them: If leading and trailing options are &lt;code&gt;true&lt;/code&gt;, &lt;code&gt;func&lt;/code&gt; is called on the trailing edge of the timeout only if the function is called &lt;strong&gt;more than once&lt;/strong&gt; during the &lt;code&gt;wait&lt;/code&gt; timeout.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;49&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;scrollHandler&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Scrolling and rolling&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;debounced&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;debounce&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;scrollHandler&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;600&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;throttled&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;throttle&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;scrollHandler&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;600&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;scroll&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;scrollHandler&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// regular&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// document.addEventListener(&amp;quot;scroll&amp;quot;, debounced); // debounce&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// document.addEventListener(&amp;quot;scroll&amp;quot;, throttled); // throttle&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;once&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#once&quot;&gt;once&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;once(func)&lt;/code&gt;: Create a function that can be called only once. &lt;a href=&quot;https://lodash.com/docs/latest#once&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.once&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.once@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;50&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;initialize&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;once&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;createApplication&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;initialize&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// `createApplication` is invoked&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;initialize&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// // `createApplication` is not invoked&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;curry---partial&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#curry---partial&quot;&gt;curry - partial&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;A blog post that explains the differences between them: &lt;a href=&quot;https://2ality.com/2011/09/currying-vs-part-eval.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Currying versus partial application (with JavaScript code)&lt;/a&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;curry(func, arity = func.length)&lt;/code&gt;: &lt;a href=&quot;https://lodash.com/docs/latest#curry&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.curry&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.curry@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;partial(func, parameters)&lt;/code&gt;: &lt;a href=&quot;https://lodash.com/docs/latest#partial&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.partial&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.partial@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;51&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;regularFunction&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;curried&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;curry&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;regularFunction&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;curried&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;curried&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;curried&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;partiallyApplied&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;partial&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;regularFunction&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;partiallyApplied&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;bind&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#bind&quot;&gt;bind&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;bind(func, this, optionalArgs)&lt;/code&gt;: Create a function with your preferred &lt;code&gt;this&lt;/code&gt; binding, and optionally pass (or apply) arguments to that function. The difference with &lt;code&gt;Function.prototype.bind&lt;/code&gt; is that it doesn’t set the &lt;code&gt;length&lt;/code&gt; property. &lt;a href=&quot;https://lodash.com/docs/latest#bind&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.bind&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.bind@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;52&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;greet&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;greeting&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;punctuation&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;greeting&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;punctuation&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fred&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;bound&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;greet&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hi&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;bound&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;hi fred!&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;other-function-methods&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#other-function-methods&quot;&gt;Other function methods&lt;/a&gt;&lt;/h3&gt;&lt;ol&gt;&lt;li&gt;&lt;code&gt;memoize(func, [resolver])&lt;/code&gt; Cache the result of a function. &lt;a href=&quot;https://lodash.com/docs/latest#memoize&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.memoize&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.memoize@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;unary(func)&lt;/code&gt; Creates a function that accepts only one argument. &lt;a href=&quot;https://lodash.com/docs/latest#unary&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.unary&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.unary@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;wrap(value, wrapper = identity)&lt;/code&gt; Wrap a function within another function (kind of). &lt;a href=&quot;https://lodash.com/docs/latest#wrap&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.wrap&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.wrap@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;after(n, func)&lt;/code&gt; Creates a function that invokes &lt;code&gt;func&lt;/code&gt; only after the function has been called &lt;code&gt;n&lt;/code&gt; times. &lt;a href=&quot;https://lodash.com/docs/latest#after&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.after&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.after@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;before(n, func)&lt;/code&gt; Creates a function that can be called at most &lt;code&gt;n - 1&lt;/code&gt; times. &lt;a href=&quot;https://lodash.com/docs/latest#before&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Docs&lt;/a&gt; - &lt;a href=&quot;https://www.npmjs.com/package/lodash.before&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;weekly downloads&lt;/a&gt; - &lt;a href=&quot;https://bundlephobia.com/result?p=lodash.before@latest&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;size&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;53&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 2 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;unary&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [6, 8, 10], what you&amp;#x27;d expect&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 2 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;parseInt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [6, NaN, 2], wrong because parseInt(string, radix)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 3 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;wrap&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;escape&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;&amp;lt;p&amp;gt; + &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; + &amp;lt;/p&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 3 */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fred, barney, &amp;amp; pebbles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;&amp;lt;p&amp;gt;fred, barney, &amp;amp;amp; pebbles&amp;lt;/p&amp;gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* 4 and 5*/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;saves&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;profile&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;settings&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;logTheFirst2&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;before&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;saves&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, function &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Logging the save.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;completionMessage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;after&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;saves&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, function &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Done saving!&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;saves&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Doing other things.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;logTheFirst2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;completionMessage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Doing other things. (1)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Logging the save.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Doing other things. (2)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Logging the save.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Doing other things. (3)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Done saving!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;* If you like the format, I have similar posts for the &lt;a href=&quot;/array-prototype-methods/&quot;&gt;Array.prototype&lt;/a&gt; and the &lt;a href=&quot;/javascript-string-methods/&quot;&gt;String.prototype.&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://lodash.com/docs/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Lodash documentation&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/lodash/lodash/wiki/FP-Guide&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Lodash &lt;abbr title=&quot;Functional Programming&quot;&gt;FP&lt;/abbr&gt; Guide&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://simonsmith.io/dipping-a-toe-into-functional-js-with-lodash-fp&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Dipping a toe into functional &lt;abbr title=&quot;JavaScript&quot;&gt;JS&lt;/abbr&gt; with lodash/fp&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/lodash/lodash/wiki/Resources&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Collection of posts in Lodash Github page&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/lodash/lodash/wiki/Roadmap&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Lodash Roadmap&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://lodash.com/custom-builds&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Use lodash-cli to create custom builds&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Lodash&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Lodash Wikipedia&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=EyuuKn19gKQ&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Dechat.tv: Lo-Dash with John-David Dalton&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://shzhangji.com/blog/2017/03/13/why-use-lodash-when-es6-is-available/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Lodash vs &lt;abbr title=&quot;ECMAScript 6&quot;&gt;ES6&lt;/abbr&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtki { font-style: italic; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk28 { color: #5CA7E4; }
  .night-owl-no-italics .mtk43 { color: #41EEC6; }
  .night-owl-no-italics .mtk12 { color: #FFCB8B; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[JavaScript string methods]]></title><description><![CDATA[See the most useful JavaScript string methods, what they do, and examples on how to use them. All that, in the least possible space.]]></description><link>https://markoskon.com/javascript-string-methods/</link><guid isPermaLink="false">https://markoskon.com/javascript-string-methods/</guid><pubDate>Tue, 08 Oct 2019 19:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In this post, you will find useful string methods and examples on how to use them. All strings, whether they are in &lt;em&gt;object form&lt;/em&gt; or &lt;em&gt;literals&lt;/em&gt;, inherit from the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/prototype&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype&lt;/code&gt;&lt;/a&gt; object which is where all the string methods come from. This post tries to list as many useful string methods as possible, in the least possible space. It’s not meant to be an extensive reference.&lt;/p&gt;&lt;p&gt;Keep in mind that none of the string methods mutates the original string; they return a new string. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Glossary/Mutable&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Strings in JavaScript are immutable.&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;slice&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#slice&quot;&gt;slice&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;str.slice(startIndex, endIndex = str.length)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Returns a portion of the string from start to end index (end not included).
&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.slice()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;world&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;Hello&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// for negative indices it counts from the end of the string.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;world&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;Hello&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;split&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#split&quot;&gt;split&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;str.split(splitPattern, limit = all)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Split the string into an array. The characters that match the split pattern are thrown away.
&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.split()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;Hello&amp;quot;, &amp;quot;world&amp;quot;], words.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;H&amp;quot;, &amp;quot;e&amp;quot;, &amp;quot;l&amp;quot;, &amp;quot;l&amp;quot;, &amp;quot;o&amp;quot;, &amp;quot; &amp;quot;, ..., &amp;quot;d&amp;quot;], characters.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;Hello world&amp;quot;], as is.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;Hell&amp;quot;, &amp;quot; w&amp;quot;, &amp;quot;rld&amp;quot;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;O&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;Hell&amp;quot;, &amp;quot; w&amp;quot;, &amp;quot;rld&amp;quot;], you can use regex.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;H&amp;quot;, &amp;quot;e&amp;quot;, &amp;quot;l&amp;quot;, &amp;quot;l&amp;quot;, &amp;quot;o&amp;quot;], 5 is the new array length.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;indexof&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#indexof&quot;&gt;indexOf&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;str.indexOf(searchString, fromIndex = 0)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Returns the first index if it finds the string, otherwise, it returns &lt;code&gt;-1&lt;/code&gt;. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.indexOf()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;imagine&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;imagine&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// -1, &amp;quot;w&amp;quot; doesn&amp;#x27;t exist in the string.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;imagine&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 4, finds the second &amp;quot;i&amp;quot;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See also &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.lastIndexOf()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;charat&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#charat&quot;&gt;charAt&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;str.charAt(index = 0)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Returns the character at the index. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.charAt()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learn&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;charAt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;r&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learn&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;charAt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;l&amp;quot;, the first character.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learn&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;charAt&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;99&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;&amp;quot;, returns an empty string if the index is out of range.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;includes&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#includes&quot;&gt;includes&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;str.includes(string, fromIndex = 0)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;See if the string contains the given string. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.includes()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learning js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learning js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;JS&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false, it&amp;#x27;s case-sensitive.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learning js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;ea&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;match&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#match&quot;&gt;match&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;str.match(regexp)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;See if the string matches the regular expression. If you use the &lt;em&gt;global flag&lt;/em&gt;, it returns an array with the matching strings. If you don’t use the global flag, the returned array has &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match#Additional_properties&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;some additional properties&lt;/a&gt;. If you use both &lt;em&gt;capture groups&lt;/em&gt; and the global flag, you won’t get back the capture groups. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.match()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Season 8 was bad&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;bad&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// without the global flag, notice the extra properties.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;bad&amp;quot;, index: 13, input: &amp;quot;Season 8 was bad&amp;quot;, groups: undefined]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Season 8 was bad&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// with global flag.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;as&amp;quot;, &amp;quot;as&amp;quot;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Season 8 was bad&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;\w&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;(as)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// capture group, returns 1st match and the groups.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;Seas&amp;quot;, &amp;quot;as&amp;quot;, index: 0, input: &amp;quot;Season 8 was bad&amp;quot;, groups: undefined]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Season 8 was bad&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;\w&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;(as)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// global and capture groups, the global wins.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;Seas&amp;quot;, &amp;quot;was&amp;quot;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Season 8 was bad&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;good&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Season 8 was bad&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;&amp;quot;, index: 0, input: &amp;quot;Season 8 was bad&amp;quot;, groups: undefined]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Season 8 was bad&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.matchAll()&lt;/code&gt;&lt;/a&gt; if you want to use both capture groups and the global flag. Use &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.search()&lt;/code&gt;&lt;/a&gt; if you want less details, for example, to see only if the pattern exists, and to get the index of the first match. There is also the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;RegExp.prototype.test()&lt;/code&gt;&lt;/a&gt; for simple checks and the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;RegExp.prototype.exec()&lt;/code&gt;&lt;/a&gt; which is similar to &lt;code&gt;matchAll&lt;/code&gt;.&lt;/p&gt;&lt;h2 id=&quot;replace&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#replace&quot;&gt;replace&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;str.replace(pattern, replacementStr)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Find the regex in the string and replace it with the replacement string. The pattern can be a regex or a string.
&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.replace()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello there&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;there&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;Hello world&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello there&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hi&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;Hi there&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello there&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;H3llo there&amp;quot;, string pattern = replace the first.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello there&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;H3llo there&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello there&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;H3llo th3r3&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;John Doe&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;\w&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;\s&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;\w&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;$2, $1&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Doe, John, see the notice below.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See also:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;special replacement patterns&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Using a function&lt;/a&gt; instead of a replacement string.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;trim&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#trim&quot;&gt;trim&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;str.trim()&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Removes &lt;em&gt;whitespace characters&lt;/em&gt; from the start and from the end of the string. Whitespace characters are space, tab, line endings, etc. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.trim()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;    Hello world.   &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;Hello world.&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Use &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;trimStart&lt;/code&gt;&lt;/a&gt;/&lt;code&gt;trimLeft&lt;/code&gt; to remove whitespace characters only from the beginning and &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimEnd&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;trimEnd&lt;/code&gt;&lt;/a&gt;/&lt;code&gt;trimRight&lt;/code&gt; to remove only from the end.&lt;/p&gt;&lt;h2 id=&quot;concat&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#concat&quot;&gt;concat&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;str.concat(stringN)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Merge two or more strings into a new string. The &lt;code&gt;+&lt;/code&gt; operator &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat#Performance&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;is more performant&lt;/a&gt;.
&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.concat()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learn&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;ing&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;learning&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learn&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;ing&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;learning js&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learn&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;ng&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;learn1ng&amp;quot;, using numbers.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;tolowercase&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#tolowercase&quot;&gt;toLowerCase&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;str.toLowerCase()&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Returns the string in lowercase. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.toLowerCase()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toLowerCase&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;hello world&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See also &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.toLocaleLowerCase()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;touppercase&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#touppercase&quot;&gt;toUpperCase&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;str.toUpperCase()&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Returns the string in uppercase. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.toUpperCase()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toUpperCase&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;HELLO WORLD&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See also &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.toLocaleUpperCase()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;startswith&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#startswith&quot;&gt;startsWith&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;str.startsWith(searchString, fromIndex = 0)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;See if the string starts with the given string. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.startsWith()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learning js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;startsWith&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learn&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learning js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;startsWith&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learning js!&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;startsWith&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learn&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;endswith&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#endswith&quot;&gt;endsWith&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;str.endsWith(searchString, length = str.length)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;See if the string ends with the given string. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;String.prototype.endsWith()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learning js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;endsWith&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learning js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;endsWith&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;JS&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false, it&amp;#x27;s case-sensitive.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;learning js!&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;endsWith&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true, we ignore the &amp;quot;!&amp;quot; character here.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;the-rest-string-prototype-methods&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#the-rest-string-prototype-methods&quot;&gt;The rest string prototype methods&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;padStart&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;padEnd&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;repeat&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;substring&lt;/code&gt;&lt;/a&gt;, almost identical to slice.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/prototype#HTML_wrapper_methods&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Hypertext Markup Language&quot;&gt;HTML&lt;/abbr&gt; wrapper methods&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk28 { color: #5CA7E4; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Yargs examples]]></title><description><![CDATA[Learn how to use Yargs to parse CLI arguments and create help menus with some practical examples. You can also find explanations for common CLI terms.]]></description><link>https://markoskon.com/yargs-examples/</link><guid isPermaLink="false">https://markoskon.com/yargs-examples/</guid><pubDate>Tue, 01 Oct 2019 17:16:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;a href=&quot;https://www.npmjs.com/package/yargs&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Yargs&lt;/a&gt; is a Node package that parses arguments and generates help menus for your &lt;abbr title=&quot;Command-Line Interface&quot;&gt;CLI&lt;/abbr&gt; tools. In this post, you’ll see how to configure Yargs to accomplish those tasks with examples. But before we see the examples, it will be useful to explain some &lt;abbr title=&quot;Command-Line Interface&quot;&gt;CLI&lt;/abbr&gt; terms first.&lt;/p&gt;&lt;h2 id=&quot;cli-terms&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#cli-terms&quot;&gt;&lt;abbr title=&quot;Command-Line Interface&quot;&gt;CLI&lt;/abbr&gt; Terms&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;#commands-and-options&quot;&gt;Commands and options&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#node-shebang&quot;&gt;Node shebang&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#bin-field-in-packagejson&quot;&gt;bin field in package.json&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#special-characters&quot;&gt;Special characters&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;commands-and-options&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#commands-and-options&quot;&gt;Commands and options&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;abbr title=&quot;Command-Line Interface&quot;&gt;CLI&lt;/abbr&gt; tools accept two types of arguments: &lt;em&gt;commands&lt;/em&gt; and &lt;em&gt;options&lt;/em&gt;.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The commands are arguments that don’t have a hyphen (&lt;code&gt;-&lt;/code&gt;) in front of them. For example, &lt;code&gt;git clone&lt;/code&gt; or &lt;code&gt;git init&lt;/code&gt;; &lt;code&gt;clone&lt;/code&gt; and &lt;code&gt;init&lt;/code&gt; are two different &lt;code&gt;git&lt;/code&gt; commands. Use commands if your program is big and performs a wide range of tasks. If your program performs only a specific task, you don’t need commands.&lt;/li&gt;&lt;li&gt;The options, on the other hand, are prefixed with hyphens. With two hyphens you indicate the full name of the option: e.g.&lt;code&gt;--verbose&lt;/code&gt; and with one the &lt;em&gt;alias&lt;/em&gt;: e.g.&lt;code&gt;-v&lt;/code&gt;. Use options to get input from the user and customize the behavior of the program.&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;node-shebang&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#node-shebang&quot;&gt;Node shebang&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Add this at the top of your file:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#!/usr/bin/env node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I will not attempt to explain &lt;a href=&quot;https://en.wikipedia.org/wiki/Shebang_(Unix)&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;what a shebang is&lt;/a&gt;—I didn’t find a good, non-technical explanation—but, instead, I will tell you what it does. It locates the &lt;code&gt;node&lt;/code&gt; executable and allows you to run the script as a binary in Unix systems. For example, you can run the program with &lt;code&gt;./scipt.js&lt;/code&gt; instead of &lt;code&gt;node script.js&lt;/code&gt;. There’s also an &lt;a href=&quot;https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/shebang.md&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;ESLint rule&lt;/a&gt; for the correct usage of shebang.&lt;/p&gt;&lt;h3 id=&quot;bin-field-in-packagejson&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#bin-field-in-packagejson&quot;&gt;bin field in package.json&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Use &lt;code&gt;package.json&lt;/code&gt;’s &lt;code&gt;bin&lt;/code&gt; field to provide aliases for your scripts. You can then use those aliases to call your scripts after you install your package globally. You can install your package globally by running &lt;code&gt;npm link&lt;/code&gt; or by publishing it. Consider the following &lt;code&gt;package.json&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;package.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;calculate-stuff&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;bin&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;area&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;./area.js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;circle-area&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;./circle-area.js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Install it globally with `npm link`.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Run it with `area --width 10 --height 5` or with `circle-area --radius 5`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;By specifying the bin fields, you can now call the area script with:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;area --width num --height num&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and the circle-area script with:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;circle-area --radius num&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you don’t provide aliases, you have to call the index script with &lt;code&gt;calculate-stuff&lt;/code&gt; and figure out what to do from there.&lt;/p&gt;&lt;h3 id=&quot;special-characters&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#special-characters&quot;&gt;Special characters&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;When working with command-line tools, you may encounter some special characters:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The argument is required: &lt;code&gt;&amp;lt;argument&amp;gt;&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;This argument is optional: &lt;code&gt;[argument]&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Use the pipe operator for name/alias: &lt;code&gt;&amp;lt;name|alias&amp;gt;&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;You indicate an array with an ellipsis &lt;code&gt;[arguments…]&lt;/code&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Resources (kind of):&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Command-line_interface#Command_description_syntax&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Wikipedia &lt;abbr title=&quot;Command-Line Interface&quot;&gt;CLI&lt;/abbr&gt;, Command description syntax&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Opengroup utility argument syntax&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/yargs/yargs/blob/master/docs/advanced.md#positional-arguments&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Yargs positional arguments&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;configure-an-option&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#configure-an-option&quot;&gt;Configure an option&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let’s assume that you want to write a program that gets from the user the width and the height of a rectangle, calculates the area, and prints the result in the console:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;area.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Get the arguments from somewhere.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getArguments&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The area is &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can use Yargs to get the width and height arguments from the user and create a help menu. Calculating the area of a rectangle is a trivial task, but the point is to see how to configure Yargs to parse options and create help menus.&lt;/p&gt;&lt;p&gt;You can start by requiring Yargs. By doing that, you now have access to the arguments.&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;area.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#!/usr/bin/env node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;yargs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you now call the program with:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;node area.js --message=hello&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or, thanks to the shebang, with:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;./area.js --message=hello&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The program will log the following object in the console:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{ _: [], message: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hello&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;$0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;area.js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is already useful but let’s configure it further. You can add the &lt;em&gt;name&lt;/em&gt; of the program the user sees when they open the &lt;em&gt;help menu&lt;/em&gt; with the &lt;code&gt;scriptName&lt;/code&gt; method. A user can see the help menu by calling the program with the &lt;code&gt;--help&lt;/code&gt; option.&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;area.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#!/usr/bin/env node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;yargs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;scriptName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;area&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can teach the user how to use your tool when they request the help menu. To do that, you can display a helpful message with the &lt;code&gt;usage&lt;/code&gt; method. The &lt;code&gt;$0&lt;/code&gt; will be replaced by the script (program) name.&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;area.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#!/usr/bin/env node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;yargs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;scriptName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;area&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;usage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Usage: $0 -w num -h num&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can also show an &lt;em&gt;example&lt;/em&gt; of how to use your tool in the help menu with the &lt;code&gt;example&lt;/code&gt; method. With the first parameter you specify what user has to type in the console, and with the second what the program should print:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;area.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;yargs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;scriptName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;area&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;usage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Usage: $0 -w num -h num&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;example&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;$0 -w 5 -h 6&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Returns the area (30) by multiplying the width with the height.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let’s now start configuring some options. You’ll configure the width (&lt;code&gt;-w&lt;/code&gt;) option with the &lt;code&gt;option&lt;/code&gt; method. This method takes the option name as the first parameter and a configuration object as the second. You can find &lt;a href=&quot;https://github.com/yargs/yargs/blob/HEAD/docs/api.md#optionskey-opt&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;all the valid configuration options in the Yargs &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; page&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;The first thing you can do is to add the &lt;code&gt;--width&lt;/code&gt; as an alias for the &lt;code&gt;-w&lt;/code&gt; option. To do that, you define the &lt;code&gt;alias&lt;/code&gt; property of the configuration object:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;area.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#!/usr/bin/env node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;yargs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;scriptName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;area&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;usage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Usage: $0 -w num -h num&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;example&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;$0 -w 5 -h 6&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Returns the area (30) by multiplying the width with the height.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;option&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    alias: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can show a help menu message for the width option with the &lt;code&gt;describe&lt;/code&gt; property. This message will show up when the user asks for the help menu:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;area.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#!/usr/bin/env node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;yargs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;scriptName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;area&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;usage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Usage: $0 -w num -h num&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;example&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;$0 -w 5 -h 6&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Returns the area (30) by multiplying the width with the height.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;option&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    alias: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    describe: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width of the area.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can make the &lt;code&gt;width&lt;/code&gt; option &lt;em&gt;required&lt;/em&gt; and show an error message when the user forgets to provide it:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;area.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#!/usr/bin/env node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;yargs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;scriptName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;area&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;usage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Usage: $0 -w num -h num&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;example&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;$0 -w 5 -h 6&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Returns the area (30) by multiplying the width with the height.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;option&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    alias: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    describe: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width of the area.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    demandOption: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width is required.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;An alternative is to use a default value with the &lt;code&gt;default&lt;/code&gt; property instead of requiring the option. For example, you can add the number &lt;code&gt;5&lt;/code&gt; as the default value for the width with &lt;code&gt;default: 5&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;You can provide a &lt;code&gt;type&lt;/code&gt; for the option with the &lt;code&gt;type&lt;/code&gt; property:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;area.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;15&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#!/usr/bin/env node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;yargs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;scriptName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;area&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;usage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Usage: $0 -w num -h num&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;example&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;$0 -w 5 -h 6&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Returns the area (30) by multiplying the width with the height.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;option&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    alias: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    describe: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width of the area.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    demandOption: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width is required.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    type: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Instead of using the &lt;code&gt;type&lt;/code&gt; property, you can also use the &lt;code&gt;number&lt;/code&gt; property. For example, you can say that &lt;code&gt;number: true&lt;/code&gt;. Other type options you can choose from are the &lt;code&gt;boolean&lt;/code&gt;, &lt;code&gt;array&lt;/code&gt;, and &lt;code&gt;string&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;Finally, you can say how many numbers you expect after the width option with the &lt;code&gt;nargs&lt;/code&gt; property. In this example, you only want one, so you can express that with: &lt;code&gt;nargs: 1&lt;/code&gt;. If the user calls the program with &lt;code&gt;-w 10 11&lt;/code&gt;, only the first value (&lt;code&gt;10&lt;/code&gt;) will be assigned to the &lt;code&gt;width&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;area.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;16&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#!/usr/bin/env node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;yargs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;scriptName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;area&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;usage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Usage: $0 -w num -h num&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;example&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;$0 -w 5 -h 6&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Returns the area (30) by multiplying the width with the height.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;option&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    alias: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    describe: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width of the area.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    demandOption: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width is required.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    type: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    nargs: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And that’s it for the &lt;code&gt;width&lt;/code&gt; option. You can now do something similar for the &lt;code&gt;height&lt;/code&gt; option:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;area.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;17&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#!/usr/bin/env node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;yargs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;scriptName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;area&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;usage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Usage: $0 -w num -h num&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;example&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;$0 -w 5 -h 6&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Returns the area (30) by multiplying the width with the height.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;option&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    alias: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    describe: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width of the area.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    demandOption: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width is required.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    type: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    nargs: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  })&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;option&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    alias: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    describe: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The height of the area.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    demandOption: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The height is required.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    type: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    nargs: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Instead of using the &lt;code&gt;option&lt;/code&gt; method, you can use the individual methods to configure the options. One of those methods is the &lt;code&gt;describe&lt;/code&gt; method. In the following snippet, I’m using the &lt;code&gt;describe&lt;/code&gt; method to override the message of the &lt;code&gt;--help&lt;/code&gt; and &lt;code&gt;--version&lt;/code&gt; options. More about the individual methods in a bit:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;area.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;18&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#!/usr/bin/env node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;yargs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;scriptName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;area&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;usage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Usage: $0 -w num -h num&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;example&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;$0 -w 5 -h 6&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Returns the area (30) by multiplying the width with the height.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;option&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    alias: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    describe: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width of the area.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    demandOption: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width is required.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    type: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    nargs: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  })&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;option&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    alias: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    describe: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The height of the area.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    demandOption: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The height is required.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    type: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    nargs: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  })&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;help&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Show help.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Show version number.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Finally, you can use the &lt;code&gt;epilog&lt;/code&gt; method to print a message at the end of the help menu. In the following example, I show some copyright information.&lt;/p&gt;&lt;p&gt;If everything goes well, you can get the &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; options and print the result in the console:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;area.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;19&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#!/usr/bin/env node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;yargs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;scriptName&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;area&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;usage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Usage: $0 -w num -h num&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;example&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;$0 -w 5 -h 6&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Returns the area (30) by multiplying the width with the height.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;option&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    alias: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    describe: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width of the area.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    demandOption: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width is required.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    type: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    nargs: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  })&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;option&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    alias: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    describe: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The height of the area.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    demandOption: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The height is required.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    type: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    nargs: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  })&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;help&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Show help.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Override --help usage message.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Show version number.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Override --version usage message.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;epilog&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;copyright 2019&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The area is &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the following snippet, you can see what the program prints in the console if you call it with the &lt;code&gt;--help&lt;/code&gt; option:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;20&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;./area.js --help&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Usage: area -w num -h num&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Options:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#   --help        Show help.                     [boolean]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#   --version     Show version number.           [boolean]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#   -w, --width   The width of the area.         [number] [required]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#   -h, --height  The height of the area.        [number] [required]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Examples:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#   area -w 5 -h 6  Returns the area (30) by multiplying&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#                   the width with the height.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# copyright 2019&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is the output if you call it &lt;em&gt;without&lt;/em&gt; the &lt;code&gt;--width&lt;/code&gt; and &lt;code&gt;--height&lt;/code&gt; arguments:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;21&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;node area.js&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Usage: area -w num -h num&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Options:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#   --help        Show help.                     [boolean]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#   --version     Show version number.           [boolean]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#   -w, --width   The width of the area.         [number] [required]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#   -h, --height  The height of the area.        [number] [required]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Examples:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#   area -w 5 -h 6  Returns the area (30) by multiplying&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#                   the width with the height.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# copyright 2019&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;use-the-individual-methods&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#use-the-individual-methods&quot;&gt;Use the individual methods&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Instead of using the &lt;code&gt;option&lt;/code&gt; method, you can use the individual methods. For example, the configuration for the &lt;code&gt;--width&lt;/code&gt; option can be written as shown below:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;22&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#!/usr/bin/env node&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// area.js&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;var { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;yargs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// ...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;alias&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width of the area.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;demandOption&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The width is required.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// .default(&amp;quot;w&amp;quot;, 5)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;nargs&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;alias&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The height of the area.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;demandOption&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;The height is required.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// .default(&amp;quot;h&amp;quot;, 5)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;h&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;nargs&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// ...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;run-the-program&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#run-the-program&quot;&gt;Run the program&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;You can now run the program in the following ways:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;./area.js -w 5 -h 6&lt;/code&gt;, if you add the node shebang at the top of the file.&lt;/li&gt;&lt;li&gt;&lt;code&gt;node area.js -w 5 -h 6&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;npm link&lt;/code&gt; to install it globally, and then &lt;code&gt;area -w 5 -h 6&lt;/code&gt;—replace the &lt;code&gt;area&lt;/code&gt; with the name you set up in the &lt;code&gt;bin&lt;/code&gt; field of your &lt;code&gt;package.json&lt;/code&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;other-interesting-configuration-options&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#other-interesting-configuration-options&quot;&gt;Other interesting configuration options&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/yargs/yargs/blob/HEAD/docs/api.md#impliesx-y&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;.implies()&lt;/code&gt;&lt;/a&gt;. &lt;code&gt;implies(&amp;#x27;w&amp;#x27;, &amp;#x27;h&amp;#x27;)&lt;/code&gt; means that if &lt;code&gt;-w&lt;/code&gt; has a value, then &lt;code&gt;-h&lt;/code&gt; should have a value too. It could be useful in our case because the program needs both options to calculate the area.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/yargs/yargs/blob/HEAD/docs/api.md#strictenabledtrue&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;.strict()&lt;/code&gt;&lt;/a&gt;. Throws errors if the options/command requirements are not met. For example, if the type of an option is not correct, it throws an error.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/yargs/yargs/blob/master/docs/tricks.md#quotes&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Dealing with quotes&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;commands&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#commands&quot;&gt;Commands&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;I don’t need it right now, maybe I will revisit it in the future. For now, see &lt;a href=&quot;https://github.com/yargs/yargs/blob/HEAD/docs/advanced.md&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Advanced in Yargs docs.&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;See the &lt;a href=&quot;https://github.com/yargs/yargs&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Yargs GitHub page.&lt;/a&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/yargs/yargs/blob/1b477454f87fd125184b3514360e23964a009478/docs/examples.md&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Examples&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/yargs/yargs/blob/HEAD/docs/advanced.md&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Advanced topics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/yargs/yargs/tree/1b477454f87fd125184b3514360e23964a009478/example&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;More examples (some are outdated)&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/yargs/yargs/blob/HEAD/docs/api.md&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/yargs/yargs/blob/1b477454f87fd125184b3514360e23964a009478/docs/tricks.md&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Tricks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://docs.npmjs.com/cli/v8/configuring-npm/package-json/#bin&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Node Package Manager&quot;&gt;NPM&lt;/abbr&gt; docs for package.json’s bin field&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/shebang.md&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;ESLint node/shebang rule&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk39 { color: #C789D6; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Curl examples]]></title><description><![CDATA[Explore the basic curl options for the HTTP protocol with some practical examples.]]></description><link>https://markoskon.com/curl-examples/</link><guid isPermaLink="false">https://markoskon.com/curl-examples/</guid><pubDate>Thu, 26 Sep 2019 15:16:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;code&gt;curl&lt;/code&gt; is a &lt;abbr title=&quot;Command-Line Interface&quot;&gt;CLI&lt;/abbr&gt; tool that allows you to transfer data to or from a server in a variety of different protocols. In this post, you can find some examples that demonstrate the basic &lt;code&gt;curl&lt;/code&gt; options for the &lt;abbr title=&quot;Hypertext Transfer Protocol&quot;&gt;HTTP&lt;/abbr&gt;/&lt;abbr title=&quot;Hypertext Transfer Protocol Secure&quot;&gt;HTTPS&lt;/abbr&gt; protocols.&lt;/p&gt;&lt;h2 id=&quot;make-a-get-request&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#make-a-get-request&quot;&gt;Make a GET request&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;code&gt;GET&lt;/code&gt; is the default &lt;abbr title=&quot;Hypertext Transfer Protocol&quot;&gt;HTTP&lt;/abbr&gt; method, so you don’t have to use an option. You can pass only the &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;curl https://www.google.com&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;specify-the-http-method&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#specify-the-http-method&quot;&gt;Specify the &lt;abbr title=&quot;Hypertext Transfer Protocol&quot;&gt;HTTP&lt;/abbr&gt; Method&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You can specify the &lt;abbr title=&quot;Hypertext Transfer Protocol&quot;&gt;HTTP&lt;/abbr&gt; method with the &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-X&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;-X or --request&lt;/code&gt;&lt;/a&gt; option. In the following example, I make an &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;OPTIONS&lt;/code&gt;&lt;/a&gt; request:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;curl -X OPTIONS -i https://jsonplaceholder.typicode.com/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-i&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;-i or --include&lt;/code&gt;&lt;/a&gt; option gives back the response headers, not only the response body—more about that in a bit.&lt;/p&gt;&lt;h3 id=&quot;1-perform-a-post-request&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#1-perform-a-post-request&quot;&gt;1. Perform a POST request&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;When you perform a &lt;code&gt;POST&lt;/code&gt; request, you usually send some data to the server. You can send data with the &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-d&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;-d or --data&lt;/code&gt;&lt;/a&gt; option:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;curl https://jsonplaceholder.typicode.com/todos \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     --data &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;title=Groceries&amp;amp;body=Buy groceries.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# The backslash (\) spans the command over multiple lines&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You don’t have to state the method with &lt;code&gt;-X POST&lt;/code&gt; because &lt;code&gt;POST&lt;/code&gt; is the default method when you use the &lt;code&gt;--data&lt;/code&gt; option. You send the data as &lt;code&gt;content-type: application/x-www-form-urlencoded&lt;/code&gt;. See also &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-F&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;-F or --form&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#--data-raw&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;--data-raw&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&lt;h3 id=&quot;2-update-with-the-put-method&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#2-update-with-the-put-method&quot;&gt;2. Update with the PUT method&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;If you want to perform a &lt;code&gt;PUT&lt;/code&gt; request, you have to specify the method along with the data you want to send:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;curl https://jsonplaceholder.typicode.com/todos/1 \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     -X PUT \&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;     --data &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;title=Groceries&amp;amp;body=Buy groceries.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;get-the-headers&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-the-headers&quot;&gt;Get the headers&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When you make an &lt;abbr title=&quot;Hypertext Transfer Protocol&quot;&gt;HTTP&lt;/abbr&gt; request with &lt;code&gt;curl&lt;/code&gt;, the default output you get is the response body. If you want to get the headers, you have 3 options:&lt;/p&gt;&lt;h3 id=&quot;1-get-both-response-headers-and-body&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#1-get-both-response-headers-and-body&quot;&gt;1. Get both response headers and body&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;This is what you want most of the times. To get both response headers and body, you can use the &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-i&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;-i or --include&lt;/code&gt;&lt;/a&gt; option:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;curl https://www.google.com/ -i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;2-get-only-the-response-headers&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#2-get-only-the-response-headers&quot;&gt;2. Get only the response headers&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;To get only the response headers—without the response body—use the &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-I&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;-I or --head&lt;/code&gt;&lt;/a&gt; option:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;curl https://www.google.com/ -I&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With this option, you perform a &lt;code&gt;HEAD&lt;/code&gt; &lt;abbr title=&quot;Hypertext Transfer Protocol&quot;&gt;HTTP&lt;/abbr&gt; request. You can achieve the same thing if you set the &lt;abbr title=&quot;Hypertext Transfer Protocol&quot;&gt;HTTP&lt;/abbr&gt; method to &lt;code&gt;HEAD&lt;/code&gt; with &lt;code&gt;curl -X HEAD&lt;/code&gt;. But because you get only the response body by default, you also have to include the headers with &lt;code&gt;-i or --include&lt;/code&gt;, so the final command would be: &lt;code&gt;curl -X HEAD -i&lt;/code&gt;. As a result, the &lt;code&gt;-I or --head&lt;/code&gt; option is preferred.&lt;/p&gt;&lt;h3 id=&quot;3-get-the-request-headers-too&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#3-get-the-request-headers-too&quot;&gt;3. Get the request headers too&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Sometimes, you want more details about the exchange between the server and the client. For example, you may want to see the request headers. In this case, you can use the &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-v&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;-v or --verbose&lt;/code&gt;&lt;/a&gt; option. You get a lot more information, though, not only the request headers:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;curl https://www.google.com/ --verbose&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To find the request headers, look for the lines that start with &lt;code&gt;&amp;gt;&lt;/code&gt;. The response headers, on the other hand, start with &lt;code&gt;&amp;lt;&lt;/code&gt;. The lines that start with an asterisk (&lt;code&gt;*&lt;/code&gt;) are &lt;abbr title=&quot;Transmission Control Protocol&quot;&gt;TCP&lt;/abbr&gt; or &lt;abbr title=&quot;Transport Layer Security&quot;&gt;TLS&lt;/abbr&gt; stuff.&lt;/p&gt;&lt;h2 id=&quot;follow-redirects&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#follow-redirects&quot;&gt;Follow redirects&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;To follow the redirects use the &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-L&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;-L or --location&lt;/code&gt;&lt;/a&gt; option. You should also append the response headers with the &lt;code&gt;-i&lt;/code&gt; option to see what’s going on:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;curl http://google.com --location -i&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Try the same request without the &lt;code&gt;--location&lt;/code&gt; option if you want to see the difference.&lt;/p&gt;&lt;h2 id=&quot;save-console-output-to-file&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#save-console-output-to-file&quot;&gt;Save console output to file&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You can use the &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-o&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;-o or --output&lt;/code&gt;&lt;/a&gt; option to save the console output in a file:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;curl https://www.google.com -i -o google.txt&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;save-a-file&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#save-a-file&quot;&gt;Save a file&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you want to save a file and keep the original filename in your local machine, use the &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-O&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;-O or --remote-name&lt;/code&gt;&lt;/a&gt; option:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;curl -O https://markoskon.com/static/fa71d793057a033cf6b13329754cb6fc/dbbca/all-cool-dev.jpg&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you want to give the file a new name, use the &lt;code&gt;-o or --output&lt;/code&gt; instead:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;curl -o gatsby-modals.jpg https://markoskon.com/static/fa71d793057a033cf6b13329754cb6fc/dbbca/all-cool-dev.jpg&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;advanced&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#advanced&quot;&gt;Advanced&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;More useful options for another post:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Upload a file with the &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-T&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;-T or --upload-file&lt;/code&gt;&lt;/a&gt; option.&lt;/li&gt;&lt;li&gt;Save multiple files with &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-o&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;-o or --output&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-d&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Other options&lt;/a&gt; you have to send data to the server.&lt;/li&gt;&lt;li&gt;Set headers with &lt;a href=&quot;https://curl.haxx.se/docs/manpage.html#-H&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;-H or --header&lt;/code&gt;&lt;/a&gt; option.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;further-reading&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#further-reading&quot;&gt;Further reading&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://curl.haxx.se/docs/manpage.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;curl Man Page (reference)&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://curl.haxx.se/docs/manual.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;curl tutorial&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Array prototype methods]]></title><description><![CDATA[See the most useful JavaScript array methods, what they do, and examples on how to use them. All that, in the least possible space.]]></description><link>https://markoskon.com/array-prototype-methods/</link><guid isPermaLink="false">https://markoskon.com/array-prototype-methods/</guid><pubDate>Sun, 15 Sep 2019 19:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In this post, you will find useful JavaScript array methods and some examples on how to use them. In the title I mention array prototype methods instead of array methods; let me explain a bit where this comes from.&lt;/p&gt;&lt;p&gt;You can create an array with the &lt;em&gt;bracket syntax&lt;/em&gt;: &lt;code&gt;const arr = [1, 2, 3]&lt;/code&gt; or with the &lt;code&gt;Array&lt;/code&gt; constructor: &lt;code&gt;const arr = new Array(1, 2, 3)&lt;/code&gt;. No matter what method you choose, &lt;a href=&quot;/notes-from-ydkjs-this-and-object-prototypes/#chapter-3-objects&quot;&gt;you will get back an object&lt;/a&gt; that inherits from the &lt;code&gt;Array&lt;/code&gt;. As a result, this object (or this array) will have some handy methods you can use to change the contents of the array or get back an answer. Those are the &lt;code&gt;Array.prototype&lt;/code&gt; methods.&lt;/p&gt;&lt;p&gt;The goal of this post is to list as many methods as possible, in the least possible space. It’s not meant to be an extensive reference. If you want to learn more about a method, check the links to the &lt;abbr title=&quot;Mozilla Developer Network Web Docs&quot;&gt;MDN&lt;/abbr&gt; documentation.&lt;/p&gt;&lt;h2 id=&quot;methods-that-modify-the-array&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#methods-that-modify-the-array&quot;&gt;Methods that modify the array&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Use these on the arguments of a function if you want to trigger people that like functional programming.&lt;/p&gt;&lt;h3 id=&quot;1-fill&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#1-fill&quot;&gt;1. fill()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.fill(value, start = 0, end = arr.length)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Fills the array with the given value from start to end index (end not included). &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.fill()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// .fill(value, start, end)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [0, 0, 0]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 1, 1, 1, 1]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 5, 5]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 5, 5, 4]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;2-reverse&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#2-reverse&quot;&gt;2. reverse()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.reverse()&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Reverses the array. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.reverse()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;reverse&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [3, 2, 1]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;3-pop&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#3-pop&quot;&gt;3. pop()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.pop()&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Removes the last element. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.pop()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2], returns the removed element: 3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;4-shift&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#4-shift&quot;&gt;4. shift()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.shift()&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Removes the first element. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.shift()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;shift&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [2, 3], returns 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;5-push&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#5-push&quot;&gt;5. push()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.push(elementN)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Adds the given elements at end of the array. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.push()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// .push(element1, ...)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2, 3, 4, 5], returns the new length: 5&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2, 3, 4], returns 4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;6-unshift&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#6-unshift&quot;&gt;6. unshift()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.unshift(elementN)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Adds the given elements at start of the array. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.unshift()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// .unshift(element1, ...)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;unshift&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [4, 5, 1, 2, 3], returns 5 (new length)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;unshift&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [4, 1, 2, 3], returns 4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;7-sort&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#7-sort&quot;&gt;7. sort()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.sort(compareFunction)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Sorts the array. &lt;abbr title=&quot;(Things) To Do&quot;&gt;TODO&lt;/abbr&gt;. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.sort()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 id=&quot;8-splice&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#8-splice&quot;&gt;8. splice()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.splice(start, deleteCount = all from start, elementNToAdd)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Can delete and add elements in the array at the same time. Returns the deleted items. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.splice()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// .splice(start, deleteCount, element1, ...)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;splice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// only delete: [1], returns [2, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;splice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// only delete: [3], returns [1, 2]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;splice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// only add: [1, 2, 4, 5, 3], returns []&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;splice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// only add: [1, 2, 3, 4, 5], returns []&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;splice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;two&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;three&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// delete and add: [1, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;], returns [2, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;splice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;99&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;two&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;three&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// delete and add: [1, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;], returns [2, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype#Mutator_methods&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;All the mutator methods.&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;methods-that-do-not-modify-the-array&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#methods-that-do-not-modify-the-array&quot;&gt;Methods that do &lt;em&gt;not&lt;/em&gt; modify the array&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;These methods return a new array/result without modifying the initial array.&lt;/p&gt;&lt;h3 id=&quot;1-concat&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#1-concat&quot;&gt;1. concat()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.concat(valueN)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Merge two or more arrays into a new array. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.concat()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2, 3, 4]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2, 3, 4]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 2, 3, 4, 5, 6]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;2-join&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#2-join&quot;&gt;2. join()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;.join(separator)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Join array items into a string. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.join()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;1,2,3&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;123&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; - &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;quot;1 - 2 - 3&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;3-slice&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#3-slice&quot;&gt;3. slice()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;slice(start = 0, end = array.length)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Return a portion of the array from start to end index (end not included). &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.slice()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [3, 4, 5]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [3, 4]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;slice&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [3, 4, 5]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;4-includes&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#4-includes&quot;&gt;4. includes()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.includes(element, fromIndex = 0)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;See if the array contains the given value. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.Prototype.includes&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// .includes(value, index)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;5-indexof&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#5-indexof&quot;&gt;5. indexOf()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.indexOf(element, fromIndex = 0)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Returns the first index of the given element in the array or -1 if it doesn’t exist. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.indexOf()&lt;/code&gt;&lt;/a&gt;. To get the last index of the element, use &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.lastIndexOf()&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// -1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// -1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype#Accessor_methods&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;All the accessor methods&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;methods-that-iterate-the-array&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#methods-that-iterate-the-array&quot;&gt;Methods that iterate the array&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Methods that iterate the array and call the given function for every element. None of these methods modifies the initial array. The function you pass as a parameter has the following signature: &lt;code&gt;function(element, index, array)&lt;/code&gt;, although most of the times, you’ll use only the first parameter: &lt;code&gt;function(element)&lt;/code&gt;. The only &lt;em&gt;exception&lt;/em&gt; is the function for the &lt;code&gt;reduce&lt;/code&gt; method which has the following signature: &lt;code&gt;function(accumulator, element, index, array)&lt;/code&gt;.&lt;/p&gt;&lt;h3 id=&quot;1-map&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#1-map&quot;&gt;1. map()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.map(callback)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Returns a new array of &lt;em&gt;equal length&lt;/em&gt; that contains the transformed elements. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.Prototype.map()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [2, 4, 6]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&amp;quot;1&amp;quot;, &amp;quot;2&amp;quot;, &amp;quot;3&amp;quot;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;2-foreach&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#2-foreach&quot;&gt;2. forEach()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.forEach(callback)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Iterates an array and calls the given function; it returns &lt;code&gt;undefined&lt;/code&gt;. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.Prototype.forEach()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// 0: 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// 1: 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// 2: 3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;3-reduce&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#3-reduce&quot;&gt;3. reduce()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.reduce(callback, initialValue)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Iterates the array and returns anything you like; a value, a smaller array, or an equal-length array. Use it when no other method in this section can give what you want. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.Prototype.reduce()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// .reduce(callback, initialValue)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 6, the sum of the elements&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}, []); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [1, 3], an array with only the even numbers. Although filter is a better fit here.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;4-filter&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#4-filter&quot;&gt;4. filter()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.filter(callback)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Returns a new array that contains the filtered elements. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.Prototype.filter()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;15&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// [2], 2 is the only even number.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// []&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;5-find&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#5-find&quot;&gt;5. find()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.find(callback)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Returns the first element it finds, or &lt;code&gt;undefined&lt;/code&gt; if it doesn’t find anything. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.Prototype.find()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;16&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 2, The number 2 is even&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 1, 1 is the first odd number.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// undefined&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;6-every&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#6-every&quot;&gt;6. every()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.every(callback)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Returns &lt;code&gt;true&lt;/code&gt; if every element in the array satisfies the check, otherwise, it returns &lt;code&gt;false&lt;/code&gt;. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.Prototype.every()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;17&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;every&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false, The array has even numbers too.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;every&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true, The array has only odd numbers.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;7-some&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#7-some&quot;&gt;7. some()&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;arr.some(callback)&lt;/code&gt;&lt;/p&gt;&lt;p&gt;Returns &lt;code&gt;true&lt;/code&gt; if it finds &lt;em&gt;at least one&lt;/em&gt; element or &lt;code&gt;false&lt;/code&gt; otherwise. &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.Prototype.some()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;18&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;some&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// true, Has at least one even number.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;some&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;); &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// false, The array has no even numbers.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype#Iteration_methods&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;All the iteration methods&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;Every iterator method also takes an &lt;em&gt;optional second parameter&lt;/em&gt; the &lt;code&gt;thisArgument&lt;/code&gt;, that&amp;#x27;s used as the &lt;code&gt;this&lt;/code&gt; value inside the callback.&lt;/div&gt;&lt;p&gt;&lt;abbr title=&quot;(Things) To Do&quot;&gt;TODO&lt;/abbr&gt;: &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.flat()&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.flatMap()&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Mozilla Developer Network Web Docs&quot;&gt;MDN&lt;/abbr&gt;: Array.prototype&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Mozilla Developer Network Web Docs&quot;&gt;MDN&lt;/abbr&gt;: Array&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk12 { color: #FFCB8B; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Tail calls, tail-recursive functions, and tail call optimization]]></title><description><![CDATA[Find out what is a tail call, a tail-recursive function, and how the compiler can optimize them.]]></description><link>https://markoskon.com/tail-calls-tail-functions-tail-call-optimization/</link><guid isPermaLink="false">https://markoskon.com/tail-calls-tail-functions-tail-call-optimization/</guid><pubDate>Fri, 06 Sep 2019 16:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Learn what is a &lt;em&gt;tail call&lt;/em&gt;, a &lt;em&gt;tail-recursive function&lt;/em&gt;, and how the compiler can optimize them. I will start with something that wasn’t obvious for me: a function cannot be a &lt;em&gt;tail call&lt;/em&gt;; it can be a &lt;em&gt;tail function&lt;/em&gt;. An example of a tail function is a &lt;em&gt;tail-recursive&lt;/em&gt; function; a function &lt;em&gt;call&lt;/em&gt; can be a tail call.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;Although I use the term &lt;em&gt;tail function&lt;/em&gt;, you should avoid using it for functions that are not recursive because no one else does.&lt;/div&gt;&lt;h2 id=&quot;tail-call&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#tail-call&quot;&gt;Tail call&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The first question is when a function call is a tail call. The technical explanation says that:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;A function call is a tail call when it’s the last action of the caller function.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;A different way to put this is the following:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;A function call is a tail call when the called function returns the same thing as the function that called it.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;I like the last explanation more because it hints a connection with the call-stack, as you’ll see shortly.&lt;/p&gt;&lt;h3 id=&quot;examples-of-tail-calls&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#examples-of-tail-calls&quot;&gt;Examples of tail calls&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;In the following example, the function call &lt;code&gt;returnNumber(2)&lt;/code&gt; is a tail call because it’s the last thing the &lt;code&gt;return2&lt;/code&gt; function (caller function) does. Or, if you prefer the other explanation, the function call &lt;code&gt;returnNumber(2)&lt;/code&gt; is a tail call because it returns the same thing as the &lt;code&gt;return2&lt;/code&gt; function.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;returnNumber&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;return2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;returnNumber&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;return2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can implement the &lt;code&gt;return2&lt;/code&gt; function in a way that the function call &lt;code&gt;returnNumber(x)&lt;/code&gt; is not a tail call:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-gutter-pad&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-gutter grvsc-line-number&quot; aria-hidden=&quot;true&quot; data-content=&quot;1&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;returnNumber&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-gutter-pad&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-gutter grvsc-line-number&quot; aria-hidden=&quot;true&quot; data-content=&quot;2&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-gutter-pad&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-gutter grvsc-line-number&quot; aria-hidden=&quot;true&quot; data-content=&quot;3&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-gutter-pad&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-gutter grvsc-line-number&quot; aria-hidden=&quot;true&quot; data-content=&quot;4&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;return2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-gutter-pad&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-gutter grvsc-line-number&quot; aria-hidden=&quot;true&quot; data-content=&quot;5&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;spare1&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-gutter-pad&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-gutter grvsc-line-number&quot; aria-hidden=&quot;true&quot; data-content=&quot;6&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;spare1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;returnNumber&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-gutter-pad&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-gutter grvsc-line-number&quot; aria-hidden=&quot;true&quot; data-content=&quot;7&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-gutter-pad&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-gutter grvsc-line-number&quot; aria-hidden=&quot;true&quot; data-content=&quot;8&quot;&gt;&lt;/span&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;return2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the example above, the &lt;code&gt;return2&lt;/code&gt; function gives the same result, but, now, the function call &lt;code&gt;returnNumber(1)&lt;/code&gt;, at line 6, is not a tail call because it returns 1 and the caller function &lt;code&gt;return2&lt;/code&gt; returns 2. Or, if you prefer the technical explanation, the function call &lt;code&gt;returnNumber(1)&lt;/code&gt; is not a tail call because it’s &lt;em&gt;not&lt;/em&gt; the last action of the caller function &lt;code&gt;return2&lt;/code&gt;. The last action of the &lt;code&gt;return2&lt;/code&gt; function it to resolve the expression &lt;code&gt;spare1 + returnNumber(1)&lt;/code&gt; and return it. As it seems, returning a value is &lt;em&gt;not&lt;/em&gt; considered an action.&lt;/p&gt;&lt;p&gt;For recognizing tail calls in expressions and statements, and for some pitfalls, see &lt;a href=&quot;https://2ality.com/2015/06/tail-call-optimization.html#checking-whether-a-function-call-is-in-a-tail-position&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;checking whether a function call is in a tail position.&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;tail-functions&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#tail-functions&quot;&gt;Tail functions&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let’s now assume that you can name as &lt;em&gt;tail function&lt;/em&gt; a function that contains a tail call. In the first snippet, the function &lt;code&gt;return2&lt;/code&gt; is a tail function, but, in the second snippet, it’s not. As a result, whether a function is a tail function or not, depends on how you implement it. Let’s now see an example of that by using a &lt;em&gt;tail-recursive function&lt;/em&gt; and regular recursive function.&lt;/p&gt;&lt;p&gt;The following example shows a tail-recursive function that returns &lt;a href=&quot;https://en.wikipedia.org/wiki/Factorial&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;the factorial&lt;/a&gt; of a number:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// acc = accumulator which is a fancy name for a variable&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// that you use to store a temporary result.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorialTail&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorial&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk18&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And here you see a recursive function (without a tail call) that does the same thing:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorial&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorial&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The tail-recursive function stores the result in an &lt;em&gt;accumulator&lt;/em&gt; variable and passes it to the next function call. On the other hand, the plain recursive function performs the calculation in an expression, right before returning it.&lt;/p&gt;&lt;h2 id=&quot;tail-call-optimization&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#tail-call-optimization&quot;&gt;Tail call optimization&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You saw when a function call is tail call and when a function is a tail function. But why this is important? The answer has to do with the call-stack and a trick the compiler does that’s called &lt;em&gt;tail call optimization&lt;/em&gt; (&lt;abbr title=&quot;Tail Call Optimization&quot;&gt;TCO&lt;/abbr&gt;).&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Tail call optimization happens when the compiler recognizes that a function call is a tail call and reuses the current stack frame, instead of placing a new one on top that will increase the stack size.&lt;/p&gt;&lt;/blockquote&gt;&lt;div class=&quot;note&quot;&gt;If you use JavaScript, it turns out you shouldn&amp;#x27;t care much because &lt;a href=&quot;https://kangax.github.io/compat-table/es6/#test-proper_tail_calls_(tail_call_optimisation)&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Tail Call Optimization&quot;&gt;TCO&lt;/abbr&gt; is supported only by Safari&lt;/a&gt;—it&amp;#x27;s &lt;a href=&quot;https://www.chromestatus.com/feature/5516876633341952&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;deprecated on Chrome.&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Instead of getting technical with call-stacks, stack-frames, and local/global variables, I’ll show you a visualization that shows what happens in the call stack when you call &lt;code&gt;factorialTail(4)&lt;/code&gt;. In the first snippet, the compiler does not perform &lt;abbr title=&quot;Tail Call Optimization&quot;&gt;TCO&lt;/abbr&gt; and in the second it does. I got the idea from the &lt;a href=&quot;https://en.wikipedia.org/wiki/Tail_call#Example_programs&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Wikipedia page&lt;/a&gt; but changed it a bit.&lt;/p&gt;&lt;p&gt;No tail call optimization → 5 stack frames:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// factorialTail(number, acc = 1)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorialTail&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorialTail&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorialTail&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorialTail&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorialTail&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;24&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;24&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;24&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;24&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;24&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Tail call optimization → 1 stack frame:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// factorialTail(number, acc = 1)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorialTail&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorialTail&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorialTail&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorialTail&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;factorialTail&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;24&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The first snippet shows that new frames are being allocated—indicated by the indentation—when the compiler does not perform tail call optimization. The second snippet shows that when the compiler performs &lt;abbr title=&quot;Tail Call Optimization&quot;&gt;TCO&lt;/abbr&gt;, it reuses the current frame for the new function call, instead of adding a new frame to the call-stack.&lt;/p&gt;&lt;h2 id=&quot;technical-explanation-problem&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#technical-explanation-problem&quot;&gt;Technical explanation problem&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The following example is from Wikipedia’s page about &lt;a href=&quot;https://en.wikipedia.org/wiki/Tail_call&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;tail call&lt;/a&gt;. The author says that the &lt;code&gt;a(data)&lt;/code&gt; call is in the tail position. By the way, please, give descriptive names to your variables/functions! This makes sense with the second explanation because it returns the same thing as the &lt;code&gt;foo2&lt;/code&gt; function. It doesn’t make sense with the first explanation, though, because the &lt;code&gt;a(data)&lt;/code&gt; call is not the last action of the &lt;code&gt;foo2&lt;/code&gt; function. After the &lt;code&gt;a(data)&lt;/code&gt; call, the function stores that result in a variable and then returns it.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;foo2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;ret&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;ret&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Sources and some relevant links.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://2ality.com/2015/06/tail-call-optimization.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Tail call optimization in ECMAScript 6&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://link.medium.com/bVBvf6pByZ&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Recursion&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.geeksforgeeks.org/tail-recursion-fibonacci/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Tail Recursion for Fibonacci.&lt;/a&gt; It’s a bit more complex than the factorial (and by a bit I mean a lot).&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Tail_call&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Wikipedia page for Tail Call&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk18 { color: #5F7E97; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Puppeteer examples]]></title><description><![CDATA[Learn how to accomplish common tasks with Puppeteer through some practical examples.]]></description><link>https://markoskon.com/puppeteer-examples/</link><guid isPermaLink="false">https://markoskon.com/puppeteer-examples/</guid><pubDate>Mon, 26 Aug 2019 16:00:00 GMT</pubDate><content:encoded>&lt;p&gt;This post will help you get started with Puppeteer in Node and learn how to perform some common tasks. Let’s start with a recommended structure for your project.&lt;/p&gt;&lt;h2 id=&quot;project-structure&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#project-structure&quot;&gt;Project Structure&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Write your code inside an &lt;code&gt;async&lt;/code&gt; &lt;abbr title=&quot;Immediately-invoked Function Expression&quot;&gt;IIFE&lt;/abbr&gt; in the &lt;code&gt;index.js&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;index.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;async&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Your code goes here.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;})();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Or create a new file that you will import:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;screenshot.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;async&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Your code goes here.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Also, a &lt;a href=&quot;https://www.npmjs.com/package/nodemon&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;nodemon&lt;/a&gt; script can be useful here to re-run your code after you make changes:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;package.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;scripts&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;start&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;nodemon src/index.js --ignore data&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;launch-and-create-a-new-page&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#launch-and-create-a-new-page&quot;&gt;Launch and create a new page&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Launch a &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-class-browser&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;browser&lt;/a&gt; and open a new &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-class-page&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;page&lt;/a&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = await &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;puppeteer&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;launch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ headless: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = await &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;newPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-class-puppeteer&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Puppeteer class documentation&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;emulate-a-device&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#emulate-a-device&quot;&gt;Emulate a device&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You can &lt;em&gt;emulate a device&lt;/em&gt; with &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-pageemulateoptions&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;page.emulate&lt;/a&gt;. This is a &lt;a href=&quot;https://github.com/GoogleChrome/puppeteer/blob/master/lib/DeviceDescriptors.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;list with the available devices&lt;/a&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;devices&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;puppeteer/DeviceDescriptors&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;emulate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;devices&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;iPhone X&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;set-page-viewport&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#set-page-viewport&quot;&gt;Set page viewport&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Instead of emulating a device, you can set the &lt;em&gt;page viewport&lt;/em&gt; with &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-pagesetviewportviewport&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;page.setViewport&lt;/a&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setViewport&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ width: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1920&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, height: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1080&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;visit-a-url&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#visit-a-url&quot;&gt;Visit a &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;After you set the device or the viewport, you can &lt;em&gt;visit a &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;&lt;/em&gt; with &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-pagegotourl-options&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;page.goto&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;goto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;a-screenshot-script&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#a-screenshot-script&quot;&gt;A screenshot script&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You can &lt;em&gt;take screenshots&lt;/em&gt; of a page with &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-pagescreenshotoptions&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;page.screenshot&lt;/a&gt;. Below you can find a &lt;em&gt;screenshot script&lt;/em&gt; where I put all the previous sections together:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;screenshot.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;puppeteer&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;puppeteer&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;async&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://example.com&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;fullPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;headless&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;} &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {}) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = await &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;puppeteer&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;launch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;headless&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = await &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;newPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;typeof&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;devices&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;puppeteer/DeviceDescriptors&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;emulate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;devices&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;device&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setViewport&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ width: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1920&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, height: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1080&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;goto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;screenshot&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    path: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;filename&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;screenshots/&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.png&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;screenshots/&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.png&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;fullPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You should also create the directories that you’ll store the screenshots, somewhere in your code:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;index.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;fs&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fs&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;mkdirp&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;mkdirp&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Create directories.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;directories&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;screenshots&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;directories&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;fs&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;existsSync&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)) &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;mkdirp&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;close-the-browser&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#close-the-browser&quot;&gt;Close the browser&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Don’t forget to &lt;em&gt;close&lt;/em&gt; the browser after you finish your work:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;create-pdfs&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#create-pdfs&quot;&gt;Create pdfs&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Besides screenshots, you can also &lt;em&gt;create pdfs&lt;/em&gt; with &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-pagepdfoptions&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;page.pdf&lt;/a&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;pdf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  path: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;filename&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;pdfs/&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.pdf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;pdfs/&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getTime&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.pdf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  format: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;A4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;get-access-to-the-window-object&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-access-to-the-window-object&quot;&gt;Get access to the window object&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you want access to the &lt;code&gt;window&lt;/code&gt; or &lt;code&gt;document&lt;/code&gt; objects—to &lt;em&gt;scrape&lt;/em&gt; some information from the page, for example—you can use the &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-pageevaluatepagefunction-args&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;page.evaluate&lt;/a&gt; method:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;imageUrls&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = await &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;images&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;article img&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;urls&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;images&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;urls&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The function you pass to evaluate is &lt;em&gt;not a closure&lt;/em&gt;. As a result, it doesn’t have access to variables defined in the parent scope. Because of that, if you want to use an outside variable (a selector, for example) inside the function, you have to pass that variable as an argument to evaluate:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;imageSelector&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;article img&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;imageUrls&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = await &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;evaluate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;selector&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;images&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;selector&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;urls&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;images&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;urls&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;imageSelector&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;By the way, you can’t pass an external library (&lt;a href=&quot;https://www.npmjs.com/package/get-urls&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;get-urls&lt;/a&gt;, for example) as an argument. Instead, assign the result of the evaluate to a variable and use the library outside.&lt;/p&gt;&lt;h2 id=&quot;type-and-click&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#type-and-click&quot;&gt;Type and click&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you want to type some text inside an input, use the &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-pagetypeselector-text-options&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;page.type&lt;/a&gt; method:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#searchbox input&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Headless Chrome&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And if you want to click something, use the &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-pageclickselector-options&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;page.click&lt;/a&gt; method:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;click&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;my-button&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;wait-for-selector-to-appear&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#wait-for-selector-to-appear&quot;&gt;Wait for selector to appear&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;After you perform an action, you can wait for a selector to appear before you proceed any further. You can do that with the &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-pagewaitforselectorselector-options&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;page.waitForSelector&lt;/a&gt; method:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;15&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;waitForSelector&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;page-events&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#page-events&quot;&gt;Page events&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Handle events emitted by the &lt;code&gt;Page&lt;/code&gt; with the &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-event-close&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;page.on&lt;/a&gt; or &lt;code&gt;page.once&lt;/code&gt; methods:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;16&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;once&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Page loaded.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Use &lt;code&gt;on&lt;/code&gt; to handle &lt;em&gt;every&lt;/em&gt; event and &lt;code&gt;once&lt;/code&gt; to handle only the &lt;em&gt;first&lt;/em&gt;. Additionally, you can use the &lt;code&gt;page.removeListener()&lt;/code&gt; method to remove the listener:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;17&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;requestLogger&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;());&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;requestLogger&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// later&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;removeListener&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;requestLogger&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;skip-requests&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#skip-requests&quot;&gt;Skip requests&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You can &lt;em&gt;skip requests&lt;/em&gt; by enabling request interception with &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-pagesetrequestinterceptionvalue&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;page.setRequestInterception(true)&lt;/a&gt;. You then listen for the &lt;a href=&quot;https://pptr.dev/#?product=Puppeteer&amp;amp;version=v1.19.0&amp;amp;show=api-event-request&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;request event&lt;/a&gt;, and you call &lt;code&gt;request.abort()&lt;/code&gt;, &lt;code&gt;request.continue()&lt;/code&gt;, or &lt;code&gt;request.respond()&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;18&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setRequestInterception&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;resourceType&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;() &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;abort&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;further-reading&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#further-reading&quot;&gt;Further Reading&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://pptr.dev/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Puppeteer documentation&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://addyosmani.com/blog/puppeteer-recipes/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Web Performance Recipes With Puppeteer&lt;/a&gt; by Addy Osmani.&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk39 { color: #C789D6; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk12 { color: #FFCB8B; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Page transitions in Gatsby]]></title><description><![CDATA[You can find here some experiments I made with complex page transitions in Gatsby.]]></description><link>https://markoskon.com/page-transitions-in-gatsby/</link><guid isPermaLink="false">https://markoskon.com/page-transitions-in-gatsby/</guid><pubDate>Sun, 25 Aug 2019 23:00:00 GMT</pubDate><content:encoded>&lt;p&gt;You can find many examples on how to implement page transitions in Gatsby, but some are now &lt;em&gt;outdated&lt;/em&gt;, some use plugins or libraries that &lt;em&gt;overcomplicate&lt;/em&gt; things, and none of them implements transitions with some “complex” logic. Let me explain what I mean with the “complex” logic by describing what kind of page transitions I want to create.&lt;/p&gt;&lt;p&gt;I want to &lt;em&gt;slide-up&lt;/em&gt; the current screen when I go from the root route &lt;code&gt;/&lt;/code&gt; to the posts route &lt;code&gt;/posts/&lt;/code&gt; and &lt;em&gt;slide it down&lt;/em&gt; when I go the opposite way. In other words, imagine that the &lt;abbr title=&quot;Uniform Resource Locators&quot;&gt;URLs&lt;/abbr&gt; with more paths are &lt;em&gt;positioned lower&lt;/em&gt; than those with fewer paths:&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/df6b5557a9839c1a70d9f8f68d11df2f/example-vertical-transitions.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/743cdb0bc501e50d8242fa8e79aee414/example-vertical-transitions.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/e7a75f3bda578ba95f848b7edbd95aa8/example-vertical-transitions.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Vertical transitions example&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;Also, when you go through a &lt;em&gt;collection&lt;/em&gt; of some posts, for example, I want the screen to &lt;em&gt;slide left&lt;/em&gt; or &lt;em&gt;right&lt;/em&gt; depending on the &lt;em&gt;order&lt;/em&gt; of the posts.&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/e92d47ed33bf36d203f879d216c3a2b6/example-horizontal-transitions.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/9a15951a552815f5829922ec9d1397f5/example-horizontal-transitions.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/b015f468d230a90d3d07d0f4bc7a2ae0/example-horizontal-transitions.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Horizontal transitions example&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;In any other case, the screen will &lt;em&gt;fade-in&lt;/em&gt;. This is just an idea I had that I wanted to implement; I don’t claim that it results in a good user experience, nor I’m suggesting that you should use it in your projects.&lt;/p&gt;&lt;h2 id=&quot;transition-logic&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#transition-logic&quot;&gt;Transition Logic&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;I used a &lt;a href=&quot;https://github.com/MarkosKon/gatsby-page-transitions/blob/master/wrapPageElement.jsx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;wrapPageElement layout&lt;/a&gt; to manage the transitions because it has the following advantages over a regular layout component:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;It &lt;em&gt;doesn’t umount&lt;/em&gt; when you navigate on a different page. This is useful because I want it to remember the previous pathname.&lt;/li&gt;&lt;li&gt;It has access to the location prop.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;I have a function called &lt;a href=&quot;https://github.com/MarkosKon/gatsby-page-transitions/blob/master/src/layouts/Layout/get-animation.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;getAnimation&lt;/code&gt;&lt;/a&gt; that takes as arguments the &lt;em&gt;current&lt;/em&gt; pathname and the &lt;em&gt;previous&lt;/em&gt; and returns the correct animation. It also takes an optional &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; array that has the slugs of the posts and their order. The layout calls that method and passes the result in a wrapper component, that you’ll see in the next section.&lt;/p&gt;&lt;h2 id=&quot;using-only-reveal-animations&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#using-only-reveal-animations&quot;&gt;Using only reveal animations&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;In the first solution, that’s located in the &lt;a href=&quot;https://github.com/MarkosKon/gatsby-page-transitions&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;master branch&lt;/a&gt;, I don’t use both reveal and exit animations. I use &lt;em&gt;only reveal animations&lt;/em&gt; because I want something minimal. I create a &lt;a href=&quot;https://github.com/MarkosKon/gatsby-page-transitions/blob/master/src/layouts/Layout/AnimatedContent.jsx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;wrapper component&lt;/a&gt; that wraps the section I want to animate, and I pass to it an &lt;a href=&quot;https://github.com/MarkosKon/gatsby-page-transitions/blob/master/src/layouts/Layout/animations.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;emotion keyframe object&lt;/a&gt;—with the animation prop. I then use that animation object inside the component’s &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;. The component animates/renders when the current animation is &lt;em&gt;different&lt;/em&gt; from the previous or when the &lt;em&gt;pathname changes&lt;/em&gt;—I pass the pathname string to the &lt;code&gt;key&lt;/code&gt; prop. This is not exactly the effect I had in mind, but it’s quite pleasing, especially the slide-left/right. I am a fan of those animations because they are not complicated, they are performant, if they only use &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;, and they are not so intrusive. By the way, I do something similar in this blog to fade-in the content area of the pages.&lt;/p&gt;&lt;h3 id=&quot;full-page&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#full-page&quot;&gt;Full page&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;After that, I wrapped a &lt;em&gt;bigger part&lt;/em&gt; of the layout with the wrapper component to animate the &lt;em&gt;whole page&lt;/em&gt;, not only the content portion. The result is closer to what I had in mind, but it’s not as smooth as in the previous solution. You can find this solution in the &lt;a href=&quot;https://github.com/MarkosKon/gatsby-page-transitions/tree/full-page&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;full-page branch.&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;using-the-transition-hook-from-react-spring&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#using-the-transition-hook-from-react-spring&quot;&gt;Using the transition hook from react-spring&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;But if I wanted to achieve the result you saw in the GIFs, I would have to use both enter and leave animations. The &lt;strong&gt;main problem&lt;/strong&gt; here is that when you animate a page in, you don’t know what the &lt;em&gt;exit animation&lt;/em&gt; will be. You also want a library that will create two pages when in fact there is only one. &lt;code&gt;react-spring&lt;/code&gt; kind of does all of these with the &lt;a href=&quot;https://www.react-spring.io/docs/hooks/use-transition&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;useTransition hook&lt;/a&gt;. There are some &lt;em&gt;bugs&lt;/em&gt; though that I didn’t investigate much.&lt;/p&gt;&lt;p&gt;To animate with &lt;code&gt;react-spring&lt;/code&gt;, I did the following:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;I &lt;a href=&quot;https://github.com/MarkosKon/gatsby-page-transitions/blob/react-spring-transition/src/layouts/Layout/animations.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;changed the animations&lt;/a&gt; from emotion keyframes to &lt;code&gt;react-spring&lt;/code&gt; transition objects. I didn’t change the logic inside the &lt;code&gt;getAnimation&lt;/code&gt; function, only some imports.&lt;/li&gt;&lt;li&gt;I removed the wrapper component, and instead, I &lt;a href=&quot;https://github.com/MarkosKon/gatsby-page-transitions/blob/react-spring-transition/src/layouts/Layout/index.jsx#L63-L99&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;wrapped the content&lt;/a&gt; I wanted to animate with an &lt;code&gt;animated.div&lt;/code&gt;. That &lt;code&gt;animated.div&lt;/code&gt; is under a transition map in the &lt;abbr title=&quot;JavaScript XML&quot;&gt;JSX&lt;/abbr&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;You can find this solution in the &lt;a href=&quot;https://github.com/MarkosKon/gatsby-page-transitions/tree/react-spring-transition&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;react-spring-transition branch&lt;/a&gt;.&lt;/p&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/LekoArts/gatsby-starter-portfolio-emma&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;LekoArts mount animations&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/ryanwiemer/gatsby-using-page-transitions&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Framer motion&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/TylerBarnes/gatsby-plugin-transition-link&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-plugin-transition-link&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[GraphQL queries inside MDX files]]></title><description><![CDATA[See what options you have when you want to query data with GraphQL inside your MDX files.]]></description><link>https://markoskon.com/graphql-queries-inside-mdx/</link><guid isPermaLink="false">https://markoskon.com/graphql-queries-inside-mdx/</guid><pubDate>Thu, 22 Aug 2019 15:25:00 GMT</pubDate><content:encoded>&lt;p&gt;When you want to query data with &lt;em&gt;GraphQL&lt;/em&gt; inside your &lt;em&gt;&lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt;&lt;/em&gt; pages, you have the following options:&lt;/p&gt;&lt;h2 id=&quot;default-mdx-config&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#default-mdx-config&quot;&gt;Default &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; config&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you are using the default configuration of &lt;code&gt;gatsby-plugin-mdx&lt;/code&gt;, just export a GraphQL query as you would do in a regular Gatsby page. By default configuration, I mean that you installed &lt;code&gt;gatsby-plugin-mdx&lt;/code&gt;, &lt;code&gt;@mdx-js/mdx&lt;/code&gt;, and &lt;code&gt;@mdx-js/react&lt;/code&gt;, and finally, you added &lt;code&gt;gatsby-plugin-mdx&lt;/code&gt; as a plugin in &lt;code&gt;gatsby-config.js&lt;/code&gt;. Then, you can access the query data from &lt;code&gt;props.data.yourdata&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;In the following example, I render the astronaut image from the default Gatsby starter, and I display the props:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/example.mdx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;mdx&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk4&quot;&gt;# Example&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;Example MDX page. Here&amp;#x27;s the image of an astronaut:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { graphql } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Image &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-image&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  query {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    astronaut: file(relativePath: { regex: &amp;quot;/gatsby-astronaut/i&amp;quot; }) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      childImageSharp {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        fluid(maxWidth: 600) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          ...GatsbyImageSharpFluid_tracedSVG&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;`;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;astronaut&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;astronaut&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;childImageSharp&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;Log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;the&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;props.data&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;custom-templates&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#custom-templates&quot;&gt;Custom templates&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you create the &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; pages &lt;em&gt;programmatically&lt;/em&gt;, and you render them with a &lt;em&gt;custom template&lt;/em&gt;, create a new component that uses a &lt;code&gt;StaticQuery&lt;/code&gt;, then import that component in your &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; page and render it.&lt;/p&gt;&lt;p&gt;If you try to create a page query inside the &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; file or try to render a &lt;code&gt;StaticQuery&lt;/code&gt;, you’ll get the following &lt;strong&gt;error&lt;/strong&gt;:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Error: It appears like Gatsby is misconfigured. Gatsby related GraphQL calls are supposed to only be evaluated at compile time, and then compiled away…&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Recommended folder structure:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;__ src&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;____ components&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;______ AstronautImage.jsx&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;____ pages&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;______ index.js&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;______ example.mdx&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;strong&gt;&lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; file&lt;/strong&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/example.mdx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;mdx&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk4&quot;&gt;# Example&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;Here&amp;#x27;s the image of an astronaut:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; AstronautImage &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/AstronautImage&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;AstronautImage&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And finally, the &lt;strong&gt;custom component&lt;/strong&gt; that uses the StaticQuery:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/AstronautImage.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { graphql, StaticQuery } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Image &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-image&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;StaticQuery&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      query {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        astronaut: file(relativePath: { regex: &amp;quot;/gatsby-astronaut/i&amp;quot; }) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          childImageSharp {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            fluid(maxWidth: 600) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              ...GatsbyImageSharpFluid_tracedSVG&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;astronaut&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;astronaut&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;childImageSharp&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;extra&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#extra&quot;&gt;Extra&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;In this section you can find an &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; template, a &lt;code&gt;gatsby-node.js&lt;/code&gt; file that creates programmatically &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; pages, and some links.&lt;/p&gt;&lt;h3 id=&quot;custom-template-file&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#custom-template-file&quot;&gt;Custom template file&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/templates/MDXTemplate.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { graphql } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { MDXRenderer } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-plugin-mdx&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Layout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/layout&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  data: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    mdx: { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Hello from the template&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;MDXRenderer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;MDXRenderer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Notice the slug field in the MDX type you created&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// in onCreateNode.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// The $slug variable comes from the page context&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// you passed while creating the page.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  query MDXBySlug($slug: String!) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    mdx(fields: { slug: { eq: $slug } }) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      body&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;`;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;gatsby-nodejs&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#gatsby-nodejs&quot;&gt;gatsby-node.js&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-node.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createFilePath&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-source-filesystem&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;mdxTemplate&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./src/templates/MDXTemplate.jsx&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;onCreatePage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  actions: { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;createPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;deletePage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Assuming only MDX pages have a frontmatter field...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;deletePage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      component: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;mdxTemplate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      context: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        slug: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;onCreateNode&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;getNode&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createNodeField&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;internal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mdx&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createFilePath&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;getNode&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createNodeField&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;slug&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/ChristopherBiscardi/gatsby-mdx/issues/187#issuecomment-437161966&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub issue&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://spectrum.chat/gatsby-js/general/static-query-in-a-component-in-a-page-that-already-runs-a-graphql-query~86751427-3d9a-4df2-8aef-64fc4d752286&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Spectrum Chat&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk4 { color: #82B1FF; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[wrapRootElement vs wrapPageElement]]></title><description><![CDATA[We see the differences between two browser APIs in Gatsby: the wrapRootElement and the wrapPageElement.]]></description><link>https://markoskon.com/wrap-root-element-vs-wrap-page-element/</link><guid isPermaLink="false">https://markoskon.com/wrap-root-element-vs-wrap-page-element/</guid><pubDate>Wed, 21 Aug 2019 12:00:00 GMT</pubDate><content:encoded>&lt;p&gt;According to Gatsby documentation, you can use &lt;a href=&quot;https://www.gatsbyjs.org/docs/browser-apis/#wrapRootElement&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;wrapRootElement&lt;/a&gt; to wrap your application with &lt;em&gt;provider&lt;/em&gt; components and &lt;a href=&quot;https://www.gatsbyjs.org/docs/browser-apis/#wrapPageElement&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;wrapPageElement&lt;/a&gt; to wrap your pages with components that &lt;em&gt;won’t get unmounted&lt;/em&gt; on page change. But that explanation begs the question: why we don’t do both with &lt;code&gt;wrapPageElement&lt;/code&gt;, and instead, we need two separate &lt;abbr&gt;API&lt;/abbr&gt;s to accomplish those tasks? Let’s see their &lt;em&gt;differences&lt;/em&gt; to understand why.&lt;/p&gt;&lt;h2 id=&quot;differences&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#differences&quot;&gt;Differences&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;First of all, &lt;code&gt;wrapPageElement&lt;/code&gt; is a &lt;em&gt;child&lt;/em&gt; of &lt;code&gt;wrapRootElement&lt;/code&gt; as you can see in the following image:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:916px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/4853e0cab1282b523c9789036d541a24/9cf12/their-relationship-in-html-dark.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:60.83333333333334%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAMABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAQAF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAByoBiP//EABQQAQAAAAAAAAAAAAAAAAAAACD/2gAIAQEAAQUCX//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABQQAQAAAAAAAAAAAAAAAAAAACD/2gAIAQEABj8CX//EABoQAAICAwAAAAAAAAAAAAAAAAABEBEhMWH/2gAIAQEAAT8h3kvpY3P/2gAMAwEAAgADAAAAEIgv/8QAFREBAQAAAAAAAAAAAAAAAAAAABH/2gAIAQMBAT8QR//EABURAQEAAAAAAAAAAAAAAAAAAAAR/9oACAECAQE/EFf/xAAbEAEAAgIDAAAAAAAAAAAAAAABABEhYRBBUf/aAAgBAQABPxAQWw+xB2juyjFEvRx//9k=&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;their relationship in html&quot; title=&quot;wrapRootElement vs wrapPageElement&quot; src=&quot;/static/4853e0cab1282b523c9789036d541a24/9cf12/their-relationship-in-html-dark.jpg&quot; srcSet=&quot;/static/4853e0cab1282b523c9789036d541a24/a5e48/their-relationship-in-html-dark.jpg 480w,/static/4853e0cab1282b523c9789036d541a24/9cf12/their-relationship-in-html-dark.jpg 916w&quot; sizes=&quot;(max-width: 916px) 100vw, 916px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;wrapRootElement vs wrapPageElement&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;Additionally, &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/issues/10688#issuecomment-450353014&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;wrapPageElement is a child of the router&lt;/a&gt;—&lt;code&gt;wrapRootElement&lt;/code&gt; is not—so it has access to the router props. You can access those props if you destructure the &lt;code&gt;props&lt;/code&gt; field from the first argument:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-browser.js|gatsby-ssr.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;wrapPageElement&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the following snippet you can see an example of that &lt;code&gt;props&lt;/code&gt; field:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;path&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;location&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;href&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;http://localhost:8001/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;ancestorOrigins&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {},&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;origin&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;http://localhost:8001&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;protocol&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;http:&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;host&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;localhost:8001&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;hostname&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;localhost&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;port&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;8001&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;pathname&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;search&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;hash&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;state&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;key&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;initial&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;pageResources&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;json&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;pageContext&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;isCreatedByStatefulCreatePages&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;page&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;componentChunkName&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;component---src-pages-index-js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;path&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;webpackCompilationHash&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;4987305ccd829dc361b7&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;uri&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;pageContext&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;isCreatedByStatefulCreatePages&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;pathContext&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;isCreatedByStatefulCreatePages&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As a result, &lt;code&gt;wrapPageElement&lt;/code&gt; renders every time the page changes—&lt;code&gt;wrapRootElement&lt;/code&gt; does not—making it ideal for &lt;a href=&quot;/page-transitions-in-gatsby/&quot;&gt;complex page transitions&lt;/a&gt;, or for stuff that need the page path, like an &lt;a href=&quot;/gatsby-react-intl-example/&quot;&gt;internationalization context provider&lt;/a&gt; for example. On the other hand, because &lt;code&gt;wrapRootElement&lt;/code&gt; doesn’t render when the page changes, it’s a good fit for context providers that don’t need the page, like theme or global application state providers. And that’s their biggest difference.&lt;/p&gt;&lt;p&gt;One similarity they share is that they both &lt;em&gt;mount only once&lt;/em&gt;, as opposed to a regular &lt;code&gt;Layout&lt;/code&gt; component—that you use inside your pages—that &lt;em&gt;will unmount&lt;/em&gt; every time the page changes.&lt;/p&gt;&lt;p&gt;Finally, if you don’t provide an implementation for &lt;code&gt;wrapPageElement&lt;/code&gt; in &lt;code&gt;gatsby-ssr.js&lt;/code&gt;, it will use the implementation from &lt;code&gt;gatsby-browser.js&lt;/code&gt;. This is not true for &lt;code&gt;wrapRootElement&lt;/code&gt;.&lt;/p&gt;&lt;h2 id=&quot;conclusion&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Coming back to the initial question, yes, you can use &lt;code&gt;wrapPageElement&lt;/code&gt; element for everything, but it’s better to use it only for providers that need the router props, or for page transition layouts, and use &lt;code&gt;wrapRootElement&lt;/code&gt; for any other provider, like theme and global state providers.&lt;/p&gt;&lt;h2 id=&quot;extra&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#extra&quot;&gt;Extra&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Here I list some links and the code I used to find the differences.&lt;/p&gt;&lt;h3 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://www.gatsbyjs.org/docs/browser-apis/#wrapRootElement&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;wrapRootElement documentation&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.gatsbyjs.org/docs/browser-apis/#wrapPageElement&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;wrapPageElement documentation&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/gatsbyjs/gatsby/issues/10688#issuecomment-450353014&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub issue&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;code&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#code&quot;&gt;Code&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The &lt;code&gt;gatsby-browser.js&lt;/code&gt; file:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-browser.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Layout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./src/components/Layout&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;wrapRootElement&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;restProps&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;wrapRootElement&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;restProps&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;wrapPageElement&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;restProps&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// &amp;lt;Layout name=&amp;quot;wrapPageElement&amp;quot; props={{}} args={args} mode=&amp;quot;browser&amp;quot;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;wrapPageElement&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;restProps&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;browser&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And the &lt;code&gt;Layout&lt;/code&gt; component:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/Layout.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { useEffect } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; Layout mounted.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; Layout restProps:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; Layout arguments:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [])&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; Layout rendered.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;data-name&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;data-mode&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk39 { color: #C789D6; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Create a pre-commit hook]]></title><description><![CDATA[Create a pre-commit hook with husky and lint-staged, and preserve the quality of your code]]></description><link>https://markoskon.com/create-a-pre-commit-hook-with-husky-and-lint-staged/</link><guid isPermaLink="false">https://markoskon.com/create-a-pre-commit-hook-with-husky-and-lint-staged/</guid><pubDate>Tue, 20 Aug 2019 12:25:00 GMT</pubDate><content:encoded>&lt;p&gt;A pre-commit hook preserves the quality of your code by running &lt;em&gt;lint&lt;/em&gt;, &lt;em&gt;format&lt;/em&gt;, and/or &lt;em&gt;test&lt;/em&gt; scripts before commits. It prevents commits if it finds a problem in the code, or, in other words, if one of the previous scripts fails. A popular tool that is used for setting up pre-commit hooks is &lt;a href=&quot;https://github.com/typicode/husky&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;husky&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&lt;code&gt;husky&lt;/code&gt;, is often used along with another tool the &lt;a href=&quot;https://github.com/okonet/lint-staged&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;lint-staged&lt;/code&gt;&lt;/a&gt;. As the name suggests, &lt;code&gt;lint-staged&lt;/code&gt; improves the performance of your pre-commit hook by allowing you to run scripts only against the staged files. For example, you don’t have to run the &lt;code&gt;lint&lt;/code&gt; script for the entire project but only for the files that changed.&lt;/p&gt;&lt;h2 id=&quot;install-dependencies&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#install-dependencies&quot;&gt;Install dependencies&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let’s see how you can create a pre-commit hook with &lt;code&gt;husky&lt;/code&gt; and &lt;code&gt;lint-staged&lt;/code&gt;. First, install the dependencies:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add -D husky lint-staged&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;configure-husky&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#configure-husky&quot;&gt;Configure husky&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Then, configure &lt;code&gt;husky&lt;/code&gt; to run the &lt;code&gt;lint-staged&lt;/code&gt; script before you commit the code:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;package.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;pre-commit-hook&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;private&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;version&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;1.0.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;main&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;src/index.js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;license&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;MIT&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;scripts&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {},&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;husky&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;hooks&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;pre-commit&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;lint-staged&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;By the way, you can &lt;a href=&quot;https://github.com/typicode/husky/blob/master/DOCS.md#supported-hooks&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;create more Git hooks&lt;/a&gt; with &lt;code&gt;husky&lt;/code&gt;; you are not restricted to pre-commit hooks.&lt;/p&gt;&lt;h2 id=&quot;linting&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#linting&quot;&gt;Linting&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You now have to configure &lt;code&gt;lint-staged&lt;/code&gt;. The following script runs ESLint against the staged files and fails—it won’t commit the code—if it finds a lint error:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;package.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;pre-commit-hook&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;scripts&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;lint&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint --ext js,jsx src&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;husky&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;hooks&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;pre-commit&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;lint-staged&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;lint-staged&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;*.{js,jsx}&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Notice that you only run the &lt;code&gt;eslint&lt;/code&gt; command in the &lt;code&gt;lint-staged&lt;/code&gt; script and not the &lt;code&gt;lint&lt;/code&gt; script I highlighted above. If you run the latter, it would run ESLint against the entire project &lt;em&gt;multiple times&lt;/em&gt;—for each staged file— and would slow down the pre-commit hook without a reason. Needless to say that I’ve made that mistake in the past.&lt;/p&gt;&lt;h2 id=&quot;formatting&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#formatting&quot;&gt;Formatting&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;In addition to linting, a pre-commit hook can also &lt;em&gt;format&lt;/em&gt; the code. A popular formatting tool is Prettier. Depending on &lt;a href=&quot;/configuring-eslint-with-prettier/&quot;&gt;how you configured Prettier with ESLint&lt;/a&gt;, the format command may differ. In the following example, let’s assume that you &lt;a href=&quot;/configuring-eslint-with-prettier/#2-run-prettier-with-eslint&quot;&gt;configured ESLint to run Prettier&lt;/a&gt; (this is the best way), and as a result, you can run both tools with the &lt;code&gt;eslint --fix&lt;/code&gt; command:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;package.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;pre-commit-hook&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;husky&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;hooks&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;pre-commit&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;lint-staged&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;lint-staged&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;*.{js,jsx}&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint --fix&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;git add&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;note&quot;&gt;If you use &lt;a href=&quot;https://github.com/prettier/prettier-eslint&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;prettier-eslint&lt;/code&gt;&lt;/a&gt;, you run &lt;code&gt;prettier-eslint --write&lt;/code&gt;; if you use only Prettier, you run &lt;code&gt;prettier --write&lt;/code&gt;.&lt;/div&gt;&lt;p&gt;After you format the code, you run &lt;code&gt;git add&lt;/code&gt; to stage any JavaScript files that changed after the formatting.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;From version 10 onwards, you don’t have to use &lt;code&gt;git add&lt;/code&gt; to stage the files because &lt;code&gt;lint-staged&lt;/code&gt; adds them automatically in the commit to &lt;a href=&quot;https://github.com/okonet/lint-staged/releases/tag/v10.0.0&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;prevent race conditions.&lt;/a&gt; In the next examples, I will omit it.&lt;/div&gt;&lt;p&gt;But because we can run ESLint only against our JavaScript files, the rest of our files—&lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;, &lt;abbr title=&quot;JavaScript Object Notation&quot;&gt;JSON&lt;/abbr&gt;, e.t.c.—remain unformatted. Let’s fix that by creating another file rule that runs prettier to format the remaining files:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;package.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;pre-commit-hook&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;husky&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;hooks&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;pre-commit&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;lint-staged&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;lint-staged&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;*.{js,jsx}&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint --fix&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;*.{md,mdx,json,css,scss,yaml,yml}&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;prettier --write&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See the &lt;a href=&quot;https://github.com/okonet/lint-staged#examples&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;lint-staged documentation&lt;/a&gt; for more examples.&lt;/p&gt;&lt;h2 id=&quot;optional-testing&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#optional-testing&quot;&gt;Optional testing&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Finally, you can run a test script— in this case with &lt;a href=&quot;https://jestjs.io/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Jest&lt;/a&gt;—in your &lt;code&gt;lint-staged&lt;/code&gt; script:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;package.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;pre-commit-hook&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;husky&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;hooks&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;pre-commit&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;lint-staged&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;lint-staged&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;*.{js,jsx}&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint --fix&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;jest --findRelatedTests --bail&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;*.{md,mdx,json,css,scss,yaml,yml}&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;prettier --write&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;--findRelatedTests&lt;/code&gt; flag instructs Jest to check if the staged files have tests and run only those tests. Additionally, with the &lt;code&gt;--bail&lt;/code&gt; flag, Jest will stop testing if a single test fails.&lt;/p&gt;&lt;p&gt;Keep in mind, that most people prefer to run only lint and format scripts in their pre-commit hooks and leave the test scripts for Continuous Integration. But for simple projects, it’s ok to run test scripts too.&lt;/p&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/typicode/husky/blob/master/DOCS.md&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Husky documentation&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/okonet/lint-staged&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;lint-staged&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk39 { color: #C789D6; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Unit testing with react-scripts]]></title><description><![CDATA[Write unit tests with react-scripts to quickly test some code if you don’t want to set up a build process just for testing.]]></description><link>https://markoskon.com/unit-testing-with-react-scripts/</link><guid isPermaLink="false">https://markoskon.com/unit-testing-with-react-scripts/</guid><pubDate>Mon, 19 Aug 2019 16:20:00 GMT</pubDate><content:encoded>&lt;p&gt;You can use &lt;a href=&quot;https://www.npmjs.com/package/react-scripts&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;react-scripts&lt;/a&gt; to write &lt;em&gt;unit tests&lt;/em&gt; without setting up a build process with Babel and Webpack/Rollup. It’s useful when you want to quickly test an idea, but you’re not sure if you want to create a library yet. It can also be useful when your code lives inside a yarn workspace and doesn’t need a build process.&lt;/p&gt;&lt;h2 id=&quot;install-react-scripts&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#install-react-scripts&quot;&gt;Install react-scripts&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Install &lt;code&gt;react-scripts&lt;/code&gt; as a &lt;code&gt;devDependency&lt;/code&gt; by typing in your terminal:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add -D react-scripts&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;write-test-scripts&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#write-test-scripts&quot;&gt;Write test scripts&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Create some &lt;em&gt;test scripts&lt;/em&gt; in your &lt;code&gt;package.json&lt;/code&gt;, that will help you run the tests:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;package.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;scripts&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;test&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;react-scripts test&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;test:ci&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;cross-env CI=true react-scripts test&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;test:ci:alt&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;react-scripts test --ci --watchAll=false&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;test:jsdom&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;yarn test --env=jsdom&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;test:staged&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;yarn test:ci --findRelatedTests&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;test:coverage&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;yarn test:ci --coverage&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;what-the-test-scripts-do&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#what-the-test-scripts-do&quot;&gt;What the test scripts do&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;The &lt;code&gt;test&lt;/code&gt; script runs the tests in watch mode—which is the default option.&lt;/li&gt;&lt;li&gt;If you want to &lt;em&gt;run the tests and exit&lt;/em&gt;, you can set the &lt;code&gt;CI&lt;/code&gt; environmental variable to &lt;code&gt;true&lt;/code&gt;. That’s what the &lt;code&gt;test:ci&lt;/code&gt; script does, with the help of the &lt;a href=&quot;https://www.npmjs.com/package/cross-env&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;cross-env&lt;/a&gt; package. An alternative to that is to set the &lt;code&gt;--watchAll&lt;/code&gt; flag to &lt;code&gt;false&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;If your tests require the &lt;abbr&gt;DOM&lt;/abbr&gt;—if you are testing React components for example—you can use the &lt;code&gt;test:jsdom&lt;/code&gt; script which sets the &lt;code&gt;--env&lt;/code&gt; flag to &lt;code&gt;jsdom&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;The &lt;code&gt;test:staged&lt;/code&gt; script is useful for running tests with a &lt;a href=&quot;/create-a-pre-commit-hook-with-husky-and-lint-staged/&quot;&gt;pre-commit hook&lt;/a&gt;—with &lt;a href=&quot;https://www.npmjs.com/package/husky&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;husky&lt;/a&gt; and &lt;a href=&quot;https://www.npmjs.com/package/lint-staged&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;lint-staged&lt;/a&gt; for example.&lt;/li&gt;&lt;li&gt;Finally, the &lt;code&gt;test:coverage&lt;/code&gt; script runs the tests and creates a coverage report. You can &lt;a href=&quot;https://create-react-app.dev/docs/running-tests#configuration&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;configure the coverage script&lt;/a&gt; further if you want.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;write-tests&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#write-tests&quot;&gt;Write tests&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;To write tests, use the &lt;code&gt;test&lt;/code&gt; or &lt;code&gt;it&lt;/code&gt; functions and &lt;em&gt;assert&lt;/em&gt; your logic with the &lt;code&gt;expect&lt;/code&gt; function. You can optionally &lt;em&gt;organize&lt;/em&gt; your tests inside a &lt;code&gt;describe&lt;/code&gt; function. In the following snippet, I wrote some tests for a “flatten” function, that takes a nested array as input and returns a flat array.&lt;/p&gt;&lt;p&gt;The tests:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/flatten.test.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; flatten &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./flatten&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Flatten tests:&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Flattens an array.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;nestedArray&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;flatArray&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;nestedArray&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toEqual&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;flatArray&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Returns empty array when the input is an empty array.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;expectedResult&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toEqual&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;expectedResult&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Infinite nesting tests:&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Goes 4 levels deep.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;nestedArray&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]]], [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;flatArray&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;nestedArray&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toEqual&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;flatArray&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;describe&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Exact level tests:&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Goes exactly two levels deep.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;nestedArray&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]], &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;flatArray&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;nestedArray&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toEqual&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;flatArray&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The flatten function:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/flatten.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;level&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;9999&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  if &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;isArray&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; return &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;shouldGoDeeper&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;lvl&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;lvl&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; + &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &amp;lt;= &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;level&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toFlat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;lvl&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    if &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;shouldGoDeeper&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;lvl&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &amp;amp;&amp;amp; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;isArray&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      return &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toFlat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;lvl&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; + &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    return &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;concat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;item&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toFlat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [])&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;flatten&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;useful-links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#useful-links&quot;&gt;Useful links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://create-react-app.dev/docs/running-tests&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Create React App - Running Tests.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://jestjs.io/docs/en/expect&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Jest Expect.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://testing-library.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Integration and &lt;abbr title=&quot;End-to-End&quot;&gt;E2E&lt;/abbr&gt; testing with testing-library.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://create-react-app.dev/docs/debugging-tests#debugging-tests-in-visual-studio-code&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Debugging Tests in Visual Studio Code&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk39 { color: #C789D6; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Useful VS Code shortcuts]]></title><description><![CDATA[You can find here some practical VS Code shortcuts I use all the time that will help you improve your productivity.]]></description><link>https://markoskon.com/useful-vscode-shortcuts/</link><guid isPermaLink="false">https://markoskon.com/useful-vscode-shortcuts/</guid><pubDate>Sun, 18 Aug 2019 12:10:00 GMT</pubDate><content:encoded>&lt;p&gt;In this post, you can find some practical VS Code shortcuts that can improve your productivity. They are shortcuts for navigating inside a file and between files, for text selection, and more. In the first section, you’ll see how you can change a shortcut.&lt;/p&gt;&lt;h2 id=&quot;configure-shortcuts&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#configure-shortcuts&quot;&gt;Configure shortcuts&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;To change the default shortcuts, first, open the &lt;em&gt;Go to File&lt;/em&gt; dropdown with &lt;code&gt;Ctrl + P&lt;/code&gt;. Then, type the greater-than sign &lt;code&gt;&amp;gt;&lt;/code&gt; to bring up the &lt;em&gt;Command Palette&lt;/em&gt;. Finally, type &lt;code&gt;&amp;quot;shortcuts&amp;quot;&lt;/code&gt;, and select the &lt;em&gt;Open Keyboard Shortcuts&lt;/em&gt; from the dropdown as shown in the video below.&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/571fea95179e2cf7cad1921a98a01cdc/keyboard-shortcuts.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/120c50fb7e39c1e90d9ec614cdc98d7f/keyboard-shortcuts.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/7db49e29f8ca893ec18e849f91013f4b/keyboard-shortcuts.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;How to &lt;em&gt;Open Keyboard Shortcuts&lt;/em&gt;&lt;/figcaption&gt;&lt;/figure&gt;&lt;div class=&quot;note&quot;&gt;You can open the command palette with &lt;code&gt;Ctrl + Shift + P&lt;/code&gt;.&lt;/div&gt;&lt;p&gt;This will open Keyboard Shortcuts in a new &lt;em&gt;open editor&lt;/em&gt;. From there, you can type the name of the shortcut you want to change or its key-binding. You can also search for keywords from within the command palette, without opening the keyboard shortcuts, but you can’t search for a shortcut by the keybinding. I find it useful to right-click to open the context menu and select what I want to change from the shortcut. For example, many keywords have a &lt;em&gt;when clause&lt;/em&gt;. That means that you can activate them under specific conditions. In the next video, I change the default shortcut for &lt;em&gt;Select All occurrences&lt;/em&gt;—notice that it has a when clause when the editor has focus.&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/323896a940dddea873be5c383c8bf18e/change-keybinding.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/5e7ffe05328e8c75a7f89640932de015/change-keybinding.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/e0193d160eacc7556d67a8670080ad77/change-keybinding.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;How to change a shortcut&lt;/figcaption&gt;&lt;/figure&gt;&lt;h2 id=&quot;select-text&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#select-text&quot;&gt;Select text&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;This section contains shortcuts that you can use to select text efficiently.&lt;/p&gt;&lt;h3 id=&quot;select-nextprevious-occurrence&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#select-nextprevious-occurrence&quot;&gt;Select next/previous occurrence&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Select some text and then press &lt;code&gt;Ctrl + D&lt;/code&gt; to select the &lt;em&gt;next occurrence&lt;/em&gt; of that text. In the video below, I use that shortcut to rename some React components.&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/6dba5b38404b5157adf99365b96f6b48/next-occurence.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/2ca8b722bba0d7d31693ae73e1121e20/next-occurence.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/9d2007e1f56fa9e13ea44ab3486fd743/next-occurence.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Add next occurrence into the selection&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;You can use this shortcut to rename, for example, a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element to a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; or remove some double-quotes. There is a shortcut to select the &lt;em&gt;previous occurrence&lt;/em&gt;, but it’s not enabled by default. It’s called &lt;em&gt;Add Selection To Previous Find Match.&lt;/em&gt; I configured it to &lt;code&gt;Ctrl + Shift + D&lt;/code&gt; because it’s similar to the &lt;code&gt;Ctrl + D&lt;/code&gt; of the next occurrence, so it’s easy to remember.&lt;/p&gt;&lt;h3 id=&quot;select-all-occurrences&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#select-all-occurrences&quot;&gt;Select all occurrences&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Select some text and then press &lt;code&gt;Ctrl + Shift + L&lt;/code&gt; to select &lt;em&gt;all occurrences&lt;/em&gt; of that text. It can be useful when you want to rename a component for example. I changed this shortcut to &lt;code&gt;Ctrl + Shift + A&lt;/code&gt; because I associate the &lt;code&gt;A&lt;/code&gt; with &lt;em&gt;All&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;If you want to avoid editing something accidentally, before you press &lt;code&gt;Ctrl + Shift + L&lt;/code&gt;, press &lt;code&gt;Ctrl + F&lt;/code&gt; instead and check how many times the text is present in the search pop up:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:810px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/a27bb52027fb0905a20a6d386ff648d5/ac7f0/search-pop-up-occurrences.png&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:69.16666666666667%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAA7DAAAOwwHHb6hkAAACKElEQVQoz02SZ27cMBCFdQ17JYq9c8VOSt7iNZD8zxkC5P5HCCQh5QMJDPvjmxl67znnWmur9fF4Hu1xfzyez89t21Ipr5ReKaXW13WrtZZSW+u9r7W2wXsvOCslG2umCczzDBFGCEOEMMaA0A7mH2/vkgttLGOMECKFVFIxxga/LFfngvfXnUUr4dbvfv3yIS6hLKV9lfaLsp9gdlwIpQghRmsMIcFoCDEuPsSUpVRKKc45F4oLwU44V0IkCAOElFKMMSakr1uKcXFuINIS6ShXEIwAAAjhfAAhRAidAUBoBGACYBpHRGhZ7yE35cJglJJKVcOLYZQxa4ySUkolhJBq/9geSLHfB8AMAKY8f7xyv/nyMUiCOcGKEmO0ddZofb0uhODLZRzHcZomsDPBgxkAREhcn2m9+7IOMcYQYwghHbQjGVdny2K8s8kvOefee4yxlJpzIoTU2q5uQYQNJacYYqvNGCOEDN5ba7XWt0UsWloptJLO7UnS2kgp4Qw145JxismAmD6VjeN0GcfLKXcc3y7jPjyUv73v0+fSNE17PxiMdVLrbHi1nFNKCdntUlopKZVWWjPOs1VGcsGY4OyPCztDzanW2mvZer9lf2+51RpjWNfttbXPj15a/3arz3X/cQwBY/z3/NBaKUe95lIeNa3J15x2e2p7tHQrcVl8zPnqrPe7qYz9e3xgjFFKz3LClBG6Z5tzwTkne4UJBOG59Sye/1SD3/56iesDGfdZAAAAAElFTkSuQmCC&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;The number of occurrences as shown in the Search pop-up&quot; title=&quot;The number of occurrences as shown in the Search pop-up&quot; src=&quot;/static/a27bb52027fb0905a20a6d386ff648d5/ac7f0/search-pop-up-occurrences.png&quot; srcSet=&quot;/static/a27bb52027fb0905a20a6d386ff648d5/3166f/search-pop-up-occurrences.png 480w,/static/a27bb52027fb0905a20a6d386ff648d5/ac7f0/search-pop-up-occurrences.png 810w&quot; sizes=&quot;(max-width: 810px) 100vw, 810px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;The number of occurrences as shown in the Search pop-up&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;If that doesn’t help, you can also press &lt;code&gt;F3&lt;/code&gt; to cycle through the occurrences to make sure you won’t overwrite something by accident. You can also get the number of selections from the &lt;em&gt;status bar&lt;/em&gt;, at the bottom of your screen:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:611px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/ab43e5d3370b66e05f1f70089222e1b0/34df8/number-of-selections-status-bar.png&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:79.16666666666667%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAIAAACZeshMAAAACXBIWXMAAAsTAAALEwEAmpwYAAACsUlEQVQoz02TW2scNxTH5yOkubi7q+todB1pNJoZzc27O7sU2yXXQmrc0pjEoS8pfcwHyFtIAslLCc3HDbsbG/8Qh6Mj/py/dFDinFNaSany3GqttVLGGCmlMSY3Rsk9SiKE8DVlWZYhNE2TwD0IIXid3WwXEC72GdpzUCKEGGN1E2OMyaFyK/4AYaQgdBAiQg6aGzEhpIlxHLqEEoIJ3a8dGOOUkBkhKwjf/3TXQQjw7uS2bSGFMkZZlxhb8rySvhV5rY3xvii85xmL/S/Ldg0xtLk1WgMAbsRVCHXbq9AkLsTYjeNq6sfjGNvNNK1Wq+12u5y24zTVIXTD8ersnFB23RwxjGPbDn2X1HVdNEsX16rZ6mZty1i1x23b9V0/jEOMsW3bcbUlhOK9GCGUMlZVdQghUXukFJTxVBrKFWUiyzLGmBCC80wIkaYUIXhjm1Ja1XXdNImVwgguMnYYsnO7GyoptNZZxo0xWinBOYTw+rVxmqaucD6EJPdN8L5r27bbhXEc6yaOm7MuxlD6se/bGL33h0EcbGcsW47L1fGUCCmVUiGEMgTnnLW5sa4aT40UVnKVsYyleC+FGM8IoQhRmjrmirRM5ov5YgHms9n8FrOfj3ZVACAACEJyaIjx6wcPGgAgTTXSGRRJrEpnZGnzwuhQWJ/rOpRl4Srvjc2FllzyOVwcgTkHs1f37gC4wAjwOhUDT+L212o6qdYn9fq0Xp+6YeOawYZGh1hx/VAWj4Q7y+wpy08yuxbuEVU2r5qzdbWpknt/f8Ov/8ve/M//+SbffEVXX+5Pl9n2YjadP26fXvz5/vnLT+cvPlxcfnx++fG3qy//Pnm7+ePdnauvR399TvpnL7uZHLrNw8e/s5RyLnaTJIRQKhHq5gsPoYEwh8BDUEJYAEB3Hw0ijL4DjCugPyctw7sAAAAASUVORK5CYII=&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;The number of selections as shown in the Status Bar&quot; title=&quot;The number of selections as shown in the Status Bar&quot; src=&quot;/static/ab43e5d3370b66e05f1f70089222e1b0/34df8/number-of-selections-status-bar.png&quot; srcSet=&quot;/static/ab43e5d3370b66e05f1f70089222e1b0/3166f/number-of-selections-status-bar.png 480w,/static/ab43e5d3370b66e05f1f70089222e1b0/34df8/number-of-selections-status-bar.png 611w&quot; sizes=&quot;(max-width: 611px) 100vw, 611px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;The number of selections as shown in the Status Bar&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;h3 id=&quot;smart-select&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#smart-select&quot;&gt;Smart select&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;I find kind of hard to explain what &lt;em&gt;smart select&lt;/em&gt; does, so I suggest to see for yourself in the video below:&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/ab994a27b2dda7f0b8f42a7bce02c2a6/smart-select.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/bf7823099c90d62488843d54cf36f228/smart-select.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/a2ae5397f461ce900adca1929144db7d/smart-select.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Smart select&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;Smart select can be useful when you want to select large blocks of code. In the example above, I select all the render code inside a React component. To do that, you place your cursor inside the code you want to select, and then you press &lt;code&gt;Shift + Alt + Right Arrow&lt;/code&gt; to gradually expand the selection. If you messed it up and selected more than you wanted, press &lt;code&gt;Shift + Alt + LeftArrow&lt;/code&gt;—or just &lt;code&gt;LeftArrow&lt;/code&gt; since you are already holding &lt;code&gt;Shift + Alt&lt;/code&gt;—to shrink the selection.&lt;/p&gt;&lt;p&gt;Smart Select doesn’t work well with &lt;abbr title=&quot;JavaScript XML&quot;&gt;JSX&lt;/abbr&gt; tags. By that I mean it doesn’t gradually select the parent tags but instead selects all the content inside the render method at once. For that reason, I use the &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=closedcontour.very-smart-select&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Very Smart Select extension&lt;/a&gt;.&lt;/p&gt;&lt;h3 id=&quot;undo-cursor-position&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#undo-cursor-position&quot;&gt;Undo cursor position&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;If you used select next/previous occurrence, and you selected more text than you wanted, you can press &lt;code&gt;Ctrl + U&lt;/code&gt; to return to the &lt;em&gt;previous cursor position&lt;/em&gt;. This also works with smart select or if you navigate between the top/bottom brackets that you’ll see in the navigation section. One problem with this shortcut, though, is that it’s close to the &lt;em&gt;redo&lt;/em&gt; keyword &lt;code&gt;Ctrl + Y&lt;/code&gt;. So before you press it, spend some seconds and try to recall the correct keybinding.&lt;/p&gt;&lt;h3 id=&quot;select-words&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#select-words&quot;&gt;Select words&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;You can press &lt;code&gt;Ctrl + Shift + Left/Right Arrow&lt;/code&gt; to select words. To move the cursor from word to word, you can press &lt;code&gt;Ctrl + Left/Right Arrow&lt;/code&gt;.&lt;/p&gt;&lt;h3 id=&quot;vertical-selection&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#vertical-selection&quot;&gt;Vertical selection&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;You can vertically select text with &lt;code&gt;Ctrl + Alt + Down/Up Arrow&lt;/code&gt;. If you mess up the selection, press &lt;code&gt;Escape&lt;/code&gt; and try again. You can also press the &lt;code&gt;Ctrl + U&lt;/code&gt; shortcut you saw in the previous section to &lt;em&gt;undo the cursor position&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;A use case for the vertical selection shortcut is to copy a component’s props—in other words, the function parameters—and paste them in the line you want to &lt;em&gt;render&lt;/em&gt; the component. Check the following video for an example:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Copy the props with vertical select:&lt;/li&gt;&lt;/ol&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/3041db9309dfb5bdf775a74e28216d74/vertical-select.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/2c86dc801bea50f0ee8b493281599289/vertical-select.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/dfaa5a3ec0b4a457ac964ef9f193a8c7/vertical-select.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Vertical select&lt;/figcaption&gt;&lt;/figure&gt;&lt;ol start=&quot;2&quot;&gt;&lt;li&gt;Paste the selection in the render method. I’m also selecting the &lt;a href=&quot;#select-nextprevious-occurrence&quot;&gt;previous occurrence&lt;/a&gt; to replace the comma with &lt;code&gt;={&amp;quot;&amp;quot;}&lt;/code&gt;:&lt;/li&gt;&lt;/ol&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/fae289d148194f385111605be6653319/paste-vertical-selection.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/b7ae265463ef75fad97e57bd2ca1358c/paste-vertical-selection.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/99b75818744a14623ca77a042739a29c/paste-vertical-selection.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Paste vertical selection&lt;/figcaption&gt;&lt;/figure&gt;&lt;h2 id=&quot;undoredo&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#undoredo&quot;&gt;Undo/Redo&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You probably know that you can undo recent changes with &lt;code&gt;Ctrl + Z&lt;/code&gt;. But what if you go too far and discard some changes that you want? Press &lt;code&gt;Ctrl + Y&lt;/code&gt; to redo the changes. This combination may not seem that impressive, but it’s really useful in practice.&lt;/p&gt;&lt;h2 id=&quot;navigation&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#navigation&quot;&gt;Navigation&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;This section contains shortcuts for navigating inside an open file, different files, or different views in VS Code. Instead of searching for the file in the explorer with your mouse, you can spend some seconds to think about what you want to accomplish, recall the shortcut, and use it to navigate fast without moving your hands away from the keyword.&lt;/p&gt;&lt;h3 id=&quot;move-to-the-startend-of-a-bracket&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#move-to-the-startend-of-a-bracket&quot;&gt;Move to the start/end of a bracket.&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Imagine that you are at the top bracket &lt;code&gt;{&lt;/code&gt; of a long function, and you want to go fast to the bottom bracket &lt;code&gt;}&lt;/code&gt;. In this case, you can break the function into smaller functions because it does more than it should. An alternative is to press &lt;code&gt;Ctrl + Shift + \&lt;/code&gt; (backslash) to toggle between the top and bottom brackets. I don’t use it frequently, but when I do, I find it really useful.&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/70ea08b255f9a8e9d6dfbdf90747d2e4/top-bottom-brackets.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/4b687535fcd4936f5918329a65fddf00/top-bottom-brackets.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/91430d7ee1d999c8de529afa4a6c143e/top-bottom-brackets.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Top/bottom bracket navigation&lt;/figcaption&gt;&lt;/figure&gt;&lt;h3 id=&quot;other-ways-to-move-quickly-inside-a-file&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#other-ways-to-move-quickly-inside-a-file&quot;&gt;Other ways to move quickly inside a file&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;Page Up&lt;/code&gt; and &lt;code&gt;Page Down&lt;/code&gt; can help you move quickly when you are inside a file. Again, the undo cursor position &lt;code&gt;Ctrl + U&lt;/code&gt; can be useful here.&lt;/li&gt;&lt;li&gt;To go to the top of the file, press &lt;code&gt;Ctrl + Home&lt;/code&gt;, and to go to the bottom, press &lt;code&gt;Ctrl + End&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;For small distances, the &lt;code&gt;Up/Down Arrow&lt;/code&gt; keys will be enough.&lt;/li&gt;&lt;li&gt;If you know what you’re looking for, you can search for the text with &lt;code&gt;Ctrl + F&lt;/code&gt; and cycle through the occurrences with the &lt;code&gt;F3&lt;/code&gt; key. This is probably the fastest way to move in a long file.&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;go-to-a-specific-line&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#go-to-a-specific-line&quot;&gt;Go to a specific line&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;If you want to go to a specific line—you maybe saw the number from an error call-stack—you can first press &lt;code&gt;Ctrl + P&lt;/code&gt; to open the &lt;em&gt;Go to File&lt;/em&gt; dropdown. Then, type the &lt;em&gt;colon&lt;/em&gt; (&lt;code&gt;:&lt;/code&gt;) character, after that the line you want to go to, and finally press &lt;code&gt;Enter&lt;/code&gt; to jump to that line. An invaluable shortcut in the rare cases where you know the number of the line.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;Instead of typing the colon character to navigate to a line, you can type the at sign @ to navigate to a symbol.&lt;/div&gt;&lt;h3 id=&quot;move-to-a-different-file&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#move-to-a-different-file&quot;&gt;Move to a different file&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;If you know the name of the file, press &lt;code&gt;Ctrl + P&lt;/code&gt; to open the &lt;em&gt;Go to File&lt;/em&gt; dropdown and then type the name of the file. You can then select the file you want to open from the dropdown. If you type a generic file name like &lt;code&gt;index.js&lt;/code&gt;, you may see a lot of results. You can limit the results if you know the exact file path, for example, you can instead type &lt;code&gt;src/pages/index.js&lt;/code&gt; to get more relevant results.&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/227a49e29f94607678effd9b814a41b7/navigate-to-a-file.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/6e6b1136dd258a97a6c251c404a4070d/navigate-to-a-file.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/4acbc03bf525d727e2b6f3093e71b2c0/navigate-to-a-file.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;How to navigate to a different file.&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;One dirty trick you can use after you open the file is to save it with &lt;code&gt;Ctrl + S&lt;/code&gt;. You do that to pin the file in the open editors because if you try to open another file, you will replace it with the new file.&lt;/p&gt;&lt;p&gt;If you don’t know the name of the file, but you know what’s inside that file, you can press &lt;code&gt;Ctrl + Shift + F&lt;/code&gt; to open the &lt;em&gt;Search&lt;/em&gt; view. You can then type the text you’re looking for and open a file with the mouse. If you don’t want to use the mouse, you can press &lt;code&gt;Tab&lt;/code&gt; to select the next interactive element until you reach the result list. To select a result, you’ll have to press the &lt;code&gt;Down Arrow&lt;/code&gt; while the list is highlighted. If you press the &lt;code&gt;Shift&lt;/code&gt;, you’ll probably end up in the file you have open (aka &lt;em&gt;open editor&lt;/em&gt;).&lt;/p&gt;&lt;h3 id=&quot;navigate-to-different-views&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#navigate-to-different-views&quot;&gt;Navigate to different views&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;In the previous section, I mentioned that you can use &lt;code&gt;Ctrl + Shift + F&lt;/code&gt; to navigate to the &lt;em&gt;Search&lt;/em&gt; view. It’s useful to know the shortcuts for the other views too. You can see those shortcuts inside the UI if you hover over the view icons with your mouse. The view icons are in the left-most sidebar.&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:659px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/dfcb3b3614177e12b9038fc7c84265db/a4cc4/view-icons.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:71.25%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAOABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAQAF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAABywBqP//EABYQAQEBAAAAAAAAAAAAAAAAAAARIP/aAAgBAQABBQJVx//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABQQAQAAAAAAAAAAAAAAAAAAACD/2gAIAQEABj8CX//EABkQAQACAwAAAAAAAAAAAAAAAAEAMRAhYf/aAAgBAQABPyFY9R2uN5//2gAMAwEAAgADAAAAENDP/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPxA//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPxA//8QAGhAAAwADAQAAAAAAAAAAAAAAAAERITFRYf/aAAgBAQABPxBdeWnesZFAxRlDeLZfWf/Z&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;The view icons in the sidebar&quot; title=&quot;The view icons in the sidebar&quot; src=&quot;/static/dfcb3b3614177e12b9038fc7c84265db/a4cc4/view-icons.jpg&quot; srcSet=&quot;/static/dfcb3b3614177e12b9038fc7c84265db/a5e48/view-icons.jpg 480w,/static/dfcb3b3614177e12b9038fc7c84265db/a4cc4/view-icons.jpg 659w&quot; sizes=&quot;(max-width: 659px) 100vw, 659px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;The view icons in the sidebar&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;ul&gt;&lt;li&gt;To open the &lt;em&gt;Explorer&lt;/em&gt; view, press &lt;code&gt;Ctrl + Shift + E&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;To open the &lt;em&gt;Source control&lt;/em&gt; view, press &lt;code&gt;Ctrl + Shift + G&lt;/code&gt;, release the keys, and press &lt;code&gt;G&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;To open the &lt;em&gt;Extensions&lt;/em&gt; view, press &lt;code&gt;Ctrl + Shift + X&lt;/code&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;These shortcuts are easy to remember because the last key corresponds to the name of the view. For example, &lt;code&gt;E&lt;/code&gt; for the explorer view, &lt;code&gt;G&lt;/code&gt; for &lt;code&gt;git&lt;/code&gt;, and &lt;code&gt;X&lt;/code&gt; for extensions. There is also the debug view that you can open with &lt;code&gt;Ctrl + Shift + G&lt;/code&gt;, but, as I already mentioned a few million times, I use this keybinding for the &lt;em&gt;Add Selection To Previous Find Match&lt;/em&gt;.&lt;/p&gt;&lt;h2 id=&quot;shortcuts-for-terminals&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#shortcuts-for-terminals&quot;&gt;Shortcuts for terminals&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You probably know that you can open and close the terminal if you press &lt;code&gt;Ctrl + `&lt;/code&gt; (the &lt;code&gt;grave accent&lt;/code&gt; character also known as &lt;em&gt;backtick&lt;/em&gt;). This shortcut is called &lt;em&gt;View: Toggle Integrated Terminal&lt;/em&gt;. But there’s another shortcut that’s called: &lt;em&gt;View: Focus Active Editor Group.&lt;/em&gt; If you configure the latter to the same keybinding—that is &lt;code&gt;Ctrl + `&lt;/code&gt;—and you specify a &lt;em&gt;when clause&lt;/em&gt; with a value of &lt;code&gt;terminalFocus&lt;/code&gt;, you can then switch the focus between the terminal and the active editor. To add a when clause, right-click the setting and select &lt;em&gt;change when expression.&lt;/em&gt;&lt;/p&gt;&lt;p&gt;You can move from terminal to terminal with &lt;code&gt;Alt + Up/Down Arrow&lt;/code&gt; (if the terminal has focus), and you can split it (in other words, open a new terminal) with &lt;code&gt;Ctrl + Shift + 5&lt;/code&gt;. Finally, to kill the active terminal, you need to configure the &lt;em&gt;Terminal: Kill the Active Terminal Instance&lt;/em&gt; shortcut. I’ve configured mine to &lt;code&gt;Ctrl + Shift + 6&lt;/code&gt;.&lt;/p&gt;&lt;h2 id=&quot;delete-a-line&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#delete-a-line&quot;&gt;Delete a line&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;There are a lot of ways you can delete a line:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You can cut the text with &lt;code&gt;Ctrl + X&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;You can move the cursor to the line you want to delete and press &lt;code&gt;Ctrl + Shift + K&lt;/code&gt;. Use this over the cut if you don’t want to override the text inside your clipboard. By cutting some text you also copy it in your clipboard.&lt;/li&gt;&lt;li&gt;You can select the entire line with &lt;code&gt;Ctrl + L&lt;/code&gt; and then press &lt;code&gt;Delete&lt;/code&gt; to delete the selection.&lt;/li&gt;&lt;li&gt;You can press &lt;code&gt;Home&lt;/code&gt; to go at the beginning of the line, press &lt;code&gt;Shift + End&lt;/code&gt; to select the line, and finally, press &lt;code&gt;Delete&lt;/code&gt; to delete it.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;formatting&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#formatting&quot;&gt;Formatting&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;You can format an open document by pressing &lt;code&gt;Shift + Alt + F&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;You can toggle word wrap with &lt;code&gt;Alt + Z&lt;/code&gt; which is useful when working with text files.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;pressing-the-alt-key-alone&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#pressing-the-alt-key-alone&quot;&gt;Pressing the &lt;code&gt;Alt&lt;/code&gt; key alone&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Many Windows shortcuts include the &lt;code&gt;Alt&lt;/code&gt; key. For example, the &lt;code&gt;Alt + Tab&lt;/code&gt; shortcut to switch between open windows. I use that shortcut all the time, but, sometimes, I might not press it correctly, and only the &lt;code&gt;Alt&lt;/code&gt; registers. Pressing the &lt;code&gt;Alt&lt;/code&gt; key alone in Windows programs &lt;a href=&quot;https://en.wikipedia.org/wiki/Alt_key#Alt_key_pressed_alone&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;transfers the focus&lt;/a&gt; to a menu bar, and you lose focus on what you’re working on. It’s good to know that when that happens inside VS Code, you can press the &lt;code&gt;Alt&lt;/code&gt; key again to restore focus.&lt;/p&gt;&lt;h2 id=&quot;resources&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#resources&quot;&gt;Resources&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://code.visualstudio.com/docs/getstarted/keybindings&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;VS Code keybindings&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://code.visualstudio.com/docs/getstarted/tips-and-tricks&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;VS Code tips and tricks&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Fix oversized icons from react-fontawesome]]></title><description><![CDATA[If your react-fontawesome icons appear oversized when you first load the page in an SSR build, then this fix is for you.]]></description><link>https://markoskon.com/fix-oversized-icons-from-react-fontawesome/</link><guid isPermaLink="false">https://markoskon.com/fix-oversized-icons-from-react-fontawesome/</guid><pubDate>Sat, 17 Aug 2019 12:10:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;problem&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#problem&quot;&gt;Problem&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You are using &lt;a href=&quot;https://github.com/FortAwesome/react-fontawesome&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;react-fontawesome&lt;/a&gt; to render some Fontawesome icons in your app, and you notice that in an &lt;abbr&gt;SSR&lt;/abbr&gt; build your icons get huge on page load, only to shrink back to their normal size a bit later. This is what it looks like:&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/fd911f5d744cd192f6fd5e4e0a90afb1/bug-reproduction.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/2e9fca6dba66f269571f16b60eb60343/bug-reproduction.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/efff1ecb9af44f0f75212d27a10140dd/bug-reproduction.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Bug demonstration&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;And this is the code:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/** &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;@jsx&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt; jsx */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { jsx, Box } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme-ui&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { FontAwesomeIcon } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@fortawesome/react-fontawesome&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { faHeart } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@fortawesome/free-solid-svg-icons&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Layout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@affectionatedoor/gatsby-theme-ui/src/components/Layout&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Box&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;sx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        position: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;relative&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        minHeight: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;70vh&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        bg: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;mute&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;accent&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;FontAwesomeIcon&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;sx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          position: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;absolute&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          top: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;calc(50% - 20px)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          left: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;calc(50% - 20px)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;icon&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;faHeart&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;2x&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;solution&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#solution&quot;&gt;Solution&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;To solve this—assuming you installed the &lt;a href=&quot;https://www.npmjs.com/package/@fortawesome/fontawesome-svg-core&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;@fortawesome/fontawesome-svg-core&lt;/a&gt; package—you’ll have to do 2 things:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Import the &lt;code&gt;@fortawesome/fontawesome-svg-core/styles.css&lt;/code&gt; stylesheet before React loads. I’m using Gatsby, so I load the stylesheet in &lt;code&gt;gatsby-browser.js&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-browser.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@fortawesome/fontawesome-svg-core/styles.css&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Then prevent fontawesome from loading the &lt;abbr&gt;CSS&lt;/abbr&gt; styles again:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { jsx, Box } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme-ui&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { FontAwesomeIcon } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@fortawesome/react-fontawesome&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { faHeart } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@fortawesome/free-solid-svg-icons&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Layout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@affectionatedoor/gatsby-theme-ui/src/components/Layout&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { config } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@fortawesome/fontawesome-svg-core&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// You should do that in a Layout file or in `gatsby-browser.js`.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;autoAddCss&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Skipping content...&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Now the icons are displayed in their correct size, as you can see in the following gif:&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/691a3d2ce8ee50bc31a1488132fa2f1d/bug-resolved.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/1d796d6d3f28ced6668a22a5c968fbab/bug-resolved.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/f39da428ebab76964dc1077e6bf0ffd3/bug-resolved.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Bug resolved&lt;/figcaption&gt;&lt;/figure&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/FortAwesome/react-fontawesome/issues/134&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub issue&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Preserve new lines and spacing in CSS]]></title><description><![CDATA[See how you can preserve the new lines and spacing of text in HTML by using the white-space CSS property.]]></description><link>https://markoskon.com/preserve-new-lines-and-spacing/</link><guid isPermaLink="false">https://markoskon.com/preserve-new-lines-and-spacing/</guid><pubDate>Wed, 14 Aug 2019 13:20:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;problem&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#problem&quot;&gt;Problem&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You got some text (maybe from a server) that has newlines and spacing. This what the text looks like in JavaScript:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;I have a newline here&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; and some extra white           space for some reason.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now you want to display it in &lt;abbr&gt;HTML&lt;/abbr&gt;, so you render it in &lt;abbr&gt;JSX&lt;/abbr&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And this is the result:&lt;/p&gt;&lt;div style=&quot;padding:8px;background-color:#1d1d1d;color:white;display:flex;align-items:center;justify-content:center;border-radius:5px&quot;&gt;&lt;p&gt;I have a newline here
 and some extra white           space for some reason.&lt;/p&gt;&lt;/div&gt;&lt;p&gt;The newlines and spaces are ignored.&lt;/p&gt;&lt;h2 id=&quot;solution&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#solution&quot;&gt;Solution&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you want to preserve new lines and white space, you can use the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/white-space&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;white-space&lt;/a&gt; &lt;abbr&gt;CSS&lt;/abbr&gt; property with the &lt;code&gt;pre-wrap&lt;/code&gt; value:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk16&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;white-space&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;pre-wrap&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So the &lt;abbr&gt;JSX&lt;/abbr&gt; now becomes:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ whiteSpace: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;pre-wrap&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And this is what it looks like:&lt;/p&gt;&lt;div style=&quot;padding:8px;background-color:#1d1d1d;color:white;display:flex;align-items:center;justify-content:center;border-radius:5px;white-space:pre-wrap&quot;&gt;&lt;p&gt;I have a newline here
 and some extra white           space for some reason.&lt;/p&gt;&lt;/div&gt;&lt;p&gt;You can also use a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;preformatted text element&lt;/a&gt; &lt;code&gt;&amp;lt;pre&amp;gt;&lt;/code&gt;.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk16 { color: #FF6363; }
  .night-owl-no-italics .mtk15 { color: #80CBC4; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[How to break up long links with CSS]]></title><description><![CDATA[Use CSS to break up long text with overflow-wrap (aka word-wrap) or word-break.]]></description><link>https://markoskon.com/break-up-long-links/</link><guid isPermaLink="false">https://markoskon.com/break-up-long-links/</guid><pubDate>Wed, 14 Aug 2019 13:00:00 GMT</pubDate><content:encoded>&lt;h2 id=&quot;problem&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#problem&quot;&gt;Problem&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You have a really long link, for example, a link to a GitHub issue, and it overflows the container. This will usually happen in a mobile layout:&lt;/p&gt;&lt;div style=&quot;background-color:#1d1d1d;padding:8px;width:300px&quot;&gt;&lt;a href=&quot;https://github.com/facebook/react/issues/14920#issuecomment-471070149&quot; style=&quot;color:#f18fe8;word-break:initial&quot; target=&quot;noopener noreferrer&quot;&gt;https://github.com/facebook/react/issues/14920#issuecomment-471070149&lt;/a&gt;&lt;/div&gt;&lt;p&gt;This is the code for the link:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://github.com/facebook/react/issues/14920#issuecomment-471070149&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#f18fe8&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  https://github.com/facebook/react/issues/14920#issuecomment-471070149&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This can happen if you create a link in Markdown and you forget to give it a title:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;markdown&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk4&quot;&gt;## Useful links&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk37&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk4&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;https://github.com/facebook/react/issues/14920#issuecomment-471070149&lt;/span&gt;&lt;span class=&quot;mtk4&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk33&quot;&gt;https://github.com/facebook/react/issues/14920#issuecomment-471070149&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;solution&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#solution&quot;&gt;Solution&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;To solve this, either write a descriptive text for the link—the best solution—or use one of the following &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; properties:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;overflow-wrap: break-word;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/word-break&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;word-break: break-word;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;And if you do that, this is the result:&lt;/p&gt;&lt;div style=&quot;background-color:#1d1d1d;padding:8px;width:300px&quot;&gt;&lt;a href=&quot;https://github.com/facebook/react/issues/14920#issuecomment-471070149&quot; style=&quot;color:#f18fe8;word-break:break-word&quot; target=&quot;noopener noreferrer&quot;&gt;https://github.com/facebook/react/issues/14920#issuecomment-471070149&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://github.com/facebook/react/issues/14920#issuecomment-471070149&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#f18fe8&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    wordBreak: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;break-word&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  https://github.com/facebook/react/issues/14920#issuecomment-471070149&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk4 { color: #82B1FF; }
  .night-owl-no-italics .mtk33 { color: #FF869A; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Dark mode in React with Theme UI]]></title><description><![CDATA[Learn how to implement dark mode in your Gatsby application fast with the Theme UI library.]]></description><link>https://markoskon.com/dark-mode-in-react-with-theme-ui/</link><guid isPermaLink="false">https://markoskon.com/dark-mode-in-react-with-theme-ui/</guid><pubDate>Tue, 13 Aug 2019 01:00:00 GMT</pubDate><content:encoded>&lt;p&gt;A few months ago, I searched for the best dark mode solution for a React application. I &lt;a href=&quot;/dark-mode-in-react/&quot;&gt;wrote a post&lt;/a&gt; about that if you are interested. But that was three months ago, and three months is a long time in web development—not really, just trying to create some drama. Nowadays, the solution to dark mode is a lot easier and has a name: &lt;a href=&quot;https://theme-ui.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Theme UI&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;With the Theme UI library, you can style your applications &lt;em&gt;consistently&lt;/em&gt; with a &lt;em&gt;design system&lt;/em&gt; (&lt;a href=&quot;https://styled-system.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;styled-system&lt;/a&gt;) and a &lt;abbr&gt;CSS&lt;/abbr&gt;-in-&lt;abbr&gt;JS&lt;/abbr&gt; library (&lt;a href=&quot;https://emotion.sh/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;emotion&lt;/a&gt;). Additionally, Theme UI offers support for &lt;abbr&gt;MDX&lt;/abbr&gt;, and who doesn’t love &lt;abbr&gt;MDX&lt;/abbr&gt;? In the following examples, I will use Gatsby because the &lt;abbr&gt;MDX&lt;/abbr&gt; support is great. But you can &lt;a href=&quot;https://mdxjs.com/getting-started&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;use &lt;abbr&gt;MDX&lt;/abbr&gt; with many other React apps&lt;/a&gt;; you don’t have to use Gatsby.&lt;/p&gt;&lt;p&gt;Let’s see now in practice how you can add dark mode to your site with Theme UI.&lt;/p&gt;&lt;h2 id=&quot;the-easy-way&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#the-easy-way&quot;&gt;The easy way&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/MarkosKon/theme-ui-dark-mode/tree/with-custom-theme&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub repository&lt;/a&gt;. Checkout to the &lt;code&gt;with-custom-theme&lt;/code&gt; branch.&lt;/p&gt;&lt;p&gt;The easy way to add Theme UI in your application is to use a &lt;a href=&quot;https://www.npmjs.com/package/@affectionatedoor/gatsby-theme-ui&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Gatsby theme&lt;/a&gt; I made. There’s nothing special about that theme; it just setups Theme UI and exposes &lt;a href=&quot;https://github.com/MarkosKon/theme-playground/tree/master/packages/gatsby-theme-ui/src/components&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;some &lt;abbr&gt;UI&lt;/abbr&gt; components&lt;/a&gt; I use in my projects. Those components include &lt;a href=&quot;/gatsby-background-image-example/&quot;&gt;background images&lt;/a&gt;, &lt;a href=&quot;/scroll-reveal-animations-with-react-spring/&quot;&gt;animation on scroll&lt;/a&gt; components, buttons, and many others.&lt;/p&gt;&lt;p&gt;But before you can enjoy dark mode in your application, you’ll have to do 4 things:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Create a new &lt;code&gt;hello-world&lt;/code&gt; starter:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;gatsby new &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; git@github.com:gatsbyjs/gatsby-starter-hello-world.git&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Install my theme:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add @affectionatedoor/gatsby-theme-ui&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Add it as a plugin in &lt;code&gt;gatsby-config.js&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-config.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    plugins: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@affectionatedoor/gatsby-theme-ui&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Use the &lt;code&gt;Layout&lt;/code&gt; component from my theme in the index page:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/index.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Layout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@affectionatedoor/gatsby-theme-ui/src/components/Layout&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Hello world!&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;If you start the development server and visit the homepage, you will see this screen:&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/abca25b2be8c02a971c22a65592a2f4d/gatsby-theme-ui.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/f578e1d7b1d1c58b60be575039ef31f3/gatsby-theme-ui.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/402cfc0e94d1160d411c44eb6044ece2/gatsby-theme-ui.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Homepage with my Gatsby theme&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;You can also try to build and serve the app locally with &lt;code&gt;yarn build&lt;/code&gt; and &lt;code&gt;yarn serve&lt;/code&gt;. You will not experience any of the problems with the context that I mentioned in my previous post. Theme UI implements the &lt;a href=&quot;/dark-mode-in-react/#dan-abramovs-solution-with-css&quot;&gt;last solution&lt;/a&gt; I showed with the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr&gt;CSS&lt;/abbr&gt; custom properties&lt;/a&gt;, the same solution &lt;a href=&quot;https://twitter.com/dan_abramov&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Dan Abramov&lt;/a&gt; uses for his personal blog. Not by default, but with a small option—you’ll see that in a bit.&lt;/p&gt;&lt;p&gt;But you may not need all the components I have stuffed inside that theme. You may just don’t want to use my stinky theme. That’s fine, I don’t blame you. Instead, you may want something less opinionated. If that’s the case, you can use the &lt;a href=&quot;https://theme-ui.com/gatsby-plugin&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;official Gatsby Theme UI theme&lt;/a&gt;.&lt;/p&gt;&lt;h2 id=&quot;using-the-official-theme&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#using-the-official-theme&quot;&gt;Using the official theme&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/MarkosKon/theme-ui-dark-mode/tree/master&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub repository - master branch&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;The official Theme UI theme for Gatsby, let’s refer to it as the &lt;em&gt;official theme&lt;/em&gt;, doesn’t do a lot of things; it’s the definition of &lt;em&gt;minimal&lt;/em&gt;. It wraps Gatsby’s root element with a &lt;a href=&quot;https://theme-ui.com/getting-started&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;ThemeProvider&lt;/a&gt;, and it creates some &lt;em&gt;empty&lt;/em&gt; files for the &lt;a href=&quot;https://theme-ui.com/theming&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;theme&lt;/a&gt; and the &lt;a href=&quot;https://theme-ui.com/mdx-components&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;custom &lt;abbr&gt;MDX&lt;/abbr&gt; components&lt;/a&gt; (don’t worry about the last, they are not important). We can then &lt;a href=&quot;https://www.gatsbyjs.org/blog/2019-04-29-component-shadowing/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;shadow&lt;/a&gt; those empty files in our app, and fill them with our code.&lt;/p&gt;&lt;p&gt;But before we do that, let’s install the dependencies first:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add theme-ui gatsby-plugin-theme-ui @emotion/core @mdx-js/react&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, add the plugin in the plugin array:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-config.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  plugins: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-plugin-theme-ui&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The next thing you’ll have to do is &lt;em&gt;overwrite&lt;/em&gt;, or &lt;em&gt;shadow&lt;/em&gt;, the empty theme file from the official theme:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/gatsby-plugin-theme-ui/index.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  useCustomProperties: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  initialColorMode: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  colors: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    text: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#000&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    background: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#fff&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    primary: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#07c&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    modes: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      dark: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        text: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#fff&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        background: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#000&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        primary: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#0cf&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can &lt;a href=&quot;https://theme-ui.com/theming&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;add a ton of useful stuff&lt;/a&gt; inside the theme object, but here I add only the colors, in an attempt to be minimal like the official theme. Also, notice the &lt;code&gt;useCustomProperties&lt;/code&gt; field I highlighted in the code above. I said before that it’s a good idea to use &lt;abbr&gt;CSS&lt;/abbr&gt; custom properties. If you don’t use them, and you change the theme from light to dark in production, when you reload the page, you’ll see a brief flash. That flash is caused because you see momentarily the light theme before the dark—your chosen theme in this case. It has to do with how React’s &lt;em&gt;hydrate&lt;/em&gt; method works.&lt;/p&gt;&lt;p&gt;Now that you have a basic theme, it’s time to use it in your code. Open the index page, and paste the following code:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/index.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/** &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;@jsx&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt; jsx */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { jsx, Styled } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme-ui&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ThemeSwitcher &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/theme-switcher&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;sx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        backgroundColor: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        minHeight: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;100vh&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        display: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;flex&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        alignItems: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        justifyContent: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        flexDirection: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;ThemeSwitcher&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Styled.h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Hello world!&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Styled.h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you are not familiar with emotion, you may be wondering what the &lt;code&gt;@jsx jsx&lt;/code&gt; comment does at the top of the file. With that comment, you declare that you want to use the &lt;a href=&quot;https://theme-ui.com/jsx-pragma&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;custom &lt;abbr&gt;JSX&lt;/abbr&gt; pragma from Theme UI&lt;/a&gt;. What this thing does is not as scary as it sounds. Let me explain.&lt;/p&gt;&lt;p&gt;Your &lt;abbr&gt;JSX&lt;/abbr&gt; code at build time is transformed to &lt;a href=&quot;https://reactjs.org/docs/react-without-jsx.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;React.createElement&lt;/a&gt; function calls. For example, this &lt;code&gt;div&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;red&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Hello World&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;During build time becomes this:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    style: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;red&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello World&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you don’t believe me, you can watch this process real-time with the &lt;a href=&quot;https://babeljs.io/en/repl#?babili=false&amp;amp;browsers=&amp;amp;build=&amp;amp;builtIns=false&amp;amp;spec=false&amp;amp;loose=false&amp;amp;code_lz=DwEwlgbgBAzgLgTwDYFMC8BvDUDGB7JPAJwC4oAiIlEcqAXzoD4AJFJQqAdWKRGAHpwERkA&amp;amp;debug=false&amp;amp;forceAllTransforms=false&amp;amp;shippedProposals=false&amp;amp;circleciRepo=&amp;amp;evaluate=false&amp;amp;fileSize=false&amp;amp;timeTravel=false&amp;amp;sourceType=module&amp;amp;lineWrap=true&amp;amp;presets=es2015%2Creact%2Cstage-2&amp;amp;prettier=false&amp;amp;targets=&amp;amp;version=7.5.5&amp;amp;externalPlugins=&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Babel Online compiler&lt;/a&gt;. The &lt;code&gt;createElement&lt;/code&gt; function takes 3 arguments: the component type, the props, and the children.&lt;/p&gt;&lt;p&gt;So, coming back to the custom pragma, instead of using the &lt;code&gt;React.createElement&lt;/code&gt; function, we use the &lt;code&gt;jsx&lt;/code&gt; function from Theme UI. For example, the &lt;code&gt;React.createElement&lt;/code&gt; you saw in the previous code snippet becomes:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { jsx } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme-ui&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;jsx&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    style: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;red&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hello World&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We do that because we want to use &lt;a href=&quot;https://theme-ui.com/sx-prop&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;the sx prop&lt;/a&gt; from Theme UI—which is not a standard &lt;abbr&gt;JSX&lt;/abbr&gt; property like the &lt;code&gt;style&lt;/code&gt; for example—to style our components. Speaking of the &lt;code&gt;sx&lt;/code&gt; prop, I use it on the index page to position the content of the div at the center of the screen. I also use a &lt;code&gt;ThemeSwitcher&lt;/code&gt; component that doesn’t exist yet. This component is a button that switches our themes, as the name suggests.&lt;/p&gt;&lt;p&gt;Let’s now create that &lt;code&gt;ThemeSwitcher&lt;/code&gt; component. Create a new file at &lt;code&gt;src/components/theme-switcher.js&lt;/code&gt; and paste the following code:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/theme-switcher.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/** &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;@jsx&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt; jsx */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { jsx, useColorMode } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme-ui&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;ThemeSwitcher&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;colorMode&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setColorMode&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useColorMode&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;nextColorMode&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;colorMode&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; === &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; ? &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;button&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;sx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        position: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;absolute&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        top: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        right: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        backgroundColor: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;primary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        border: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        px: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        py: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        cursor: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;pointer&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setColorMode&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;nextColorMode&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      Toggle mode&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;ThemeSwitcher&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the &lt;code&gt;ThemeSwitcher&lt;/code&gt; component, I use the &lt;code&gt;sx&lt;/code&gt; prop to style the button because no one likes ugly buttons, and I also use the &lt;code&gt;useColorMode&lt;/code&gt; hook that allows us to change the theme.&lt;/p&gt;&lt;p&gt;And that’s it. If you now start the development server, this is what you’ll see:&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/2bd5630fb2ab5ed98e20ae2e7966ec64/gatsby-plugin-theme-ui.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/f4f88d79c6caddf9df7b978b8645b555/gatsby-plugin-theme-ui.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/5a1c09d3abf9a26d30431d6f71d4d233/gatsby-plugin-theme-ui.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Homepage with the official theme&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;Wrapping up, I want to say that few times I feel joy using a JavaScript library. When I use Theme UI, it’s one of those times (lol).&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Modals in Gatsby]]></title><description><![CDATA[In this post, you’ll see how to create modals in Gatsby, and how to render them in different pages to improve SEO.]]></description><link>https://markoskon.com/modals-in-gatsby/</link><guid isPermaLink="false">https://markoskon.com/modals-in-gatsby/</guid><pubDate>Thu, 25 Jul 2019 09:13:00 GMT</pubDate><content:encoded>&lt;p&gt;Imagine that you want to build an Instagram-like app in Gatsby. You display a &lt;em&gt;grid of images&lt;/em&gt; on the homepage, and when you click on an image, you render it inside a &lt;em&gt;modal&lt;/em&gt;. That modal has a full-size version of the image and some extra information. The information may be the text of the post or counts for &lt;em&gt;likes&lt;/em&gt; and &lt;em&gt;comments&lt;/em&gt;. If you are a visual person, this is &lt;a href=&quot;https://instagatsby.netlify.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;what the finished app looks like&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;The modal is an important part of the application, so you want it to satisfy the following &lt;strong&gt;requirements&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The modal should be &lt;em&gt;accessible&lt;/em&gt; and somewhat &lt;em&gt;pretty&lt;/em&gt;. A popular library that can help you with that is &lt;a href=&quot;https://github.com/reactjs/react-modal&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;react-modal&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;You also want to have &lt;em&gt;good &lt;abbr&gt;&lt;abbr title=&quot;Search Engine Optimization&quot;&gt;SEO&lt;/abbr&gt;&lt;/abbr&gt;&lt;/em&gt;. To achieve that, you want to display the modal on a &lt;em&gt;different&lt;/em&gt; page. By rendering the modal on a different page, Google is now able to index the extra post information. Another benefit is that you can &lt;em&gt;share&lt;/em&gt; the picture with a link. Finally, you can use the back button to close the modal and return to the homepage. The last is something the users expect. If you don’t do that, you risk your users leaving the page while trying to close the modal (lol).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;So how can you implement that modal in Gatsby?&lt;/p&gt;&lt;h2 id=&quot;create-the-pages&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#create-the-pages&quot;&gt;Create the pages&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;First, you have to &lt;strong&gt;create the pages&lt;/strong&gt; from your data. &lt;a href=&quot;https://github.com/MarkosKon/gatsby-modal&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;In this example (repo link)&lt;/a&gt;, I’m using the &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-source-instagram/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-source-instagram&lt;/a&gt; plugin as my data source. I’m querying the last 12 posts from &lt;a href=&quot;https://www.instagram.com/alicexz/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;alicexz’s&lt;/a&gt; Instagram account. &lt;a href=&quot;https://www.npmjs.com/package/@affectionatedoor/gatsby-theme-ui&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;I’m also using a theme&lt;/a&gt; that setups &lt;a href=&quot;https://theme-ui.com&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;theme-ui&lt;/a&gt; in Gatsby and &lt;a href=&quot;https://github.com/MarkosKon/theme-playground/tree/master/packages/gatsby-theme-ui&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;exposes some components&lt;/a&gt;. This is what my &lt;code&gt;gatsby-config.js&lt;/code&gt; looks like:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-config.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  siteMetadata: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    title: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Alice X. Zhang&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  plugins: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@affectionatedoor/gatsby-theme-ui&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      resolve: `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-source-instagram&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      options: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        username: `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;alicexz&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I create the pages with the &lt;a href=&quot;https://www.gatsbyjs.org/docs/node-apis/#createPages&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;createPages &lt;abbr&gt;API&lt;/abbr&gt;&lt;/a&gt; from Gatsby Node:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-node.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createPages&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;async&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, actions: { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;createPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; } }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = await &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    query {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      allInstaNode {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        nodes {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;errors&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;errors&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;postTemplate&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./src/templates/InstaModalPost/index.jsx&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;allInstaNode&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      path: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      component: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;postTemplate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      context: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        id: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now that we have the pages, the next thing you have to do is to render the modal.&lt;/p&gt;&lt;h2 id=&quot;render-the-modal&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#render-the-modal&quot;&gt;Render the modal&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A good place to &lt;strong&gt;render the modal&lt;/strong&gt; is in the post template. But now the question is, how can you render the index page that’s sitting &lt;em&gt;behind&lt;/em&gt; the modal?&lt;/p&gt;&lt;p&gt;If you take a look at &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/tree/master/examples/gatsbygram&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsbygram&lt;/a&gt; (an example app that literally does the same thing we do here), you can see that &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/blob/master/examples/gatsbygram/src/layouts/index.js#L35-L44&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;it uses a PageRenderer&lt;/a&gt; component to render the background page. At the time of writing, &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/page-renderer.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;PageRenderer&lt;/a&gt; is an &lt;strong&gt;&lt;a href=&quot;https://github.com/gatsbyjs/gatsby/issues/6360&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;undocumented component&lt;/a&gt;&lt;/strong&gt;. This means that is not supposed to be used that much (?). You can see that the only prop that’s being passed to the PageRenderer component is the &lt;em&gt;location&lt;/em&gt;. This will be useful later.&lt;/p&gt;&lt;p&gt;You’re now going to do something similar in the post template file. In gatsbygram, this is done in a &lt;code&gt;Layout&lt;/code&gt; component, but I find it easier to do in the &lt;a href=&quot;https://github.com/MarkosKon/gatsby-modal/blob/master/src/templates/InstaModalPost/index.jsx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;template file&lt;/a&gt;. The previous link has the completed code. If you want to follow along, better paste the code below for now:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/templates/InstaModalPost/index.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/** &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;@jsx&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt; jsx */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { useState } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { jsx, Styled } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme-ui&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { graphql, navigate, PageRenderer } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Img &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-image&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Modal &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-modal&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Link &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@affectionatedoor/gatsby-theme-ui/src/components/Link&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Times, Heart, Comment } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../../components/Icons&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./style.css&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;Modal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setAppElement&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#___gatsby&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;modalStyles&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  overlay: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    backgroundColor: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;rgba(0, 0, 0, 0.58)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  content: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    position: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;relative&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    top: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    left: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    right: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    bottom: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    maxWidth: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;960px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    margin: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;32px auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    padding: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    border: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;InstaPostTemplate&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  data: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    instaNode: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;caption&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;comments&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;likes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      localFile: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;        childImageSharp: { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;modalOpen&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setModalOpen&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;modalCloseTimeout&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;closeModal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setModalOpen&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;setTimeout&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;navigate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;modalCloseTimeout&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;PageRenderer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ pathname: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Modal&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;isOpen&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;modalOpen&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onRequestClose&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;closeModal&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;modalStyles&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;contentLabel&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Modal&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;closeTimeoutMS&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;modalCloseTimeout&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Styled.root&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;sx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              bg: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              display: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;flex&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              flexDirection: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              position: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;relative&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;close modal&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;sx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                width: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;50px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                height: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;50px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                position: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;absolute&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                display: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;flex&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                alignItems: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                justifyContent: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                m: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                right: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                top: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                zIndex: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                borderRadius: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;50%&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;:hover&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  bg: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#fbf9f926&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;preventDefault&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;closeModal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Times&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;sx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ fontSize: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Img&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;sx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ mt: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, px:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;small&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;sx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ mr: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Heart&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;sx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;secondary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, fontSize: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;likes&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;small&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;small&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;sx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ mr: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Comment&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;sx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;secondary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, fontSize: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;comments&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;small&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;sx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ my: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, px:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;caption&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Styled.root&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Modal&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;InstaPostTemplate&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  data: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    instaNode: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      caption: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      comments: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      id: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      likes: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      localFile: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        childImageSharp: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          fluid: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        })&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      })&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    })&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  })&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;InstaPostTemplate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  query InstaPostModal($id: String) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    instaNode(id: { eq: $id }) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      likes&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      localFile {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        childImageSharp {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          fluid(maxWidth: 1200) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            ...GatsbyImageSharpFluid&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      comments&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      caption&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;`;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/templates/InstaModalPost/style.css&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* react-modal transitions */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.ReactModal__Overlay&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;overflow&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;translateY&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;-10&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: opacity &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.3&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;cubic-bezier&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.445&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.05&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.55&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.95&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;), transform&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.3&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;cubic-bezier&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.445&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.05&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.55&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.95&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.ReactModal__Overlay--after-open&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;translateY&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.ReactModal__Overlay--before-close&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;translateY&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;-10&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we run the code in &lt;em&gt;development&lt;/em&gt; (after you &lt;a href=&quot;https://github.com/MarkosKon/gatsby-modal/blob/master/src/pages/index.jsx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;create the index page&lt;/a&gt;, the &lt;a href=&quot;https://github.com/MarkosKon/gatsby-modal/tree/master/src/components&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;other 2 components&lt;/a&gt; and &lt;a href=&quot;https://github.com/MarkosKon/gatsby-modal/blob/master/src/%40affectionatedoor/gatsby-theme-ui/components/Layout.jsx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;shadow the layout&lt;/a&gt; from the theme), everything works just fine:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:1245px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/fa71d793057a033cf6b13329754cb6fc/e51fc/all-cool-dev.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:57.70833333333334%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAMABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAQCAwX/xAAWAQEBAQAAAAAAAAAAAAAAAAADAQL/2gAMAwEAAhADEAAAAcxtF2LWRNF//8QAHBAAAgEFAQAAAAAAAAAAAAAAAQIAAxEhMTJB/9oACAEBAAEFAvbGnMOT0SWia//EABcRAQADAAAAAAAAAAAAAAAAAAECEBH/2gAIAQMBAT8Bk6V//8QAFhEAAwAAAAAAAAAAAAAAAAAAARAx/9oACAECAQE/ARV//8QAGxABAQABBQAAAAAAAAAAAAAAAQBhAhARIUH/2gAIAQEABj8C6jSvOZWMSr5t/8QAGhABAAMAAwAAAAAAAAAAAAAAAQARITFhkf/aAAgBAQABPyF9WiCgsLSOxXexpW1yKhiSgm29z//aAAwDAQACAAMAAAAQ2x//xAAZEQADAAMAAAAAAAAAAAAAAAAAAREhUbH/2gAIAQMBAT8QxGpwTcP/xAAWEQEBAQAAAAAAAAAAAAAAAAABABH/2gAIAQIBAT8Q1Fdv/8QAHBABAQACAgMAAAAAAAAAAAAAAREAITFxkbHB/9oACAEBAAE/EJJAal4LkuXS6qmvWRRfyTLJJCaRvOB8IG95uTVfzP/Z&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;everything is fine in development&quot; title=&quot;Artwork by Alice X. Zhang&quot; src=&quot;/static/fa71d793057a033cf6b13329754cb6fc/e51fc/all-cool-dev.jpg&quot; srcSet=&quot;/static/fa71d793057a033cf6b13329754cb6fc/a5e48/all-cool-dev.jpg 480w,/static/fa71d793057a033cf6b13329754cb6fc/1fe05/all-cool-dev.jpg 960w,/static/fa71d793057a033cf6b13329754cb6fc/e51fc/all-cool-dev.jpg 1245w&quot; sizes=&quot;(max-width: 1245px) 100vw, 1245px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Artwork by Alice X. Zhang&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;But if you try to &lt;em&gt;build&lt;/em&gt; the project, you see that the background page is missing:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:1262px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/0644a27f94c2faabfc9acbd1118964ad/b32f1/problem-in-prod.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:56.875%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAALABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAMEAv/EABUBAQEAAAAAAAAAAAAAAAAAAAED/9oADAMBAAIQAxAAAAGB8lJVhgY//8QAGhAAAQUBAAAAAAAAAAAAAAAAAQACAxEyMf/aAAgBAQABBQKTQDmK7U/SSQzP/8QAFxEBAAMAAAAAAAAAAAAAAAAAARARIf/aAAgBAwEBPwFcqP/EABURAQEAAAAAAAAAAAAAAAAAABBB/9oACAECAQE/Aaf/xAAaEAACAgMAAAAAAAAAAAAAAAAAAREhAhBC/9oACAEBAAY/AhLKHNk6t8iP/8QAGxAAAgIDAQAAAAAAAAAAAAAAAAERQRAxkdH/2gAIAQEAAT8haJErLBUdRoEpsb9YX//aAAwDAQACAAMAAAAQOz//xAAXEQEBAQEAAAAAAAAAAAAAAAABABFR/9oACAEDAQE/ENjwEX//xAAWEQEBAQAAAAAAAAAAAAAAAAAAATH/2gAIAQIBAT8Qhdf/xAAcEAEAAwACAwAAAAAAAAAAAAABABEhMVFBcbH/2gAIAQEAAT8QZtOFHbAdFaawZ7gzbmGlLXmH6QRXvUas879n/9k=&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;background image missing&quot; title=&quot;Artwork by Alice X. Zhang&quot; src=&quot;/static/0644a27f94c2faabfc9acbd1118964ad/b32f1/problem-in-prod.jpg&quot; srcSet=&quot;/static/0644a27f94c2faabfc9acbd1118964ad/a5e48/problem-in-prod.jpg 480w,/static/0644a27f94c2faabfc9acbd1118964ad/1fe05/problem-in-prod.jpg 960w,/static/0644a27f94c2faabfc9acbd1118964ad/b32f1/problem-in-prod.jpg 1262w&quot; sizes=&quot;(max-width: 1262px) 100vw, 1262px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Artwork by Alice X. Zhang&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;h2 id=&quot;pagerenderer-problem&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#pagerenderer-problem&quot;&gt;PageRenderer problem&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;This happens because the PageRenderer behaves differently in &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/public-page-renderer-prod.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;production&lt;/a&gt;. If you take a look at the &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/public-page-renderer-dev.js#L8&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;development version&lt;/a&gt; of page renderer, you will see that the component downloads the page data using the location prop. This &lt;em&gt;does not happen&lt;/em&gt; in production. Following the &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/commits/master/packages/gatsby/cache-dir/public-page-renderer-prod.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;changes&lt;/a&gt; in the production file, I suspect that this &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/pull/14359&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;happened recently as a part of some performance optimizations&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;As a result, if you want to use the PageRenderer component to display the index page behind the modal, you’ll have to download the page data &lt;em&gt;yourself&lt;/em&gt;. In the &lt;a href=&quot;https://gatsbygram.gatsbyjs.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;live gatsbygram site&lt;/a&gt;, the modal works fine without downloading the page data. But that happens because the deployed version of the site probably uses an earlier version of Gatsby.&lt;/p&gt;&lt;p&gt;But how to get the page data?&lt;/p&gt;&lt;h2 id=&quot;getting-the-page-data&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#getting-the-page-data&quot;&gt;Getting the page data&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;All the &lt;a href=&quot;https://www.gatsbyjs.org/docs/browser-apis/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;browser &lt;abbr&gt;API&lt;/abbr&gt;’s&lt;/a&gt; that you can implement in your &lt;code&gt;gatsby-browser.js&lt;/code&gt; file, take the &lt;code&gt;loadPage&lt;/code&gt; method as a parameter. This method accepts a page path and returns the data for that page. This is exactly what we want. So the &lt;strong&gt;plan&lt;/strong&gt; now is to implement an appropriate browser &lt;abbr&gt;API&lt;/abbr&gt; where:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;We download the index page data,&lt;/li&gt;&lt;li&gt;and store them somewhere to use later in the &lt;code&gt;PageRenderer&lt;/code&gt; component.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;A good candidate for that is to implement the &lt;a href=&quot;https://www.gatsbyjs.org/docs/browser-apis/#onPrefetchPathname&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;onPrefetchPathname&lt;/a&gt; method. This method is called whenever Gatsby prefetches the data for a page at &lt;em&gt;idle time&lt;/em&gt;. This happens when it encounters a &lt;code&gt;Link&lt;/code&gt; for that page. For example, if you have in the &lt;em&gt;index&lt;/em&gt; page a &lt;code&gt;Link&lt;/code&gt; to &lt;em&gt;page-2&lt;/em&gt;, Gatsby will download the data for page-2 at idle time. This way, the navigation between pages feels instant. For this to work, you’ll have to add a link to the homepage in the template. In our case, the link is &lt;em&gt;already&lt;/em&gt; in the template. &lt;a href=&quot;https://github.com/MarkosKon/gatsby-modal/blob/master/src/templates/InstaModalPost/index.jsx#L88-L115&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;It’s the button that closes the modal&lt;/a&gt;. This is the implementation of the &lt;code&gt;onPrefetchPathname&lt;/code&gt; method:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-browser.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@fortawesome/fontawesome-svg-core/styles.css&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// This only works if in the modal page you add a&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Link to the homepage.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;onPrefetchPathname&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;loadPage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  if &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;indexPageData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; === &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;loadPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;then&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;indexPageData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      if &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;setIndexPageData&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setIndexPageData&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// https://github.com/gatsbyjs/gatsby/issues/7454#issuecomment-425403812&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;shouldUpdateScroll&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  routerProps: { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;getSavedScrollPosition&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getSavedScrollPosition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can see that I’m saving the page data in the &lt;code&gt;window&lt;/code&gt;. I’m also calling the &lt;code&gt;setIndexPageData&lt;/code&gt; method, if it’s truthy, that &lt;a href=&quot;https://github.com/MarkosKon/gatsby-modal/blob/master/src/templates/InstaModalPost/index.jsx#L51-L55&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;causes a re-render by setting the state in the template&lt;/a&gt;. If we load the modal page &lt;em&gt;directly&lt;/em&gt;, the &lt;em&gt;initial&lt;/em&gt; result is &lt;code&gt;null&lt;/code&gt; for some reason. This is what you have to add in the template file:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/templates/InstaModalPost/index.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { useState, useEffect } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping imports and modal styles...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;InstaPostTemplate&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping props..&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;building&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;typeof&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; === &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;indexPageData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setIndexPageData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    !&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;building&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &amp;amp;&amp;amp; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;indexPageData&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setIndexPageData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setIndexPageData&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;indexPageData&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [])&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Modal stuff.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;modalOpen&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setModalOpen&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;modalCloseTimeout&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;closeModal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setModalOpen&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;setTimeout&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;navigate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;modalCloseTimeout&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;PageRenderer&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;location&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ pathname: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;pageResources&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;indexPageData&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* skipping... */&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;One thing to note about prefetching data is that it may not always work. For example, the mobile Chrome offers the &lt;em&gt;“Lite mode”&lt;/em&gt; where the browser refuses to download data for pages the user may never visit. In this case, we are not able to render the background page by implementing the &lt;code&gt;onPrefetchPathname&lt;/code&gt; method.&lt;/p&gt;&lt;h2 id=&quot;scroll-position-caveat&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#scroll-position-caveat&quot;&gt;Scroll position caveat&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You may also notice in the previous &lt;code&gt;gatsby-browser.js&lt;/code&gt; snippet, that I’m implementing the &lt;a href=&quot;https://www.gatsbyjs.org/docs/browser-apis/#shouldUpdateScroll&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;shouldUpdateScroll &lt;abbr&gt;API&lt;/abbr&gt;&lt;/a&gt;. If you don’t do that, and you return to the index page after closing the modal, &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/issues/7454&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;you’ll lose your scroll position&lt;/a&gt; in the index page, and you’ll start at the top of the page. This is obviously really annoying, and the implementation above fixes it.&lt;/p&gt;&lt;h2 id=&quot;further-improvement&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#further-improvement&quot;&gt;Further improvement&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The modal in this example could be further improved. For example, we could add &lt;em&gt;next&lt;/em&gt; and &lt;em&gt;previous&lt;/em&gt; buttons to cycle through the images when the modal is open. Gatsbygram does this but also &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/blob/master/examples/gatsbygram/src/components/modal.js#L23-L27&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;adds keyboard navigation&lt;/a&gt; with the &lt;a href=&quot;https://www.npmjs.com/package/mousetrap&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;mousetrap&lt;/a&gt; library. There are some accessibility issues as well. For example, the modal pages do not have a Heading 1 element because Instagram &lt;abbr&gt;API&lt;/abbr&gt; does not have a title for posts. Finally, because we’re downloading data for many pages (when the modal opens), the performance may suffer as well.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk15 { color: #80CBC4; }
  .night-owl-no-italics .mtk16 { color: #FF6363; }
  .night-owl-no-italics .mtk11 { color: #FFEB95; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Change the URLs of posts in Gatsby]]></title><description><![CDATA[Learn how to change the URLs of your pages in Gatsby.]]></description><link>https://markoskon.com/change-the-url-of-posts-in-gatsby/</link><guid isPermaLink="false">https://markoskon.com/change-the-url-of-posts-in-gatsby/</guid><pubDate>Wed, 17 Jul 2019 17:00:00 GMT</pubDate><content:encoded>&lt;p&gt;If you want to create an &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; blog in Gatsby, you have to do 3 things:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Install 3 packages: &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-plugin-mdx/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;gatsby-plugin-mdx&lt;/code&gt;&lt;/a&gt;, &lt;code&gt;@mdx-js/mdx&lt;/code&gt;, and &lt;code&gt;@mdx-js/react&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Add the &lt;code&gt;gatsby-plugin-mdx&lt;/code&gt; to your plugins array inside &lt;code&gt;gatsby-config.js&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Create some &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; files inside &lt;code&gt;src/pages&lt;/code&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;And now you have an &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; blog. If you create a &lt;code&gt;src/pages/post-1.mdx&lt;/code&gt; file, Gatsby will create a page for that file and will be available at:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;http://example.com/post-1/&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But sometimes, you want your posts to be under a &lt;code&gt;/posts/&lt;/code&gt; &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;. For example:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;http://example.com/posts/post-1/&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;One way to do this is to &lt;a href=&quot;https://www.gatsbyjs.org/docs/mdx/programmatically-creating-pages&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;create the &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; pages yourself&lt;/a&gt; with the &lt;a href=&quot;https://www.gatsbyjs.org/docs/node-apis/#createPages&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;createPages&lt;/code&gt;&lt;/a&gt; &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt;. But creating the pages this way requires 3 extra steps:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You have to implement the &lt;code&gt;createPages&lt;/code&gt; &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; in your &lt;code&gt;gatsby-node.js&lt;/code&gt; to create the pages and maybe the &lt;a href=&quot;https://www.gatsbyjs.org/docs/node-apis/#onCreateNode&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;onCreateNode&lt;/code&gt;&lt;/a&gt; to add extra fields to your nodes—for example, a slug in the &lt;code&gt;Mdx&lt;/code&gt; GraphQL type.&lt;/li&gt;&lt;li&gt;You have to install and configure the &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-source-filesystem/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;gatsby-source-filesystem&lt;/code&gt;&lt;/a&gt; plugin to look for &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; files. This is important because otherwise, your &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; files won’t be available to GraphQL queries; and you want that for the first step (to create the pages with the &lt;code&gt;createPages&lt;/code&gt; &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt;).&lt;/li&gt;&lt;li&gt;Finally, you have to create a post template to use it as a layout for your post pages.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;But that’s only one way to create custom &lt;abbr title=&quot;Uniform Resource Locators&quot;&gt;URLs&lt;/abbr&gt; for your posts; let’s now see what alternatives you have.&lt;/p&gt;&lt;p&gt;See also &lt;a href=&quot;/working-with-data-in-gatsby&quot;&gt;Working with data in Gatsby&lt;/a&gt;.&lt;/p&gt;&lt;h2 id=&quot;folder-solution&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#folder-solution&quot;&gt;Folder solution&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you want to change only the &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt; of your posts, you can place your &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; files inside folders. For example, if you want a bunch of notes under the &lt;code&gt;/notes/&lt;/code&gt; &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;, create a notes folder, and place your notes inside that folder. Consider the following file structure:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;src&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|__ pages&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|____ index.js&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|____ page-2.js&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|____ notes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ note-1.mdx&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ note-2.mdx&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This solution has some limitations though. For example, you can’t pass context data to your page or use a custom template for the posts. If you want to have those options, you can use the &lt;code&gt;onCreatePage&lt;/code&gt; &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt;.&lt;/p&gt;&lt;h2 id=&quot;oncreatepage-api&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#oncreatepage-api&quot;&gt;onCreatePage &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You can use the &lt;code&gt;createPages&lt;/code&gt; &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; to programmatically create pages. But in addition to the &lt;code&gt;createPages&lt;/code&gt;, there is another Node &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt;: the &lt;a href=&quot;https://www.gatsbyjs.org/docs/node-apis/#onCreatePage&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;onCreatePage&lt;/code&gt;&lt;/a&gt;. This &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; is called, as you may have guessed, when a page is created. But an important detail here is that is &lt;em&gt;not&lt;/em&gt; called for those created by the &lt;code&gt;createPages&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;So the plan is to use the &lt;code&gt;onCreatePage&lt;/code&gt; to delete the created pages from &lt;code&gt;src/pages&lt;/code&gt; and then create new pages with the updated path. You don’t want to delete all the pages, though, only the &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; pages that you’ll use as posts. To identify them, you can add a &lt;code&gt;frontmatter&lt;/code&gt; field called &lt;code&gt;type&lt;/code&gt; with a value of &lt;code&gt;post&lt;/code&gt; at the top of the file. For example:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;markdown&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;post&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk4&quot;&gt;# Post 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;Content&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;oncreatepage-example&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#oncreatepage-example&quot;&gt;onCreatePage example&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;To see this in action, create a new project with the &lt;a href=&quot;https://github.com/gatsbyjs/gatsby-starter-hello-world&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;hello-world starter&lt;/a&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;mkdir change-post-url&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; change-post-url&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;gatsby new &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; https://github.com/gatsbyjs/gatsby-starter-hello-world.git&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Install &lt;code&gt;gatsby-plugin-mdx&lt;/code&gt; and the other dependencies:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add gatsby-plugin-mdx @mdx-js/mdx @mdx-js/react&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Configure the plugin in your &lt;code&gt;gatsby-config.js&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-config.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  plugins: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-plugin-mdx&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, create an &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; file inside &lt;code&gt;src/pages&lt;/code&gt; that will be used as a regular page:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/page-2.mdx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;md&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk4&quot;&gt;# Page 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;This is the second page in MDX.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;import { Link } from &amp;quot;gatsby&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Go back to homepage&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And another &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; file that you’ll use as a post:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/post-1.mdx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;md&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;post&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk4&quot;&gt;# Post 1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;This is my first post.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After you do all the above, you end up with 3 pages:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;/&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;/page-2/&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;/post-1/&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;What’s left now is to change the &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt; of &lt;code&gt;/post-1/&lt;/code&gt; page to &lt;code&gt;/posts/post-1/&lt;/code&gt;. Implement the &lt;code&gt;onCreatePage&lt;/code&gt; &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; in your &lt;code&gt;gatsby-node.js&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-node.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;onCreatePage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  actions: { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;createPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;deletePage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;deletePage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      path: `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/posts&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If the page has a &lt;code&gt;frontmatter&lt;/code&gt; object in the context, then we’re dealing with an &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; page. To check if it’s also a post, you look inside that frontmatter object for a &lt;code&gt;type&lt;/code&gt; field with a value of &lt;code&gt;&amp;quot;post&amp;quot;&lt;/code&gt;. If all the previous are true, you delete the page, and create a new one with the updated path:&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;Notice that I change only the path in the &lt;code&gt;createPage&lt;/code&gt; method. You can also pass some &lt;code&gt;context&lt;/code&gt; or a template (via the &lt;code&gt;component&lt;/code&gt; field) if you want. Check the &lt;a href=&quot;https://www.gatsbyjs.org/docs/actions/#createPage&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;createPage&lt;/code&gt;&lt;/a&gt; method for more details.&lt;/div&gt;&lt;p&gt;After implementing the &lt;code&gt;onCreatePage&lt;/code&gt; &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt;, you end up with the following pages:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;/&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;/page-2/&lt;/code&gt;&lt;/li&gt;&lt;li&gt;&lt;code&gt;/posts/post-1/&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;You can do that for any data you display on your site; it doesn’t have to be a post. If you’re building a hotel website, that data could be rooms or special offers.&lt;/p&gt;&lt;h2 id=&quot;get-the-mdx-files-with-graphql&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-the-mdx-files-with-graphql&quot;&gt;Get the &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; files with GraphQL&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You may want to create a page that lists all the posts. To do that, you want to get your &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; pages with a GraphQL query. &lt;code&gt;gatsby-source-filesystem&lt;/code&gt; can help you with that. First, install the plugin:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add gatsby-source-filesystem&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And configure it in your &lt;code&gt;gatsby-config.js&lt;/code&gt; to look for files in your &lt;code&gt;src/pages&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-config.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  plugins: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-plugin-mdx&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      resolve: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-source-filesystem&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      options: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        path: `&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${__dirname}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/src/pages&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;list-all-posts-example&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#list-all-posts-example&quot;&gt;List all posts example&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;If you want to show only the posts (&lt;code&gt;type: post&lt;/code&gt;), you can write a GraphQL query like the following:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;AllPostsQuery {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  allMdx(filter: { frontmatter: { type: { eq: &amp;quot;post&amp;quot; } } }) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    nodes {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      timeToRead&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      excerpt(pruneLength: 200)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;`;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The following snippet shows how to display the posts in the index page:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/index.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { graphql, Link } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; slugify &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;slugify&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  data: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    allMdx: { nodes: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;posts&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;posts&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Hello world!&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;In the next section, you can find all the posts.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Posts&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;ul&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;posts&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/posts/&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;slugify&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;headings&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk25&quot;&gt;                lower: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk25&quot;&gt;              }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h3&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;headings&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h3&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;post&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;excerpt&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        ))&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;ul&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    allMdx(filter: { frontmatter: { type: { eq: &amp;quot;post&amp;quot; } } }) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      nodes {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        timeToRead&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        excerpt(pruneLength: 200)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        headings(depth: h1) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          value&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          depth&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;`;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There are better ways to get the slug of the page; don’t consider what I did above a good practice. I use &lt;code&gt;slugify&lt;/code&gt; to transform the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; that I get from GraphQL—assuming that you should only have one &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; per page. A better way would be to add the slug yourself as a &lt;code&gt;frontmatter&lt;/code&gt; field in the post. You can also do it programmatically on built time with &lt;code&gt;onCreateNode&lt;/code&gt;, and make it available in your &lt;code&gt;mdx&lt;/code&gt; GraphQL queries as a &lt;code&gt;fields&lt;/code&gt; property—this is a common practice but adds more complexity.&lt;/p&gt;&lt;h2 id=&quot;use-the-page-creator-plugin&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#use-the-page-creator-plugin&quot;&gt;Use the page creator plugin&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Another thing you may want to do is to move your &lt;abbr title=&quot;JSX in Markdown&quot;&gt;MDX&lt;/abbr&gt; posts from the &lt;code&gt;src/pages&lt;/code&gt; directory to a &lt;code&gt;posts&lt;/code&gt; directory. You can use the &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-plugin-page-creator/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;gatsby-plugin-page-creator&lt;/code&gt;&lt;/a&gt; to create pages from a different folder. First, install the plugin:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add gatsby-plugin-page-creator&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, configure it in your &lt;code&gt;gatsby-config.js&lt;/code&gt; to create pages from the files in the &lt;code&gt;posts&lt;/code&gt; folder (also change the folder for the &lt;code&gt;gatsby-source-filesystem&lt;/code&gt;):&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-config.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;15&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  plugins: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-plugin-mdx&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      resolve: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-source-filesystem&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      options: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;posts&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        path: `&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${__dirname}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/posts&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      resolve: `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-plugin-page-creator&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      options: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        path: `&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${__dirname}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/posts&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you move the &lt;code&gt;post-1.mdx&lt;/code&gt; file from &lt;code&gt;src/pages&lt;/code&gt; to &lt;code&gt;posts&lt;/code&gt;, everything should work as before.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk4 { color: #82B1FF; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Working with data in Gatsby]]></title><description><![CDATA[You will see how you to work with data in Gatsby from hard coding them, to transformer plugins, and finally to MDX.]]></description><link>https://markoskon.com/working-with-data-in-gatsby/</link><guid isPermaLink="false">https://markoskon.com/working-with-data-in-gatsby/</guid><pubDate>Sun, 23 Jun 2019 15:12:03 GMT</pubDate><content:encoded>&lt;p&gt;In this post, you will see how to work with data in Gatsby from hard coding them, to transformer plugins, and finally to &lt;abbr&gt;MDX&lt;/abbr&gt;.&lt;/p&gt;&lt;p&gt;Say you want to create an application for a &lt;em&gt;travel agency&lt;/em&gt;. The agency organizes 6 tours in different countries over the world. Their homepage should have a section that lists those tours. They also want to show on a different page some extra information about each tour. The first thought that comes to my mind is to create a section on the homepage where each tour will be represented by a card. That section may look like this:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:1920px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/3225f861aae9af685c093b805d6945c2/af8d6/tour-cards.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:50.208333333333336%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAKABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAMEBf/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/9oADAMBAAIQAxAAAAHTjsUtY4T/xAAbEAACAgMBAAAAAAAAAAAAAAABAgADBBASE//aAAgBAQABBQKzhSzqs80lxmMSdf/EABURAQEAAAAAAAAAAAAAAAAAABAR/9oACAEDAQE/Aaf/xAAWEQADAAAAAAAAAAAAAAAAAAAQITH/2gAIAQIBAT8BdH//xAAeEAACAAYDAAAAAAAAAAAAAAAAAQIQERMhkTIzYf/aAAgBAQAGPwJK2s+HUtHBaERVcv/EABoQAQACAwEAAAAAAAAAAAAAAAEAEBEhQWH/2gAIAQEAAT8hIhY9lfa6Q1WIZDh61//aAAwDAQACAAMAAAAQCD//xAAXEQADAQAAAAAAAAAAAAAAAAAAAREh/9oACAEDAQE/EMRFZ//EABcRAQADAAAAAAAAAAAAAAAAAAABEWH/2gAIAQIBAT8Q0XL/xAAbEAEBAQEBAAMAAAAAAAAAAAABEQAxIWFxgf/aAAgBAQABPxAdKGoGc+MOFpZ+M4feACHS+DBMSjx3ihsozud//9k=&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;The cards in tours section&quot; title=&quot;The cards in tours section&quot; src=&quot;/static/3225f861aae9af685c093b805d6945c2/af8d6/tour-cards.jpg&quot; srcSet=&quot;/static/3225f861aae9af685c093b805d6945c2/a5e48/tour-cards.jpg 480w,/static/3225f861aae9af685c093b805d6945c2/1fe05/tour-cards.jpg 960w,/static/3225f861aae9af685c093b805d6945c2/af8d6/tour-cards.jpg 1920w&quot; sizes=&quot;(max-width: 1920px) 100vw, 1920px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;The cards in tours section&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;What’s the best way to implement this requirement?&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;By the way, I created a &lt;a href=&quot;https://github.com/MarkosKon/working-with-data-in-gatsby&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;repo on GitHub&lt;/a&gt; if you want to see the complete code. I&amp;#x27;m using &lt;a href=&quot;https://github.com/styled-system/styled-system&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;styled-system&lt;/a&gt; and &lt;a href=&quot;https://github.com/rebassjs/rebass&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;rebass&lt;/a&gt; to style things.&lt;/div&gt;&lt;p&gt;First of all, you have to create the &lt;a href=&quot;https://github.com/MarkosKon/working-with-data-in-gatsby/blob/master/src/components/TourCard.jsx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Card component&lt;/a&gt; (you can find the code in the link). The card component needs 5 props:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;A title.&lt;/li&gt;&lt;li&gt;A description.&lt;/li&gt;&lt;li&gt;A price.&lt;/li&gt;&lt;li&gt;A URL that links to the “read more” page.&lt;/li&gt;&lt;li&gt;An image.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The first solution is to create in &lt;abbr&gt;JSX&lt;/abbr&gt; &lt;em&gt;6 different cards&lt;/em&gt; and &lt;em&gt;hard code&lt;/em&gt; the data for each tour.&lt;/p&gt;&lt;h2 id=&quot;hard-coding-the-data&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#hard-coding-the-data&quot;&gt;Hard coding the data&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;To do this, go to the index page, and create 6 different cards. In each card, you pass down the text data as props.&lt;/p&gt;&lt;p&gt;You also want to pass an image. For that, put your images in a folder named &lt;a href=&quot;https://github.com/MarkosKon/working-with-data-in-gatsby/tree/hard-coding/src/images/tours&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;src/images/tours&lt;/a&gt;, and write a GraphQL query to get them.&lt;/p&gt;&lt;p&gt;The full code for the index page is the following:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/index.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { graphql } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Flex, Box } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/Primitives&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Heading1 } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/Variants&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Layout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../layouts/Layout&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; SEO &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/SEO&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; TourCard &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/TourCard&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// eslint-disable-next-line react/prop-types&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;IndexPage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;tours&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;allFile&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;edges&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    image: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;childImageSharp&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    originalName: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;childImageSharp&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;originalName&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;SEO&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Home&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;keywords&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;calc(100vh - 100px)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;pt&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Heading1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;textAlign&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;mb&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          Available Tours&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Heading1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Flex&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;flexWrap&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;wrap&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ maxWidth: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1200px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, margin: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;0 auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;TourCard&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Spain&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluidImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              tours&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;originalName&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                originalName&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;spain&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Week in Spain&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/tours/spain&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;TourCard&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;France&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluidImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              tours&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;originalName&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                originalName&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;France&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Week in France&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/tours/france&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;TourCard&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Germany&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluidImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              tours&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;originalName&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                originalName&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;Germany&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Week in Germany&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/tours/germany&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;TourCard&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Greece&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluidImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              tours&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;originalName&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                originalName&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;Greece&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Week in Greece&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/tours/greece&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;TourCard&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluidImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              tours&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;originalName&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                originalName&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;Japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Week in Japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/tours/japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;TourCard&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;USA&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Week in USA&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/tours/usa&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluidImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              tours&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;originalName&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; originalName&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;USA&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Flex&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  query TourQuery {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    allFile(filter: { relativePath: { regex: &amp;quot;/tours/&amp;quot; } }) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      edges {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        node {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          childImageSharp {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            fluid {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              ...GatsbyImageSharpFluid_tracedSVG&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              originalName&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;`;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;IndexPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There is a &lt;em&gt;minor problem&lt;/em&gt; with this method. The text data are &lt;em&gt;not linked&lt;/em&gt; with the image. That means that you have to write a function to compare the &lt;code&gt;originalName&lt;/code&gt; of the image with the current card name, as shown below:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/index.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;TourCard&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluidImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    tours&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;originalName&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; originalName&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;Japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Week in Japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/tours/japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The other requirement is to create pages with additional information for each tour. For that, you can either create custom pages in &lt;code&gt;src/pages&lt;/code&gt; with &lt;abbr&gt;JSX&lt;/abbr&gt; or create a blog with markdown or &lt;abbr&gt;MDX&lt;/abbr&gt;. That’s true for every method you’ll see here, and we’ll ignore that requirement for now.&lt;/p&gt;&lt;p&gt;Hard coding the tour data is fine if you don’t have a lot of items. In our case, the items are 6 which is not a small number. If the agency increases the tours in the future, it will become unmanageable.&lt;/p&gt;&lt;p&gt;Before we see the next method, let’s make an improvement on the current one.&lt;/p&gt;&lt;h3 id=&quot;hard-coding-improvement&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#hard-coding-improvement&quot;&gt;Hard coding improvement&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;If you want to avoid hard coding and writing 6 different cards, you can create a &lt;abbr&gt;JSON&lt;/abbr&gt; or a JavaScript file that contains the tour data. You can then import that file, and &lt;code&gt;map&lt;/code&gt; through it to display the tours.&lt;/p&gt;&lt;p&gt;Create a file with the tour data in &lt;code&gt;src/data/tours.js&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/data/tours.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    title: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Spain&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    price: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    description: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Week in Spain&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    url: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/tours/spain&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    title: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;France&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    price: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    description: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Week in France&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    url: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/tours/france&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    title: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Germany&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    price: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    description: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Week in Germany&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    url: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/tours/germany&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    title: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Greece&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    price: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    description: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Week in Greece&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    url: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/tours/greece&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    title: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    price: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    description: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Week in Japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    url: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/tours/japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    title: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;USA&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    price: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    description: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1 Week in USA&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    url: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/tours/usa&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, import that file in &lt;code&gt;src/pages/index.js&lt;/code&gt;, and use it:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/index.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Flex&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;flexWrap&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;wrap&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ maxWidth: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1200px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, margin: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;0 auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;tourData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;regExp&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;RegExp&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;TourCard&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluidImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          tours&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;originalName&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; originalName&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;regExp&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  })&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Flex&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The code above is better because &lt;em&gt;we avoid duplication&lt;/em&gt;. But we still have the problem where the images are not linked with the rest of the data. To solve this, you can use a “transformer” plugin.&lt;/p&gt;&lt;h2 id=&quot;gatsby-transformer-json&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#gatsby-transformer-json&quot;&gt;gatsby-transformer-json&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Another option you have is to take advantage of the &lt;a href=&quot;https://www.gatsbyjs.org/docs/creating-a-source-plugin/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Gatsby source plugins&lt;/a&gt;. You’ll do almost the same thing you did in the &lt;a href=&quot;#hard-coding-improvement&quot;&gt;hard coding improvement&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;You will place your data in a &lt;abbr&gt;JSON&lt;/abbr&gt; file, and the &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-transformer-json/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-transformer-json&lt;/a&gt; plugin will transform them into “tour” objects. Then, you will write a GraphQL query to get those objects.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;If you prefer the &lt;abbr&gt;YAML&lt;/abbr&gt; format over &lt;abbr&gt;JSON&lt;/abbr&gt;, you can use the &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-transformer-yaml/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr&gt;YAML&lt;/abbr&gt; plugin&lt;/a&gt;.&lt;/div&gt;&lt;p&gt;You start by installing the plugin:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add gatsby-transformer-json&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, you configure it in your &lt;code&gt;gatsby-config.js&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-config.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;pkg&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./package&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  siteMetadata: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    title: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pkg&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    description: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pkg&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    author: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pkg&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;author&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  plugins: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-plugin-react-helmet&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-transformer-json&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      resolve: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-source-filesystem&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      options: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        path: `&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${__dirname}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/src/data&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      resolve: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-source-filesystem&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      options: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;images&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        path: `&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${__dirname}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/src/images&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The next thing you have to do is to you create a file in &lt;code&gt;src/data/tours.json&lt;/code&gt; with the following content. Remove the JavaScript file you added earlier, or transform it into a &lt;abbr&gt;JSON&lt;/abbr&gt; file:&lt;/p&gt;&lt;p&gt;Notice the highlighted &lt;code&gt;image&lt;/code&gt; fields:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/data/tours.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;title&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;Spain&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;price&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;description&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;1 Week in Spain&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;url&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;/tours/spain&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;image&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;images/tours/spain.jpg&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;title&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;France&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;price&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;description&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;1 Week in France&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;url&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;/tours/france&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;image&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;images/tours/france.jpg&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;title&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;Germany&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;price&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;description&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;1 Week in Germany&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;url&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;/tours/germany&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;image&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;images/tours/germany.jpg&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;title&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;Greece&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;price&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;description&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;1 Week in Greece&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;url&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;/tours/greece&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;image&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;images/tours/greece.jpg&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;title&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;Japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;price&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;description&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;1 Week in Japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;url&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;/tours/japan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;image&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;images/tours/japan.jpg&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;title&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;USA&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;price&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;800$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;description&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;1 Week in USA&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;url&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;/tours/usa&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;image&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;images/tours/usa.jpg&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With that image field, you can now place your tour images in the &lt;code&gt;src/data/images/tours&lt;/code&gt; folder. They will be available in GraphQL queries as &lt;code&gt;childImageSharp&lt;/code&gt; fields inside the tour objects. You no longer have to search for the images.&lt;/p&gt;&lt;p&gt;The &lt;code&gt;gatsby-transformer-json&lt;/code&gt; plugin created for us 2 GraphQL types: The &lt;code&gt;allToursJson&lt;/code&gt; and &lt;code&gt;toursJson&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;Because we want all the tours, write in your index page a GraphQL query that uses the &lt;code&gt;allToursJson&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  query TourQuery {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    allToursJson {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      edges {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        node {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          description&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          price&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          title&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          url&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          image {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            childImageSharp {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              fluid {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                ...GatsbyImageSharpFluid_tracedSVG&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;`;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With this query in place, your tour data will be available in the &lt;code&gt;data.allToursJson&lt;/code&gt; field. You now have to go to the index page, and display the result:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/index.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping imports&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;IndexPage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;tours&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;allToursJson&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;edges&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    return {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      image: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;childImageSharp&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;SEO&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Home&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;keywords&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;calc(100vh - 100px)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;pt&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Heading1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;textAlign&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;mb&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          Available Tours&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Heading1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Flex&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;flexWrap&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;wrap&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ maxWidth: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1200px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, margin: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;0 auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;tours&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;TourCard&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluidImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          ))&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Flex&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To recap, with this method you &lt;em&gt;accomplish 3 things&lt;/em&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You separate your data from your &lt;abbr&gt;UI&lt;/abbr&gt;.&lt;/li&gt;&lt;li&gt;You avoid code duplication.&lt;/li&gt;&lt;li&gt;You link the images with the data.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;But we still have the other requirement. To remind you, the client wants you to create pages with extra information for each tour. We conveniently ignored that requirement, but we’ll have to address it now.&lt;/p&gt;&lt;p&gt;In other words, you’ll have to create something like a blog where the blog post is a tour. A good solution for that requirement is to use the &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-mdx/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-mdx&lt;/a&gt; plugin.&lt;/p&gt;&lt;h2 id=&quot;using-abbrmdxabbr&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#using-abbrmdxabbr&quot;&gt;Using &lt;abbr&gt;MDX&lt;/abbr&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Instead of &lt;abbr&gt;MDX&lt;/abbr&gt;, you can use the traditional markdown files. The problem with markdown files is that all the tour “posts” will have the &lt;em&gt;same structure&lt;/em&gt;. For example, you can’t add an &lt;em&gt;interactive React component&lt;/em&gt;, say an accordion, in the middle of a post.&lt;/p&gt;&lt;p&gt;On the other hand, with &lt;abbr&gt;MDX&lt;/abbr&gt; you can squeeze in React code if you need to. The idea here is to create an &lt;abbr&gt;MDX&lt;/abbr&gt; file for each tour where:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The file will have &lt;code&gt;frontmatter&lt;/code&gt; fields instead of &lt;abbr&gt;JSON&lt;/abbr&gt; fields to store data for each tour.&lt;/li&gt;&lt;li&gt;For each &lt;abbr&gt;MDX&lt;/abbr&gt; file, you will create a new page with additional information.&lt;/li&gt;&lt;li&gt;You will be able to add interactive elements inside the markdown text.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;To &lt;a href=&quot;https://www.gatsbyjs.org/docs/mdx/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;use &lt;abbr&gt;MDX&lt;/abbr&gt; in Gatsby&lt;/a&gt; you need to install the following packages:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add @mdx-js/mdx @mdx-js/react gatsby-mdx&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can optionally install some remark packages to help with the formatting of the markdown:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add gatsby-remark-images gatsby-remark-smartypants gatsby-remark-copy-linked-files gatsby-remark-external-links&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You also have to configure the plugin in your &lt;code&gt;gatsby-config.js&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-config.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  siteMetadata: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    title: `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Travel Agency&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    description: `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Create a travel agency site to see theme&amp;#x27;s limitations.&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    author: `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mark&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  plugins: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      resolve: `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-source-filesystem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      options: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        name: `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;tours&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        path: `&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${__dirname}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/content/tours&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      resolve: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-source-filesystem&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      options: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;destinations&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        path: `&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${__dirname}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/content/destinations&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      resolve: `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-mdx&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      options: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        extensions: [`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.mdx&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`, `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.md&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        defaultLayouts: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          default: `&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${__dirname}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/src/components/layouts/Layout.jsx&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        gatsbyRemarkPlugins: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            resolve: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-remark-images&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            options: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              maxWidth: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1920&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              linkImagesToOriginal: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            resolve: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-remark-smartypants&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            options: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              dashes: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;oldschool&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          { resolve: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-remark-copy-linked-files&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, options: {} },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            resolve: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-remark-external-links&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            options: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              target: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;_blank&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              rel: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;noopener&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, if you place your &lt;abbr&gt;MDX&lt;/abbr&gt; files inside the &lt;code&gt;src/pages&lt;/code&gt; folder, the plugin will create pages for those files out of the box.&lt;/p&gt;&lt;p&gt;But if you do that, the &lt;abbr&gt;URL&lt;/abbr&gt; for the tour in Spain will be &lt;code&gt;https://example.com/spain-tour&lt;/code&gt;. I want it to be: &lt;code&gt;https://example.com/tours/spain&lt;/code&gt;. You may also want to have &lt;em&gt;unpublished&lt;/em&gt; tours (drafts), or the client may want to add trips to single destinations instead of only having tours. That’s why I instruct the source filesystem plugin to look inside the &lt;code&gt;content/destinations&lt;/code&gt; folder for &lt;abbr&gt;MDX&lt;/abbr&gt; files in the &lt;code&gt;gatsby-config.js&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;So, if you want to place the tour pages in a &lt;em&gt;custom path&lt;/em&gt;, you’ll have to configure yourself the page creation in your &lt;code&gt;gatsby-node.js&lt;/code&gt;. There are &lt;em&gt;2 steps&lt;/em&gt; here:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Generate slugs for the &lt;abbr&gt;MDX&lt;/abbr&gt; pages (&lt;code&gt;onCreateNode&lt;/code&gt; &lt;abbr&gt;API&lt;/abbr&gt;).&lt;/li&gt;&lt;li&gt;Create the pages (&lt;code&gt;createPages&lt;/code&gt; &lt;abbr&gt;API&lt;/abbr&gt;).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;I will explain what happens after the following code snippet:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-node.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* eslint-disable no-console */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createFilePath&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-source-filesystem&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// 1. Create those slugs from file names.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;onCreateNode&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;getNode&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createNodeField&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;internal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mdx&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createFilePath&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;getNode&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;frontmatterTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;tour&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;destination&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;frontmatterType&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;frontmatterTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;frontmatterType&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;parentPath&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;frontmatterType&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; === &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;tour&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; ? &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;tours&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;destinations&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createNodeField&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;slug&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        value: `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;parentPath&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// 2. Create pages&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createPages&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;async&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createPage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = await &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        allMdx(filter: { frontmatter: { published: { eq: true } } }) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          edges {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            node {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              fields {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                slug&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              frontmatter {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                type&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;errors&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;errors&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;allMdx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;edges&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;tourTemplate&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./src/templates/Tour.jsx&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;destinationTemplate&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./src/templates/Destination.jsx&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; === &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;tour&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;tourTemplate&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;destinationTemplate&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      path: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;fields&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;slug&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      component: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      context: { id: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the &lt;em&gt;first step&lt;/em&gt;, you create the slugs for the &lt;abbr&gt;MDX&lt;/abbr&gt; pages, and you store them as node fields.&lt;/p&gt;&lt;p&gt;In the &lt;em&gt;second step&lt;/em&gt;, you create the pages. You get all the published &lt;abbr&gt;MDX&lt;/abbr&gt; nodes, and, for each of them, you create a page where you pass:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The &lt;code&gt;slug&lt;/code&gt; you created earlier as &lt;em&gt;page path&lt;/em&gt;. This is the &lt;abbr&gt;URL&lt;/abbr&gt; that you type in the browser to get the page.&lt;/li&gt;&lt;li&gt;The node id (&lt;code&gt;gatsby-mdx&lt;/code&gt; created that) as an id field using the &lt;code&gt;context&lt;/code&gt;. This is used by a GraphQL query in the template to get the correct page.&lt;/li&gt;&lt;li&gt;You specify the &lt;em&gt;appropriate template&lt;/em&gt; depending if the &lt;abbr&gt;MDX&lt;/abbr&gt; file is a tour or a destination.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;With this configuration, you can create pages for tours and destinations. But you won’t display the last in the &lt;abbr&gt;UI&lt;/abbr&gt;, or create &lt;abbr&gt;MDX&lt;/abbr&gt; files for them. I added the logic just to show what you can do in a &lt;code&gt;gatsby-node.js&lt;/code&gt; file.&lt;/p&gt;&lt;p&gt;The next thing you’ll have to do is to create the templates in &lt;a href=&quot;https://github.com/MarkosKon/working-with-data-in-gatsby/blob/master/src/templates/Tour.jsx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;src/templates/Tour.jsx&lt;/a&gt; and &lt;a href=&quot;https://github.com/MarkosKon/working-with-data-in-gatsby/blob/master/src/templates/Destination.jsx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;src/templates/Destination.jsx&lt;/a&gt; (The code is almost the same). I won’t list the code for the templates here, check the GitHub links.&lt;/p&gt;&lt;p&gt;Now, you may want to &lt;em&gt;organize&lt;/em&gt; your &lt;abbr&gt;MDX&lt;/abbr&gt; files in the following way. Each tour will have a folder where inside that folder will be an &lt;code&gt;index.mdx&lt;/code&gt; file and the images the tour post needs:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;content&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|__ tours&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|____ france&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ france.jpg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ index.mdx&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|____ germany&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ germany.jpg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ index.mdx&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|____ greece&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ greece.jpg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ index.mdx&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|____ japan&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ japan.jpg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ index.mdx&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|____ spain&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ spain.jpg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ index.mdx&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|____ usa&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ usa.jpg&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|______ index.mdx&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;|__ destinations&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For example, the &lt;abbr&gt;MDX&lt;/abbr&gt; file for the tour in France may look like this:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;md&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;France&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;France tour&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;tour&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;published&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;2019-06-20T15:15:10.284Z&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./france.jpg&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;800$&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;duration&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;7 days&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;destination&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Paris&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;travelers&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;45+&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;---&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk4&quot;&gt;## Experience France first hand&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;import { Box } from &amp;quot;../../../src/components/Primitives&amp;quot;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;{4}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;bg&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#1d1d1d&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  Too bored at this point to add actual content but you get the idea.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It’s a tedious task to create all the files yourself, so I suggest to &lt;a href=&quot;https://github.com/MarkosKon/working-with-data-in-gatsby&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;clone the repo&lt;/a&gt;, checkout to the &lt;a href=&quot;https://github.com/MarkosKon/working-with-data-in-gatsby/tree/mdx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;mdx branch&lt;/a&gt;, and inspect the result.&lt;/p&gt;&lt;p&gt;The last &lt;em&gt;two things&lt;/em&gt; you have to do is to change the GraphQL query and the way you &lt;code&gt;map&lt;/code&gt; the data in the index page:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/index.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;15&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping imports&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;IndexPage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;tours&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;allMdx&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;edges&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    return {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;description&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;price&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      url: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;fields&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;slug&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      image: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;childImageSharp&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* skipping */&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  query Tours {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    allMdx(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      filter: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        frontmatter: { type: { eq: &amp;quot;tour&amp;quot; }, published: { eq: true } }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    ) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      edges {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        node {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          fields {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            slug&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          frontmatter {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            title&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            price&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            description&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            image {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              childImageSharp {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                fluid {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                  ...GatsbyImageSharpFluid&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;`;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;IndexPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can also check out a &lt;a href=&quot;https://egghead.io/playlists/why-gatsby-uses-graphql-1c319a1c&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;similar tutorial on Egghead&lt;/a&gt; by &lt;a href=&quot;https://twitter.com/jlengstorf&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Jason Lengstorf&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;This was an unexpectedly long post, and I kind of regret starting it (lol). Anyway, before you leave you can see some limitations this solution has in the next section.&lt;/p&gt;&lt;h2 id=&quot;limitations&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#limitations&quot;&gt;Limitations&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;The current solution with the &lt;abbr&gt;MDX&lt;/abbr&gt; files doesn’t support multiple languages. I’m sure that a travel agency will want their content to be available in a bunch of different languages. To do that, you’ll have to change your &lt;code&gt;gatsby-node.js&lt;/code&gt; file. I may add another section in the future (honestly, I won’t) on how to do this. At the very least, I can add a branch in the GitHub repo. For now, you can take a look at &lt;a href=&quot;/gatsby-react-intl-example/&quot;&gt;an internationalization guide in Gatsby&lt;/a&gt; I wrote previously.&lt;/li&gt;&lt;li&gt;If the client wants to edit and add new tours or destinations, the &lt;abbr&gt;MDX&lt;/abbr&gt; files probably won’t cut it. You may have to use a &lt;abbr&gt;CMS&lt;/abbr&gt; as your data source.&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk28 { color: #5CA7E4; }
  .night-owl-no-italics .mtk12 { color: #FFCB8B; }
  .night-owl-no-italics .mtk39 { color: #C789D6; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk4 { color: #82B1FF; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Storybook - Display code for render props components]]></title><description><![CDATA[We see a solution on how to display the correct code for render props components in Storybook.]]></description><link>https://markoskon.com/storybook-display-code-for-render-props-components/</link><guid isPermaLink="false">https://markoskon.com/storybook-display-code-for-render-props-components/</guid><pubDate>Thu, 23 May 2019 20:05:03 GMT</pubDate><content:encoded>&lt;h2 id=&quot;problem&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#problem&quot;&gt;Problem&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You have a &lt;a href=&quot;https://reactjs.org/docs/render-props.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;render props&lt;/a&gt; component, and you want to display the source code for it in &lt;a href=&quot;https://storybook.js.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Storybook&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;For example, let’s say that you have the following &lt;code&gt;Toggle&lt;/code&gt; Component:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;Toggle.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { useState } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Toggle&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;startVisible&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;visible&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setVisible&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;startVisible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toggle&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setVisible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;visible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;visible&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;toggle&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;Toggle&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  startVisible: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;Toggle&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;defaultProps&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  startVisible: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Toggle&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You write a story for it:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;stories/Toggle.stories.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { storiesOf } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@storybook/react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Toggle &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../src/components/Toggle&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;storiesOf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Toggle&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Toggle&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;visible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;toggle&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;toggle&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;visible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Hide&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Show&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;visible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            Lorem ipsum dolor sit, amet consectetur adipisicing elit.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            Dicta quo expedita tempore, sunt quos quis incidunt ratione&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            asperiores soluta impedit eveniet. Numquam, ipsum est maxime&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            hic sit rem reprehenderit dicta!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Toggle&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you want to display the source code for that story, the most obvious solution is to use the &lt;a href=&quot;https://github.com/storybooks/storybook/tree/master/addons/info&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Info addon&lt;/a&gt;. You can &lt;a href=&quot;https://github.com/storybooks/storybook/tree/master/addons/info#installation&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;install it&lt;/a&gt; with:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add -D @storybook/addon-info&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and you can use it in your story:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;stories/Toggle.stories.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { storiesOf } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@storybook/react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { withInfo } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@storybook/addon-info&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Toggle &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../src/components/Toggle&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;storiesOf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Toggle&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;addDecorator&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;withInfo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Should be before any other decorators..&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Toggle&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* skipping */&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Toggle&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you start the storybook server with &lt;code&gt;yarn storybook&lt;/code&gt;, this is what it looks like:&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/247c44f69f1fba16eb07b87e5be26651/storybook-addon-info.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/3ee095e627cdb977ada85f3210c40ce4/storybook-addon-info.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/84566e9fab8b47ebeab6edae3cd0ccb8/storybook-addon-info.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Storybook addon source&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;As you can see, when you click the “show info” button, you can’t see the render props code.&lt;/p&gt;&lt;h2 id=&quot;solution&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#solution&quot;&gt;Solution&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;To solve this, you can use another Storybook addon the &lt;a href=&quot;https://github.com/storybooks/storybook/tree/master/addons/storysource&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;storysource&lt;/a&gt;. You can &lt;a href=&quot;https://github.com/storybooks/storybook/tree/master/addons/storysource#getting-started&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;install it&lt;/a&gt; with:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add -D @storybook/addon-storysource&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Import it in your &lt;code&gt;.storybook/addons.js&lt;/code&gt; file:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.storybook/addons.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// rest addons...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@storybook/addon-storysource/register&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And create a custom Webpack configuration file in &lt;code&gt;.storybook/webpack.config.js&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.storybook/webpack.config.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;rules&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    test:&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\.&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;stories&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\.&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;jsx&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk18&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    loaders: [&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@storybook/addon-storysource/loader&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)]&lt;/span&gt;&lt;span class=&quot;mtk18&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    enforce: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;pre&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk18&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;config&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, if you restart your storybook server, you’ll see the following:&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/ac2ef491c05c5f4abe202f16a71fe650/storybook-addon-source.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/a0dcea3a0844f04236d8f788705f5e03/storybook-addon-source.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/8edaa55238de64828e24d12bfaf7ed4d/storybook-addon-source.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Storybook addon source&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;If you navigate to the “story” tab of the addons, at the bottom of the screen, you can see the correct code. Also, when you navigate between stories, the code for that story is automatically highlighted.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk28 { color: #5CA7E4; }
  .night-owl-no-italics .mtk18 { color: #5F7E97; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Implementing dark mode in React]]></title><description><![CDATA[It may seem easy, but it’s deceptively hard to get it right. We break down 4 solutions for implementing dark mode in React.]]></description><link>https://markoskon.com/dark-mode-in-react/</link><guid isPermaLink="false">https://markoskon.com/dark-mode-in-react/</guid><pubDate>Mon, 13 May 2019 22:12:03 GMT</pubDate><content:encoded>&lt;p&gt;In this post, you’ll see 4 methods you can use to add dark mode in a React application. You will also see their limitations and some of React’s limitations. If I were to start a new project, I would use only the last 2 methods or, even better, a library like &lt;a href=&quot;https://theme-ui.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Theme UI&lt;/a&gt;. Nevertheless, in my 100% unbiased opinion, I think it’s an interesting read.&lt;/p&gt;&lt;h2 id=&quot;ideal-solution&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#ideal-solution&quot;&gt;Ideal solution&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The ideal solution for implementing “dark mode” in a React application satisfies the following &lt;strong&gt;requirements&lt;/strong&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The app supports &lt;abbr title=&quot;Server-Side Rendering&quot;&gt;SSR&lt;/abbr&gt;. If the app runs only on the client-side, then all solutions work without a problem. Here I use a static/prerendered app with Gatsby.&lt;/li&gt;&lt;li&gt;The app remembers the selected mode, so you’ll want to save it in local storage.&lt;/li&gt;&lt;li&gt;The app uses React’s Context &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; to implement dark mode. You may already be using something like &lt;a href=&quot;https://www.styled-components.com/docs/advanced#theming&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;styled-components themes&lt;/a&gt; not only for colors, but for implementing a &lt;em&gt;design system&lt;/em&gt;, or for creating component &lt;em&gt;primitives&lt;/em&gt; with &lt;a href=&quot;https://styled-system.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;styled-system&lt;/a&gt; and &lt;a href=&quot;https://rebassjs.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;rebass&lt;/a&gt;. As a result, you may want the styling to be in &lt;em&gt;one place&lt;/em&gt;, and you don’t want to switch between styled-components, &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;, or inline styling.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Spoiler: None of the solutions checks all the boxes above. Let’s take them one by one to see why this happens. We’ll start with the context.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;This is &lt;em&gt;not&lt;/em&gt; a step by step guide and also covers some advanced React topics. Check this &lt;a href=&quot;https://github.com/MarkosKon/gatsby-dark-mode&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub repository that has the full code&lt;/a&gt;. I will also give a link with the relevant branch in each section.&lt;/div&gt;&lt;h2 id=&quot;dark-mode-with-context-no-local-storage&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#dark-mode-with-context-no-local-storage&quot;&gt;Dark mode with context (no local storage)&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/MarkosKon/gatsby-dark-mode&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub repo master branch&lt;/a&gt;&lt;/p&gt;&lt;p&gt;In the first solution, you’ll use context, but you won’t save the theme in the local storage. To implement the context, I’m using a blog post by Kent C. Dodds called &lt;a href=&quot;https://kentcdodds.com/blog/how-to-use-react-context-effectively&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;How to use react context effectively.&lt;/em&gt;&lt;/a&gt; (See also &lt;a href=&quot;https://github.com/kentcdodds/kentcdodds.com/blob/319db97260078ea4c263e75166f05e2cea21ccd1/content/blog/how-to-optimize-your-context-value/index.md&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;How to optimize your context value&lt;/em&gt;&lt;/a&gt;). The truth is that I’m not applying the performance optimizations from the linked posts because they are not relevant in our case—more about that in a bit.&lt;/p&gt;&lt;p&gt;Create a new file &lt;code&gt;theme-context.jsx&lt;/code&gt; and place it in the &lt;code&gt;src/context&lt;/code&gt; folder. The file looks like this:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/context/theme-context.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  useState,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  useContext,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  useCallback,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  createContext,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;} &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;ThemeProvider&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; BaseThemeProvider } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;styled-components&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { lightTheme, darkTheme } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../themes&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;ThemeContext&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createContext&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;ThemeProvider&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;themeString&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setThemeString&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;themeObject&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;themeString&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; === &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; ? &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;darkTheme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;lightTheme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;ThemeContext.Provider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;themeString&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;setThemeString&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;BaseThemeProvider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;themeObject&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;BaseThemeProvider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;ThemeContext.Provider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useContext&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;ThemeContext&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;throw&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;useTheme must be used within a ThemeProvider&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;themeString&lt;/span&gt;&lt;span class=&quot;mtk18&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setThemeString&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toggleTheme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useCallback&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    if &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;themeString&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; === &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setThemeString&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    else if &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;themeString&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; === &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setThemeString&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;span class=&quot;mtk18&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;themeString&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    theme: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;themeString&lt;/span&gt;&lt;span class=&quot;mtk18&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;toggleTheme&lt;/span&gt;&lt;span class=&quot;mtk18&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { ThemeProvider, useTheme };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let’s try to break down what’s going on in this file. In short, we’re creating a new context for the theme that we can use inside our components with a hook. More specifically:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;We create a new component that stores the current theme in the state. The current theme is a string that can be &lt;code&gt;&amp;quot;light&amp;quot;&lt;/code&gt; or &lt;code&gt;&amp;quot;dark&amp;quot;&lt;/code&gt;. We call the component &lt;code&gt;ThemeProvider&lt;/code&gt; but think of it as a regular React component that has some state and renders some children.&lt;/li&gt;&lt;li&gt;We use the theme from the state as the &lt;code&gt;value&lt;/code&gt; for a new context (&lt;code&gt;ThemeContext&lt;/code&gt;). We wrap the &lt;code&gt;children&lt;/code&gt; of the previous component with the &lt;code&gt;ThemeContext.Provider&lt;/code&gt; (See how to use &lt;a href=&quot;https://reactjs.org/docs/context.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;context in React docs&lt;/a&gt;).&lt;/li&gt;&lt;li&gt;In the same component, we use the theme provider from &lt;code&gt;styled-components&lt;/code&gt; (&lt;code&gt;BaseThemeProvider&lt;/code&gt;). We wrap the &lt;code&gt;children&lt;/code&gt; of the component with the &lt;code&gt;BaseThemeProvider&lt;/code&gt; and synchronize the two themes when the first changes. We synchronize the two themes with the &lt;code&gt;themeObject&lt;/code&gt; variable which is also the &lt;code&gt;value&lt;/code&gt; for the &lt;code&gt;styled-components&lt;/code&gt; context.&lt;/li&gt;&lt;li&gt;We’ll wrap Gatsby’s root element with the &lt;code&gt;ThemeProvider&lt;/code&gt; component (in a bit) in &lt;code&gt;gatsby-browser.js&lt;/code&gt; and &lt;code&gt;gatsby-ssr.js&lt;/code&gt; files.&lt;/li&gt;&lt;li&gt;Finally, we create a hook that uses the new context. Inside that hook, we show an error if someone tries to use the context outside of a provider (see the previous step). We also memoize the &lt;code&gt;toggleTheme&lt;/code&gt; function with a &lt;code&gt;useCallback&lt;/code&gt; hook, but, in this case, it’s not that important because we won’t pass that function as a prop to a component. You can remove it if you want. &lt;strong&gt;To use the theme context in a component, you only have to use the hook.&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;You might be wondering why are we creating a new context for the current theme, instead of using the context from &lt;code&gt;styled-components&lt;/code&gt;. We do that because we want inside the context &lt;code&gt;value&lt;/code&gt; the function that toggles the theme, something that the context from &lt;code&gt;styled-components&lt;/code&gt; &lt;a href=&quot;https://github.com/styled-components/styled-components/blob/master/packages/styled-components/src/models/ThemeProvider.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;doesn’t seem to offer&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Let’s now talk about the performance optimizations we skipped—you can safely skip this paragraph. The &lt;code&gt;value&lt;/code&gt; we pass to the theme context is an object. We pass it with &lt;code&gt;value={{ themeString, setThemeString }}&lt;/code&gt;. This means that we are creating and passing a different object in each render. The components that use the context render when the value of the context changes. In a hypothetical scenario where a parent of the &lt;code&gt;ThemeProvider&lt;/code&gt; component renders, the &lt;code&gt;ThemeProvider&lt;/code&gt; component should also render. Because the value of the context is different in every render, that means that the components that use the context should also render. These would be some unnecessary renders because the theme didn’t change. For this reason, many people memoize the context &lt;code&gt;value&lt;/code&gt; with the &lt;code&gt;useMemo&lt;/code&gt; hook to ensure that it doesn’t change when the theme is the same. Additionally, they wrap the components that use the theme with &lt;code&gt;memo&lt;/code&gt; that prevents re-renders when the props are the same. See this &lt;a href=&quot;https://codesandbox.io/s/ryyqj2nl6n?view=editor&amp;amp;file=/src/count-context.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;codesandbox&lt;/a&gt; from Kent C. Dodds that illustrates that. In our case, we’re not wrapping the &lt;code&gt;ThemeProvider&lt;/code&gt; component in a parent component that renders all the time. The only time the &lt;code&gt;ThemeProvider&lt;/code&gt; renders is when the theme changes, and, in this case, we want the components that use the context to render. That’s why I skipped the performance optimizations.&lt;/p&gt;&lt;p&gt;Next, you want to create the &lt;code&gt;styled-components&lt;/code&gt; theme objects in &lt;code&gt;src/themes/&lt;/code&gt; folder. I said that I want to use the theme for other things, not only for colors but let’s use them only for colors to keep the code simple:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/themes/index.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;lightTheme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  bg: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  bgDark: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;pink&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  accent: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;blue&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;darkTheme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  bg: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#2c1320&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  bgDark: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#15090f&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  accent: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#ef86a9&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { lightTheme, darkTheme };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, you wrap the Gatsby’s root element in &lt;code&gt;gatsby-browser.js&lt;/code&gt; and &lt;code&gt;gatsby-ssr.js&lt;/code&gt;. The files are identical; just copy-and-paste the same code:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-ssr.js/gatsby-browser.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;normalize.css&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;typeface-fira-sans&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;typeface-merriweather&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { ThemeProvider } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./src/context/theme-context&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; GlobalStyle &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./src/components/GlobalStyle&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;wrapRootElement&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;ThemeProvider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;GlobalStyle&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;ThemeProvider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You also want a &lt;code&gt;Toggle&lt;/code&gt; component that will switch between light and dark mode. For this reason, I copied the Toggle component from Dan Abramov’s blog, which is a slightly altered &lt;code&gt;Toggle&lt;/code&gt; from &lt;a href=&quot;https://github.com/aaronshaf/react-toggle&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;react-toggle&lt;/a&gt;. In the comments, it says that it has some &lt;em&gt;accessibility&lt;/em&gt; improvements. So you can either copy the &lt;a href=&quot;https://github.com/gaearon/overreacted.io/blob/master/src/components/Toggle.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Toggle.js&lt;/code&gt;&lt;/a&gt;, &lt;a href=&quot;https://github.com/gaearon/overreacted.io/blob/master/src/components/Toggle.css&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Toggle.css&lt;/code&gt;&lt;/a&gt;, and add the &lt;a href=&quot;https://github.com/gaearon/overreacted.io/tree/master/src/assets&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;sun/moon images&lt;/a&gt; from &lt;a href=&quot;https://github.com/gaearon/overreacted.io&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Dan Abramov’s blog&lt;/a&gt;, or just use the default toggle from &lt;code&gt;react-toggle&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;You’ll place the toggle somewhere in the &lt;code&gt;Header&lt;/code&gt; component. I’m also using the theme colors, in the &lt;code&gt;Container&lt;/code&gt; component, and the theme hook:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/header.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Link } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; styled &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;styled-components&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Toggle &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./Toggle&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; sun &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../images/sun.png&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; moon &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../images/moon.png&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { useTheme } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../context/theme-context&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Container&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;styled&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;bgDark&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;margin-bottom&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1.45&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;rem&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;text-decoration&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Header&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;siteTitle&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toggleTheme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Container&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          margin: &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;0 auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          maxWidth: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;960&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          padding: &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1.45rem 1.0875rem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ margin: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;siteTitle&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Toggle&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;defaultChecked&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;toggleTheme&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;icons&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;checked&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;img&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ pointerEvents: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;moon&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;aria-hidden&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;moon&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;unchecked&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;img&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ pointerEvents: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;sun&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;aria-hidden&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;sun&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Container&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;Header&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  siteTitle: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;Header&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;defaultProps&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  siteTitle: ``,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Header&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And this is what the app looks like after the changes:&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/e8de77823b81a482675dee78c01b7bd4/context.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/77e7058f9b595dbe84812a690fb78ca1/context.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/17c4eaf477063b47e382523a7f7fa725/context.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Dark mode with context&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;It works fine in both development and production modes, but every time you &lt;em&gt;reload&lt;/em&gt; the page, it defaults back to light mode. If your app doesn’t reload much, it might be ok; but you never know how the user will use your app. As a result, this behavior can become &lt;em&gt;annoying&lt;/em&gt; really fast. To fix that, you can save the preferred user theme in &lt;em&gt;local storage&lt;/em&gt;:&lt;/p&gt;&lt;h2 id=&quot;dark-mode-with-context-and-local-storage&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#dark-mode-with-context-and-local-storage&quot;&gt;Dark mode with context and local storage&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/MarkosKon/gatsby-dark-mode/tree/context-local-storage-bug&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub repo context-local-storage-bug branch&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I will use a custom hook to save the theme string in local storage. Alternatively, you can use an &lt;a href=&quot;https://github.com/dance2die/react-use-localstorage&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Node Package Manager&quot;&gt;NPM&lt;/abbr&gt; package&lt;/a&gt; for that. You can use the &lt;code&gt;useLocalStorage&lt;/code&gt; hook by giving a &lt;code&gt;name&lt;/code&gt; string (theme) and the &lt;code&gt;initialValue&lt;/code&gt; (“light”). It returns the value and a function to change it. The hook keeps in the state the value, and when the value changes, it runs a side-effect to save the value in the local storage. It initializes the state with the existing value in local storage or with the &lt;code&gt;initialValue&lt;/code&gt; from the user. It also has some guards for &lt;abbr title=&quot;Server-Side Rendering&quot;&gt;SSR&lt;/abbr&gt; (&lt;code&gt;windowGlobal&lt;/code&gt; variable).&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/hooks/useLocalStorage.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { useState, useEffect } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useLocalStorage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;initialValue&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;windowGlobal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;typeof&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; !== &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;undefined&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &amp;amp;&amp;amp; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setValue&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    if &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;windowGlobal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;currentValue&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;windowGlobal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;localStorage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getItem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      return &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;currentValue&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; ? &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;currentValue&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;initialValue&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    return &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;initialValue&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    if &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;windowGlobal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;windowGlobal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;localStorage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setItem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;JSON&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;stringify&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;windowGlobal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;setValue&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To use this hook in the &lt;code&gt;ThemeProvider&lt;/code&gt;, you only have to change 2 lines of code:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/context/theme-context.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { useContext, useCallback, createContext } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;ThemeProvider&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; BaseThemeProvider } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;styled-components&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { useLocalStorage } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../hooks/useLocalStorage&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { lightTheme, darkTheme } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../themes&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;ThemeContext&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createContext&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;ThemeProvider&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;themeString&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setThemeString&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useLocalStorage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;themeObject&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;themeString&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; === &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; ? &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;darkTheme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;lightTheme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;ThemeContext.Provider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;themeString&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;setThemeString&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;BaseThemeProvider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;themeObject&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;BaseThemeProvider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;ThemeContext.Provider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping hook implementation&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { ThemeProvider, useTheme };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you try it in development, it works fine. You can switch the theme by pressing the toggle, and if you reload the page, the app remembers your preference. But if you build it with &lt;code&gt;gatsby build&lt;/code&gt;, and serve it locally with &lt;code&gt;gatsby serve&lt;/code&gt;, you’ll see the following:&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/d57a60dc90ba5370463bcb9af6541ed8/context-local-storage.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/5b8d469e568033a8dd878c3b3379bf06/context-local-storage.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/4919fbc13c44006d4190094ee13e1288/context-local-storage.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;The bug with context and local storage&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;If you choose the dark mode, the theme is getting stored correctly in local storage, but if you reload the page you see the light mode. Also, the &lt;code&gt;Toggle&lt;/code&gt; component is now broken. It needs some extra clicks to change the theme after reloading the page (if you had dark mode selected). If you log in the console the themes and context, you’ll see that everything is fine; the dark mode is selected as expected. So, why is this happening?&lt;/p&gt;&lt;p&gt;This happens because of how React’s &lt;em&gt;hydrate&lt;/em&gt; method treats differences between client and server. During build time, we apply the default light theme, so we add to the &lt;abbr title=&quot;Document Object Model&quot;&gt;DOM&lt;/abbr&gt; elements the &lt;code&gt;styled-components&lt;/code&gt; classes for the light theme. When we go to the client and try to hydrate the markup, React sees that we now have a &lt;em&gt;different theme&lt;/em&gt; from local storage, so we want to apply &lt;em&gt;different classes&lt;/em&gt; for the dark mode. &lt;a href=&quot;https://reactjs.org/docs/react-dom.html#hydrate&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;React doesn’t do that for attributes&lt;/a&gt;. Only for text &lt;a href=&quot;https://github.com/facebook/react/issues/11128#issuecomment-334882514&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;mainly because of timestamps differences&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;You can see that if you create a post context with 3 posts, and store them the same way you store the theme in local storage. After you save them in local storage, you can comment one post out to create a difference between the server (3 posts) and the client (2 posts). You’ll see that React will hydrate the text correctly, as it’s shown in the following video:&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/MarkosKon/gatsby-dark-mode/tree/posts&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub repo posts branch&lt;/a&gt;&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/745ec82ad96e40e750471ccefebb0d4f/posts.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/f6349e12c14a59bf7f5d3324e5c064f9/posts.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/548b0d7be297939849e62b9282e95e06/posts.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;React hydrates the text correctly&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;In this case, &lt;a href=&quot;https://github.com/facebook/react/issues/8017#issuecomment-256351955&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;you can force an extra render&lt;/a&gt; when the component mounts to update the classes. If you do that, this is what the app looks like in production:&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/1a470441c451d73bf2b07fbdad18a88b/context-local-storage-correct.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/a4193bd8e857e6fdaf1f3cf3984ba769/context-local-storage-correct.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/25e7017e3a997a70d7377424cd1748dd/context-local-storage-correct.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Forcing an extra render&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/MarkosKon/gatsby-dark-mode/tree/context-local-storage&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub repo context-local-storage (correct)&lt;/a&gt;&lt;/p&gt;&lt;p&gt;It works now, but you momentarily see a &lt;em&gt;flash of unstyled content&lt;/em&gt;. This happens because you go quickly from light to dark mode. It’s quite noticeable because the color differences are big. You can &lt;em&gt;tone it down&lt;/em&gt; if you add a &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; transition in the items that change color, but you’ll have to do this for every item. Also, if your app takes some time to load, or the users access your app from a slow network, they will be stuck for a while with the incorrect theme until the app becomes interactive.&lt;/p&gt;&lt;p&gt;It seems that you &lt;em&gt;can’t&lt;/em&gt; have a perfect solution if you only use context. In the following method, you’ll run some code &lt;em&gt;before React&lt;/em&gt; to manipulate the &lt;abbr title=&quot;Document Object Model&quot;&gt;DOM&lt;/abbr&gt; and change the colors with &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; variables&lt;/a&gt;:&lt;/p&gt;&lt;h2 id=&quot;dan-abramovs-solution-with-css&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#dan-abramovs-solution-with-css&quot;&gt;Dan Abramov’s solution with &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;em&gt;In this section, I will only give a brief overview of this method. If you want the full code, please check the &lt;a href=&quot;https://github.com/MarkosKon/gatsby-dark-mode/tree/css&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; branch on the GitHub repository&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;You saw earlier that you can’t rely on context due to the way React’s hydrate method treats differences between client and server. So you’ll have to do something else. You’ll want to run your JavaScript code that will initialize the dark mode in a &lt;code&gt;script&lt;/code&gt; tag (before React loads). You’ll place that &lt;code&gt;script&lt;/code&gt; right after the opening &lt;code&gt;body&lt;/code&gt; tag because you want the &lt;code&gt;body&lt;/code&gt; element to exist, but you don’t want the browser to render something on the screen and see that flash again. This works because &lt;a href=&quot;https://hacks.mozilla.org/2017/09/building-the-dom-faster-speculative-parsing-async-defer-and-preload/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;inline scripts block rendering&lt;/a&gt;. In a Gatsby application, one of the ways you can add a script tag is by &lt;a href=&quot;https://www.gatsbyjs.org/docs/custom-html/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;overriding the default html.js file&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Inside that script, you declare an &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Glossary/IIFE&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Immediately-invoked Function Expression&quot;&gt;IIFE&lt;/abbr&gt;&lt;/a&gt; where you do the following:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You get the saved theme from local storage and save the correct one if necessary.&lt;/li&gt;&lt;li&gt;You perform a &lt;a href=&quot;https://caniuse.com/#feat=prefers-color-scheme&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;matchMedia query for a preferred color scheme&lt;/a&gt;. If the user has a preferred color scheme, you aggregate the saved and the preferred, giving priority to the saved.&lt;/li&gt;&lt;li&gt;You add a class to the body element for the preferred mode (dark, light). You declare your colors with &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; custom properties under &lt;code&gt;body.light&lt;/code&gt; and &lt;code&gt;body.dark&lt;/code&gt; (meaning that the colors will change when the class of the body changes).&lt;/li&gt;&lt;li&gt;You attach to the window object the current theme and some methods that you’ll use inside your &lt;code&gt;header&lt;/code&gt; component later to change the theme.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/html.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;HTML&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;extends&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;React&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Component&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;htmlAttributes&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;charSet&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;utf-8&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;httpEquiv&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;x-ua-compatible&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;ie=edge&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;meta&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;viewport&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;width=device-width, initial-scale=1, shrink-to-fit=no&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;headComponents&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;bodyAttributes&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;script&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;dangerouslySetInnerHTML&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              __html: &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              (function() {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                window.__onThemeChange = function() {};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                function setTheme(newTheme) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                  window.__theme = newTheme;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                  preferredTheme = newTheme;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                  document.body.className = newTheme;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                  window.__onThemeChange(newTheme);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                var preferredTheme;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                try {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                  preferredTheme = localStorage.getItem(&amp;#x27;theme&amp;#x27;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                } catch (err) { }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                window.__setPreferredTheme = function(newTheme) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                  setTheme(newTheme);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                  try {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                    localStorage.setItem(&amp;#x27;theme&amp;#x27;, newTheme);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                  } catch (err) {}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                var darkQuery = window.matchMedia(&amp;#x27;(prefers-color-scheme: dark)&amp;#x27;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                darkQuery.addListener(function(e) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                  window.__setPreferredTheme(e.matches ? &amp;#x27;dark&amp;#x27; : &amp;#x27;light&amp;#x27;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                setTheme(preferredTheme || (darkQuery.matches ? &amp;#x27;dark&amp;#x27; : &amp;#x27;light&amp;#x27;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              })();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;preBodyComponents&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;___gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;dangerouslySetInnerHTML&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ __html: &lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;body }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;postBodyComponents&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;HTML&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  htmlAttributes: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  headComponents: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  bodyAttributes: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  preBodyComponents: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  body: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  postBodyComponents: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is the code outside of the template string with comments that explain what it does:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// This is a callback that gets called by setTheme.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// You’ll assign a setState function to this callback to&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// update the React state later inside the header component.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__onThemeChange&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// An inner function that changes the mode but&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// doesn’t save in local storage. You won’t use this.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// This is used inside the header component&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// to set the initial state. It’s also used to keep track&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// of the mode when the header component mounts/unmounts.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;__theme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;preferredTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__onThemeChange&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Get the saved theme from local storage&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;preferredTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;preferredTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;localStorage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getItem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// The function that changes the mode and saves&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// to local storage. You’ll use that inside the header&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// component.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__setPreferredTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;localStorage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setItem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk18&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;darkQuery&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;matchMedia&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;(prefers-color-scheme: dark)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// When the user changes the preferred color scheme,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// call the window.__setPreferredTheme method.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;darkQuery&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__setPreferredTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;matches&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Set the theme for the first time by aggregating the&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// saved theme (preferred theme variable) and the color&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// scheme query. Don&amp;#x27;t forget the parenthesis, they are&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// important&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;preferredTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;darkQuery&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;matches&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;})();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Next, go to the &lt;code&gt;Header&lt;/code&gt; component (because that’s where the &lt;code&gt;Toggle&lt;/code&gt; component is) and do the following:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Get the correct theme from &lt;code&gt;window.__theme&lt;/code&gt; in an effect that runs only on mount.&lt;/li&gt;&lt;li&gt;When the user clicks the &lt;code&gt;Toggle&lt;/code&gt; to change the theme, you call the &lt;code&gt;window.__setPreferredTheme()&lt;/code&gt; method. This method saves the theme in &lt;code&gt;localStorage&lt;/code&gt;, and updates the body class and the React state.&lt;/li&gt;&lt;li&gt;The &lt;code&gt;window.__onThemeChange()&lt;/code&gt; is a callback that gets called by &lt;code&gt;window.setPreferredTheme()&lt;/code&gt; and updates the React state in this case.&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/header.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { useState, useEffect } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipped&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Container&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;styled&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;--color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;--bgDark&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;margin-bottom&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1.45&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;rem&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;text-decoration&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;--color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Header&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;siteTitle&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setTheme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;__theme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__onThemeChange&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;__theme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [])&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Container&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          margin: &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;0 auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          maxWidth: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;960&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          padding: &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1.45rem 1.0875rem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ margin: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;siteTitle&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Toggle&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;checked&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__setPreferredTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;checked &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        ) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ height: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;28px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Container&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipped&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Because you don’t want to render the Toggle with the wrong state on mount, you render a placeholder &lt;code&gt;div&lt;/code&gt; element if the theme is &lt;code&gt;null&lt;/code&gt;. The theme is &lt;code&gt;null&lt;/code&gt; on mount both in development and production, which is a good thing because you don’t want differences between the development and production. An alternative is to use the &lt;code&gt;useLayoutEffect&lt;/code&gt; instead of &lt;code&gt;useEffect&lt;/code&gt; that will run the effect before React renders the component with the wrong state on screen. This is not a good practice, though, because it delays browser paints. So pretend I didn’t mention it and stick with the first option.&lt;/p&gt;&lt;p&gt;Now, you can use &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; variables for the colors instead of getting them from the &lt;code&gt;styled-components&lt;/code&gt; theme. I define those variables in a &lt;code&gt;GlobalStyle.jsx&lt;/code&gt; component in this example, but you can import a regular &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; file if you want:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/GlobalStyle.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { createGlobalStyle } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;styled-components&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;GlobalStyle&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createGlobalStyle&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipped&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;--accent&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;--bg&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.light&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;--bg&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;--bg&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;D&lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;ark&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pink&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;--color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;--accent&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;blue&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.dark&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;-webkit-font-smoothing&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;antialiased&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;--bg&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;2c1320&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;--bg&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;D&lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;ark&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;15090f&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;--color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;--accent&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;ef86a9&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;GlobalStyle&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you build the application, this is how it looks. P.S. Not exactly, in the following video I render the &lt;code&gt;Toggle&lt;/code&gt; in the wrong state on mount. You can see that when I change the theme to dark mode and refresh the page. Don’t worry though, the code above doesn’t do that.&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/d9b4fff385e76aecedb8eaf0a8e58e00/css.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/32bfd11d7dbbbdee191dd2aa010e1d5b/css.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/49a0884193591ed680d4f9b89bbbd23c/css.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;The solution with &lt;abbr&gt;CSS&lt;/abbr&gt; variables&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;By the way, in this example, I’m still wrapping the root element with a &lt;code&gt;ThemeProvider&lt;/code&gt; from &lt;code&gt;styled-components&lt;/code&gt;. I just don’t use the theme for the colors. See an out-of-the-box &lt;a href=&quot;/dark-mode-in-react-with-theme-ui/&quot;&gt;dark mode solution with Theme UI&lt;/a&gt; if you don’t like that. I should also note that &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; variables (or &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; custom properties) &lt;a href=&quot;https://caniuse.com/#feat=css-variables&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;do not work on Internet Explorer&lt;/a&gt;.&lt;/p&gt;&lt;h2 id=&quot;a-refactor-of-the-css-solution&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#a-refactor-of-the-css-solution&quot;&gt;A refactor of the &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; solution&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/MarkosKon/gatsby-dark-mode/tree/css-refactor&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub repo css-refactor branch&lt;/a&gt;&lt;/p&gt;&lt;p&gt;When I first wrote this article more than a year ago, I treated Dan’s solution as a black box without explaining it much which is something I didn’t like. I made some edits in the previous section, but I also want to show you a refactor of this method.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;This section needs a rewrite (a rewrite of the rewrite) because after writing it, I experimented a bit more and  pushed to the repo more branches that use a &lt;em&gt;context provider&lt;/em&gt; that I think are better. Check the GitHub repo (&lt;a href=&quot;https://github.com/MarkosKon/gatsby-dark-mode/tree/master&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;master branch&lt;/a&gt;) for those solutions.&lt;/div&gt;&lt;p&gt;The gist of this method is that you want to run the code that switches the mode in a script. In other words, you take the control from React and give it to an inline script. You do that because React doesn’t handle this use case well. In the next snippet, you can see the script code with syntax highlighting, outside of a string prop:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__onThemeChange&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;__theme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;preferredTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__onThemeChange&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;preferredTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;preferredTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;localStorage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getItem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__setPreferredTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;localStorage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setItem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk18&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;darkQuery&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;matchMedia&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;(prefers-color-scheme: dark)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;darkQuery&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__setPreferredTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;matches&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;preferredTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;darkQuery&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;matches&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;})();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I find it a bit complicated, so, in the next snippet, you can find a more straight-forward (?) version with comments that explain what happens in each step:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// I use regular functions and var instead of&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// const to support older browsers (not IE).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// I also give names to the functions for&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// easier debugging.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;initializeTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 1. Get the existing theme from local storage&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// and save it to window.__theme.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;__theme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;localStorage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getItem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Couldn’t get the theme from local storage.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 2. Inside React, you “subscribe” to theme updates by&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// overwriting the following callback.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__onThemeChangeCallback&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 3. The function that changes the theme and&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// calls the callback.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// You’ll use that variable to set the initial&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// React state. It&amp;#x27;s also used to store the&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// correct mode when the component mounts&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// and unmounts.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;__theme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Change the class, call the callback, and&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// save the theme in local storage.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__onThemeChangeCallback&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;localStorage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setItem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk18&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Couldn’t save the theme in local storage.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 4. A color scheme listener that calls the setTheme&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// method.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;darkQuery&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;matchMedia&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;(prefers-color-scheme: dark)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;darkQuery&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;darkQueryListener&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;matches&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// 5. Set the theme for the first time according to&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// the saved theme and the color scheme query.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;__theme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;darkQuery&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;matches&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;})();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A problem with both of those snippets is that you can’t use the code inside the Toggle for more than one component. You can’t extract it to a &lt;code&gt;useDarkMode&lt;/code&gt; hook for example because every time you assign a callback to &lt;code&gt;onThemeChangeCallback&lt;/code&gt;, inside a React component, you overwrite the previous component’s callback. As a result, their state will get out of sync. If you want to use the theme only inside a &lt;code&gt;Toggle&lt;/code&gt; component, you don’t have a problem. You can try to solve this by using the theme in a single context component, but you may face the same problems with hydration all over again. So instead of overwriting a single callback, you can keep track of a callback array, and then iterate through it inside the script and call them one-by-one. You can also overengineer the problem with an observer pattern.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;initializeTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;__theme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;localStorage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getItem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Couldn’t get the theme from local storage.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__addCallback&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cb&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cb&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__removeCallback&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cb&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!==&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cb&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;__theme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cb&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cb&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;localStorage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setItem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk18&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;newTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Couldn’t save the theme in local storage.&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;var &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;darkQuery&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;matchMedia&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;(prefers-color-scheme: dark)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;darkQuery&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;addListener&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;darkQueryListener&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;matches&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;__theme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;||&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;darkQuery&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;matches&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;})();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This how to use the code above inside the &lt;code&gt;Header&lt;/code&gt; component.&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/header.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;__theme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;__theme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__addCallback&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__removeCallback&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;callback&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}, []);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/header.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Toggle&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;checked&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    window&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;__setTheme&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;checked &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dark&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;light&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I use the last solution in this blog, and, as far as I know, it works. The only difference is that I don’t use a &lt;code&gt;Layout&lt;/code&gt; component that unmounts on page change. Instead, I wrap Gatsby’s &lt;code&gt;pageElement&lt;/code&gt; with the &lt;code&gt;Layout&lt;/code&gt;.&lt;/p&gt;&lt;h2 id=&quot;links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://kentcdodds.com/blog/how-to-use-react-context-effectively&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;How to use react context effectively&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://kentcdodds.com/blog/always-use-memo-your-context-value&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Always use memo your context value&lt;/a&gt;&lt;/li&gt;&lt;li&gt;React hydrate styles:&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/facebook/react/issues/11128#issuecomment-334882514&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://github.com/facebook/react/issues/11128#issuecomment-334882514&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/facebook/react/issues/8017#issuecomment-256351955&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://github.com/facebook/react/issues/8017#issuecomment-256351955&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://reactjs.org/docs/react-dom.html#hydrate&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://reactjs.org/docs/react-dom.html#hydrate&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Dan Abramov’s dark mode implementation:&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://twitter.com/dan_abramov/status/1086790808840343552&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Twitter thread&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/gaearon/overreacted.io/commit/4ef0b123c76a3836fe6db67c500255c241c490f8&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Switch from context to &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; (source code on GitHub)&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/gaearon/overreacted.io/blob/master/src/html.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Override Gatsby’s html.js&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/gaearon/overreacted.io/blob/master/src/components/Layout.js&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Layout component&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/gaearon/overreacted.io/blob/master/src/utils/global.css&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Night Mode with Mix Blend Mode: Difference&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://dev.wgao19.cc/2019-05-04__sun-moon-blending-mode/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Post&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://darkmodejs.learn.uno&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Library&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Other dark mode solutions. They kind of fall into the previous 3 categories.&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://flaviocopes.com/dark-mode/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://flaviocopes.com/dark-mode/&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://medium.com/maxime-heckel/switching-off-the-lights-adding-dark-mode-to-your-react-app-with-context-and-hooks-f41da6e07269&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://medium.com/maxime-heckel/switching-off-the-lights-adding-dark-mode-to-your-react-app-with-context-and-hooks-f41da6e07269&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-plugin-use-dark-mode/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://www.gatsbyjs.org/packages/gatsby-plugin-use-dark-mode/&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/donavon/use-dark-mode#readme&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;https://github.com/donavon/use-dark-mode#readme&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtki { font-style: italic; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk12 { color: #FFCB8B; }
  .night-owl-no-italics .mtk18 { color: #5F7E97; }
  .night-owl-no-italics .mtk15 { color: #80CBC4; }
  .night-owl-no-italics .mtk26 { color: #EC5F67; }
  .night-owl-no-italics .mtk11 { color: #FFEB95; }
  .night-owl-no-italics .mtk16 { color: #FF6363; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk43 { color: #41EEC6; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Displaying hundreds of images with react-window and gatsby-image]]></title><description><![CDATA[See how to display hundreds of images with react-window and gatsby-image by building an app that displays all the Hearthstone cards in a grid. You can also see the compromises you have to make.]]></description><link>https://markoskon.com/displaying-hundreds-of-images-with-react-window-and-gatsby-image/</link><guid isPermaLink="false">https://markoskon.com/displaying-hundreds-of-images-with-react-window-and-gatsby-image/</guid><pubDate>Sat, 30 Mar 2019 22:12:03 GMT</pubDate><content:encoded>&lt;p&gt;This post is a step-by-step guide on how to use &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-image/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-image&lt;/a&gt; and &lt;a href=&quot;https://github.com/bvaughn/react-window&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;react-window&lt;/a&gt; to display a large number of images. The app we’re going to build displays in a grid all the available &lt;a href=&quot;https://playhearthstone.com/en-us/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Hearthstone&lt;/a&gt; cards. We choose Hearthstone cards because well… I like Hearthstone and because at this moment, there are over 1800 cards. That translates to a lot of images we’ll have to display, so it’ll be a good exercise. The &lt;a href=&quot;https://github.com/MarkosKon/gatsby-image-react-window&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;completed project&lt;/a&gt; is available on GitHub if you want to take a look. We’ll also see some &lt;a href=&quot;#caveats&quot;&gt;limitations&lt;/a&gt; our approach has along the way.&lt;/p&gt;&lt;h2 id=&quot;get-the-project&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#get-the-project&quot;&gt;Get the project&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you want to follow along, clone the project, and checkout to the &lt;em&gt;start&lt;/em&gt; branch. In this branch, we’ve used the default Gatsby starter, removed some unused files, edited some styles, and finally, we added the data and the images. It has over 1800 images (about 90mb), so it may take a while to download.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Get the project&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;git clone https://github.com/MarkosKon/gatsby-image-react-window&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; gatsby-image-react-window&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;git checkout start&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;install-and-configure&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#install-and-configure&quot;&gt;Install and configure&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The next thing we want to do is to install our dependencies. The default Gatsby starter has already installed and configured all the image plugins we need. We only need to install &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-transformer-json/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-transformer-json&lt;/a&gt; which will parse our data. We’ll also install 3 libraries for &lt;code&gt;react-window&lt;/code&gt; and &lt;a href=&quot;https://www.npmjs.com/package/lodash.sortby&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;lodash.sortby&lt;/a&gt; to sort our data:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Install dependencies&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add gatsby-transformer-json&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add react-window react-virtualized-auto-sizer memoize-one&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add lodash.sortby&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After we install our dependencies, we’ll configure the transformer &lt;abbr&gt;JSON&lt;/abbr&gt; plugin. This is a &lt;a href=&quot;https://www.gatsbyjs.org/tutorial/part-six/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;transformer plugin&lt;/a&gt; that transforms the output of the &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-source-filesystem/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-source-filesystem&lt;/a&gt; into something more useful. As a result, we’ll have to point a folder to the source plugin (&lt;code&gt;src/data/cards&lt;/code&gt;), and give our data a name (&lt;em&gt;cards&lt;/em&gt;) that we’ll use later in our GraphQL queries. To do that, we open the &lt;code&gt;gatsby-config.js&lt;/code&gt; file, and we add the highlighted lines:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-config.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  siteMetadata: { &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* ...skipping stuff */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;plugins&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// ...skipping stuff&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      resolve: `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-source-filesystem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      options: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        name: `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        path: `&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${__dirname}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/src/data/cards&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-transformer-sharp&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-plugin-sharp&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-transformer-json&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// ...skipping stuff&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  ]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The transformer &lt;abbr&gt;JSON&lt;/abbr&gt; plugin will prepare for us 2 GraphQL &lt;em&gt;types&lt;/em&gt;: &lt;code&gt;allCardsJson&lt;/code&gt; and &lt;code&gt;cardsJson&lt;/code&gt;. We’ll use the &lt;em&gt;first&lt;/em&gt;. You can play around with the GraphQL queries in the GraphiQL server if you navigate to &lt;code&gt;http://localhost:8000/___graphql&lt;/code&gt;. Remember that we have thousands of images, so it may take a while to process them as we’ll see soon (spoiler: it took me 7 minutes).&lt;/p&gt;&lt;h3 id=&quot;magic-tricks&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#magic-tricks&quot;&gt;Magic tricks&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;I want to mention here a &lt;em&gt;cool trick&lt;/em&gt; we do with our data which I blatantly copied from &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/tree/master/examples/gatsbygram&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsbygram&lt;/a&gt;. If you take a look at &lt;code&gt;src/data/cards&lt;/code&gt;, you’ll see that we have a &lt;code&gt;cards.json&lt;/code&gt; file with our card data and an &lt;em&gt;images&lt;/em&gt; folder with our image files. If you open &lt;code&gt;cards.json&lt;/code&gt;, you’ll see an &lt;code&gt;image&lt;/code&gt; field that points to the images folder e.g.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;Ice Lance&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;cost&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;dbfId&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;172&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;image&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;images/188.png&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With this sorcery, we can &lt;em&gt;bind&lt;/em&gt; our imageSharp fields (we’ll see them shortly) &lt;em&gt;directly&lt;/em&gt; into our data. I don’t know which plugin is responsible for that (I suspect &lt;code&gt;gatsby-transformer-json&lt;/code&gt;), but I wish I knew that sooner.&lt;/p&gt;&lt;p&gt;We can now start the development server to see if everything works with &lt;code&gt;gatsby develop&lt;/code&gt;. If you already opened the server, you’ll have to restart it.&lt;/p&gt;&lt;h2 id=&quot;the-graphql-query&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#the-graphql-query&quot;&gt;The GraphQL query&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;In our index page, we’ll write our GraphQL query that will load all the data and the images. We’ll pass that data into a &lt;code&gt;Cards&lt;/code&gt; component. That component will have a &lt;a href=&quot;https://react-window.now.sh/#/examples/grid/fixed-size&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;FixedSizeGrid&lt;/a&gt; from &lt;code&gt;react-window&lt;/code&gt; and a &lt;em&gt;cell&lt;/em&gt; that will display the actual card images.&lt;/p&gt;&lt;p&gt;But before we continue, let’s talk about a &lt;em&gt;compromise&lt;/em&gt; we’ll have to make. It has to do with our bundle size and the &lt;em&gt;progressive loading&lt;/em&gt; of the images.&lt;/p&gt;&lt;p&gt;If we use the default &lt;a href=&quot;https://www.gatsbyjs.org/docs/querying-with-graphql/#fragments&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GraphQL fragment&lt;/a&gt; from the available &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-image/#fragments&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-image fragments&lt;/a&gt; (a fragment is a collection of fields that’s used for convenience, alternatively we could require each field manually), say &lt;em&gt;GatsbyImageSharpFluid&lt;/em&gt;, our bundle size will end up at 3.5mb! This happens because Gatsby adds the query data into a separate &lt;abbr&gt;JSON&lt;/abbr&gt; file that gets downloaded after we load the page. In that file, we’ll also get, as an object field, the base64 inline image that’s used for the Medium-style progressive loading. For 3-4 images that extra size is ok. But for hundreds or even thousands of images, we’ll just have to &lt;em&gt;forget the progressive loading&lt;/em&gt;. The same thing is true for the traced &lt;abbr&gt;SVG&lt;/abbr&gt; technique (and worse) if you’re wondering. So we’ll fall back to the simple fade-in, and use the &lt;code&gt;GatsbyImageSharpFluid_noBase64&lt;/code&gt; fragment.&lt;/p&gt;&lt;p&gt;Also, because we have about 1800 images, &lt;a href=&quot;https://github.com/lovell/sharp/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;sharp&lt;/a&gt; will take a while to process our images. For example, it took me about 7 minutes to generate the 3700+ required thumbnails.&lt;/p&gt;&lt;p&gt;Now, let’s get our data, and log them into the console. Open the &lt;code&gt;index.js&lt;/code&gt; file inside &lt;code&gt;src/pages&lt;/code&gt;, and add the highlighted lines:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/index.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { graphql } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; sortBy &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;lodash.sortby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Layout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/layout&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; SEO &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/seo&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// import Cards from &amp;quot;../components/Cards&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;IndexPage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;allCardsJson&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;edges&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;sortedCards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;sortBy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cost&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;sortedCards&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;SEO&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Home&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;keywords&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`, `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`, `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`]&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Hi people&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Welcome to your new Gatsby site.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Now go build something great.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* &amp;lt;Cards cards={sortedCards} /&amp;gt; */&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  query indexPage {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    allCardsJson {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      edges {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        node {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          dbfId&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          name&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          cost&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          image {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            childImageSharp {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              fluid {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;                ...GatsbyImageSharpFluid_noBase64&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;              }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;`;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;IndexPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we want to see the &lt;abbr&gt;JSON&lt;/abbr&gt; file we mentioned earlier, we’ll have to build the app with &lt;code&gt;gatsby build&lt;/code&gt; and open the &lt;em&gt;Network&lt;/em&gt; tab of the Chrome DevTools. But I’ve already done this for you. In the next image, you can see the size of the file which is 102kb for our query (which is acceptable for so many images):&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:825px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/323171869fc2a2e590d597e5a2fcd600/ec45b/all-images-size.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:57.50000000000001%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAMABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAAECBf/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/9oADAMBAAIQAxAAAAHt2DSE/8QAFxABAAMAAAAAAAAAAAAAAAAAABARQf/aAAgBAQABBQKaa//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABQQAQAAAAAAAAAAAAAAAAAAACD/2gAIAQEABj8CX//EABsQAAMAAgMAAAAAAAAAAAAAAAABERAxIUFR/9oACAEBAAE/IVH0ceC1omUeH//aAAwDAQACAAMAAAAQoP8A/8QAFREBAQAAAAAAAAAAAAAAAAAAABH/2gAIAQMBAT8QV//EABURAQEAAAAAAAAAAAAAAAAAAAAR/9oACAECAQE/EEf/xAAcEAACAwADAQAAAAAAAAAAAAABEQAhQTFRYdH/2gAIAQEAAT8QQ0vVEx63zL/SDcacBJhBgFBVWT//2Q==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;The file with the image data&quot; title=&quot;The file with the image data&quot; src=&quot;/static/323171869fc2a2e590d597e5a2fcd600/ec45b/all-images-size.jpg&quot; srcSet=&quot;/static/323171869fc2a2e590d597e5a2fcd600/a5e48/all-images-size.jpg 480w,/static/323171869fc2a2e590d597e5a2fcd600/ec45b/all-images-size.jpg 825w&quot; sizes=&quot;(max-width: 825px) 100vw, 825px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;The file with the image data&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;And in the following image, you can see what the object looks like if you open it in the &lt;em&gt;preview&lt;/em&gt;:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:802px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/11c3a7b1b94cf7449f356cb5e266516e/f4623/all-images-whats-inside.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:49.791666666666664%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAKABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAMBAgX/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAHbkoMFB//EABYQAQEBAAAAAAAAAAAAAAAAAAEQMf/aAAgBAQABBQIpk//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABQQAQAAAAAAAAAAAAAAAAAAACD/2gAIAQEABj8CX//EABkQAAMAAwAAAAAAAAAAAAAAAAEQEQAxgf/aAAgBAQABPyGiYusO8//aAAwDAQACAAMAAAAQMw//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/ED//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/ED//xAAbEAEBAQEAAwEAAAAAAAAAAAABEQAhMUFx8f/aAAgBAQABPxC0hk43CWKji/jeT5q87m+zv//Z&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;What&amp;#x27;s inside that file&quot; title=&quot;What&amp;#x27;s inside that file&quot; src=&quot;/static/11c3a7b1b94cf7449f356cb5e266516e/f4623/all-images-whats-inside.jpg&quot; srcSet=&quot;/static/11c3a7b1b94cf7449f356cb5e266516e/a5e48/all-images-whats-inside.jpg 480w,/static/11c3a7b1b94cf7449f356cb5e266516e/f4623/all-images-whats-inside.jpg 802w&quot; sizes=&quot;(max-width: 802px) 100vw, 802px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;What&amp;#x27;s inside that file&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;h2 id=&quot;add-fixedsizedgrid-from-react-window&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#add-fixedsizedgrid-from-react-window&quot;&gt;Add FixedSizedGrid from react-window&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;We have our data; let’s now create the actual grid. As we said earlier, we’ll use the &lt;a href=&quot;https://react-window.now.sh/#/examples/grid/fixed-size&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;FixedSizeGrid&lt;/a&gt; from &lt;code&gt;react-window&lt;/code&gt;. We’ll also use the standalone &lt;a href=&quot;https://github.com/bvaughn/react-virtualized-auto-sizer&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;AutoSizer&lt;/a&gt; component from &lt;code&gt;react-virtualized&lt;/code&gt;. This component will make our grid &lt;em&gt;responsive&lt;/em&gt; and will try to fill all the available space, so we don’t have to specify a static grid width and height.&lt;/p&gt;&lt;p&gt;We start with the &lt;code&gt;Grid&lt;/code&gt;, and later we’ll add the &lt;code&gt;Cell&lt;/code&gt;. Create a new file &lt;code&gt;src/components/Cards.jsx&lt;/code&gt;, paste the following code, and we’ll talk about it later:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/Cards.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;FixedSizeGrid&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Grid } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-window&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; AutoSizer &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-virtualized-auto-sizer&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./cards.css&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      minHeight: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;100vh&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      backgroundColor: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#d6cae2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      marginTop: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;2em&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      position: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;sticky&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      top: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;0px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;AutoSizer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;defaultWidth&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1920&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;defaultHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1080&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cardWidth&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;286&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cardHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;395&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;floor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; / &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardWidth&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;rowCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;ceil&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; / &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Grid&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;grid&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;columnWidth&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardWidth&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;rowCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;rowCount&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;rowHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardHeight&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;itemData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Cell&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Grid&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;AutoSizer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Cards&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Also, create a &lt;abbr&gt;CSS&lt;/abbr&gt; file &lt;code&gt;src/components/cards.css&lt;/code&gt; that we’ll use to center the cards inside the &lt;code&gt;Grid&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/cards.css&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* to center cards inside grid */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.grid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;relative&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let’s explain what we do in the code above:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;In the &lt;code&gt;AutoSizer&lt;/code&gt; component, we pass a &lt;code&gt;defaultWidth&lt;/code&gt; and a &lt;code&gt;defaultHeight&lt;/code&gt;. That’s useful at build time when we don’t have the window object available.&lt;/li&gt;&lt;li&gt;We’re calculating the number of columns and rows based on the &lt;em&gt;number&lt;/em&gt; of cards we have and their &lt;em&gt;size&lt;/em&gt; in pixels (&lt;code&gt;columnCount&lt;/code&gt;, &lt;code&gt;rowCount&lt;/code&gt;).&lt;/li&gt;&lt;li&gt;The “grid” &lt;code&gt;className&lt;/code&gt; prop is used for centering the cards with &lt;abbr&gt;CSS&lt;/abbr&gt;. We’re specifying the &lt;code&gt;columnWidth&lt;/code&gt; and &lt;code&gt;rowHeight&lt;/code&gt; to be equal to the &lt;code&gt;cardWidth&lt;/code&gt; and &lt;code&gt;cardHeight&lt;/code&gt; respectively. Finally, we pass with the &lt;code&gt;itemData&lt;/code&gt; prop the &lt;code&gt;cards&lt;/code&gt; and the &lt;code&gt;columnCount&lt;/code&gt; down to the &lt;code&gt;Cell&lt;/code&gt; component that we’ll see shortly.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;For this example, we don’t have to create a separate file for the &lt;code&gt;Cell&lt;/code&gt;. It would have made more sense to do that if we were developing a more complex app. So in the same file, we continue with the &lt;code&gt;Cell&lt;/code&gt; and the &lt;code&gt;gatsby-image&lt;/code&gt; components:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/Cards.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;FixedSizeGrid&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Grid } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-window&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; AutoSizer &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-virtualized-auto-sizer&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; GatsbyImage &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-image&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./cards.css&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Cell&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;rowIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;singleColumnIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; + &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;rowIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; * &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;card&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;singleColumnIndex&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;card&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;card&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;dbfId&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            width: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;286px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            height: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;395px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            display: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;inline-block&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;         &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;GatsbyImage&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;card&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;card&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;childImageSharp&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* ...skipping Cards */&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Cards&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let’s explain what happens here:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The &lt;code&gt;Cell&lt;/code&gt; component, which represents each card, takes from the &lt;code&gt;Grid&lt;/code&gt; 3 standard props: &lt;code&gt;columnIndex&lt;/code&gt;, &lt;code&gt;rowIndex&lt;/code&gt;, and &lt;code&gt;style&lt;/code&gt;. It also takes the &lt;em&gt;optional&lt;/em&gt; &lt;code&gt;data&lt;/code&gt; prop which comes from the &lt;code&gt;itemData&lt;/code&gt; we mentioned earlier.&lt;/li&gt;&lt;li&gt;We see that we apply that &lt;code&gt;style&lt;/code&gt; prop to the container. The style prop positions our cells inside the grid.&lt;/li&gt;&lt;li&gt;Because the &lt;code&gt;Grid&lt;/code&gt; gives us only the &lt;code&gt;columnIndex&lt;/code&gt; and the &lt;code&gt;rowIndex&lt;/code&gt;, but our cards are in a &lt;em&gt;one-dimensional array&lt;/em&gt;, we’re doing a conversion with the &lt;code&gt;singleColumnIndex&lt;/code&gt; variable.&lt;/li&gt;&lt;li&gt;Sometimes, the cards may not fill the last row. In this case, the card would be &lt;code&gt;undefined&lt;/code&gt; because the &lt;code&gt;singleColumnIndex&lt;/code&gt; will point out of the array. Additionally, we’ll render an empty container, and not bother rendering the card stuff (I’m talking about the &lt;code&gt;card &amp;amp;&amp;amp;&lt;/code&gt; check).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Now, if we want to see the result, we’ll have to comment out the 2 “cards” lines we added earlier in the index page, and remove the &lt;code&gt;console.log&lt;/code&gt; statement. In the following image, we can see the result:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:1280px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/5ed86a9874fae272248fa2887524288c/38b44/all-images-result.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:56.25%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAALABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAUCBAb/xAAVAQEBAAAAAAAAAAAAAAAAAAABAP/aAAwDAQACEAMQAAABsieM6MRCf//EABoQAAIDAQEAAAAAAAAAAAAAAAIDAAESERP/2gAIAQEAAQUC3y9xeSG2FPQqi3sEf//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABURAQEAAAAAAAAAAAAAAAAAABAR/9oACAECAQE/Aaf/xAAbEAACAgMBAAAAAAAAAAAAAAAAAgEREiMxM//aAAgBAQAGPwKdSnkpeCwdOlQx/8QAHBABAAMAAgMAAAAAAAAAAAAAAQARITFRcaHw/9oACAEBAAE/IWiMVOJ9yC02dRrfJ1yIivSYZHgn/9oADAMBAAIAAwAAABCIH//EABYRAQEBAAAAAAAAAAAAAAAAAAABEf/aAAgBAwEBPxDVr//EABcRAQEBAQAAAAAAAAAAAAAAAAEAEVH/2gAIAQIBAT8Q12Fv/8QAHBABAAIDAQEBAAAAAAAAAAAAAQARITFBkWGB/9oACAEBAAE/EDqcI9BqZAues/X5GCyxRN43tSmXyMNa1xzXJtL1o3eT/9k=&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;The card grid&quot; title=&quot;The card grid&quot; src=&quot;/static/5ed86a9874fae272248fa2887524288c/38b44/all-images-result.jpg&quot; srcSet=&quot;/static/5ed86a9874fae272248fa2887524288c/a5e48/all-images-result.jpg 480w,/static/5ed86a9874fae272248fa2887524288c/1fe05/all-images-result.jpg 960w,/static/5ed86a9874fae272248fa2887524288c/38b44/all-images-result.jpg 1280w&quot; sizes=&quot;(max-width: 1280px) 100vw, 1280px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;The card grid&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;One last thing we want to do is to optimize the performance of our Grid.&lt;/p&gt;&lt;h2 id=&quot;optimize-performance&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#optimize-performance&quot;&gt;Optimize performance&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;We already have a performance optimization in our &lt;code&gt;Grid&lt;/code&gt;. We avoid passing an &lt;em&gt;anonymous function&lt;/em&gt; as a cell. When we do that, the cell mounts/unmounts between renders, and that’s a problem when we render complex cells. That’s why the &lt;code&gt;itemData&lt;/code&gt; prop exists by the way. It allows us to pass data down to our cells instead of doing that with an &lt;em&gt;anonymous component&lt;/em&gt; and &lt;em&gt;composition&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;The first thing we want to do is to make our cell a &lt;a href=&quot;https://reactjs.org/docs/react-api.html#reactmemo&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;memo&lt;/a&gt; component (aka &lt;a href=&quot;https://reactjs.org/docs/react-api.html#reactpurecomponent&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;pure component&lt;/a&gt;). On top of that, we’ll compare its props with the &lt;a href=&quot;https://react-window.now.sh/#/api/areEqual&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;areEqual&lt;/a&gt; function (the equivalent of &lt;a href=&quot;https://reactjs.org/docs/react-component.html#shouldcomponentupdate&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;shouldComponentUpdate&lt;/a&gt; for functional components) from &lt;code&gt;react-window&lt;/code&gt; to skip renders if the complex props like the &lt;code&gt;style&lt;/code&gt; don’t change (&lt;em&gt;deep equality&lt;/em&gt; check instead of &lt;em&gt;shallow&lt;/em&gt; from the pure component).&lt;/p&gt;&lt;p&gt;You can add the highlighted lines in the &lt;code&gt;src/components/Cards.jsx&lt;/code&gt; file:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/Cards.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { memo } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; GatsbyImage &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-image&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;FixedSizeGrid&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Grid, areEqual } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-window&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; AutoSizer &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-virtualized-auto-sizer&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./cards.css&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Cell&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;memo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;rowIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;singleColumnIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; + &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;rowIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; * &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;card&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;singleColumnIndex&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* ...skipping render */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;areEqual&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// ...skipping the rest&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can optionally add &lt;em&gt;memoization&lt;/em&gt; for the &lt;code&gt;itemData&lt;/code&gt;, although I believe this is not necessary for our application. Anyway, this is how you do with the &lt;code&gt;memoize-one&lt;/code&gt; library:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/Cards.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { memo } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; GatsbyImage &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-image&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;FixedSizeGrid&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Grid, areEqual } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-window&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; AutoSizer &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-virtualized-auto-sizer&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; memoize &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;memoize-one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./cards.css&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createItemData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;memoize&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Cell&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;memo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;rowIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* ...skipping Cell */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;areEqual&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      minHeight: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;100vh&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      backgroundColor: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#d6cae2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      marginTop: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;2em&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      position: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;sticky&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      top: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;0px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;AutoSizer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;defaultWidth&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1920&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;defaultHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1080&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cardWidth&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;286&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cardHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;395&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;floor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; / &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardWidth&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;rowCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;ceil&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; / &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;itemData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createItemData&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Grid&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;grid&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;columnWidth&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardWidth&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;rowCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;rowCount&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;rowHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardHeight&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;itemData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;itemData&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Cell&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Grid&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;AutoSizer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Cards&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For more performance tips, check this &lt;a href=&quot;https://www.youtube.com/watch?v=nySib7ipZdk&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;YouTube video&lt;/a&gt; from the creator of the &lt;code&gt;react-window&lt;/code&gt; library. In the next section, I compiled a list with some &lt;em&gt;limitations&lt;/em&gt; and &lt;em&gt;potential problems&lt;/em&gt;.&lt;/p&gt;&lt;h2 id=&quot;caveats&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#caveats&quot;&gt;Caveats&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;We have to forget about the progressive loading feature of the &lt;code&gt;gatsby-image&lt;/code&gt; component due to bundle size. If we could configure &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-plugin-sharp/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-plugin-sharp&lt;/a&gt; to put the placeholder images in a &lt;em&gt;separate file&lt;/em&gt; instead of adding them as inline base64 strings in a &lt;abbr&gt;JSON&lt;/abbr&gt; file, this would &lt;em&gt;not&lt;/em&gt; be a problem.&lt;/li&gt;&lt;li&gt;If a user scrolls down the grid &lt;em&gt;really fast&lt;/em&gt;, they will trigger a ton of downloads, and that will compromise the user experience and our bandwidth. I’m talking about server bandwidth, but the same is true for user data. You can see that in action if you add a &lt;em&gt;Network throttle&lt;/em&gt; in the &lt;em&gt;Performance&lt;/em&gt; tab of Chrome DevTools.&lt;/li&gt;&lt;li&gt;If, for some reason, we can’t combine our data with the images, &lt;a href=&quot;#magic-tricks&quot;&gt;as we showed earlier&lt;/a&gt;, and they are in separate objects, we’ll have to search for the image on runtime, with a small performance overhead:&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Getting the data from the GraphQL queries (index page).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;allCardsJson&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;edges&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;images&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;allImageSharp&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;edges&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Finding the image (cell component).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;images&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;imageUrl&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk39 { color: #C789D6; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk16 { color: #FF6363; }
  .night-owl-no-italics .mtk15 { color: #80CBC4; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[A performance problem when you combine useReducer and useContext]]></title><description><![CDATA[We investigate a performance problem when using useReducer and useContext instead of redux and react-redux for application state management.]]></description><link>https://markoskon.com/usereducer-and-usecontext-a-performance-problem/</link><guid isPermaLink="false">https://markoskon.com/usereducer-and-usecontext-a-performance-problem/</guid><pubDate>Wed, 27 Mar 2019 22:12:03 GMT</pubDate><content:encoded>&lt;p&gt;&lt;strong&gt;&lt;abbr title=&quot;Too Long; Didn&amp;#x27;t Read&quot;&gt;TL;DR&lt;/abbr&gt;:&lt;/strong&gt; Instead of choosing redux and &lt;a href=&quot;https://github.com/reduxjs/react-redux&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;react-redux&lt;/a&gt; for state management, I created an &lt;a href=&quot;https://github.com/MarkosKon/filter-demo/blob/master/src/components/AppContainer.jsx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;AppContainer component&lt;/a&gt; that internally uses a &lt;a href=&quot;https://reactjs.org/docs/hooks-reference.html#usereducer&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;useReducer hook&lt;/a&gt;, and shares the dispatch/state with the &lt;a href=&quot;https://reactjs.org/docs/hooks-reference.html#usecontext&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;useContext hook&lt;/a&gt;. This can lead to performance problems for components that use the context, but when the context changes, they don’t need to render again.&lt;/p&gt;&lt;p&gt;To solve this, &lt;strong&gt;I broke the component into 2 parts&lt;/strong&gt;; into a &lt;em&gt;parent&lt;/em&gt; component that uses the context, and a &lt;em&gt;child&lt;/em&gt; component that takes the context data &lt;em&gt;as props&lt;/em&gt;. This way, we can use &lt;a href=&quot;https://reactjs.org/docs/react-api.html#reactpurecomponent&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;PureComponent&lt;/a&gt; (&lt;a href=&quot;https://reactjs.org/docs/react-api.html#reactmemo&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;memo&lt;/a&gt;) and &lt;a href=&quot;https://reactjs.org/docs/react-component.html#shouldcomponentupdate&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;shouldComponentUpdate&lt;/a&gt; (&lt;a href=&quot;https://reactjs.org/docs/react-api.html#reactmemo&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;areEqual&lt;/a&gt;) on the expensive child to skip unnecessary renders. It’s the second solution &lt;a href=&quot;https://github.com/facebook/react/issues/15156&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;our prophet gives in this GitHub issue&lt;/a&gt;. Alternatively, you can use &lt;code&gt;redux&lt;/code&gt; and &lt;code&gt;react-redux&lt;/code&gt;…&lt;/p&gt;&lt;p&gt;We’ll also see the steps I took to understand the problem, measure, and finally optimize the code. As you can imagine, I didn’t come up with all this, but instead, I &lt;a href=&quot;#further-readingsources&quot;&gt;read the work of other brilliant people&lt;/a&gt;.&lt;/p&gt;&lt;h2 id=&quot;disclaimers&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#disclaimers&quot;&gt;Disclaimers&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;I want to say here that I don’t have a clue if the React team approves this pattern (&lt;code&gt;useReducer&lt;/code&gt; + &lt;code&gt;useContext&lt;/code&gt; instead of React + &lt;code&gt;react-redux&lt;/code&gt;). The hooks are still new, and the documentation not complete. So, it’s expected that we, as developers, we’ll find a way to misuse them and embarrass ourselves in the process.&lt;/p&gt;&lt;p&gt;Anyway… I used it because I wanted a side project to experiment with React hooks and more specifically with the &lt;code&gt;useReducer&lt;/code&gt; hook. I searched in Google, and &lt;a href=&quot;https://medium.com/@seantheurgel/react-hooks-as-state-management-usecontext-useeffect-usereducer-a75472a862fe&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;some guides&lt;/a&gt; (when I say guides I mean blog posts) suggested using it alongside the &lt;code&gt;useContext&lt;/code&gt; hook. I liked that because I would not have to &lt;em&gt;“mapStateToProps”&lt;/em&gt; or &lt;em&gt;“mapDispatchToProps”&lt;/em&gt;, which is something that annoys me, but instead, I would just require stuff from the &lt;code&gt;useContext&lt;/code&gt; hook. With that out of the way, let’s see what this app does.&lt;/p&gt;&lt;h2 id=&quot;a-quick-description-of-the-app&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#a-quick-description-of-the-app&quot;&gt;A quick description of the app&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;a href=&quot;https://playhearthstone.com/en-us/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Hearthstone&lt;/a&gt; is an online card game created by Blizzard. &lt;a href=&quot;https://hsfilter.netlify.com&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;HSFilter&lt;/a&gt;, on the other hand, gives you the ability to filter Hearthstone cards based on attributes you choose, and then add them to a deck (max 30 cards) that you can use to play against your opponents. It’s built with &lt;a href=&quot;https://www.gatsbyjs.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Gatsby&lt;/a&gt; if you’re wondering. Let’s now proceed with some general performance advice.&lt;/p&gt;&lt;h2 id=&quot;performance-advice&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#performance-advice&quot;&gt;Performance advice&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;First of all, you don’t have to optimize for performance if you don’t have performance problems. If you do, you’re doing &lt;a href=&quot;https://stackify.com/premature-optimization-evil/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;premature optimization&lt;/a&gt;. Instead, you start by writing &lt;em&gt;readable&lt;/em&gt; code that you are comfortable with, after that you &lt;em&gt;measure&lt;/em&gt; the performance, and &lt;em&gt;if&lt;/em&gt; you have problems then you optimize.&lt;/p&gt;&lt;p&gt;It’s also better to spot the performance problems in the production build. That’s because the production code is much faster than the development build. As a result, a problem in development may be negligible in production. So don’t freak out with dropped frames in development.&lt;/p&gt;&lt;p&gt;Also, it’s good to add some &lt;abbr title=&quot;Central Processing Unit&quot;&gt;CPU&lt;/abbr&gt; throttle in Chrome DevTools to emulate the performance on lower-end devices. Your development pc is probably quite powerful, so it will handle well whatever you throw at it.&lt;/p&gt;&lt;h2 id=&quot;understanding-that-we-have-a-problem&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#understanding-that-we-have-a-problem&quot;&gt;Understanding that we have a problem&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;So having all that in mind, I started monitoring some interactions &lt;a href=&quot;https://hsfilter.netlify.com&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;in my app&lt;/a&gt; with Chrome DevTools (performance tab). One problem I noticed (spoiler: they were more), was occurring when I clicked a card from the collection with the intention to add it into the deck. You can see the interaction in the following gif:&lt;/p&gt;&lt;figure class=&quot;video-wrapper&quot;&gt;&lt;video preload=&quot;none&quot; poster=&quot;/241f2c0fa1b76a08e230cfd745e8cc19/production-x4-add-card.png&quot; muted=&quot;&quot; controls=&quot;&quot; playsinline=&quot;&quot; loop=&quot;&quot;&gt;&lt;source src=&quot;/346a3aa61a1323e02e008ad2cc4c0b23/production-x4-add-card.webm&quot; type=&quot;video/webm&quot;/&gt;&lt;source src=&quot;/990094e12f086c897441de5eac69be90/production-x4-add-card.mp4&quot; type=&quot;video/mp4&quot;/&gt;&lt;/video&gt;&lt;figcaption&gt;Add a card in the deck interaction.&lt;/figcaption&gt;&lt;/figure&gt;&lt;p&gt;First of all, I can hear the Hearthstone players saying: &lt;em&gt;“Why do you even want to add Cursed Blade into your deck; that card is terrible.”&lt;/em&gt; I agree, but let’s move on. We see in the following image that the click handler took about 275ms with an x4 &lt;abbr title=&quot;Central Processing Unit&quot;&gt;CPU&lt;/abbr&gt; throttle applied in the production build:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:551px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/6e631bc658bf9cd3eb36773d13526953/a2731/production-x4-add-card.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:67.5%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAOABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAIBAwX/xAAWAQEBAQAAAAAAAAAAAAAAAAAAAQL/2gAMAwEAAhADEAAAAdeGbJCwr//EABcQAQEBAQAAAAAAAAAAAAAAABEAARD/2gAIAQEAAQUCZ2Y4X//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABURAQEAAAAAAAAAAAAAAAAAABAR/9oACAECAQE/Aaf/xAAXEAEBAQEAAAAAAAAAAAAAAAAxAAEQ/9oACAEBAAY/AiIne//EABoQAAIDAQEAAAAAAAAAAAAAAAABESFRkfD/2gAIAQEAAT8hlrg6rcPMEk3BXpY//9oADAMBAAIAAwAAABDnL//EABcRAQADAAAAAAAAAAAAAAAAAAABESH/2gAIAQMBAT8QyFv/xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/ED//xAAcEAEAAwACAwAAAAAAAAAAAAABABEhMUFRYZH/2gAIAQEAAT8Qq4iV9UN+UvuWhAvDGoIxa+aIoDd53P/Z&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Production x4 slowdown&quot; title=&quot;Production x4 slowdown&quot; src=&quot;/static/6e631bc658bf9cd3eb36773d13526953/a2731/production-x4-add-card.jpg&quot; srcSet=&quot;/static/6e631bc658bf9cd3eb36773d13526953/a5e48/production-x4-add-card.jpg 480w,/static/6e631bc658bf9cd3eb36773d13526953/a2731/production-x4-add-card.jpg 551w&quot; sizes=&quot;(max-width: 551px) 100vw, 551px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Production x4 slowdown&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;This is pretty bad if you have many users with mid to low-end devices. So another tip is to always use your analytics to see if it’s even worth spending your time optimizing. Maybe the majority of your users access your app from a desktop. I don’t have any users but whatever. This problem seemed interesting enough, so I continued investigating. The next thing we’ll do is to figure out if we use sub-optimally our 3rd party libraries.&lt;/p&gt;&lt;h2 id=&quot;investigating-3rd-party-libraries&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#investigating-3rd-party-libraries&quot;&gt;Investigating 3rd party libraries&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;For this project, I’m using the &lt;a href=&quot;https://react-window.now.sh/#/examples/grid/fixed-size&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;FixedSizeGrid&lt;/a&gt; from &lt;a href=&quot;https://github.com/bvaughn/react-window&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;react-window&lt;/a&gt; to &lt;a href=&quot;/displaying-hundreds-of-images-with-react-window-and-gatsby-image/&quot;&gt;display the cards&lt;/a&gt;. It’s similar to &lt;a href=&quot;https://github.com/bvaughn/react-virtualized&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;react-virtualized&lt;/a&gt;, but simpler, faster, and &lt;a href=&quot;https://bundlephobia.com/result?p=react-window@1.7.1&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;smaller&lt;/a&gt;. If you are not familiar with the library, you can skip to the next section; it’s not the point of the post anyway. I will now list the code for the component that renders the &lt;code&gt;FixedSizeGrid&lt;/code&gt; and the code for the &lt;code&gt;GridItem&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;Take a quick look at the highlighted lines, and we’ll talk about it later:&lt;/p&gt;&lt;h3 id=&quot;cardsjsx-code-snippet&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#cardsjsx-code-snippet&quot;&gt;Cards.jsx code snippet&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;Cards.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { useState, useEffect, useRef, useContext } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; styled &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;styled-components&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;FixedSizeGrid&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Grid } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-window&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; AutoSizer &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-virtualized-auto-sizer&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; memoize &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;memoize-one&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { boxShadow } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;styled-system&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { toast } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-toastify&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Flex, Box, Heading, Centered, Text } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../Primitives&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; GridItem &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./GridItem&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { DeckContext } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../../context/deck-context&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; CardDetailsModal &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../Modals/CardDetailsModal&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping styling and boring utilities...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createOpenModal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;memoize&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;card&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ open: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;card&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createItemData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;memoize&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;searchedCards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;openModal&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;it runs!&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; || {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;searchedCards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;openModal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useContext&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;DeckContext&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;; &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping state and effects...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Container&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;bg&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;tuscan&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;raisinBlack&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* skipping... */&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;100vh&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ overflowX: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;searchedCards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;AutoSizer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;defaultWidth&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1920&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;defaultHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1080&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cardWidth&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &amp;lt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; || &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &amp;lt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; ? &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;180&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;250&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cardHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &amp;lt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; || &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &amp;lt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; ? &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;250&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;345&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;floor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; / &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardWidth&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;rowCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;ceil&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;searchedCards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; / &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;openModal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createOpenModal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;setModalInfo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;itemData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createItemData&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;searchedCards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;openModal&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;CenteredGrid&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;columnWidth&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardWidth&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;rowHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardHeight&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;rowCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;rowCount&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;itemData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;itemData&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;GridItem&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;CenteredGrid&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;AutoSizer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        ) &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Centered&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;minHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;50vh&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fontSize&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;No cards. Try different filters.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Centered&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Container&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;Cards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  cards: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;arrayOf&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Cards&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;griditemjsx-code-snippet&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#griditemjsx-code-snippet&quot;&gt;GridItem.jsx code snippet&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;GridItem.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { useState, useEffect, useRef, useContext, memo } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; styled &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;styled-components&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { areEqual } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-window&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; BaseImage } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;rebass&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { toast } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-toastify&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Box, Button } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../Primitives&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { FaSearch, FaMinus } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../Icons&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { addUnconditionally, validateAdd, inDeck } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../../utils/deck&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { DeckContext } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../../context/deck-context&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { addCard, removeCard } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../../ducks/deck&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// ...skipping styling and utilities&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;GridItem&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;memo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;rowIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;searchedCards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;openModal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;singleColumnIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; + &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;rowIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; * &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;searchedCards&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;singleColumnIndex&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;errorToast&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useRef&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;imageRef&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useRef&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;dispatch&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useContext&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;DeckContext&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const [&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;quantity&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setQuantity&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;] = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; ? &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getQuantity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useEffect&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setQuantity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getQuantity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Container&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;ActionContainer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;quantity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* ...skipping UI stuff */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;ActionContainer&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Button&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;variant&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;transparent&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Add &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;data-microtip-position&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;bottom&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;tooltip&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ padding: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;resultingDeck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;addUnconditionally&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;validateAdd&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;resultingDeck&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, deck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;ignoreSize&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;dispatch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;addCard&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ card: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;toast&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;isActive&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;errorToast&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  errorToast&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;current &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; toast&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;🔥 &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;ref&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;imageRef&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ opacity: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getOpacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;quantity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/resources/images/&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;imageUrl&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Button&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;lt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Container&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}, areEqual);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;// ...skipping proptypes&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;export default GridItem;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In &lt;a href=&quot;#cardsjsx-code-snippet&quot;&gt;Cards.jsx&lt;/a&gt; I render a grid (&lt;code&gt;CenteredGrid&lt;/code&gt;) and a &lt;code&gt;GridItem&lt;/code&gt; as a child. I also use the &lt;code&gt;DeckContext&lt;/code&gt;, and, as a result, the component renders when the deck in the context changes.&lt;/p&gt;&lt;p&gt;In &lt;a href=&quot;#griditemjsx-code-snippet&quot;&gt;GridItem.jsx&lt;/a&gt;, I again use the &lt;code&gt;DeckContext&lt;/code&gt;, but, in addition to that, I use a &lt;em&gt;click handler&lt;/em&gt; that dispatches to the reducer an action (&lt;code&gt;addCard&lt;/code&gt;). Finally, I render an image and some other elements depending on the quantity. The quantity represents the number of copies of a card inside the deck.&lt;/p&gt;&lt;p&gt;Some other stuff I’ve highlighted are &lt;a href=&quot;https://www.youtube.com/watch?v=nySib7ipZdk&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;performance optimizations mentioned in this video by Brian Vaughn&lt;/a&gt;, the creator of the library. Let’s name those:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;We avoid passing as a grid child an &lt;em&gt;anonymous&lt;/em&gt; component. Instead, we pass a reference e.g. &lt;code&gt;{GridItem}&lt;/code&gt; (Reference? Is that what it’s called? I’m not sure). Basically, if you pass an anonymous component, and the parent renders, it always mounts the children instead of updating them (ouch, that’s bad).&lt;/li&gt;&lt;li&gt;We’re using &lt;code&gt;memo&lt;/code&gt; for the &lt;code&gt;GridItem&lt;/code&gt; which is basically the equivalent of the &lt;code&gt;PureComponent&lt;/code&gt; for functional components.&lt;/li&gt;&lt;li&gt;We are comparing the props of the &lt;code&gt;GridItem&lt;/code&gt; with the &lt;code&gt;areEqual&lt;/code&gt; function from &lt;code&gt;react-window&lt;/code&gt;. This is the equivalent for &lt;code&gt;shouldComponentUpdate&lt;/code&gt; that’s already implemented for &lt;code&gt;Cell&lt;/code&gt; components of &lt;code&gt;react-window&lt;/code&gt; grids.&lt;/li&gt;&lt;li&gt;We’re also using &lt;em&gt;memoization&lt;/em&gt; for the props we pass with &lt;a href=&quot;https://react-window.now.sh/#/api/FixedSizeGrid&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;itemData&lt;/a&gt; (this is a &lt;code&gt;Grid&lt;/code&gt; prop) in each &lt;code&gt;GridItem&lt;/code&gt; from the &lt;code&gt;Grid&lt;/code&gt;. Because some of the props we pass are &lt;em&gt;complex types&lt;/em&gt; (not primitives), and we assign them at render, even if they are the same in &lt;em&gt;value&lt;/em&gt;, they change in &lt;em&gt;reference&lt;/em&gt;. A new object is created in every render, so the &lt;code&gt;GridItem&lt;/code&gt; will render because it does only a &lt;a href=&quot;/deep-copy-vs-shallow-copy-vs-assignment/&quot;&gt;shallow comparison&lt;/a&gt; of its props. So we &lt;em&gt;memoize&lt;/em&gt; them, and if their value is the same, we take the cached reference.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;abbr title=&quot;Post Scriptum&quot;&gt;P.S.&lt;/abbr&gt; about the memoization part: I think we could achieve the same with an &lt;code&gt;areEqual&lt;/code&gt; function in the &lt;code&gt;GridItem&lt;/code&gt;. Generally, you use memoization for &lt;em&gt;expensive&lt;/em&gt; operations, and not so much for the reason we did here. Also, this explanation took really long, and this is generally a sign that I messed it up, so have that in mind…&lt;/p&gt;&lt;p&gt;This brought a significant improvement; from 550ms in development with an x4 &lt;abbr title=&quot;Central Processing Unit&quot;&gt;CPU&lt;/abbr&gt; throttle to the current 439ms, that you’ll see shortly in the next section.&lt;/p&gt;&lt;h2 id=&quot;using-chrome-devtools&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#using-chrome-devtools&quot;&gt;Using Chrome DevTools&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Now that we know that we’re using our dependencies in the most performant way, let’s go in development mode, and investigate the issue further. The development mode has a really useful tool which is the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;User Timing &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt;&lt;/a&gt; dropdown (named as &lt;em&gt;Timings&lt;/em&gt;). You can also use the &lt;a href=&quot;https://www.youtube.com/watch?v=nySib7ipZdk&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;React Profiler&lt;/a&gt; if you have the &lt;a href=&quot;https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;React developer tools&lt;/a&gt; installed. The profiler is something similar to &lt;em&gt;Timings&lt;/em&gt; dropdown, and I won’t use it here. If you’re reading this in 2020, you should use the &lt;em&gt;new&lt;/em&gt; React profiler.&lt;/p&gt;&lt;p&gt;We narrow down to one of the red lines in the &lt;em&gt;overview&lt;/em&gt;, marked by the horribly drawn red circle in the image below. A red line means that something took longer than expected, and as a result, we dropped some frames. We go to the &lt;em&gt;main&lt;/em&gt; dropdown to find the click event, as we did in production (previous image). Now, because we are in development, we have access to the Timings dropdown. If we open it, we see the following:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:764px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/3c5854a117bbbdd49b6d30b305e4c643/321b5/development-x4-add-card.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:39.583333333333336%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAIABQDASIAAhEBAxEB/8QAFwABAAMAAAAAAAAAAAAAAAAAAAECBf/EABUBAQEAAAAAAAAAAAAAAAAAAAMC/9oADAMBAAIQAxAAAAHVkBLBY//EABcQAQEBAQAAAAAAAAAAAAAAAAABESH/2gAIAQEAAQUC2OJH/8QAFhEAAwAAAAAAAAAAAAAAAAAAARAS/9oACAEDAQE/AZC//8QAFhEAAwAAAAAAAAAAAAAAAAAAARAS/9oACAECAQE/AbK//8QAFxABAQEBAAAAAAAAAAAAAAAAADEBQf/aAAgBAQAGPwK6rr//xAAbEAABBAMAAAAAAAAAAAAAAAAAAREhYUFRkf/aAAgBAQABPyGfKlD7yzk//9oADAMBAAIAAwAAABB8L//EABYRAQEBAAAAAAAAAAAAAAAAAAEAIf/aAAgBAwEBPxBKTb//xAAXEQADAQAAAAAAAAAAAAAAAAAAASEx/9oACAECAQE/ENhOH//EABsQAQACAgMAAAAAAAAAAAAAAAEAESGhMUHB/9oACAEBAAE/EC0JYEaVqNWdcBFObunk/9k=&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Development x4 slowdown&quot; title=&quot;Development x4 slowdown&quot; src=&quot;/static/3c5854a117bbbdd49b6d30b305e4c643/321b5/development-x4-add-card.jpg&quot; srcSet=&quot;/static/3c5854a117bbbdd49b6d30b305e4c643/a5e48/development-x4-add-card.jpg 480w,/static/3c5854a117bbbdd49b6d30b305e4c643/321b5/development-x4-add-card.jpg 764w&quot; sizes=&quot;(max-width: 764px) 100vw, 764px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Development x4 slowdown&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;We see that our &lt;code&gt;AppContainer&lt;/code&gt; updates in 439ms. If we scroll down (next image), we see that we update the &lt;code&gt;ParentFilterGroup&lt;/code&gt;, which is something like a navbar in the app, and the &lt;code&gt;Cards&lt;/code&gt; component that takes the most time. In the &lt;code&gt;Cards&lt;/code&gt; component, we see some components being updated. Those components are our &lt;code&gt;GridItems&lt;/code&gt;:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:778px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/207e3fce638d53ede58aceb43779c3fe/d2936/development-x4-zoom-in.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:37.291666666666664%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAHABQDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAX/xAAWAQEBAQAAAAAAAAAAAAAAAAACAAP/2gAMAwEAAhADEAAAAagwYG//xAAXEAEBAQEAAAAAAAAAAAAAAAAAEgER/9oACAEBAAEFApTrj//EABURAQEAAAAAAAAAAAAAAAAAAAAR/9oACAEDAQE/Aar/xAAWEQADAAAAAAAAAAAAAAAAAAAAARL/2gAIAQIBAT8BlEo//8QAFRABAQAAAAAAAAAAAAAAAAAAARD/2gAIAQEABj8CL//EABkQAAIDAQAAAAAAAAAAAAAAAAARAUFR8P/aAAgBAQABPyG6MOGOf//aAAwDAQACAAMAAAAQe/8A/8QAFREBAQAAAAAAAAAAAAAAAAAAABH/2gAIAQMBAT8Qtb//xAAVEQEBAAAAAAAAAAAAAAAAAAABEP/aAAgBAgEBPxBaX//EABoQAAMBAAMAAAAAAAAAAAAAAAERIQBBUZH/2gAIAQEAAT8QUVhiSjzqGTO9+7//2Q==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Grid items take their sweet time to render&quot; title=&quot;Grid items take their sweet time to render&quot; src=&quot;/static/207e3fce638d53ede58aceb43779c3fe/d2936/development-x4-zoom-in.jpg&quot; srcSet=&quot;/static/207e3fce638d53ede58aceb43779c3fe/a5e48/development-x4-zoom-in.jpg 480w,/static/207e3fce638d53ede58aceb43779c3fe/d2936/development-x4-zoom-in.jpg 778w&quot; sizes=&quot;(max-width: 778px) 100vw, 778px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Grid items take their sweet time to render&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;They take about 12ms to update, and one of them in the middle takes about 20ms to update. This is something that should &lt;em&gt;not&lt;/em&gt; happen. We expected to see &lt;em&gt;one&lt;/em&gt; &lt;code&gt;GridItem&lt;/code&gt; updating for 20ms because this is the card we add to the deck, and it’s quantity changes. When the quantity changes, we render an extra button that, when clicked, removes the card from the deck, and we decrease the opacity of the image. The rest of the cards, though, should update almost &lt;em&gt;instantly&lt;/em&gt; because &lt;em&gt;nothing changes&lt;/em&gt; for them.&lt;/p&gt;&lt;p&gt;This happens because if we take look at &lt;a href=&quot;#griditemjsx-code-snippet&quot;&gt;the code for our GridItem&lt;/a&gt;, we can see that we’re using the &lt;code&gt;DeckContext&lt;/code&gt;. The deck changes in the context when we add a card, so every &lt;code&gt;GridItem&lt;/code&gt; renders again no matter what. Ideally, we would want to have the deck from &lt;code&gt;DeckContext&lt;/code&gt; passed &lt;em&gt;as a prop&lt;/em&gt; in the &lt;code&gt;GridItem&lt;/code&gt;. This way, we can check with &lt;code&gt;shouldComponentUpdate&lt;/code&gt; (or with an &lt;code&gt;areEqual&lt;/code&gt; implementation in functional components) if the &lt;code&gt;GridItem&lt;/code&gt; should re-render.&lt;/p&gt;&lt;h2 id=&quot;splitting-the-griditem-component&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#splitting-the-griditem-component&quot;&gt;Splitting the GridItem component&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;To achieve that, we’ll have to &lt;em&gt;split&lt;/em&gt; the &lt;code&gt;GridItem&lt;/code&gt; component into &lt;em&gt;2 parts&lt;/em&gt;. We’ll end up with one &lt;em&gt;parent&lt;/em&gt; component that uses the context, and a &lt;em&gt;child&lt;/em&gt; component that takes the context data as props. We can see below the code after the changes:&lt;/p&gt;&lt;h3 id=&quot;code-after-splitting&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#code-after-splitting&quot;&gt;Code after splitting:&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;Cards.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// omitted...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;CenteredGrid&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;columnWidth&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardWidth&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;rowHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardHeight&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;rowCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;rowCount&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;itemData&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;itemData&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;GridItemWithDeck&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;CenteredGrid&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// omitted...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;GridItemWithDeck.jsx/GridItem.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { useRef, useContext, memo } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; styled &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;styled-components&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { areEqual } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-window&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; BaseImage } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;rebass&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { toast } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-toastify&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping internal dependencies and styling...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;GridItemWithDeck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;memo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;rowIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;searchedCards&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;openModal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;singleColumnIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; + &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;rowIndex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; * &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;columnCount&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;searchedCards&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;singleColumnIndex&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;dispatch&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useContext&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;DeckContext&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;quantity&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getQuantity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Container&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;GridItem&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;dispatch&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;dispatch&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;quantity&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;quantity&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;openModal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;openModal&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Container&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;areEqual&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;GridItemWithDeck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping proptypes...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// So to recap:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// We don&amp;#x27;t render if the parent renders because&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// we are a PureComponent (memo). We render if are props&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// change and we determine that with a shallow&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// comparison. Now in the case where the deck has&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// changed because we added a card in the deck, we don&amp;#x27;t&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// render if the quantity remains the same. We achieve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// the last by implementing shouldComponentUpdate (areEqual).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;childAreEqual&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  if &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; !== &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &amp;amp;&amp;amp; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;prev&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;quantity&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; === &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;quantity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    return &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// eslint-disable-next-line react/no-multi-comp&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;GridItem&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;memo&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;deck&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;dispatch&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;openModal&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;quantity&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;errorToast&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useRef&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;imageRef&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;useRef&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    return &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; ? &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;ActionContainer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;quantity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Button&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;variant&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;icon&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Remove 1 card&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;data-microtip-position&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;bottom-left&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;tooltip&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;bg&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;paradisePink&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;dispatch&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;removeCard&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ card: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;catch&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;toast&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;isActive&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;errorToast&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;current&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                    errorToast&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;current &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; toast&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                      &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;🔥 &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;err&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;FaMinus&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Button&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Button&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;variant&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;icon&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; details&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;data-microtip-position&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;bottom-left&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;tooltip&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;bg&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;heroColors&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cardClass&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;openModal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;FaSearch&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Button&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;ActionContainer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Button&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;variant&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;transparent&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Add &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;data-microtip-position&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;bottom&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;role&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;tooltip&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ padding: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onClick&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping handler...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;ref&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;imageRef&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ opacity: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getOpacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;quantity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/resources/images/&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cardToRender&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;imageUrl&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Button&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;childAreEqual&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;GridItem&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping proptypes...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;GridItem&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;defaultProps&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  quantity: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;GridItem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the code above, we now have 2 components: the &lt;code&gt;GridItemWithDeck&lt;/code&gt; and the &lt;code&gt;GridItem&lt;/code&gt;. The &lt;code&gt;GridItemWithDeck&lt;/code&gt; uses the &lt;em&gt;context&lt;/em&gt;, and it &lt;em&gt;transforms&lt;/em&gt; the data from the &lt;code&gt;Cards&lt;/code&gt; component into something more useful for the &lt;code&gt;GridItem&lt;/code&gt;. It’s a &lt;code&gt;memo&lt;/code&gt; (pure) component, and it checks its props on every update with the &lt;code&gt;areEqual&lt;/code&gt; function from &lt;code&gt;react-window&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;The GridItem is also a &lt;code&gt;memo&lt;/code&gt; component, but it checks its props with the custom &lt;code&gt;childAreEqual&lt;/code&gt; function. That function basically says: &lt;em&gt;“If the deck changed, but the quantity remains the same, don’t render”&lt;/em&gt;. This combined with the &lt;a href=&quot;/deep-copy-vs-shallow-copy-vs-assignment/&quot;&gt;shallow prop comparison&lt;/a&gt; from &lt;code&gt;memo&lt;/code&gt; should do the trick.&lt;/p&gt;&lt;p&gt;Let’s see how it fares when we try to measure it in development:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:792px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/8f3f1e60590c6328097048f87a6344cb/b29b7/development-x4-refactor.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:64.99999999999999%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAIDAQX/xAAVAQEBAAAAAAAAAAAAAAAAAAACA//aAAwDAQACEAMQAAAB6+zeSYqVP//EABsQAAIBBQAAAAAAAAAAAAAAAAACARARISIy/9oACAEBAAEFAr0yP2kbH//EABYRAAMAAAAAAAAAAAAAAAAAABARIf/aAAgBAwEBPwFQf//EABcRAAMBAAAAAAAAAAAAAAAAAAEQERL/2gAIAQIBAT8B2bF//8QAFxAAAwEAAAAAAAAAAAAAAAAAABBBAf/aAAgBAQAGPwKEer//xAAbEAACAgMBAAAAAAAAAAAAAAAAARFxIWGR8f/aAAgBAQABPyG3RL9lUY3IFaGj/9oADAMBAAIAAwAAABDPD//EABYRAQEBAAAAAAAAAAAAAAAAAAEQEf/aAAgBAwEBPxBJqf/EABYRAQEBAAAAAAAAAAAAAAAAAAEQIf/aAAgBAgEBPxATKf/EABsQAQACAwEBAAAAAAAAAAAAAAEAESExQVGR/9oACAEBAAE/ELilacdZgsfjHS9PsIznAahbQol8uoS5OT//2Q==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;After splitting the grid items&quot; title=&quot;After splitting the grid items&quot; src=&quot;/static/8f3f1e60590c6328097048f87a6344cb/b29b7/development-x4-refactor.jpg&quot; srcSet=&quot;/static/8f3f1e60590c6328097048f87a6344cb/a5e48/development-x4-refactor.jpg 480w,/static/8f3f1e60590c6328097048f87a6344cb/b29b7/development-x4-refactor.jpg 792w&quot; sizes=&quot;(max-width: 792px) 100vw, 792px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;After splitting the grid items&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;283ms from 439ms. And if we zoom-in at the grid part:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:777px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/7a176c8ba257b872651112c0d14bcc81/aacc6/development-x4-refactor-zoom-in.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:66.04166666666667%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAECAwX/xAAVAQEBAAAAAAAAAAAAAAAAAAACA//aAAwDAQACEAMQAAAB1mySkWlT/8QAGxAAAgEFAAAAAAAAAAAAAAAAAAERAgMQEiL/2gAIAQEAAQUC2JOi4lFCx//EABYRAAMAAAAAAAAAAAAAAAAAAAEQEf/aAAgBAwEBPwGBf//EABYRAQEBAAAAAAAAAAAAAAAAABECEP/aAAgBAgEBPwFpM//EABcQAAMBAAAAAAAAAAAAAAAAAAABEBH/2gAIAQEABj8Cuic//8QAHBAAAgEFAQAAAAAAAAAAAAAAAAEhEBFBUWGB/9oACAEBAAE/IV0jyW0QlFIlrJT/2gAMAwEAAgADAAAAEJ/P/8QAFhEAAwAAAAAAAAAAAAAAAAAAEBEh/9oACAEDAQE/EIMf/8QAFREBAQAAAAAAAAAAAAAAAAAAEFH/2gAIAQIBAT8QnH//xAAeEAACAQMFAAAAAAAAAAAAAAABEQAhMdEQQWFxkf/aAAgBAQABPxC6ukvEBk0r4eJSD94sAAEW3lkraf/Z&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;A closer look into the Grid&quot; title=&quot;A closer look into the Grid&quot; src=&quot;/static/7a176c8ba257b872651112c0d14bcc81/aacc6/development-x4-refactor-zoom-in.jpg&quot; srcSet=&quot;/static/7a176c8ba257b872651112c0d14bcc81/a5e48/development-x4-refactor-zoom-in.jpg 480w,/static/7a176c8ba257b872651112c0d14bcc81/aacc6/development-x4-refactor-zoom-in.jpg 777w&quot; sizes=&quot;(max-width: 777px) 100vw, 777px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;A closer look into the Grid&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;We see that the one &lt;code&gt;GridItem&lt;/code&gt; (card) that is added to the deck takes 32ms to update, and the rest much less at about 2ms. We’re happy with that because it’s the expected behavior.&lt;/p&gt;&lt;p&gt;One last thing we want to do is to build the code and go back to the production to measure. You’ll notice that a lot of &lt;em&gt;back and forth&lt;/em&gt; goes on between development and production. These are the results in production with an x4 slowdown:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:794px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/ac7edfbcc4c14a3fe8ceae4869e3e53a/e7284/production-x4-refactor.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:64.79166666666667%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAAEDBf/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/9oADAMBAAIQAxAAAAHsVErQv//EABgQAQADAQAAAAAAAAAAAAAAAAABAiEx/9oACAEBAAEFAta1aEdf/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAFhAAAwAAAAAAAAAAAAAAAAAAACBB/9oACAEBAAY/AiL/AP/EABoQAQACAwEAAAAAAAAAAAAAAAEAkRARcVH/2gAIAQEAAT8hOLnFo+guAu4Mf//aAAwDAQACAAMAAAAQpw//xAAVEQEBAAAAAAAAAAAAAAAAAAAQEf/aAAgBAwEBPxCn/8QAFhEBAQEAAAAAAAAAAAAAAAAAABFh/9oACAECAQE/EJqP/8QAGhABAAMBAQEAAAAAAAAAAAAAAQARMWFRsf/aAAgBAQABPxBB+WOQil0wJWpWSsl2HIh4T//Z&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;After splitting in production x4 slowdown&quot; title=&quot;After splitting in production x4 slowdown&quot; src=&quot;/static/ac7edfbcc4c14a3fe8ceae4869e3e53a/e7284/production-x4-refactor.jpg&quot; srcSet=&quot;/static/ac7edfbcc4c14a3fe8ceae4869e3e53a/a5e48/production-x4-refactor.jpg 480w,/static/ac7edfbcc4c14a3fe8ceae4869e3e53a/e7284/production-x4-refactor.jpg 794w&quot; sizes=&quot;(max-width: 794px) 100vw, 794px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;After splitting in production x4 slowdown&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;One of the longer handlers took 131ms to complete. I remind you that without the splitting the handler took about 275ms. If we test this without &lt;abbr title=&quot;Central Processing Unit&quot;&gt;CPU&lt;/abbr&gt; throttling, we don’t drop any frames, so no red lines at all for desktop users.&lt;/p&gt;&lt;h2 id=&quot;wait-a-minute-ps&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#wait-a-minute-ps&quot;&gt;Wait a minute… (&lt;abbr title=&quot;Post Scriptum&quot;&gt;PS&lt;/abbr&gt;)&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;So mission complete! Our app updates now almost twice as fast. We should celebrate, right?&lt;/p&gt;&lt;p&gt;&lt;em&gt;NO! We messed up!&lt;/em&gt; (ok, I messed up, you didn’t do anything). We were not careful with the implementation of the &lt;code&gt;areEqual&lt;/code&gt; function, and as a result, we don’t update the deck inside our &lt;a href=&quot;#griditemjsx-code-snippet&quot;&gt;click handlers&lt;/a&gt;. So, every time we add a card, we update only the deck reference of the card we just added. The rest of the cards remember the &lt;em&gt;old&lt;/em&gt; deck. As a result, our &lt;em&gt;validate&lt;/em&gt; function inside the click handler does nothing!&lt;/p&gt;&lt;p&gt;To fix this, we’ll have to make the button that adds the card into the deck a child of the &lt;code&gt;GridItemWithDeck&lt;/code&gt;. We’ll lose some performance gains, but it’s necessary if we want an app without bugs. This is a performance test in development with x4 &lt;abbr title=&quot;Central Processing Unit&quot;&gt;CPU&lt;/abbr&gt; throttle after the bug fix:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:779px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/72d97d764d8cfb8da73b75f42b8effd5/2ffff/development-x4-after-bug.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:96.45833333333333%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAATABQDASIAAhEBAxEB/8QAGAABAQADAAAAAAAAAAAAAAAAAAIBAwX/xAAXAQADAQAAAAAAAAAAAAAAAAAAAQID/9oADAMBAAIQAxAAAAHrVDKqbmk5DQB//8QAGhAAAgIDAAAAAAAAAAAAAAAAABIBIgIRIP/aAAgBAQABBQJjYxnFlvx//8QAFhEAAwAAAAAAAAAAAAAAAAAAAREg/9oACAEDAQE/AUI//8QAGREAAQUAAAAAAAAAAAAAAAAAAAIQERIh/9oACAECAQE/AbKk1//EABgQAQEAAwAAAAAAAAAAAAAAAABBESBh/9oACAEBAAY/AoiMua//xAAdEAACAQQDAAAAAAAAAAAAAAAAAREgITFhQZHx/9oACAEBAAE/IVt2JejZhtjBPgEoUKj/2gAMAwEAAgADAAAAELvww//EABgRAAIDAAAAAAAAAAAAAAAAAAARARAh/9oACAEDAQE/EMGxxf8A/8QAGBEBAAMBAAAAAAAAAAAAAAAAAQAQEVH/2gAIAQIBAT8QSRkzq//EAB4QAQACAQQDAAAAAAAAAAAAAAEAESFBUXHhEDHw/9oACAEBAAE/ENjjekEpH64ihoDz1MMWguAoyvrqQACg9EqzO018f//Z&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;After fixing the bug in development x4 slowdown&quot; title=&quot;After fixing the bug in development x4 slowdown&quot; src=&quot;/static/72d97d764d8cfb8da73b75f42b8effd5/2ffff/development-x4-after-bug.jpg&quot; srcSet=&quot;/static/72d97d764d8cfb8da73b75f42b8effd5/a5e48/development-x4-after-bug.jpg 480w,/static/72d97d764d8cfb8da73b75f42b8effd5/2ffff/development-x4-after-bug.jpg 779w&quot; sizes=&quot;(max-width: 779px) 100vw, 779px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;After fixing the bug in development x4 slowdown&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;The longest update took about 320ms after the final split.&lt;/p&gt;&lt;p&gt;As you can see, React has good reasons to re-render when a prop or a parent changes because it’s &lt;em&gt;really easy to make mistakes&lt;/em&gt; when implementing the &lt;code&gt;areEqual&lt;/code&gt; method…&lt;/p&gt;&lt;h2 id=&quot;what-weve-learned&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#what-weve-learned&quot;&gt;What we’ve learned&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;You have to be careful with the context hook because when it changes, it forces expensive re-renders that may not be necessary.&lt;/li&gt;&lt;li&gt;You can mitigate that by splitting the components into 2 new components.&lt;/li&gt;&lt;li&gt;&lt;code&gt;PureComponent&lt;/code&gt; (&lt;code&gt;memo&lt;/code&gt;) and &lt;code&gt;shouldComponentUpdate&lt;/code&gt; (&lt;code&gt;areEqual&lt;/code&gt;) can help you skip renders.&lt;/li&gt;&lt;li&gt;We saw some performance optimizations for &lt;code&gt;react-window&lt;/code&gt; that we can use when we render expensive items.&lt;/li&gt;&lt;li&gt;Spend your time optimizing for performance only if it matters to your users.&lt;/li&gt;&lt;li&gt;Always measure before you start optimizing.&lt;/li&gt;&lt;li&gt;We saw how to measure the performance of our app with Chrome DevTools and the performance tab.&lt;/li&gt;&lt;li&gt;Be careful when you implement the &lt;code&gt;shouldComponentUpdate&lt;/code&gt; or &lt;code&gt;areEqual&lt;/code&gt; methods because it’s easy to introduce bugs to your application.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;further-readingsources&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#further-readingsources&quot;&gt;Further reading/sources&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/facebook/react/issues/15156&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub issue: Preventing rerenders with React.memo and useContext hook.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://reactjs.org/docs/optimizing-performance.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;React docs: Optimizing performance&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://calibreapp.com/blog/react-performance-profiling-optimization/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Profiling React performance with React 16 and Chrome Devtools.&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://blog.logrocket.com/make-react-fast-again-part-2-why-did-you-update-dd1faf79399f&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Make React Fast Again [Part 2]&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=nySib7ipZdk&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;YouTube video: Deep dive with the React DevTools profiler with Brian Vaughn&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Deep copy vs shallow copy vs assignment operator]]></title><description><![CDATA[We examine the differences between deep object copy, shallow copy, and assignment operator in JavaScript with code.]]></description><link>https://markoskon.com/deep-copy-vs-shallow-copy-vs-assignment/</link><guid isPermaLink="false">https://markoskon.com/deep-copy-vs-shallow-copy-vs-assignment/</guid><pubDate>Thu, 07 Mar 2019 22:12:03 GMT</pubDate><content:encoded>&lt;p&gt;In this post, we’ll try to understand the differences between &lt;em&gt;deep object copy&lt;/em&gt;, &lt;em&gt;shallow copy&lt;/em&gt;, and the &lt;em&gt;assignment operator&lt;/em&gt; in JavaScript. To do that, we’ll have to talk about variables and values first.&lt;/p&gt;&lt;h2 id=&quot;values-in-javascript&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#values-in-javascript&quot;&gt;Values in JavaScript&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;In this section, I will briefly talk about how I view the variables and values in JavaScript. There’s a lot to unpack, so if you want more details, check the resources below.&lt;/p&gt;&lt;p&gt;Variables point to values. Variables don’t point to other variables, and they don’t contain values. You can change where a variable points with the assignment operator (&lt;code&gt;=&lt;/code&gt;) unless you declared it with the &lt;code&gt;const&lt;/code&gt; keyword. In this case, you’ll get a syntax error.&lt;/p&gt;&lt;p&gt;In JavaScript, we have two kinds of values. The &lt;em&gt;primitive&lt;/em&gt; values and the objects (some people may use the term &lt;em&gt;reference value&lt;/em&gt; for object values). The primitive values can’t change (they are immutable) but the object values can (they are mutable). The primitive values include the &lt;code&gt;string&lt;/code&gt;, &lt;code&gt;number&lt;/code&gt;, &lt;code&gt;bigint&lt;/code&gt;, &lt;code&gt;boolean&lt;/code&gt;, &lt;code&gt;null&lt;/code&gt;, &lt;code&gt;undefined&lt;/code&gt;, and &lt;code&gt;symbol&lt;/code&gt; types. Objects are a value type on their own. Inside the objects, you can find the arrays and the functions.&lt;/p&gt;&lt;h3 id=&quot;resources&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#resources&quot;&gt;Resources&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://exploringjs.com/impatient-js/ch_values.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Values in &lt;em&gt;JavaScript for impatient programmers.&lt;/em&gt;&lt;/a&gt;, a book by Dr. Axel Rauschmayer.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://justjavascript.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;em&gt;Just JavaScript&lt;/em&gt;&lt;/a&gt;, an online course by Dan Abramov.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;assignment-operator&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#assignment-operator&quot;&gt;Assignment operator&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let’s now use the assignment operator to “copy” a value from a variable to another variable. Or, because I claimed that variables don’t contain values, let’s use the assignment operator to point both variables to the same value.&lt;/p&gt;&lt;h3 id=&quot;primitives&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#primitives&quot;&gt;Primitives&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Create a variable with the name &lt;code&gt;message&lt;/code&gt; and point it to the string value &lt;code&gt;&amp;quot;hello&amp;quot;&lt;/code&gt;.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hello&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Create a variable with the name &lt;code&gt;messageCopy&lt;/code&gt;. Point it to the same value the variable with the name &lt;code&gt;message&lt;/code&gt; currently points to.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hello&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;messageCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;At this point, both variables point to the same string value &lt;code&gt;&amp;quot;hello&amp;quot;&lt;/code&gt;. If you log the variables in the console, you’ll see the &lt;code&gt;&amp;quot;hello&amp;quot;&lt;/code&gt; string value two times:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hello&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;messageCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;messageCopy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Because primitive values are immutable, if you try to change the first letter of the &lt;code&gt;&amp;quot;hello world&amp;quot;&lt;/code&gt; string, nothing happens. It fails silently or throws a &lt;code&gt;TypeError&lt;/code&gt; in strict mode.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hello&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;messageCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;messageCopy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;H&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;messageCopy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Prints &amp;quot;hello&amp;quot;, not &amp;quot;Hello&amp;quot;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;However, you can change where the &lt;code&gt;messageCopy&lt;/code&gt; variable points to. The highlighted line points the &lt;code&gt;messageCopy&lt;/code&gt; variable to the “hello world” string value:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hello&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;messageCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;messageCopy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The variable with the name &lt;code&gt;message&lt;/code&gt; still points to the “hello” value, so if you log it in the console, the result will be “hello”.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hello&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;messageCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;messageCopy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hello world&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;message&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&quot;objects-arrays&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#objects-arrays&quot;&gt;Objects (arrays)&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;We have a similar situation with array values. To remind you, JavaScript considers array values as object type values. You can point two variables to the same array value:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbersCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbersCopy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Prints [1, 2, 3], [1, 2, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can change where the second variable points, without affecting the first (the same is true for primitive values):&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbersCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;numbersCopy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbersCopy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Prints: [1, 2, 3], [4, 2, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But because array values are mutable, you &lt;em&gt;can&lt;/em&gt; change any element of the array value. In other words, you can mutate the array value, something you can’t do with primitive values like strings. In the following example, both variables point to the same array value, so both variables will see the change:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbersCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;numbersCopy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;] &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbers&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;numbersCopy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Prints: [4, 2, 3], [4, 2, 3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As a result, the assignment operator is not a good choice to “copy” an object value from one variable to another variable. If you mutate one value, both variables will see the change.&lt;/p&gt;&lt;h2 id=&quot;shallow-copy&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#shallow-copy&quot;&gt;Shallow copy&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Now, let’s see what happens if you try to make a &lt;em&gt;shallow copy&lt;/em&gt; of an object. By shallow-copying an object, you create a new object value that has the same properties as the old object. Each property of the new object value points to the same values the old object’s properties are pointing. You’ll see what that means in a bit.&lt;/p&gt;&lt;p&gt;There are many ways you can shallow copy an object:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://www.npmjs.com/package/lodash.clone&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;lodash.clone&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Object.assign&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_object_literals&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Object spread syntax&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Let’s choose &lt;code&gt;Object.assign&lt;/code&gt; for this example because it doesn’t require an external library:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  likes: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cuddles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  favoriteHuman: { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;assign&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{}, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;catCopy&lt;/code&gt; variable points to a mutable object value. That means you can change that object value if you want. Lets start by changing its &lt;code&gt;likes&lt;/code&gt; property:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  likes: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cuddles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  favoriteHuman: { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;assign&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{}, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;likes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;food&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Nothing is stopping you from changing its object property:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  likes: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cuddles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  favoriteHuman: { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;assign&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{}, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;likes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;food&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;favoriteHuman&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;John&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let’s now log in the console the original object to see what’s going on:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  likes: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cuddles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  favoriteHuman: { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;assign&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{}, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;likes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;food&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;favoriteHuman&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;John&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You see that the &lt;code&gt;likes&lt;/code&gt; property remains intact, but the &lt;code&gt;favoriteHuman&lt;/code&gt; property changed. This is probably something you didn’t intend to do. This will start to make sense if we see what the shallow copy does. First, it creates a new object value:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* ...*/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, it creates the properties the original object had:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  likes: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;TODO&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  favoriteHuman: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;TODO&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Finally, it points the new properties to the values the old properties were pointing to:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;15&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  likes: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;likes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  favoriteHuman: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;favoriteHuman&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you evaluate the &lt;code&gt;cat.likes&lt;/code&gt;, you get the string value &lt;code&gt;&amp;quot;cuddles&amp;quot;&lt;/code&gt;. This is a string primitive value that you can’t mutate. If you evaluate the &lt;code&gt;cat.favoriteHuman&lt;/code&gt;, you get the object value &lt;code&gt;{ name: &amp;quot;Mary&amp;quot; }&lt;/code&gt;. That object is not a new object but the same object for both the &lt;code&gt;cat&lt;/code&gt; and the &lt;code&gt;catCopy&lt;/code&gt;. So, this is the problem. Object values are mutable, so if you mutate the &lt;code&gt;catCopy.favoriteHuman&lt;/code&gt;, the original object will also see the change in &lt;code&gt;cat.favoriteHuman&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;You can verify that both properties point to the same object with a strict equality check (&lt;code&gt;===&lt;/code&gt;):&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;16&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  likes: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cuddles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  favoriteHuman: { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;assign&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{}, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;favoriteHuman&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;favoriteHuman&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Prints: true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;What you would probably want for the &lt;code&gt;favoriteHuman&lt;/code&gt; is to point to a &lt;em&gt;new object value&lt;/em&gt;. Something like this:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;17&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  likes: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;likes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  favoriteHuman: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;favoriteHuman&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  likes: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cuddles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  favoriteHuman: { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, you can mutate the &lt;code&gt;catCopy&lt;/code&gt; object without worrying about the original &lt;code&gt;cat&lt;/code&gt; object. This is what &lt;em&gt;deep copy&lt;/em&gt; does.&lt;/p&gt;&lt;h2 id=&quot;deep-copy&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#deep-copy&quot;&gt;Deep copy&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Now let’s see what happens when you make a &lt;em&gt;deep copy&lt;/em&gt;. Let’s use &lt;a href=&quot;https://www.npmjs.com/package/lodash.clonedeep&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;lodash.clonedeep&lt;/a&gt; for that:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;18&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; cloneDeep &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;lodash.clonedeep&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  likes: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cuddles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  favoriteHuman: { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cloneDeep&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can now mutate the properties of the new object:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;19&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; cloneDeep &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;lodash.clonedeep&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  likes: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cuddles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  favoriteHuman: { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;cloneDeep&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;likes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;food&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;catCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;favoriteHuman&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;John&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Prints:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//   likes: &amp;#x27;cuddles&amp;#x27;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//   favoriteHuman: { name: &amp;#x27;Mary&amp;#x27; }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As you can see, with a deep copy you can mutate the new object value without worrying about mutating the original object. The drawback is that a deep copy is more expensive in &lt;abbr title=&quot;Central Processing Unit&quot;&gt;CPU&lt;/abbr&gt; cycles and memory.&lt;/p&gt;&lt;h2 id=&quot;conclusion&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you don’t want to accidentally mutate your original objects:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Avoid passing around object values with the assignment operator, instead, use shallow copy.&lt;/li&gt;&lt;li&gt;If your objects are simple and have only primitive properties, you can shallow copy them and avoid performance overhead from deep copying.&lt;/li&gt;&lt;li&gt;If your objects are complex and have properties that point to other objects, you’ll have to deep copy them with a library like &lt;code&gt;lodash.clonedeep&lt;/code&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;extra-higher-order-functions&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#extra-higher-order-functions&quot;&gt;Extra: higher-order functions&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Somewhat related to the previous is the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;code&gt;Array.prototype.map&lt;/code&gt;&lt;/a&gt;. With &lt;code&gt;map&lt;/code&gt;, you take an array value and transform it into a new array value. You then assign that value to a new variable. You may think that because &lt;code&gt;map&lt;/code&gt; creates a new array value, it’s safe to modify it. As it turns out, it depends on what type of value (primitive/object) you return from your transformer function.&lt;/p&gt;&lt;p&gt;In the following example, we have an array of cats (ok, 1 cat for brevity). We transform it into an array of people that are popular with cats.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;20&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cats&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    likes: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cuddles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    favoritePerson: { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;peopleWithCats&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cats&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;favoritePerson&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Mutate a person from the new array.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;peopleWithCats&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;John&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Log in the console the original cat array.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cats&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Result&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//    likes: &amp;quot;cuddles&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//    favoritePerson: { name: &amp;quot;John&amp;quot; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// ]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The result shouldn’t be surprising because you return an existing object value from &lt;code&gt;map&lt;/code&gt;. As a result, if you mutate the person object in the new array, you also mutate the person object inside the cat from the original cat array.&lt;/p&gt;&lt;p&gt;The same is true if you use the &lt;em&gt;spread operator&lt;/em&gt; on the cat objects which performs a shallow copy. Notice that, in the following example, we create a copy of the cats array, not an array with people. We do that to illustrate the use of the spread operator:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;21&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cats&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    likes: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cuddles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    favoritePerson: { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;catsCopy&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cats&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Mutate a cat&amp;#x27;s favorite person from the new array.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;catsCopy&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;favoritePerson&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;John&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Log in the console the original cat array.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cats&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Result&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//    likes: &amp;quot;cuddles&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//    favoritePerson: { name: &amp;quot;John&amp;quot; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// ]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A better way is to return a &lt;em&gt;new&lt;/em&gt; object value inside map. In the next example, we create an array with people again:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;22&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cats&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    likes: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;cuddles&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    favoritePerson: { name: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Mary&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;let &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;peopleWithCats&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;cats&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;favoritePerson&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// Name is a primitive value, so it&amp;#x27;s safe to return.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Or, because the people objects have only primitive properties,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// you can use the spread operator e.g. { ...favoritePerson }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Mutate a person from the new array.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk46&quot;&gt;peopleWithCats&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;John&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Log in the console the original cat array.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;cats&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Result&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//  {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//    likes: &amp;quot;cuddles&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//    favoritePerson: { name: &amp;quot;Mary&amp;quot; },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;//  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// ]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As a result, you’ll have to know what value types you return from higher-order functions because it’s possible to mutate the original arrays.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[SEO + DX focused internationalization for Gatsby]]></title><description><![CDATA[Support multiple languages, and don’t compromise the SEO or the DX in your Gatsby application with react-intl.]]></description><link>https://markoskon.com/gatsby-react-intl-example/</link><guid isPermaLink="false">https://markoskon.com/gatsby-react-intl-example/</guid><pubDate>Thu, 07 Feb 2019 22:12:03 GMT</pubDate><content:encoded>&lt;p&gt;In this post, we’ll see how we can support multiple languages in our Gatsby application with react-intl. The main objectives are the following:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Good &lt;abbr title=&quot;Search Engine Optimization&quot;&gt;SEO&lt;/abbr&gt; by rendering in the initial &lt;abbr title=&quot;Hypertext Markup Language&quot;&gt;HTML&lt;/abbr&gt; we send to the user our meta tags and of course our content.&lt;/li&gt;&lt;li&gt;Good developer experience (&lt;abbr title=&quot;Developer Experience&quot;&gt;DX&lt;/abbr&gt;) by maintaining only one page, and automatically creating copies for that page for each language we want to support.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;disclaimers&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#disclaimers&quot;&gt;Disclaimers&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Last time I checked, there wasn’t a &lt;strong&gt;definitive guide&lt;/strong&gt; on how to implement internationalization (&lt;strong&gt;i18n&lt;/strong&gt; for short) in the Gatsby documentation. There are of course many approaches and different libraries you can use for &lt;strong&gt;i18n&lt;/strong&gt; if you search on GitHub. The only solution I found that satisfies our 2 objectives is the one in this &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/issues/3853#issuecomment-433308547&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub issue&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;I want to be honest, the purpose of this post is quite selfish. I intend to use it as a “cookbook” for my custom &lt;a href=&quot;https://github.com/MarkosKon/gatsby-starter&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-starter&lt;/a&gt;. As a result, it’ll be &lt;strong&gt;opinionated&lt;/strong&gt;, and I won’t go into a lot of details explaining the code and the tools I use. In addition to that, I don’t know &lt;strong&gt;react-intl&lt;/strong&gt; in-depth, so I don’t want to suggest or claim something that is not true. So if you want something that explains a bit more, check &lt;a href=&quot;https://blog.significa.pt/i18n-with-gatsby-528607b4da81&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;the original post about react-inl in Gatsby&lt;/a&gt;. If you are still not satisfied by the original post, and you have some experience in Gatsby, you can return back here and see what I do. With that out of the way, let’s start by setting up the project.&lt;/p&gt;&lt;h2 id=&quot;project-setup&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#project-setup&quot;&gt;Project setup&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;As I said, I’ll be using my &lt;a href=&quot;https://github.com/MarkosKon/gatsby-starter&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;custom Gatsby starter&lt;/a&gt;. This starter focuses on the &lt;strong&gt;design&lt;/strong&gt; and on simple sites with &lt;strong&gt;static content&lt;/strong&gt; (it’s mainly for small businesses). Open a terminal, and type the following commands:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;gatsby new gatsby-react-intl https://github.com/MarkosKon/gatsby-starter.git&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; gatsby-react-intl&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add react-intl&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now that we’ve installed our dependencies, let’s make a plan. (By the way, we’re going to support 2 languages, Greek and English).&lt;/p&gt;&lt;h2 id=&quot;the-plan&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#the-plan&quot;&gt;The plan&lt;/a&gt;&lt;/h2&gt;&lt;ol&gt;&lt;li&gt;One of the most important things we’ll need to do is to &lt;strong&gt;override&lt;/strong&gt; the &lt;strong&gt;onCreatePage&lt;/strong&gt; method in &lt;strong&gt;gatsby-node.js&lt;/strong&gt;. For each page we have in the &lt;strong&gt;src/pages&lt;/strong&gt; directory, we’ll &lt;strong&gt;create a new page for each language we want to support&lt;/strong&gt;. We’ll also pass as &lt;strong&gt;page context&lt;/strong&gt; to that page some language info that we’ll need later in our components.&lt;/li&gt;&lt;li&gt;We’ll also need an &lt;strong&gt;&lt;abbr title=&quot;Search Engine Optimization&quot;&gt;SEO&lt;/abbr&gt;&lt;/strong&gt; component that we’ve already have in our &lt;strong&gt;src/components/&lt;abbr title=&quot;Search Engine Optimization&quot;&gt;SEO&lt;/abbr&gt;.jsx&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;A &lt;strong&gt;LanguageSwitcher&lt;/strong&gt; component. We only have two languages, so we’ll implement it as a component with two links and &lt;strong&gt;“globe”&lt;/strong&gt; icon. If we had more, it would make more sense to create a dropdown.&lt;/li&gt;&lt;li&gt;&lt;strong&gt;2 files&lt;/strong&gt; with our &lt;strong&gt;translated messages&lt;/strong&gt;, in &lt;abbr title=&quot;JavaScript Object Notation&quot;&gt;JSON&lt;/abbr&gt; format, one for Greek and one for English.&lt;/li&gt;&lt;li&gt;A &lt;strong&gt;LocalizedLink&lt;/strong&gt; component that will output the correct page depending on the language the user selects. Remember that the page we maintain is one, but the languages are two.&lt;/li&gt;&lt;li&gt;Finally, we’ll use &lt;strong&gt;react-intl to glue&lt;/strong&gt; all those parts together.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Let’s start with step 4. We’ll create a &lt;strong&gt;locales&lt;/strong&gt; folder inside our &lt;strong&gt;src&lt;/strong&gt; folder that will contain some information about our languages. Let’s create an &lt;strong&gt;index.js&lt;/strong&gt; file with the following content (it has to be in CommonJS):&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/locales/index.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  en: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    path: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;en&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    locale: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;English&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    localeShort: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;en&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    default: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  el: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    path: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    locale: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Ελληνικά&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    localeShort: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;ελ&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, let’s create &lt;strong&gt;2 &lt;abbr title=&quot;JavaScript Object Notation&quot;&gt;JSON&lt;/abbr&gt; files&lt;/strong&gt; with our messages:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/locales/el.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;navbar&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;Γειά σου&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;heading&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;Γειά σου&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;tagline&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;Κόσμε!&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/locales/en.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;navbar&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;Hello&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;heading&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;Hello&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;tagline&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;World!&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let’s now return to &lt;strong&gt;step 1&lt;/strong&gt; and follow the original order. We’re going to override the &lt;strong&gt;onCreatePage&lt;/strong&gt; method in &lt;strong&gt;gatsby-node.js&lt;/strong&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-node.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;locales&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./src/locales&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;onCreatePage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createPage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;deletePage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;actions&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Promise&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;deletePage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;keys&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locales&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;localizedPath&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locales&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;default&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;path&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locales&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;page&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        path: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;localizedPath&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        context: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          locale: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  });&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here we override the default &lt;strong&gt;onCreatePage&lt;/strong&gt; method that creates pages from the files we have in the &lt;strong&gt;src/pages&lt;/strong&gt; folder. We import the language data we created earlier, and for each language, we create a new page. We pass into those pages the &lt;strong&gt;path (localizedPath)&lt;/strong&gt;, the actual &lt;strong&gt;page&lt;/strong&gt;, and the &lt;strong&gt;locale string&lt;/strong&gt; as context which we’ll use inside our components. Don’t forget to restart the development server after creating this file if you want the changes to take effect.&lt;/p&gt;&lt;h2 id=&quot;create-the-language-specific-components&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#create-the-language-specific-components&quot;&gt;Create the language-specific components&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Now before we set up and use &lt;code&gt;react-intl&lt;/code&gt;, let’s create the components we’ll need. We start with the &lt;strong&gt;LanguageSwitcher&lt;/strong&gt; component:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/LanguageSwitcher.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; styled &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;styled-components&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { injectIntl } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-intl&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// eslint-disable-next-line import/no-extraneous-dependencies&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Location } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@reach/router&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Globe } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./Icons&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Link &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./Link&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; locales &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../locales&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Nav&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;styled&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;nav&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;flex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;align-items&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;transparent&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;box-shadow&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;svg&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;margin-left&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;60&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toPage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;pathname&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;pathname&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\/&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;[a-z]&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{2}&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;pop&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;LanguageSwitcher&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;intl&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locale&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Location&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ location: { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;pathname&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; } }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Nav&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Globe&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;keys&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locales&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locales&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;locale&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;ml&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;===&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locale&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;red&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locales&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;default&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;pathname&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locales&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;toPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;pathname&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locales&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;localeShort&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        ))&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Nav&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Location&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;LanguageSwitcher&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  intl: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    locale: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  })&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;injectIntl&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;LanguageSwitcher&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If the Globe component doesn’t exist, you can add it in the &lt;strong&gt;src/components/Icons.jsx&lt;/strong&gt; file:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/Icons.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  faHeart,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  faLink,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  faGlobeAfrica,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;} &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;@fortawesome/free-solid-svg-icons&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// ... skipping stuff&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Globe&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;FontAwesomeIcon&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;icon&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;faGlobeAfrica&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  Facebook,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  GooglePlus,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  Linkedin,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  Skype,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  Twitter,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  Instagram,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  Envelope,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  Heart,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  FaLink,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  Globe,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We continue with the &lt;strong&gt;LocalizedLink&lt;/strong&gt; component:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/LocalizedLink.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { injectIntl } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-intl&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Link &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./Link&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; locales &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../locales&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;LocalizedLink&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;intl&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locale&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locales&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locale&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; ? &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locale&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}${&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;LocalizedLink&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  to: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  intl: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    locale: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  })&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;injectIntl&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;LocalizedLink&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Notice the &lt;strong&gt;injectIntl&lt;/strong&gt; &lt;a href=&quot;https://reactjs.org/docs/higher-order-components.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Higher-Order Component&quot;&gt;HOC&lt;/abbr&gt;&lt;/a&gt; from &lt;strong&gt;react-intl&lt;/strong&gt; that we use to get the locale as a prop in our component. react-intl uses the &lt;a href=&quot;https://reactjs.org/docs/context.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Context &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt;&lt;/a&gt; to pass down the language data.&lt;/p&gt;&lt;p&gt;And we’re finished with our components; let’s now set up react-intl.&lt;/p&gt;&lt;h2 id=&quot;setting-up-react-intl&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#setting-up-react-intl&quot;&gt;Setting up react-intl&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;We’ll need to initialize &lt;strong&gt;react-intl&lt;/strong&gt; and create a context provider. The place that makes the most sense to do this is our &lt;strong&gt;reusable layout file&lt;/strong&gt;. We go to our &lt;strong&gt;src/layouts/Layout.jsx&lt;/strong&gt; file, and we paste the following code—pay attention only to the highlighted lines:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/layouts/Layout.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; styled, { ThemeProvider } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;styled-components&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { StaticQuery, graphql } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Navbar, DesktopListEmpty } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;already-styled-components&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  FormattedMessage,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  IntlProvider,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  addLocaleData,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;} &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-intl&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Locale data&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; enData &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-intl/locale-data/en&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; elData &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-intl/locale-data/el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// Messages&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; en &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../locales/en&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; el &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../locales/el&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; GlobalStyle &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./GlobalStyle&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; theme &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./theme&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Box } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/Primitives&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Link &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/Link&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; LanguageSwitcher &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/LanguageSwitcher&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// initialize some things&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;en&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;el&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk7&quot;&gt;addLocaleData&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;enData&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;elData&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;DesktopList&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;styled&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(DesktopListEmpty)&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;flex&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;align-items&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;nav&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;margin-left&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;margin-right&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locale&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;StaticQuery&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      query SiteTitleQuery {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        site {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          siteMetadata {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            title&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;ThemeProvider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;theme&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;IntlProvider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;locale&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locale&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locale&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;GlobalStyle&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Navbar&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;bc&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;rebeccapurple&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;desktopList&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                &amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;DesktopList&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, textDecoration: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;site&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;siteMetadata&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;sup&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;FormattedMessage&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;navbar&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;sup&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;LanguageSwitcher&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;DesktopList&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Home&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/page-2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Page 2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Navbar&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;80%&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;IntlProvider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;ThemeProvider&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  locale: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  children: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As you can see in the code above, we import the &lt;strong&gt;locale data&lt;/strong&gt; from &lt;strong&gt;react-intl&lt;/strong&gt;, and we “add” them with the &lt;strong&gt;addLocaleData&lt;/strong&gt; method. We also import the &lt;strong&gt;messages&lt;/strong&gt; we created earlier and pass them to an &lt;strong&gt;IntlProvider&lt;/strong&gt; as a prop. In addition to the messages, we also pass the &lt;strong&gt;locale&lt;/strong&gt; to the &lt;strong&gt;IntlProvider&lt;/strong&gt;. You may be wondering where that locale prop comes from. We mentioned something earlier while creating our &lt;strong&gt;gatsby-node.js&lt;/strong&gt; file. We’ll see exactly where it’s coming from in the next section where we going to use react-intl to translate our pages.&lt;/p&gt;&lt;h2 id=&quot;using-react-intl-in-our-pages&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#using-react-intl-in-our-pages&quot;&gt;Using react-intl in our pages&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;We can obviously delete any page we don’t need, and we can keep only the &lt;code&gt;404&lt;/code&gt; and &lt;code&gt;index&lt;/code&gt; pages. We go to our index page and paste the following code. Again pay attention to the highlighted code:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/index.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { FormattedMessage } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-intl&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Box, Heading, Text } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/Primitives&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Layout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../layouts/Layout&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; SEO &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/SEO&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;IndexPage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;pageContext&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: { &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locale&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;locale&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;locale&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;SEO&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Home&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;keywords&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;calc(100vh - 100px)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;pt&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Heading&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;variant&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;FormattedMessage&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;heading&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Heading&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;as&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;variant&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;wide&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;FormattedMessage&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;tagline&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Box&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;IndexPage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  pageContext: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;shape&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    locale: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  })&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;IndexPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As we can see, the &lt;strong&gt;locale&lt;/strong&gt; prop we pass to our &lt;strong&gt;Layout&lt;/strong&gt; component comes from our pages. It’s the &lt;strong&gt;pageContext&lt;/strong&gt; we created in our &lt;strong&gt;gatsby-node.js&lt;/strong&gt; file while duplicating our pages for each language. We also use the &lt;strong&gt;FormattedMessage&lt;/strong&gt; component to output the messages we created earlier. Feel free to create more pages and messages to test the application.&lt;/p&gt;&lt;h2 id=&quot;summary&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#summary&quot;&gt;Summary&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;We achieved our first objective which was to have &lt;strong&gt;good &lt;abbr title=&quot;Search Engine Optimization&quot;&gt;SEO&lt;/abbr&gt;&lt;/strong&gt;. To prove this, you’ll have to build your site and serve it locally with:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;gatsby build &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; gatsby serve&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you go to your browser and inspect the initial &lt;abbr title=&quot;Hypertext Markup Language&quot;&gt;HTML&lt;/abbr&gt;, you’ll see that we have both our &lt;strong&gt;meta&lt;/strong&gt; tags and our &lt;strong&gt;content&lt;/strong&gt; available before any JavaScript runs. That’s something the search engines love. If you have the &lt;strong&gt;gatsby-plugin-offline&lt;/strong&gt; installed, you’ll have to &lt;a href=&quot;/curl-examples&quot;&gt;curl the server&lt;/a&gt; to see the actual page.&lt;/p&gt;&lt;p&gt;We also completed our second objective which was to have a &lt;strong&gt;good developer experience&lt;/strong&gt;. We maintain only one copy of the page, and we output our i18n content with the FormattedMessage component.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk39 { color: #C789D6; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk12 { color: #FFCB8B; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk15 { color: #80CBC4; }
  .night-owl-no-italics .mtk16 { color: #FF6363; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk11 { color: #FFEB95; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Reveal animations on scroll with react-spring]]></title><description><![CDATA[Create reveal animations on scroll with react-spring and react-visibility-sensor.]]></description><link>https://markoskon.com/scroll-reveal-animations-with-react-spring/</link><guid isPermaLink="false">https://markoskon.com/scroll-reveal-animations-with-react-spring/</guid><pubDate>Wed, 06 Feb 2019 22:12:03 GMT</pubDate><content:encoded>&lt;p&gt;In this post, you’ll use the &lt;a href=&quot;https://github.com/react-spring/react-spring&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;react-spring&lt;/a&gt; library to create reveal animations on scroll. I’m talking about simple animations like &lt;em&gt;fade-ins&lt;/em&gt; and &lt;em&gt;slide-ups&lt;/em&gt;. To determine if an element is visible, you’ll use the &lt;a href=&quot;https://github.com/joshwnj/react-visibility-sensor&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;react-visibility-sensor&lt;/a&gt;. I will also mention some smaller libraries you can use that specialize in reveal animations—instead of &lt;code&gt;react-spring&lt;/code&gt;—and I will show a solution with &lt;a href=&quot;#a-solution-with-css-transitions&quot;&gt;react-visibility-sensor and &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; transitions&lt;/a&gt;.&lt;/p&gt;&lt;h2 id=&quot;related-libraries&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#related-libraries&quot;&gt;Related libraries&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;There are many libraries that specialize in scroll animations. A popular is &lt;a href=&quot;https://github.com/michalsnik/aos&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;aos&lt;/a&gt; at &lt;a href=&quot;https://bundlephobia.com/result?p=aos@2.3.4&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;about 4.5kb&lt;/a&gt;, and another one is &lt;a href=&quot;https://github.com/mciastek/sal&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;sal.js&lt;/a&gt;, which is &lt;a href=&quot;https://bundlephobia.com/result?p=sal.js@0.5.0&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;under 1kb&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;On the other hand, &lt;code&gt;react-visibility-sensor&lt;/code&gt; is &lt;a href=&quot;https://bundlephobia.com/result?p=react-visibility-sensor@5.0.2&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;about 2.9kb&lt;/a&gt;, and &lt;code&gt;react-spring&lt;/code&gt; is &lt;a href=&quot;https://bundlephobia.com/result?p=react-spring@8.0.1&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;around 10kb&lt;/a&gt;. Besides that, neither of them has good &lt;a href=&quot;https://en.wikipedia.org/wiki/Tree_shaking&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;tree-shaking&lt;/a&gt;. This means that you’ll end up with an additional 13kb in your final bundle size, no matter how much code you use. In fact, I tested this, and from the initial Create React App to the final version of this example, the bundle size &lt;em&gt;increased by 14kb&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;As a result, this example is useful if you’re &lt;em&gt;already&lt;/em&gt; using react-spring for animations in your app. If you don’t, &lt;code&gt;sal.js&lt;/code&gt; might be a better alternative. In the following link, you can find &lt;a href=&quot;https://github.com/MarkosKon/gatsby-starter/blob/master/src/components/Sal.jsx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;an example react component with sal.js&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;the-plan&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#the-plan&quot;&gt;The plan&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You can create repeatable animations with the &lt;code&gt;Spring&lt;/code&gt; component from &lt;code&gt;react-spring&lt;/code&gt;. While skimming through the &lt;a href=&quot;https://www.react-spring.io/docs/props/spring&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;documentation&lt;/a&gt;, I thought you can use it only for mounting animations. You specify a &lt;code&gt;from&lt;/code&gt; and a &lt;code&gt;to&lt;/code&gt; prop, and the component animates when first mounts on the screen. But later I noticed that the &lt;code&gt;from&lt;/code&gt; prop is &lt;em&gt;optional&lt;/em&gt;. Only the &lt;code&gt;to&lt;/code&gt; prop is required.&lt;/p&gt;&lt;p&gt;But what will help us here is that you can change the &lt;code&gt;to&lt;/code&gt; prop &lt;em&gt;during runtime&lt;/em&gt; and the component will animate accordingly.&lt;/p&gt;&lt;p&gt;So, the plan is to:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Use &lt;code&gt;react-visibility-sensor&lt;/code&gt; to determine if the element is visible or not,&lt;/li&gt;&lt;li&gt;Change the &lt;code&gt;to&lt;/code&gt; prop (or more specifically, the opacity) of the &lt;code&gt;Spring&lt;/code&gt; component during runtime, as shown below:&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Spring&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ opacity: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;project-setup&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#project-setup&quot;&gt;Project Setup&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/MarkosKon/react-spring-scroll&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub repo with the completed example&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The first thing you have to do is to create a new project with &lt;a href=&quot;https://github.com/facebook/create-react-app/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Create React App&lt;/a&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;npx create-react-app react-spring-scroll&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; react-spring-scroll&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, install the dependencies, and start the development server:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add react-spring react-visibility-sensor&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn start&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After that, go to the &lt;code&gt;src/App.js&lt;/code&gt; file, and add the following code. Pay attention to the highlighted lines:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/App.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Spring } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-spring/renderprops&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; VisibilitySensor &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-visibility-sensor&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// styles&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;centeredStyles&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  display: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;flex&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  alignItems: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  justifyContent: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;center&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  flexDirection: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;column&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  height: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;100%&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;h2Styles&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  fontSize: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;82px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;centeredStyles&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          height: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;100vh&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          backgroundColor: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;pink&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Spring&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;delay&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ opacity: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;h2Styles&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Hello&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Spring&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the code above, we use two components. The &lt;code&gt;Spring&lt;/code&gt; and the &lt;code&gt;VisibilitySensor&lt;/code&gt;. They are both &lt;a href=&quot;https://reactjs.org/docs/render-props.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;render prop&lt;/a&gt; components—meaning that they expose their functionality through function parameters. For example, the &lt;code&gt;VisibilitySensor&lt;/code&gt; does this through the &lt;code&gt;isVisible&lt;/code&gt;, and the &lt;code&gt;Spring&lt;/code&gt; through the &lt;code&gt;opacity&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;From &lt;code&gt;VisibilitySensor&lt;/code&gt; we use the &lt;code&gt;isVisible&lt;/code&gt; boolean flag. We pass no other props to the component.&lt;/p&gt;&lt;p&gt;In the &lt;code&gt;Spring&lt;/code&gt; component, we pass 2 props.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;We pass a &lt;code&gt;delay&lt;/code&gt; with a value of 300ms to give some time to the animation. We do that in case the page hasn’t loaded yet, or if there’s some delay with the scroll event.&lt;/li&gt;&lt;li&gt;We pass the &lt;code&gt;to&lt;/code&gt; prop. If the component (heading 2) is visible, we pass to the &lt;code&gt;to&lt;/code&gt; prop an object with an opacity property of &lt;code&gt;1&lt;/code&gt;. If it’s not visible, we change it to &lt;code&gt;0&lt;/code&gt;. Whenever that value changes, the component fades in or fades out accordingly.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;To see the effect better, you’ll add now 2 more sections. Those sections will have slightly different reveal animations. Again pay attention to the highlighted lines:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/App.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Spring } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-spring/renderprops&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; VisibilitySensor &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-visibility-sensor&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping styles...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* skipping first section... */&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* copy from here... */&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;centeredStyles&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          overflow: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          height: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;100vh&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;partialVisibility&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Spring&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;delay&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                opacity: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                transform: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;translateX(0)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;translateX(200px)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;                &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;h2Styles&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;World&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Spring&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;centeredStyles&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          height: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;100vh&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          overflow: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          backgroundColor: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#afd4d4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;partialVisibility&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ bottom: &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Spring&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;delay&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;300&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                opacity: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                transform: &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;translateY(0)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;                  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;translateY(400px)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;h2Styles&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;!!!&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Spring&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* until here... */&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We’re doing almost the same thing. But instead of just fading in and out the elements we’re &lt;em&gt;sliding them to the left&lt;/em&gt; in the “World” section and &lt;em&gt;sliding them up&lt;/em&gt; in the “!!!” section. The &lt;code&gt;overflow: &amp;quot;hidden&amp;quot;&lt;/code&gt; on the containers is there because we don’t want the heading elements expanding (overflowing) the page when we place them in their start position (for example, &lt;code&gt;translateX(200px)&lt;/code&gt;). Be careful with the &lt;code&gt;overflow&lt;/code&gt;, though; displaying the content is more important than some fancy animations.&lt;/p&gt;&lt;p&gt;I also added to every &lt;code&gt;VisibilitySensor&lt;/code&gt; component the &lt;code&gt;partialVisibility&lt;/code&gt; prop. By having that prop set to true, the following happens:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The component will become visible if a &lt;em&gt;part of it&lt;/em&gt; is visible&lt;/li&gt;&lt;li&gt;The component will hide if &lt;em&gt;all of it&lt;/em&gt; is out of the view.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;By default, the &lt;code&gt;partialVisibility&lt;/code&gt; is set to false. In this case, the behavior is the complete opposite of the above.&lt;/p&gt;&lt;p&gt;To see this clearly, add these lines to the &lt;code&gt;h2Styles&lt;/code&gt; variable:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;h2Styles&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  fontSize: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;82px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  backgroundColor: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  padding: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;16px 32px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you now scroll up and down, you will notice something. The animations occur every time the elements become visible. In the next section, you’ll see how to animate them &lt;em&gt;only once&lt;/em&gt;.&lt;/p&gt;&lt;h2 id=&quot;enhance-visibilitysensor&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#enhance-visibilitysensor&quot;&gt;Enhance VisibilitySensor&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you want to animate the elements only when they first become visible, you’ll have to override the default component from &lt;code&gt;react-visibility-sensor&lt;/code&gt; and implement an &lt;code&gt;once&lt;/code&gt; prop. That prop will allow you to turn off the sensor after the first reveal. Create the &lt;code&gt;VisibilitySensor.jsx&lt;/code&gt; component inside &lt;code&gt;src/components&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/VisibilitySensor.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React, { Component } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; VSensor &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-visibility-sensor&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;extends&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Component&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;constructor&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      active: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    };&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const { &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;once&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;theRest&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; } = &lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VSensor&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;active&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;onChange&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;once&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk43 mtki&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setState&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ active: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;turned the thing off!&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;theRest&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; })&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VSensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    );&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  once: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  children: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;defaultProps&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  once: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We keep an &lt;code&gt;active&lt;/code&gt; boolean flag in the component state. When the element first comes into view, and the &lt;code&gt;once&lt;/code&gt; prop is true, we change the &lt;code&gt;active&lt;/code&gt; state to false. By doing that, we turn off the sensor by passing to the &lt;code&gt;active&lt;/code&gt; prop a value of &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;To use this, go back to your &lt;code&gt;App.js&lt;/code&gt; and do the following:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Change the import of the &lt;code&gt;VisibilitySensor&lt;/code&gt; from the node package to the custom component.&lt;/li&gt;&lt;li&gt;Add an &lt;code&gt;once&lt;/code&gt; prop as shown below:&lt;/li&gt;&lt;/ul&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/App.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; VisibilitySensor &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./components/VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;once&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now I’ll show you another solution that uses the &lt;code&gt;VisibilitySensor&lt;/code&gt; and &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; transitions.&lt;/p&gt;&lt;h2 id=&quot;a-solution-with-css-transitions&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#a-solution-with-css-transitions&quot;&gt;A solution with &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; transitions&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;You saw earlier that if you don’t want to use &lt;code&gt;react-spring&lt;/code&gt;, you can instead use &lt;a href=&quot;#related-libraries&quot;&gt;some smaller libraries&lt;/a&gt; that specialize in reveal animations. Now I’ll show you how to do reveal animations with &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; transitions and &lt;code&gt;react-visibility-sensor&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;The plan&lt;/strong&gt; here is to swap the classes of the &lt;code&gt;h2&lt;/code&gt; elements (visible/hidden), and these classes, in turn, will trigger some &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; transitions. I choose transitions over animations because you can easily &lt;em&gt;revert&lt;/em&gt; them—if the element changes state (visible/hidden) without completing the animation. That’s assuming you want repeated reveal animations, and you don’t want to use the &lt;code&gt;once&lt;/code&gt; prop from &lt;code&gt;VisibilitySensor&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;Let’s start with the &lt;code&gt;App.js&lt;/code&gt; component:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/App.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping the other imports.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./App.css&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  return &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;centeredStyles&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          height: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;100vh&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          backgroundColor: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;pink&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fadeIn enter&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fadeIn&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;h2Styles&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              Hello&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;centeredStyles&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          height: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;100vh&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          overflow: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;partialVisibility&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;slideLeft enter&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;slideLeft&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;h2Styles&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              World&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;centeredStyles&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          height: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;100vh&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          backgroundColor: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#afd4d4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          overflow: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;hidden&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;partialVisibility&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;offset&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ bottom: &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;isVisible&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;slideUp enter&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;slideUp&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ ...&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;h2Styles&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;              !!!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          )&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;VisibilitySensor&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After that, you’ll have to write some &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; for those classes. Replace the contents of your &lt;code&gt;App.css&lt;/code&gt; with the following:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/App.css&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.fadeIn&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: opacity &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;ease-in-out&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.fadeIn.enter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: opacity &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;ease-in-out&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.slideLeft&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: opacity &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;ease-in-out&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, transform &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;ease-in-out&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;translateX&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.slideLeft.enter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: opacity &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;ease-in-out&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, transform &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;cubic-bezier&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.25&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.46&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.45&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.94&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;translateX&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.slideUp&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: opacity &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;ease-in-out&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, transform &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;ease-in-out&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;translateY&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.slideUp.enter&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: opacity &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;ease-in-out&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, transform &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;cubic-bezier&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.25&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.46&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.45&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.94&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;translateY&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@media&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;prefers-reduced-motion: reduce&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.fadeIn&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.slideLeft&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.slideUp&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;At the end of the file, there is a &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;prefers-reduced-motion media query&lt;/a&gt; that disables the animations if the user wishes so. They can enable this option from their operating system settings.&lt;/p&gt;&lt;p&gt;The last thing I want to show you is how to implement reveal animations if you use Server Side Rendering (&lt;abbr title=&quot;Server-Side Rendering&quot;&gt;SSR&lt;/abbr&gt;).&lt;/p&gt;&lt;h2 id=&quot;ssr-with-javascript-disabled&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#ssr-with-javascript-disabled&quot;&gt;&lt;abbr title=&quot;Server-Side Rendering&quot;&gt;SSR&lt;/abbr&gt; with JavaScript disabled&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The solutions you saw earlier work well for a &lt;em&gt;client-side&lt;/em&gt; application with &lt;code&gt;create-react-app&lt;/code&gt;. If you try to do the same in an application that does some &lt;abbr title=&quot;Server-Side Rendering&quot;&gt;SSR&lt;/abbr&gt;—let’s take, for example, Gatsby—you’ll see that we have the following &lt;strong&gt;problem&lt;/strong&gt;. If you load the page with JavaScript disabled, your content will be &lt;em&gt;hidden&lt;/em&gt; because the elements start with &lt;code&gt;opacity: 0&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;To solve this, you want to disable all reveal animations by default, and if JavaScript is available, you want to enable them again. You can do this by adding a &lt;code&gt;no-js&lt;/code&gt; class to your &lt;code&gt;body&lt;/code&gt; element and then writing some &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; that disables the animations when the &lt;code&gt;no-js&lt;/code&gt; class is present. After that, you add a &lt;code&gt;script&lt;/code&gt;, right after the &lt;code&gt;body&lt;/code&gt; element, that will remove the &lt;code&gt;no-js&lt;/code&gt; class from the body if JavaScript is enabled.&lt;/p&gt;&lt;p&gt;Let’s see how you can do that in Gatsby for the solution with the &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; transitions. Here’s a &lt;a href=&quot;https://github.com/MarkosKon/react-spring-scroll-gatsby&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub repo for the example in Gatsby&lt;/a&gt; if you want to take a look at the code.&lt;/p&gt;&lt;p&gt;In Gatsby, you can add a class in the body element with the &lt;code&gt;setBodyAttributes&lt;/code&gt; method that’s available in the &lt;a href=&quot;https://www.gatsbyjs.org/docs/ssr-apis/#onRenderBody&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;onRenderBody&lt;/a&gt; &lt;a href=&quot;https://www.gatsbyjs.org/docs/ssr-apis/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;&lt;abbr title=&quot;Server-Side Rendering&quot;&gt;SSR&lt;/abbr&gt; &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt;&lt;/a&gt;. Create a &lt;code&gt;gatsby-ssr.js&lt;/code&gt; file at the root of the project and implement the &lt;code&gt;onRenderBody&lt;/code&gt; method:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-ssr.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;onRenderBody&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;setBodyAttributes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setBodyAttributes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ className: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;no-js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Next, you have to write the &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; that will disable the animations when that class is present:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk16&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.no-js&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.fadeIn&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk16&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.no-js&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.slideLeft&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk16&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.no-js&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.slideUp&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The last thing you have to do is add a &lt;code&gt;script&lt;/code&gt; tag right after the &lt;code&gt;body&lt;/code&gt; element. You can do this in Gatsby with the &lt;code&gt;setPreBodyComponents&lt;/code&gt; method that’s available as a parameter of the &lt;code&gt;onRenderBody&lt;/code&gt; &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt;. As a result, you’ll have to change your &lt;code&gt;gatsby-ssr.js&lt;/code&gt; to the following:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-ssr.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;onRenderBody&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;setPreBodyComponents&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;setBodyAttributes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setBodyAttributes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ className: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;no-js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;setPreBodyComponents&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;script&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;dangerouslySetInnerHTML&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        __html: &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;document.querySelector(&amp;#x27;body&amp;#x27;).classList.remove(&amp;#x27;no-js&amp;#x27;)&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    /&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  ])&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can achieve the same result in the &lt;code&gt;react-spring&lt;/code&gt; example by adding a &lt;code&gt;.reveal&lt;/code&gt; class in the &lt;code&gt;h2&lt;/code&gt; elements and writing the following &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk16&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.no-js&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.reveal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;opacity&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!important&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;none&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;!important&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Keep an eye for &lt;code&gt;react-spring&lt;/code&gt; version 9 because it will have &lt;a href=&quot;https://github.com/react-spring/react-spring/issues/668#issuecomment-500232707&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;a method you can use to disable animations.&lt;/a&gt;&lt;/p&gt;&lt;h2 id=&quot;final-words&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#final-words&quot;&gt;Final Words&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let’s summarize now some key points you saw throughout this post:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You can determine if an element is visible with &lt;code&gt;react-visibility-sensor&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;You can use that information to animate elements with &lt;code&gt;react-spring&lt;/code&gt; or with &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; transitions.&lt;/li&gt;&lt;li&gt;You saw how to adjust the &lt;code&gt;VisibilitySensor&lt;/code&gt; to fire only once to avoid repeatable reveal animations.&lt;/li&gt;&lt;li&gt;You can use some lightweight libraries that specialize in reveal animations instead of a heavier library like &lt;code&gt;react-spring&lt;/code&gt;. I also gave a GitHub link to an example React component with &lt;code&gt;sal.js&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Finally, you saw how to implement the above in a client-side app with &lt;code&gt;create-react-app&lt;/code&gt; and in an ”&lt;abbr title=&quot;Server-Side Rendering&quot;&gt;SSR&lt;/abbr&gt;” app with Gatsby.&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtki { font-style: italic; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk12 { color: #FFCB8B; }
  .night-owl-no-italics .mtk43 { color: #41EEC6; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk15 { color: #80CBC4; }
  .night-owl-no-italics .mtk11 { color: #FFEB95; }
  .night-owl-no-italics .mtk16 { color: #FF6363; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Extremely fast loading with Gatsby and self-hosted fonts]]></title><description><![CDATA[Drastically improve the load time of your Gatsby application with self-hosted fonts from the typefaces library.]]></description><link>https://markoskon.com/extremely-fast-load-time-with-gatsby-and-self-hosted-fonts/</link><guid isPermaLink="false">https://markoskon.com/extremely-fast-load-time-with-gatsby-and-self-hosted-fonts/</guid><pubDate>Sat, 26 Jan 2019 22:12:03 GMT</pubDate><content:encoded>&lt;p&gt;In this post, you’ll see how to improve the &lt;em&gt;First Contentful Paint&lt;/em&gt; (&lt;abbr&gt;FCP&lt;/abbr&gt;) and the &lt;em&gt;First Meaningful Paint&lt;/em&gt; (&lt;abbr&gt;FMP&lt;/abbr&gt;) of your Gatsby application. The “trick” is to &lt;em&gt;self-host&lt;/em&gt; your fonts. When you do that, you can reduce the loading of your application often by 1 second on &lt;span class=&quot;small-caps&quot;&gt;3G&lt;/span&gt; connections. To make the self-hosting easier, you will use the &lt;a href=&quot;https://github.com/kyleamathews/typefaces&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;typefaces&lt;/a&gt; package. Let’s now see why you can achieve those results if you change the font-loading strategy.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;If you prefer, you can skip the explanation and the project setup, and &lt;a href=&quot;#self-hosting-fonts-with-typefaces-package&quot;&gt;go to the required steps&lt;/a&gt;. You can also check the &lt;a href=&quot;#updates&quot;&gt;updates section&lt;/a&gt; because things changed (not much) since I wrote this post.&lt;/div&gt;&lt;h2 id=&quot;problem&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#problem&quot;&gt;Problem&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When you choose some fonts from the &lt;a href=&quot;https://fonts.google.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Google fonts library&lt;/a&gt;, the recommended way to load them is to either add a &lt;code&gt;link&lt;/code&gt; tag in the &lt;code&gt;head&lt;/code&gt; of your &lt;abbr&gt;HTML&lt;/abbr&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;html&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;link&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://fonts.googleapis.com/css?family=Lato&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;stylesheet&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or use the &lt;code&gt;@import&lt;/code&gt; rule inside your &lt;abbr&gt;CSS&lt;/abbr&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://fonts.googleapis.com/css?family=Lato&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After that, you can use the fonts by referencing them in your &lt;abbr&gt;CSS&lt;/abbr&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk16&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Lato&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When we specify the &lt;code&gt;link&lt;/code&gt; or the &lt;code&gt;@import&lt;/code&gt; rule, what we download first is a small &lt;abbr&gt;CSS&lt;/abbr&gt; file with the &lt;code&gt;@font-face&lt;/code&gt; definitions for our fonts. For example:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* skipping stuff... */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* latin */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Open Sans&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-style&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;normal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Open Sans Regular&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;), &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;OpenSans-Regular&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;https://fonts.gstatic.com/s/opensans/v15/mem8YaGs126MiZpBA-UFVZ0bf8pkAg.woff2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0000-00FF&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0131&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0152-0153&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+02BB-02BC&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+02C6&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+02DA&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+02DC&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2000-206F&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2074&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+20AC&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2122&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2191&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2193&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2212&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2215&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+FEFF&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+FFFD&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* cyrillic */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Playfair Display&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-style&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;normal&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-weight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;400&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Playfair Display Regular&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;), &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;PlayfairDisplay-Regular&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    ),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;https://fonts.gstatic.com/s/playfairdisplay/v13/nuFiD-vYSZviVYUb_rj3ij__anPXDTjYgEM86xRbPQ.woff2&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;woff2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;unicode-range&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0400-045F&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+0490-0491&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+04B0-04B1&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;U+2116&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* skipping stuff... */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This file contains instructions on where to find the required fonts in various formats. There are many formats (in my case there is only &lt;code&gt;woff2&lt;/code&gt;—I’m using the latest version of Chrome—but they can be more) because not all devices or browsers use the same file types.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;The problem&lt;/strong&gt; here is that this &lt;abbr&gt;CSS&lt;/abbr&gt; file has the &lt;em&gt;highest&lt;/em&gt; possible download priority. That means that the browser will stop the initial page render until this &lt;abbr&gt;CSS&lt;/abbr&gt; file has finished downloading. This, by the way, happens for all the external &lt;abbr&gt;CSS&lt;/abbr&gt; files.&lt;/p&gt;&lt;p&gt;But that’s &lt;em&gt;not&lt;/em&gt; the only problem.&lt;/p&gt;&lt;p&gt;After that, the browser will start downloading the &lt;em&gt;actual fonts&lt;/em&gt;. The browser knows what fonts to download after parsing our &lt;abbr&gt;CSS&lt;/abbr&gt; and rendering some &lt;abbr&gt;HTML&lt;/abbr&gt; elements that use the fonts. Again here, the font requests have the &lt;em&gt;highest&lt;/em&gt; priority and also &lt;em&gt;block&lt;/em&gt; the page render.&lt;/p&gt;&lt;h2 id=&quot;solution&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#solution&quot;&gt;Solution&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A common solution to this problem is to self-host your Google fonts (or any fonts). This way, you can &lt;em&gt;skip&lt;/em&gt; the initial &lt;abbr&gt;CSS&lt;/abbr&gt; download, and start downloading the font files instead. If the fonts are not too many, or we don’t have a huge JavaScript file to download in parallel, our &lt;abbr&gt;FCP&lt;/abbr&gt; and &lt;abbr&gt;FMP&lt;/abbr&gt; can be drastically improved. To prove this, we’ll set up a basic Gatsby project.&lt;/p&gt;&lt;p&gt;&lt;em&gt;If you don’t want to set up a new project, &lt;a href=&quot;https://github.com/MarkosKon/gatsby-font-loading&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;check this repo&lt;/a&gt;. You can switch branches to test the different solutions for yourself.&lt;/em&gt;&lt;/p&gt;&lt;h2 id=&quot;setting-up-a-new-gatsby-project&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#setting-up-a-new-gatsby-project&quot;&gt;Setting up a new Gatsby project.&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;We’ll use the &lt;a href=&quot;https://www.npmjs.com/package/gatsby-cli&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-cli&lt;/a&gt; to create a new project with the &lt;a href=&quot;https://www.gatsbyjs.org/starters/gatsbyjs/gatsby-starter-default/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;default starter&lt;/a&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;gatsby new self-host-fonts&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; self-host-fonts&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;code &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I’m using &lt;code&gt;styled-components&lt;/code&gt; to add the fonts, but you can use plain &lt;abbr&gt;CSS&lt;/abbr&gt; if you want. You’ll have to install 3 separate packages for &lt;code&gt;styled-components&lt;/code&gt; to work:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add gatsby-plugin-styled-components styled-components babel-plugin-styled-components&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After that’s done, add &lt;code&gt;gatsby-plugin-styled-components&lt;/code&gt; in your &lt;code&gt;gatsby-config.js&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-config.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  siteMetadata: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// site metadata&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  plugins: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// other plugins...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-plugin-styled-components&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You’ll use the &lt;em&gt;Playfair Display&lt;/em&gt; font for the headings and &lt;em&gt;Open Sans&lt;/em&gt; for the rest of the content. You’ll first use those fonts with the recommended method from Google fonts, and then, you’ll measure the loading time.&lt;/p&gt;&lt;p&gt;First, delete the &lt;code&gt;src/components/layout.css&lt;/code&gt; to make the &lt;abbr&gt;CSS&lt;/abbr&gt; rules simpler. After that, add a global style in your &lt;code&gt;src/components/layout.js&lt;/code&gt; file:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/layout.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { StaticQuery, graphql } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { createGlobalStyle } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;styled-components&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Header &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./header&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;GlobalStyle&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;createGlobalStyle&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  @import url(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://fonts.googleapis.com/css?family=Open+Sans|Playfair+Display:400,700&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;box-sizing&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;border-box&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Open Sans&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;h3&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;h4&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;h5&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;h6&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Playfair Display&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;serif&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;StaticQuery&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      query SiteTitleQuery {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        site {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          siteMetadata {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;            title&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &amp;lt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;GlobalStyle&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Header&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;siteTitle&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;site&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;siteMetadata&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            margin: &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;0 auto&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            maxWidth: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;960&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            padding: &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;0px 1.0875rem 1.45rem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;            paddingTop: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;          }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;        &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;footer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            © &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getFullYear&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, Built with&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://www.gatsbyjs.org&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Gatsby&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;footer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;  /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  children: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And that’s all you need for this method to work.&lt;/p&gt;&lt;p&gt;Let’s test the loading time with &lt;a href=&quot;https://developers.google.com/web/tools/lighthouse/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Lighthouse&lt;/a&gt;. You’ll have to &lt;em&gt;build&lt;/em&gt; the application and &lt;em&gt;deploy&lt;/em&gt; it on Netlify—or to your preferred service. Sadly, I can’t see any benefits when I serve it locally with a tool like &lt;a href=&quot;https://www.npmjs.com/package/serve&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;serve&lt;/a&gt;. I won’t give instructions on how to &lt;a href=&quot;https://www.netlify.com/blog/2016/09/29/a-step-by-step-guide-deploying-on-netlify/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;setup Netlify&lt;/a&gt;, but don’t worry, it’s well documented.&lt;/p&gt;&lt;p&gt;Now, build the app, and deploy it on Netlify with the following commands:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;gatsby build &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; netlify deploy --prod --dir=public&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Open a new &lt;em&gt;Incognito window&lt;/em&gt; on Chrome, and enter the &lt;abbr&gt;URL&lt;/abbr&gt;. Then, open the &lt;em&gt;developer tools&lt;/em&gt;, and navigate to the &lt;em&gt;Audits&lt;/em&gt; tab. Finally, press the blue button that says &lt;em&gt;Run audits&lt;/em&gt;. The results in my case were the following:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:616px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/4a59d6bc28e6efced5f239b5950ab5f9/1108b/result-1.png&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:114.375%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAXCAIAAACEf/j0AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAC3ElEQVQ4y42UWXLcRgyGef+7WLJyBVuSk7dYM/aDt3iGQ7L3Fb2xl1STJXkqq79ioUA2QICNvzmM0/x94Qih8+lECBnPZ7Qs0zQhhKZpwhgTQvotxh+/nT+dLoxxpZQUgnM+CCG0VEZphBCllBCKCKeUYoy9dclHALDWBhecC9p2wHnw0Vo7tNYuGn/hY9soa8ryvPsniT4/Px8V/sovtdbWWga2ylOrpScf8Nd3l+MelPWcz7/VzX+PPz+Oh7IlPOEv78bjWnJrLS6HcPq1lnUopRCCF7SsKcUYx/E0TZMxttbKGZ/nOee8rmv/EEJCCK01sBaMba31yrn05b0lANDGtL29jbS9dA0hWLumkIOLKZkAa1qHPae1Vjeu/R3nnAVIznmlUrBeMxcCtzL6MEgpEcLLsnjv97T2E3yT8wf6fbAA42UaL1P7Kep2tY/kj9/Rp8E5J7aJU0pjjC9RzCkVbMmFbzDGjDEvqzoCdXJIKUkpAaCUct2z9FpHqKVYa7XWKaXrBlSw3KlemVIqhPjLMraCe53XzBjjnHvvXyZSayUgFst7ZWOMlFIpdb3P0hsTXcml61drIYSUcu8ul8yc4k4POWeKKUU0uJjXrs6cui1rzanktZS11lzBgORSMMEol1xJrmKIgzPhzc37+9unt7dP9zdPD6+PD68Pj3fHt6+eHu+6f39zuL/d/ePD7eHx7sPjL8c3rw7kLLvC+EKcAb4wb4DPxFvLZ+q0lphrLozQAlFngE3IW8dm7CzQCde6yZONzFvPJ+4hSCRAgyIKlDXcaKpAgUQiQOATiz7yiQUX2IV1bdf6Q1X7fnR77f+N56HWrjDO+DIvnPP/U1d90e9uB2MtYwxjwhhzz3jvAUAptQv+3+ij0lpvSmAYY4TQPM8AkHOOMeacr6NTSrpjykZPNsYqqXaR7qe3lPKPpUopMSVwLoTQk2NMSilK+q/vv5u8rm+tzbn8CdY2JRMoa72+AAAAAElFTkSuQmCC&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;default results&quot; title=&quot;default results&quot; src=&quot;/static/4a59d6bc28e6efced5f239b5950ab5f9/1108b/result-1.png&quot; srcSet=&quot;/static/4a59d6bc28e6efced5f239b5950ab5f9/3166f/result-1.png 480w,/static/4a59d6bc28e6efced5f239b5950ab5f9/1108b/result-1.png 616w&quot; sizes=&quot;(max-width: 616px) 100vw, 616px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;default results&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;&lt;strong&gt;1.6s for both &lt;abbr&gt;FCP&lt;/abbr&gt; and &lt;abbr&gt;FMP&lt;/abbr&gt;&lt;/strong&gt;. That’s actually really good (thanks Gatsby), but there’s room for improvement.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;The results are a bit different when I measure with the Performance tab. Before every test, I clear the data and measure in &lt;span class=&quot;small-caps&quot;&gt;3G&lt;/span&gt;. The &lt;abbr&gt;FMP&lt;/abbr&gt; happens at about &lt;em&gt;2.1s&lt;/em&gt;. If I add the &lt;code&gt;&amp;amp;display=swap&lt;/code&gt;, the &lt;abbr&gt;FMP&lt;/abbr&gt; goes down to &lt;em&gt;1.6s&lt;/em&gt; (see the &lt;a href=&quot;#updates&quot;&gt;updates section&lt;/a&gt; for context).&lt;/div&gt;&lt;p&gt;Let’s see now how you can improve that score by self-hosting the same fonts with the typefaces package.&lt;/p&gt;&lt;h2 id=&quot;self-hosting-fonts-with-typefaces-package&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#self-hosting-fonts-with-typefaces-package&quot;&gt;Self-hosting fonts with typefaces package&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;First, install the packages for Playfair Display and Open Sans typefaces. If you go to the &lt;a href=&quot;https://github.com/KyleAMathews/typefaces/tree/master/packages&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;packages section on GitHub&lt;/a&gt;, you can find both of them. Install them with:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add typeface-playfair-display typeface-open-sans&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then import them in your &lt;code&gt;gatsby-browser.js&lt;/code&gt; file:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-browser.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;typeface-playfair-display&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;typeface-open-sans&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Don’t forget to remove the &lt;code&gt;@import&lt;/code&gt; from the &lt;code&gt;&amp;lt;GLobalStyle&amp;gt;&lt;/code&gt; component in &lt;code&gt;layout.js&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;Now, &lt;em&gt;build&lt;/em&gt; again the application, &lt;em&gt;deploy&lt;/em&gt; it, and &lt;em&gt;test&lt;/em&gt; it with Lighthouse. Those were my results:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:616px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/86d030ef3f20f9177737dc5b3d00a00b/1108b/result-2.png&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:115.00000000000001%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAXCAIAAACEf/j0AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAC3ElEQVQ4y41U2Y7bRhDk/3/NWutfyEpInAB2VqsgWAOGwmtuztFzHwlJ2ZaDHK6HRg17it3DrmE3TPMVLQihvu8ZY33fI4SmaSKEjNOICcYYj8OAKPk4oOtMOOdSSrEIznknhFCL1IvCGFNKMcYIU8YYQsiBDdabDc46Y5zUBlY4WJema62NinxaprahpJjVuPPrgj6Jr/wq55XVmoEmNbVaV/EH9HocnlutrbUs+9T/WDfBu+m3p/7XXfxuvPw0XvbnYfwlDD+3WrpaK0IIYZRzds4P/XWeBgCotVJG53kuucQYEcaI4BRTa81o6cC01lZxTinFVLfKxoDWZuuu5pxzSjHGEEJyzgPk6HNwISXtbUyx2zX77p3XbwEA2pigtZMqOu0UB++YFtGHTsp1Tghh7/39K/4DtbVX3v/O/+i0NsMwDuPYvgtba62+R68f0McOrBVCULrONoRwG1ityAgVIKfMPsNa+zlbpDfCqS6EIKUEgFLKfcPMSh1syUVtiDHeN3ATW2sppUKIv6WR4cLrFBNjTAjhnEspfalMQGAQXYwRwEi5aKPvxSoaSK7kvKa0Xu425JpFUIvXXc6ZYoYRCS7mtLpzi6WkmmPJaSUlV63MIqRgC6dC8EVyGUPsjLTHt+fT4fz05vn4cD4eXo6H8+nt5YeH59Pj5Xg4Hx/OT2/Op8eXdbmSy+nx5Xh4kRS61irp1wu0IBac4zOxxgjEQCnNpWLcGisQcWD5jL11CybWaIHYzZ5iEg7cFv1CJChQTIE0muuFLA68QMKD5xMLLoiZW20XvGzizVW3z1hK3WOt97HWVmv5YtjbUGvttDGUsnmeGWPfZbE7L3Raa8YYIZRzbjesfwrnAEBKuRv+39CVnJVSu08QQvOG3XAhhJzz/W7vvZRKa1M2dCklpRXnQghhDOy3t5Tyj6VyzjFGA+C9r6V0PoS1MqGMUufcdqr/Obb33lr7V+U/Ac3wJi6r6sa5AAAAAElFTkSuQmCC&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;self-hosting results&quot; title=&quot;self-hosting results&quot; src=&quot;/static/86d030ef3f20f9177737dc5b3d00a00b/1108b/result-2.png&quot; srcSet=&quot;/static/86d030ef3f20f9177737dc5b3d00a00b/3166f/result-2.png 480w,/static/86d030ef3f20f9177737dc5b3d00a00b/1108b/result-2.png 616w&quot; sizes=&quot;(max-width: 616px) 100vw, 616px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;self-hosting results&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;There is a &lt;strong&gt;0.8 seconds&lt;/strong&gt; improvement for both &lt;abbr&gt;FCP&lt;/abbr&gt; and &lt;abbr&gt;FMP&lt;/abbr&gt;! That’s a big improvement for the cost of installing 2 packages and writing 2 lines of code.&lt;/p&gt;&lt;p&gt;If you inspect the resulting &lt;abbr&gt;HTML&lt;/abbr&gt; page by pressing &lt;code&gt;Ctrl + U&lt;/code&gt; in Windows, you see that the first &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tag, high up in the head of the page, contains the font faces and uses the &lt;code&gt;font-display&lt;/code&gt; property:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@font-face&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* ... */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-display&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;swap&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* ... */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;font-display: swap&lt;/code&gt; property tells the browser the following. If the fonts are not available in the initial page render, use the fallback font to allow the page to render. In that scenario, we see the &lt;em&gt;Flash of Unstyled Content&lt;/em&gt; (&lt;abbr&gt;FOUP&lt;/abbr&gt;). When the fonts finish downloading, the browser will replace them with the actual fonts.&lt;/p&gt;&lt;h3 id=&quot;preload-fonts&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#preload-fonts&quot;&gt;Preload fonts&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Consider adding &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;preload links&lt;/a&gt; for your fonts to start downloading them before the browser needs them. This will not improve the first paint metrics, but it may decrease the time the browser displays the fallback fonts (&lt;abbr&gt;FOUT&lt;/abbr&gt;). A Gatsby plugin that can help with that is &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-plugin-preload-fonts/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-plugin-preload-fonts&lt;/a&gt;. You should &lt;em&gt;test first&lt;/em&gt; to see if preloading the fonts improves the font-loading for your site before implementing it.&lt;/p&gt;&lt;h2 id=&quot;final-words&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#final-words&quot;&gt;Final words&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Let’s summarize some key points:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Self-hosting fonts improves the first paint metrics because you don’t download the &lt;abbr&gt;CSS&lt;/abbr&gt; file that has the font faces.&lt;/li&gt;&lt;li&gt;&lt;code&gt;font-display: swap&lt;/code&gt; eliminates the flash of invisible text by displaying fallback fonts. This should improve the first meaningful paint—if displaying text is considered meaningful for your app. I say that because sometimes in the performance tab of Chrome DevTools you see the &lt;abbr&gt;FMP&lt;/abbr&gt; happening while the text is invisible—something that seems wrong to me.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;If you want to know more about font loading, an expert on this subject is &lt;a href=&quot;https://www.zachleat.com/web/best-of/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Zach Leatherman&lt;/a&gt;. If you want something quick, you can watch this video from &lt;a href=&quot;https://www.youtube.com/watch?v=s-G1m23Emlk&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;DevTips&lt;/a&gt;.&lt;/p&gt;&lt;h2 id=&quot;updates&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#updates&quot;&gt;Updates&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Google now allows you to use &lt;code&gt;font-display: swap;&lt;/code&gt; when requesting a Google Font. This gives a small boost, but it’s still slower than self-hosting. For example, you can say:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;@import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;https://fonts.googleapis.com/css?family=Noto+Sans+HK&amp;amp;display=swap&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In fact, this is the default option when you copy the embed code from their website.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;The typefaces library &lt;a href=&quot;https://github.com/KyleAMathews/typefaces/pull/45&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;supports only the Latin subset&lt;/a&gt;. You can’t use it for other languages. My (dirty) workaround, in this case, is the following: First, I &lt;a href=&quot;/customize-google-font-requests/&quot;&gt;customize the Google Font request&lt;/a&gt;. Then, I visit the generated &lt;abbr&gt;URL&lt;/abbr&gt;, copy all the font faces, and place them in a &lt;abbr&gt;CSS&lt;/abbr&gt; file. Finally, I import that file in the &lt;code&gt;layout.js&lt;/code&gt;. The performance would be the same as if you were using the typefaces library. You can check the code in the &lt;a href=&quot;https://github.com/MarkosKon/gatsby-font-loading/tree/copy-css&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;copy-css branch of the repo&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;If you don’t trust the &lt;abbr&gt;URL&lt;/abbr&gt;s in the font faces, you can download the fonts from the Google Fonts app (“download this selection” button), self-host them, and change the remote &lt;abbr&gt;URL&lt;/abbr&gt;s to the local &lt;abbr&gt;URL&lt;/abbr&gt;s. In other words, you do the same thing the typefaces package does.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk16 { color: #FF6363; }
  .night-owl-no-italics .mtk15 { color: #80CBC4; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk11 { color: #FFEB95; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk12 { color: #FFCB8B; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Gatsby background image example]]></title><description><![CDATA[In this post, you learn how to use the gatsby-image component as a background image.]]></description><link>https://markoskon.com/gatsby-background-image-example/</link><guid isPermaLink="false">https://markoskon.com/gatsby-background-image-example/</guid><pubDate>Fri, 25 Jan 2019 22:12:03 GMT</pubDate><content:encoded>&lt;p&gt;One of the many selling points of Gatsby is the ability to handle images. It does this with the &lt;a href=&quot;https://github.com/lovell/sharp&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;sharp image processing library&lt;/a&gt; and with the &lt;a href=&quot;https://www.gatsbyjs.org/packages/gatsby-image/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-image&lt;/a&gt; component. I’ve talked in the past about &lt;a href=&quot;https://markoskon.com/gatsby-plugins-seo-and-images/#2-images&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;image processing in Gatsby&lt;/a&gt; if you want to know more.&lt;/p&gt;&lt;p&gt;Today you’ll see how to use the &lt;code&gt;gatsby-image&lt;/code&gt; component as a background image. You’ll use the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;object-fit&lt;/a&gt; property and code from this &lt;a href=&quot;https://github.com/gatsbyjs/gatsby/issues/2470&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub issue&lt;/a&gt;.&lt;/p&gt;&lt;h2 id=&quot;project-setup&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#project-setup&quot;&gt;Project setup&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Create a new project with the &lt;a href=&quot;https://www.npmjs.com/package/gatsby-cli&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gatsby-cli&lt;/a&gt; and the &lt;a href=&quot;https://www.gatsbyjs.org/starters/gatsbyjs/gatsby-starter-default/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;default starter&lt;/a&gt;. After the installation completes, open the folder, and start the development server:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;gatsby new gatsby-background-image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;cd&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; gatsby-background-image&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn start&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Next, install &lt;code&gt;styled-components&lt;/code&gt; to make the component styling a bit easier. You’ll have to install the following 3 packages:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add gatsby-plugin-styled-components styled-components babel-plugin-styled-components&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Don’t forget to open your &lt;code&gt;gatsby-config.js&lt;/code&gt;, and add the highlighted line:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;gatsby-config.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  siteMetadata: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// site metadata&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  plugins: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// other plugins...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-plugin-styled-components&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;component-definition&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#component-definition&quot;&gt;Component definition&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;After that, create a new file called &lt;code&gt;BgImage.jsx&lt;/code&gt; inside the &lt;code&gt;src/components&lt;/code&gt; folder. I’ll explain what happens here after the code:&lt;/p&gt;&lt;p&gt;If you prefer &lt;a href=&quot;https://emotion.sh/docs/introduction&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;emotion&lt;/a&gt; over &lt;code&gt;styled-components&lt;/code&gt;, &lt;a href=&quot;https://github.com/MarkosKon/theme-playground/blob/master/packages/gatsby-theme-ui/src/components/BgImage.jsx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;here’s an example with emotion and theme-ui&lt;/a&gt; and here’s &lt;a href=&quot;/dark-mode-in-react-with-theme-ui/#the-easy-way&quot;&gt;how to set up the project for theme-ui.&lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/components/BgImage.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; PropTypes &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;prop-types&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Img &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby-image&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; styled &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;styled-components&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Parent&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;styled&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;relative&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;bc&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;bc&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;FakeBgImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;styled&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(Img)&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;absolute&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;z-index&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;-1&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;img&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;object-fit&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;cover&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; !important;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;object-position&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; !important;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;object-fit: cover !important; object-position: 0% 0% !important;&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  @media &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;screen&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; and (&lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;max-width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;600&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;mobileHeight&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;mobileHeight&lt;/span&gt;&lt;span class=&quot;mtk26&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;Content&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;styled&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;absolute&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;BgImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;mobileHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;overlayColor&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Parent&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;bc&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;overlayColor&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;FakeBgImage&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;mobileHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;mobileHeight&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Content&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Content&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Parent&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;BgImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;propTypes&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  fluid: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  title: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isRequired&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  height: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  mobileHeight: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  overlayColor: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  children: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  className: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;PropTypes&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;BgImage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;defaultProps&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  height: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  mobileHeight: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  overlayColor: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;transparent&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  children: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  className: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;BgImage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;First of all, there is some prop validation going on at the end of the file with &lt;a href=&quot;https://www.npmjs.com/package/prop-types&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;prop-types&lt;/a&gt;. There are some default props as well.&lt;/p&gt;&lt;p&gt;We have a &lt;code&gt;Parent&lt;/code&gt; component—that’s used as a container—with &lt;code&gt;position: relative&lt;/code&gt;. &lt;code&gt;Parent&lt;/code&gt; has 2 children: the &lt;code&gt;FakeBgImage&lt;/code&gt; and the &lt;code&gt;Content&lt;/code&gt;. Both of those components have &lt;code&gt;position: absolute&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;&lt;code&gt;FakeBgImage&lt;/code&gt; is a regular &lt;code&gt;gatsby-image&lt;/code&gt; component—that’s why it takes &lt;code&gt;fluid&lt;/code&gt; and &lt;code&gt;title&lt;/code&gt; as props. &lt;code&gt;fluid&lt;/code&gt; and &lt;code&gt;title&lt;/code&gt; props are the only props required by the &lt;code&gt;BgImage&lt;/code&gt; component. It’s styled with the &lt;code&gt;object-fit&lt;/code&gt; &lt;abbr&gt;CSS&lt;/abbr&gt; property, and it has a &lt;code&gt;height&lt;/code&gt; property (desktop) and a &lt;code&gt;mobileHeight&lt;/code&gt; property.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;You must be careful when you set the height because the &lt;strong&gt;content may overflow the container&lt;/strong&gt;. Always check how your background image looks in mobile and adjust the &lt;code&gt;mobileHeight&lt;/code&gt;.&lt;/div&gt;&lt;p&gt;If you want to position the image differently, check the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;object-fit documentation&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;The &lt;code&gt;Content&lt;/code&gt; component is positioned absolute and takes the whole space of the parent &lt;code&gt;div&lt;/code&gt;. Additionally, the children of the parent &lt;code&gt;BgImage&lt;/code&gt; component are rendered inside the &lt;code&gt;Content&lt;/code&gt; component. Another thing to note is that we pass to the &lt;code&gt;Content&lt;/code&gt; the &lt;code&gt;className&lt;/code&gt; prop. That means that if you extend the &lt;code&gt;BgImage&lt;/code&gt; with &lt;code&gt;styled(BgImage)&lt;/code&gt;, the styles will be applied to the &lt;code&gt;Content&lt;/code&gt; component.&lt;/p&gt;&lt;p&gt;Now let’s see how you can &lt;strong&gt;use&lt;/strong&gt; that component:&lt;/p&gt;&lt;h2 id=&quot;usage&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#usage&quot;&gt;Usage&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Open the file for the home page which is located at &lt;code&gt;src/pages/index.js&lt;/code&gt;. You’ll use the &lt;code&gt;gatsby-astronaut.png&lt;/code&gt; that lives in the &lt;code&gt;src/images&lt;/code&gt; folder. Of course, you can try it with any image you like.&lt;/p&gt;&lt;p&gt;The first thing you want to do is to write a GraphQL query to get the image. Then, import &lt;code&gt;BgImage&lt;/code&gt;, and use it as shown below:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/pages/index.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; { Link, graphql } &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Layout &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/layout&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; Image &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/image&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; SEO &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/seo&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; BgImage &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;../components/BgImage&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;IndexPage&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;{ &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;SEO&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;Home&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;keywords&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`, `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;application&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`, `&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`]&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Hi people&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Welcome to your new Gatsby site.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Now go build something great.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ maxWidth: &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;300px&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;, marginBottom: &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;1.45rem&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;BgImage&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;astronaut&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;astronaut&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;childImageSharp&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;fluid&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;overlayColor&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;#04040454&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    &amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;style&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;{ color: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;mtk25&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Look at me!&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;BgImage&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/page-2/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Go to page 2&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  query {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    astronaut: file(relativePath: { eq: &amp;quot;gatsby-astronaut.png&amp;quot; }) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      childImageSharp {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        fluid(maxWidth: 300) {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;          ...GatsbyImageSharpFluid&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;      }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk19&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;`;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;export&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;IndexPage&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That’s it! Note that I’m using a transparent black color as an overlay to make the text inside the image more readable. You can add whatever color you like to create an effect, but remember to pass a transparent color.&lt;/p&gt;&lt;p&gt;You can check more examples in a &lt;a href=&quot;https://github.com/MarkosKon/gatsby-starter/blob/master/src/pages/bg-image.jsx&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Gatsby starter&lt;/a&gt; I set up.&lt;/p&gt;&lt;p&gt;This example was a quick way to take advantage of the benefits &lt;code&gt;gatsby-image&lt;/code&gt; offers, and use it as a background image in a Gatsby application.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;By default, &lt;code&gt;gatsby-image&lt;/code&gt; has an empty &lt;code&gt;alt&lt;/code&gt; property that translates to the following &lt;abbr&gt;HTML&lt;/abbr&gt; code: &lt;code&gt;&amp;lt;img alt=&amp;quot;&amp;quot; /&amp;gt;&lt;/code&gt;. That means that assistive technologies, such as screen readers, won’t announce the image. This is good for our use case because the image serves a decorative purpose. If you feel that the content of the image is important and it’s  not only for decoration, add a description of the image with the &lt;code&gt;alt&lt;/code&gt; attribute. &lt;a href=&quot;https://www.w3.org/WAI/tutorials/images/decorative/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Decorative Images on &lt;abbr&gt;W3C&lt;/abbr&gt;&lt;/a&gt;.&lt;/div&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk15 { color: #80CBC4; }
  .night-owl-no-italics .mtk16 { color: #FF6363; }
  .night-owl-no-italics .mtk26 { color: #EC5F67; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk11 { color: #FFEB95; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk25 { color: #D3423E; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Dealing with line endings in Windows with Git and ESLint]]></title><description><![CDATA[When you checkout a branch in Windows, Git may replace the line endings with CRLF. In this post, we’ll see how you can change it in LF and avoid the ESLint errors.]]></description><link>https://markoskon.com/line-endings-in-vscode-with-git-and-eslint/</link><guid isPermaLink="false">https://markoskon.com/line-endings-in-vscode-with-git-and-eslint/</guid><pubDate>Sat, 12 Jan 2019 22:12:03 GMT</pubDate><content:encoded>&lt;h2 id=&quot;problem&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#problem&quot;&gt;Problem&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you are on a Windows machine, and you switch between branches with &lt;code&gt;git checkout branch_name&lt;/code&gt;, Git may replace your carefully placed &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; (line feed) line endings with &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt; (carriage return and line feed combo).&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;&lt;p style=&quot;margin-bottom:var(--rhythm)&quot;&gt;&lt;strong&gt;Line endings in different operating systems&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;margin-bottom:var(--rhythm)&quot;&gt;Windows adds &lt;em&gt;two&lt;/em&gt; characters to mark the end of lines, when you press &lt;code&gt;Enter&lt;/code&gt; on your keyboard. It adds the &lt;em&gt;carriage return&lt;/em&gt; (CR or &lt;code&gt;\r&lt;/code&gt;) and the &lt;em&gt;line feed&lt;/em&gt; (LF or &lt;code&gt;\n&lt;/code&gt;), all together CRLF or &lt;code&gt;\r\n&lt;/code&gt;. Linux/Mac, on the other hand, add only one character, the LF or &lt;code&gt;\n&lt;/code&gt;.&lt;/p&gt;See more info about &lt;a href=&quot;https://stackoverflow.com/questions/1552749/difference-between-cr-lf-lf-and-cr-line-break-types&quot;&gt;the difference between CRLF and LF&lt;/a&gt; on a Stack Overflow issue.&lt;/div&gt;&lt;p&gt;More specifically, Git replaces the &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; line endings that &lt;em&gt;were placed by&lt;/em&gt;:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;your ESLint/Prettier formatters.&lt;/li&gt;&lt;li&gt;Linux/Mac users that committed on the repository you’re working on.&lt;/li&gt;&lt;li&gt;Git itself, depending on your Git settings.&lt;/li&gt;&lt;li&gt;or even you, if setup your code editor to add &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; (or use one that does that by default).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;When you edit/create files on Windows and press &lt;code&gt;Enter&lt;/code&gt; to move to the next line, at the end of the line, you place &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt;.&lt;/p&gt;&lt;p&gt;This behavior can be frustrating if your ESLint configuration wants &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; for line endings. In other words, you get a ton of linting errors every time you change a branch.&lt;/p&gt;&lt;h2 id=&quot;solution&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#solution&quot;&gt;Solution&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The solution is to add the following &lt;code&gt;.gitattributes&lt;/code&gt; file at the root of your project.&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.gitattributes&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Let Git decide what to do, for every file. More on that later.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; text=auto&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Overwrite the above and declare files that will always have&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# LF line endings on checkin and checkout. No ESLint/Prettier&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# issues for those files.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.js text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.jsx text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# If you&amp;#x27;re using TypeScript, also add .ts, .tsx files&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.ts text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.tsx text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# If you&amp;#x27;re using Prettier, you probably want LF in .json, .md, .css,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# and all the other files you&amp;#x27;re formatting with Prettier.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.json text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# An alternative is to ditch the above and make everything have LF on&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# checkin/checkout, but I&amp;#x27;m not sure what will happen with binary files.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# * text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Declare files that are binary so that their eol should not be modified.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Git, with the first line of this file, will probably not modify binary&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# files, but add the following just to be safe and explicit.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.png binary&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.jpg binary&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Find out more in a &lt;a href=&quot;https://help.github.com/articles/dealing-with-line-endings/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub help article about dealing with line endings in Git&lt;/a&gt;.&lt;/p&gt;&lt;h2 id=&quot;add-an-editorconfig-file&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#add-an-editorconfig-file&quot;&gt;Add an .editorconfig file&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;To make sure your code editor adds &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; instead of &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt; in the end of lines, when you edit/create files, you can add an &lt;a href=&quot;https://editorconfig.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;.editorconfig file&lt;/a&gt; in the root of your project.&lt;/p&gt;&lt;p&gt;To use it in VS Code, install the &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;EditorConfig plugin&lt;/a&gt;. The following is &lt;a href=&quot;https://github.com/airbnb/javascript/blob/master/.editorconfig&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;the .editorconfig file from Airbnb’s JavaScript style guide&lt;/a&gt;, copied from their repository on GitHub. Visit the link to see the updated version.&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.editorconfig&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;root = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;indent_style = space&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;indent_size = 2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;charset = utf-8&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;trim_trailing_whitespace = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;insert_final_newline = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;end_of_line = lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# editorconfig-tools is unable to ignore longs strings or urls&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;max_line_length = null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&quot;note&quot;&gt;&lt;b&gt;A note from Captain Obvious:&lt;/b&gt; If you&amp;#x27;re using a different style guide, you may have to adjust these settings. Search for an &lt;code&gt;.editorconfig&lt;/code&gt; file in the GitHub repository of your guide.&lt;/div&gt;&lt;h2 id=&quot;explanation&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#explanation&quot;&gt;Explanation&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;When I first posted this article, I showed the solution but I didn’t explain why it worked because I didn’t know. Now, I (kind of) know, so I will try to explain the solution above. I read a lot of documentation and relevant articles, but still wasn’t able to verify what happened in practice. This was due to a misconception, so If you have the same misconception, this post will be useful to you.&lt;/p&gt;&lt;h3 id=&quot;optimal-workflow&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#optimal-workflow&quot;&gt;Optimal workflow&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The first thing you have to think is what behavior you want from Git and your linters. For example, this a list with what I want:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;I don’t want to switch branches and my linters/Code editor start yelling at me (and have to run a format script afterwards).&lt;/li&gt;&lt;li&gt;In my projects I have setup ESLint to ask for &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; line endings. I use TypeScript, JavaScript and React, so I want the &lt;code&gt;.js&lt;/code&gt;, &lt;code&gt;.jsx&lt;/code&gt;, &lt;code&gt;.ts&lt;/code&gt;, and &lt;code&gt;.tsx&lt;/code&gt; files to always have &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; line endings.&lt;/li&gt;&lt;li&gt;I have also setup Prettier to format &lt;code&gt;.json&lt;/code&gt;, &lt;code&gt;.yml&lt;/code&gt;, &lt;code&gt;.md&lt;/code&gt;, &lt;code&gt;.mdx&lt;/code&gt;, and &lt;code&gt;.css&lt;/code&gt; files, so I want these files to have &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; line endings too.&lt;/li&gt;&lt;li&gt;I don’t want Git to alter the lines in binary files, for example, images.&lt;/li&gt;&lt;/ul&gt;&lt;h3 id=&quot;the-coreautocrlf-git-setting&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#the-coreautocrlf-git-setting&quot;&gt;The &lt;code&gt;core.autocrlf&lt;/code&gt; Git setting&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;I didn’t mentioned the &lt;code&gt;core.autocrlf&lt;/code&gt; setting in the solution, only the &lt;code&gt;.gitattributes&lt;/code&gt; file. They both control how Git handles line endings, so I want to talk about &lt;code&gt;autocrlf&lt;/code&gt; a little bit. The reason I didn’t mentioned it, is because the &lt;code&gt;.gitattributes&lt;/code&gt; file, that I showed above, takes precedence over the value of &lt;code&gt;core.autocrlf&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;The most relevant value for the &lt;code&gt;core.autocrlf&lt;/code&gt; setting, a Windows user can set, is &lt;code&gt;true&lt;/code&gt;. For example:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;git config --global core.autocrlf &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;a href=&quot;https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_core_autocrlf&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;autocrlf entry in Git book&lt;/a&gt; says that if you set it to &lt;code&gt;true&lt;/code&gt;:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;auto-converts &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt; line endings into &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; when you add a file to the index, and vice versa when it checks out code onto your filesystem.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;So we have to understand what is the &lt;em&gt;index&lt;/em&gt;, and what it means to &lt;em&gt;check out code onto your filesystem&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;Because the quote above refers to the filesystem, I will introduce another commonly used term in Git, the &lt;em&gt;working directory&lt;/em&gt; or &lt;em&gt;working tree&lt;/em&gt;. All files inside your repository are your working directory, no matter their state (staged, unstaged, modified, untracked, etc.).&lt;/p&gt;&lt;p&gt;So, for example, if you edit a file and stage it with &lt;code&gt;git add&lt;/code&gt;, that file will still be in your working directory. I had the misconception that when I stage a file (add it to the index), automatically its status changes, and that file is no longer in my working directory, only in my index. As a result, I expected the &lt;code&gt;core.autocrlf&lt;/code&gt; setting to kick in and replace the line endings to &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; for the file in my filesystem. That doesn’t happen.&lt;/p&gt;&lt;p&gt;The next term the quote above mentions is the &lt;em&gt;index&lt;/em&gt;. Index, or staging area, (let’s say that) is a Git file, stored in &lt;code&gt;.git/index&lt;/code&gt;, that keeps track of the files (and their content) that are currently staged and ready for your next commit. For example, if I create a file:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;touch my_file.json&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And use the &lt;code&gt;git add&lt;/code&gt; command:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;git add my_file.json&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That file is now in the index. You can verify that by using the &lt;code&gt;git status&lt;/code&gt; command:&lt;/p&gt;&lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:663px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/c23e515e364c6c338268f2b9b152a0a0/a57bb/git_status_output.png&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:25.83333333333333%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAIAAADKYVtkAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAyklEQVQY002NwY7DIAxE8xmbCrCBJQXs2ElK1HYvW/XW//+hFelh+zSSR5ZnPLTt8lhvz+3+2G4yS6VaayUiZlbVGCMA4MHbwAEiOucGIpp5llmY+3ijqiJCzH3BrCJ81OWc+UBVvfc9vO97v6mkoq21VZeSS/A+eA8xWgAIwccYUwohuA8GRKylnLlO25z3pTD5OtXrVtqSVr5OUwa4hPCb6JUXScVY+x92zlljLIL5RhPQgrOxm67oizHJ2p9xbKfTffxCa+zH5z+L/i1tzMbTHgAAAABJRU5ErkJggg==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;git status output&quot; title=&quot;git status output&quot; src=&quot;/static/c23e515e364c6c338268f2b9b152a0a0/a57bb/git_status_output.png&quot; srcSet=&quot;/static/c23e515e364c6c338268f2b9b152a0a0/3166f/git_status_output.png 480w,/static/c23e515e364c6c338268f2b9b152a0a0/a57bb/git_status_output.png 663w&quot; sizes=&quot;(max-width: 663px) 100vw, 663px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;&lt;p&gt;To see the contents of a file that’s inside the index, run the following command in your terminal (there are more details about the following command at the end of post):&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;git show :my_file.json &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; vi -b -&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Every branch or commit hash, (let’s say that) is another file in the Git database. The index, the branches and commits, contain instructions on how to reconstruct the repository files on your filesystem, or, in other words, on how to reconstruct your working directory.&lt;/p&gt;&lt;p&gt;The commits and the index are stored inside your &lt;code&gt;.git&lt;/code&gt; folder in an hard to inspect format, meaning that you can’t see their content easily. In contrast, your working directory is saved directly as regular files in your project folder, where it’s easy to view, edit, and delete them.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;For more details, and more accurate information about the above, see the &lt;a href=&quot;https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified&quot;&gt;Reset Demystified chapter from git book&lt;/a&gt; that talks about the three trees in Git (working directory, index, and &lt;code&gt;HEAD&lt;/code&gt;).&lt;/div&gt;&lt;p&gt;Let’s go back to the &lt;code&gt;autocrlf&lt;/code&gt; setting now because this is what this section was about. When the &lt;code&gt;autocrlf&lt;/code&gt; setting claims that will replace the &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt; to &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; when you add a file to the index, it means that will add &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; to the line endings to the file that will save to the index (and, as a result, in your next commit). It won’t change the line endings in the current file, inside your working directory. Those line endings will remain &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt; or &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; or whatever you set them.&lt;/p&gt;&lt;p&gt;It promises that will do the opposite (&lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; to &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt;) when you pull a file from the Git database to the filesystem (something I don’t want as I stated earlier, by the way). The relevant quote is:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;and vice versa (&lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; to &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt;) when it checks out code onto your filesystem.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;This happens when you &lt;code&gt;git checkout&lt;/code&gt; to branches or commit hashes. For example, &lt;code&gt;git checkout my-new-feature&lt;/code&gt; (branch) or &lt;code&gt;git checkout d36d36d&lt;/code&gt; (commit hash).&lt;/p&gt;&lt;p&gt;To pull a file from the database to your working directory (“checks out code onto your filesystem”), the file has to not exist inside the branch you are switching to. I’m not sure at the moment if Git will replace line endings if the file is only modified between branches. Also, if you delete a file that’s currently tracked by Git, lets say you delete the &lt;code&gt;package.json&lt;/code&gt; file, with &lt;code&gt;rm package.json&lt;/code&gt; and restore it with &lt;code&gt;git checkout package.json&lt;/code&gt;, Git will also pull that file from the Git database (and will replace &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; to &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt;).&lt;/p&gt;&lt;p&gt;This is why the end of line problems usually occur for files you introduced to your project with your latest branch.&lt;/p&gt;&lt;h3 id=&quot;the-gitattributes-file&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#the-gitattributes-file&quot;&gt;The &lt;code&gt;.gitattributes&lt;/code&gt; file&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The &lt;code&gt;.gitattributes&lt;/code&gt; file is an alternative to &lt;code&gt;core.autocrlf&lt;/code&gt; when you want to control how Git handles the line endings of your files.&lt;/p&gt;&lt;p&gt;I will now explain the lines in the &lt;code&gt;.gitattributes&lt;/code&gt; file I previously shared. This is the first line:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.gitattributes&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Let Git decide what to do, for every file.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; text=auto&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;First of all, let’s talk about the syntax. Each line in the &lt;code&gt;.gitattributes&lt;/code&gt; file contains:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;a path followed by a space. In this case, the path is the wildcard character (&lt;code&gt;*&lt;/code&gt;). With the wildcard character, we refer to every file, so this rule applies to all files.&lt;/li&gt;&lt;li&gt;space-separated attributes you set for those paths.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The only attribute here is the &lt;code&gt;text&lt;/code&gt; attribute that is set to the value of &lt;code&gt;auto&lt;/code&gt;. This is the passage from the &lt;a href=&quot;https://git-scm.com/docs/gitattributes#Documentation/gitattributes.txt-Settostringvalueauto&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;reference of gitattributes for what text=auto means&lt;/a&gt;:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:797px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/b3938c58aa5411d60119bc8744750bc8/a78c3/gitattributes_text_auto.png&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:21.875%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAIAAAABPYjBAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAtklEQVQI1z2M246CMBRF+f8PVIrJzEg5t7Yo0B56QROjk/iyk5WstbsQxDtZlzkIhSBMcL/NjBC3pbXSai5lrzW3Vr5bS34+j8ejdZo2BLvOPi83YfRCwuiECCYmEEZGcMJOCCfrhJzQ+zqux1G7UvQ/wN8f6k9kejJnMmceehqMXAwPPcPIOIG9gh2DYyHAydaau1J2Gf/W8ZoQ1EvSqBpT2lQ31bjPPoJNhEr4FhiVST941PwC3T/dLbz2PE8AAAAASUVORK5CYII=&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Passage from gitattributes reference that explains what text auto does&quot; title=&quot; &quot; src=&quot;/static/b3938c58aa5411d60119bc8744750bc8/a78c3/gitattributes_text_auto.png&quot; srcSet=&quot;/static/b3938c58aa5411d60119bc8744750bc8/3166f/gitattributes_text_auto.png 480w,/static/b3938c58aa5411d60119bc8744750bc8/a78c3/gitattributes_text_auto.png 797w&quot; sizes=&quot;(max-width: 797px) 100vw, 797px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt; &lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;Let’s break down the underlined sections from the above image:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;If Git decides that the content is text, its line endings are converted to &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; on checkin.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Git runs some heuristics to decide if a file is text or binary. If Git decides that the file is a text file, we have the same behavior with &lt;code&gt;autocrlf&lt;/code&gt; when you add the file in the index, that is to covert &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt; line endings to &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt;.&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;When the file has been committed with &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt;, no conversion is done.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;The second part about &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt; is not so clear to me. It refers to the checkout from the Git database to your filesystem? Or if Git updates the file’s line endings inside the Git database automatically, if you change the &lt;code&gt;gitattributes&lt;/code&gt; settings. Probably the first, but It doesn’t matter, because the next attribute, which is &lt;code&gt;eol&lt;/code&gt;, will overwrite the &lt;code&gt;text&lt;/code&gt; attribute for the files we care most:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.gitattributes&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Overwrite &amp;quot;* text=auto&amp;quot; and declare files that will always have&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# LF line endings on checkin and checkout. No ESLint/Prettier&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# issues for those files anymore.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.js text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.jsx text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.ts text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.tsx text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.json text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.md text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.mdx text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.css text eol=lf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With the rules above, we target the files that ESLint and Prettier check. Let’s now see what the &lt;code&gt;text&lt;/code&gt; attribute without a value does because it’s different than &lt;code&gt;text=auto&lt;/code&gt;:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;Setting the text attribute on a path enables end-of-line normalization and marks the path as a text file. End-of-line conversion takes place without guessing the content type. &lt;a href=&quot;https://git-scm.com/docs/gitattributes#Documentation/gitattributes.txt-Set&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gitattributes reference on setting the text attribute without a value&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;This what the &lt;code&gt;eol&lt;/code&gt; attribute does with the value &lt;code&gt;lf&lt;/code&gt;:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;This setting forces Git to normalize line endings to &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; on checkin and prevents conversion to &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt; when the file is checked out. &lt;a href=&quot;https://git-scm.com/docs/gitattributes#Documentation/gitattributes.txt-Settostringvaluelf&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;gitattributes reference on setting the eol attribute to the lf value&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;The end result is the following:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The file will be considered a text file.&lt;/li&gt;&lt;li&gt;Git will replace the line endings to &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; when you add it to the index.&lt;/li&gt;&lt;li&gt;Git will keep the &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; line endings when you bring it to your filesystem from the Git database.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Another interesting quote from the &lt;code&gt;eol&lt;/code&gt; attribute in the &lt;code&gt;gitattributes&lt;/code&gt; reference:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;eol: This attribute sets a specific line-ending style to be used in the working directory. It enables end-of-line conversion without any content checks, &lt;strong&gt;effectively setting the text attribute.&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;In other words, these files will always have &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; when you add them to your index (checkin) and when you add them to your working directory (checkout).&lt;/p&gt;&lt;p&gt;Now, although Git should already leave the binary files alone because of the first line:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.gitattributes&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; text=auto&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can be explicit and tell Git which files are binary so that their ending lines should not be modified:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.gitattributes&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.png binary&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;.jpg binary&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See also the &lt;a href=&quot;https://git-scm.com/docs/gitattributes#_end_of_line_conversion&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;end-of-line conversion section from the gitattributes reference&lt;/a&gt; that has some practical examples and more accurate information.&lt;/p&gt;&lt;h3 id=&quot;inspect-the-end-of-lines-in-the-wild&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#inspect-the-end-of-lines-in-the-wild&quot;&gt;Inspect the end of lines in the wild&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Now I will show some commands that are useful if you want to inspect the ending lines of your files, while you add/remove the files from your working directory/index.&lt;/p&gt;&lt;h4 id=&quot;the-ls-files-command&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#the-ls-files-command&quot;&gt;The &lt;code&gt;ls-files&lt;/code&gt; command&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;Probably the most useful is the plumbing command &lt;code&gt;git ls-files&lt;/code&gt; with the &lt;code&gt;--eol&lt;/code&gt; flag:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:603px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/665057f288a8885bc1de80e5e30f416f/30cdc/ls_files_eol.png&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:22.083333333333332%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAIAAAABPYjBAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAsklEQVQI1yXOSxKEIAwAUe8hGhQF+RkTIqW48P63mpqZ3r+q7kopKSXnXCnFORdCICJmRkRr7bquAOMwDMuyhBDW1W7bZsyslBrHsau1eu+NMa01ANj3/fklItd1EREA9H2PiO/7ttae52FmYwwAdMzsnJvnWUS01jHG8zxFBBGJKOcMAEqpnPN93yJSa00pee+11l9srTXGlFIAIMYovxCRmVNKf3wcR2uNmYlomqb/9gdWDCiY5U9s5wAAAABJRU5ErkJggg==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Terminal output after running git ls-files command with the eol flag on JSON files.&quot; title=&quot;Example output from the ls-files command.&quot; src=&quot;/static/665057f288a8885bc1de80e5e30f416f/30cdc/ls_files_eol.png&quot; srcSet=&quot;/static/665057f288a8885bc1de80e5e30f416f/3166f/ls_files_eol.png 480w,/static/665057f288a8885bc1de80e5e30f416f/30cdc/ls_files_eol.png 603w&quot; sizes=&quot;(max-width: 603px) 100vw, 603px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Example output from the ls-files command.&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;The fourth column shows the filename. The first column shows what type of ending line has the copy of the file inside the index. The second column shows the ending line for the file in your working directory. The third column shows the attributes you set up in the &lt;code&gt;.gitattributes&lt;/code&gt; file and their values.&lt;/p&gt;&lt;div class=&quot;note&quot;&gt;&lt;p style=&quot;margin-bottom:var(--rhythm)&quot;&gt;&lt;b&gt;Plumbing vs porcelain commands&lt;/b&gt;&lt;/p&gt;&lt;p&gt;A &lt;em&gt;plumbing&lt;/em&gt; command, that I mentioned earlier, is a low level command that&amp;#x27;s supposed to be used by other scripts and not the end-user. The opposite is a &lt;em&gt;porcelain&lt;/em&gt; command. Examples of porcelain commands are &lt;code&gt;git add&lt;/code&gt;, &lt;code&gt;git status&lt;/code&gt;, &lt;code&gt;git commit&lt;/code&gt;, etc.&lt;/p&gt;&lt;/div&gt;&lt;p&gt;If you don’t provide a path to &lt;code&gt;ls-files --eol&lt;/code&gt;, it will print a report for every file in your project. You can then pipe the output to &lt;code&gt;grep&lt;/code&gt; to search for those dirty CRLFs. For example:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;git ls-files --eol &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; grep --color &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;crlf&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Follow this link to &lt;a href=&quot;https://git-scm.com/docs/git-ls-files#Documentation/git-ls-files.txt---eol&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;make sense of the ls-files output&lt;/a&gt; because it’s not always so easy to understand.&lt;/p&gt;&lt;h4 id=&quot;inspect-coreautocrlf-and-gitattributes-values&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#inspect-coreautocrlf-and-gitattributes-values&quot;&gt;Inspect &lt;code&gt;core.autocrlf&lt;/code&gt; and &lt;code&gt;gitattributes&lt;/code&gt; values&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;See what value you have for the &lt;code&gt;core.autocrlf&lt;/code&gt; setting:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;git config core.autocrlf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Prints:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It may be useful to see the origin of this setting with the &lt;code&gt;--show-origin&lt;/code&gt; flag:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;git config  --show-origin core.autocrlf&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# Prints:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# file:C:/Program Files/Git/etc/gitconfig true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In my case, it’s coming from a default Git config file, not from global settings or the repository settings.&lt;/p&gt;&lt;p&gt;To see the &lt;code&gt;gitattributes&lt;/code&gt; settings for your project, search for the files:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;project_root/.gitattributes&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;project_root/.git/info/attributes&lt;/code&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;h4 id=&quot;see-the-contents-of-a-file-thats-inside-the-index&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#see-the-contents-of-a-file-thats-inside-the-index&quot;&gt;See the contents of a file that’s inside the index&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;To see the contents of a file that’s inside the index, run the following command in your terminal:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;git show :my_file.json &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; vi -b -&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;git show&lt;/code&gt; command “Shows various types of objects”. If you prefix a file with colon, it will show the file contents from the index. More details about the &lt;a href=&quot;https://git-scm.com/docs/gitrevisions&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;colon syntax on gitrevisions reference&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;You pipe the output of the &lt;code&gt;git show&lt;/code&gt; command to &lt;code&gt;vi&lt;/code&gt; and explicitly ask Vim to read from &lt;code&gt;stdin&lt;/code&gt; with the &lt;code&gt;-&lt;/code&gt; parameter. To exit Vim (hehe), press =&amp;gt; &lt;code&gt;:q!&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;Vim with the &lt;code&gt;-b&lt;/code&gt; flag will mark &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt; line endings as &lt;code&gt;^M&lt;/code&gt;, for example:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:406px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/f57954d6cb8d464465aaaf74384d5e1a/4be34/vi-b-notepad-json.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:51.47783251231527%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAKABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAEF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAABx4AH/8QAFBABAAAAAAAAAAAAAAAAAAAAIP/aAAgBAQABBQJf/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAFBABAAAAAAAAAAAAAAAAAAAAIP/aAAgBAQAGPwJf/8QAFhABAQEAAAAAAAAAAAAAAAAAAREg/9oACAEBAAE/IVrr/9oADAMBAAIAAwAAABDzz//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8QP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8QP//EABgQAQEAAwAAAAAAAAAAAAAAAAERIDFR/9oACAEBAAE/ELDArrmX/9k=&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;VIM window that shows a JSON file, created by notepad, that contains CRLF line endings.&quot; title=&quot;VIM window that shows a JSON file, created by notepad, that contains CRLF line endings.&quot; src=&quot;/static/f57954d6cb8d464465aaaf74384d5e1a/4be34/vi-b-notepad-json.jpg&quot; srcSet=&quot;/static/f57954d6cb8d464465aaaf74384d5e1a/4be34/vi-b-notepad-json.jpg 406w&quot; sizes=&quot;(max-width: 406px) 100vw, 406px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;VIM window that shows a JSON file, created by notepad, that contains CRLF line endings.&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;&lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; line endings are not marked by a character, for example:&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:457px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/4bcc2bca80deca26d6961cd911702cdf/e8c7f/vi-b-vim-json.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:65.86433260393872%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAEF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAABx4AH/8QAFBABAAAAAAAAAAAAAAAAAAAAIP/aAAgBAQABBQJf/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAFBABAAAAAAAAAAAAAAAAAAAAIP/aAAgBAQAGPwJf/8QAFhABAQEAAAAAAAAAAAAAAAAAAREg/9oACAEBAAE/IVrr/9oADAMBAAIAAwAAABBzz//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8QP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8QP//EABcQAQEBAQAAAAAAAAAAAAAAAAERIDH/2gAIAQEAAT8QoMCvDX//2Q==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;Vim window that shows a JSON file, created by Vim, that contains LF line endings.&quot; title=&quot;Vim window that shows a JSON file, created by Vim, that contains LF line endings.&quot; src=&quot;/static/4bcc2bca80deca26d6961cd911702cdf/e8c7f/vi-b-vim-json.jpg&quot; srcSet=&quot;/static/4bcc2bca80deca26d6961cd911702cdf/e8c7f/vi-b-vim-json.jpg 457w&quot; sizes=&quot;(max-width: 457px) 100vw, 457px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt;Vim window that shows a JSON file, created by Vim, that contains LF line endings.&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;h4 id=&quot;gits-cryptic-warnings-about-line-endings&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#gits-cryptic-warnings-about-line-endings&quot;&gt;Git’s cryptic warnings about line endings&lt;/a&gt;&lt;/h4&gt;&lt;p&gt;This is a warning I got from Git when I run &lt;code&gt;git add&lt;/code&gt; to stage a file I created with Vim (&lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; line endings).&lt;/p&gt;&lt;figure class=&quot;gatsby-resp-image-figure&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-wrapper&quot; style=&quot;position:relative;display:block;margin-left:auto;margin-right:auto;max-width:722px&quot;&gt;
      &lt;a class=&quot;gatsby-resp-image-link&quot; href=&quot;/static/fd1acb6c2d73d43b225450577ae2534b/ce04b/add-vim-json-to-index.jpg&quot; style=&quot;display:block&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;
    &lt;span class=&quot;gatsby-resp-image-background-image&quot; style=&quot;padding-bottom:11.041666666666666%;position:relative;bottom:0;left:0;background-image:url(&amp;#x27;data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAACABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAIF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAABywSD/8QAFBABAAAAAAAAAAAAAAAAAAAAEP/aAAgBAQABBQJ//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAFBABAAAAAAAAAAAAAAAAAAAAEP/aAAgBAQAGPwJ//8QAFhABAQEAAAAAAAAAAAAAAAAAAAER/9oACAEBAAE/IWK//9oADAMBAAIAAwAAABCED//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8QP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8QP//EABgQAQADAQAAAAAAAAAAAAAAAAEAESEx/9oACAEBAAE/EDXYiuEBfCf/2Q==&amp;#x27;);background-size:cover;display:block&quot;&gt;&lt;/span&gt;
  &lt;img class=&quot;gatsby-resp-image-image&quot; alt=&quot;A warning from Git in the terminal, after I run the git add command to stage a new file&quot; title=&quot; &quot; src=&quot;/static/fd1acb6c2d73d43b225450577ae2534b/ce04b/add-vim-json-to-index.jpg&quot; srcSet=&quot;/static/fd1acb6c2d73d43b225450577ae2534b/a5e48/add-vim-json-to-index.jpg 480w,/static/fd1acb6c2d73d43b225450577ae2534b/ce04b/add-vim-json-to-index.jpg 722w&quot; sizes=&quot;(max-width: 722px) 100vw, 722px&quot; style=&quot;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;/&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&quot;gatsby-resp-image-figcaption&quot;&gt; &lt;/figcaption&gt;
  &lt;/figure&gt;&lt;p&gt;At that time, my setup was &lt;code&gt;core.autocrlf&lt;/code&gt; set to &lt;code&gt;true&lt;/code&gt; and no &lt;code&gt;.gitattributes&lt;/code&gt; file. To remind you, with this setup we get the following behavior:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;When I add the file to the index, Git will convert &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt; to &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt;. This is not applicable here because the file already has &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt;.&lt;/li&gt;&lt;li&gt;Git will convert &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; to &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt; when I check it out from the Git database (this is applicable).&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The second line says that it won’t change my line endings in the working directory, so it will continue to be &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt;.&lt;/p&gt;&lt;p&gt;I think that the first line that says:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; will be replaced by &lt;abbr title=&quot;Carriage Return + Line Feed&quot;&gt;CRLF&lt;/abbr&gt; in &lt;code&gt;vim.json&lt;/code&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Refers to what will happen if I pull that file from the Git database on a checkout. Also, in case you are curious, if I remove the file from the index with &lt;code&gt;git restore --staged vim.json&lt;/code&gt;, as the output from &lt;code&gt;git status&lt;/code&gt; suggests, the file still keeps the &lt;abbr title=&quot;Line Feed&quot;&gt;LF&lt;/abbr&gt; line endings.&lt;/p&gt;&lt;h3 id=&quot;more-links&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#more-links&quot;&gt;More links&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Customizing Git - Git Attributes from Git book&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_formatting_and_whitespace&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Customizing Git - Git Configuration - Formatting and Whitespace, from Git book&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Configuring ESLint with Prettier]]></title><description><![CDATA[We’ll see 2 methods to configure ESLint with Prettier and write consistent and quality code.]]></description><link>https://markoskon.com/configuring-eslint-with-prettier/</link><guid isPermaLink="false">https://markoskon.com/configuring-eslint-with-prettier/</guid><pubDate>Fri, 04 Jan 2019 22:12:03 GMT</pubDate><content:encoded>&lt;div class=&quot;note&quot;&gt;&lt;strong&gt;Update:&lt;/strong&gt; I suggest to first check the &lt;a href=&quot;https://prettier.io/docs/en/integrating-with-linters.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Prettier documentation about Integrating with linters&lt;/a&gt;. That information was not available when I started writing this post, and I think they did a good job explaining the different options.&lt;/div&gt;&lt;p&gt;In this post, we’ll see how we can configure 2 really powerful tools we can use for &lt;strong&gt;linting&lt;/strong&gt; and &lt;strong&gt;formatting&lt;/strong&gt; our code. The first one is &lt;a href=&quot;https://eslint.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;ESLint&lt;/a&gt; which is a JavaScript linter. ESLint can analyze our code and point out &lt;strong&gt;syntactic errors&lt;/strong&gt; and &lt;strong&gt;possible bugs&lt;/strong&gt; from low-quality code. ESLint in addition to that can be used as a &lt;strong&gt;code formatter&lt;/strong&gt;. It does that by enforcing the formatting rules we write ourselves or those of the style guide we’re using. For example, &lt;a href=&quot;https://github.com/airbnb/javascript&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Airbnb’s style guide&lt;/a&gt; has a few formatting rules. &lt;a href=&quot;https://prettier.io&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Prettier&lt;/a&gt; on the other hand is just a code formatter. It makes our code look pretty by breaking long statements into multiple lines, removing extra spaces and more. Prettier can’t help us with syntactic errors but it’s a much more powerful code formatter compared to ESLint.&lt;/p&gt;&lt;h2 id=&quot;possible-problems&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#possible-problems&quot;&gt;Possible problems&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;As we see, in order to write high-quality code we want to use both of these tools. So where’s the problem? We’ll just install them and follow the official documentation. Pretty easy right? Although this is a reasonable request in theory, in practice you may experience some problems.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The first problem is that Prettier is a highly opinionated tool. This means that Prettier formatting rules are very specific and not widely adopted by everyone. In addition to that, it doesn’t have a lot of flexibility with the configuration options it provides. As a result, it’s quite common for these tools to come into &lt;strong&gt;conflict&lt;/strong&gt;. For example, you may run a script to format a file with Prettier and then immediately you’ll see the ESLint plugin reporting an error due to the formatting you just applied.&lt;/li&gt;&lt;li&gt;Another problem is that in order to use these tools you &lt;strong&gt;need a ridiculous amount of packages and editor plugins&lt;/strong&gt;. Not only that, you have &lt;strong&gt;more than one way to configure them&lt;/strong&gt; depending on your preferences. As a result, it’s quite common to end up with more dev dependencies or editor plugins that you actually need.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;In this post, we’ll focus on configuring these 2 tools in a way that seems the most reasonable to me. We want to &lt;strong&gt;first format&lt;/strong&gt; our code with Prettier and then ask ESLint to &lt;strong&gt;find linting errors&lt;/strong&gt; and &lt;strong&gt;fix&lt;/strong&gt; them. This way we’ll end up with good looking code and in addition to that, we’ll remain true to our coding style. But we’ll also briefly explore some other options we have in the end.&lt;/p&gt;&lt;p&gt;If you want to skip the setup of ESLint &lt;abbr title=&quot;Command-Line Interface&quot;&gt;CLI&lt;/abbr&gt;, the project set up with Babel and Webpack and the installation of ESLint plugin for VS Code (that’s a lot of things to skip) you can use the following links:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;#1-format-with-prettier-then-fix-with-eslint&quot;&gt;Method #1: Format with Prettier -&amp;gt; Fix with ESLint&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#2-run-prettier-with-eslint&quot;&gt;Method #2: Instruct ESLint to run Prettier&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Let’s start by configuring ESLint.&lt;/p&gt;&lt;h2 id=&quot;eslint-configuration&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#eslint-configuration&quot;&gt;ESLint configuration&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;We’ll start by creating a new project. We’ll create a folder and name it &lt;strong&gt;eslint-with-prettier&lt;/strong&gt;. You can obviously name it whatever you like. We open that folder with &lt;a href=&quot;https://code.visualstudio.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Visual Studio Code&lt;/a&gt;, which is my favorite code editor. The first thing we do is to initialize an &lt;abbr title=&quot;Node Package Manager&quot;&gt;NPM&lt;/abbr&gt; project. As you can imagine we need &lt;a href=&quot;https://nodejs.org/en/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Node&lt;/a&gt; installed for that. I’ll be using &lt;a href=&quot;https://classic.yarnpkg.com/en/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;yarn&lt;/a&gt; as a package manager but you can use &lt;abbr title=&quot;Node Package Manager&quot;&gt;NPM&lt;/abbr&gt; if you prefer. We initialize our &lt;abbr title=&quot;Node Package Manager&quot;&gt;NPM&lt;/abbr&gt; project with the default options (the “-y” option):&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn init -y&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#or&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;npm init -y&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then we’ll install ESLint as a dev dependency.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add -D eslint&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#or&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;npm i -D eslint&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After that’s done, we’ll use a really &lt;strong&gt;cool&lt;/strong&gt; feature of ESLint which the ability to &lt;strong&gt;initialize itself by answering some questions&lt;/strong&gt;. We can use a popular style guide or create our own. In our case, we’ll use &lt;a href=&quot;https://github.com/airbnb/javascript&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Airbnb’s style guide for JavaScript&lt;/a&gt; and &lt;a href=&quot;https://github.com/airbnb/javascript/tree/master/react&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;for React&lt;/a&gt;. The ESLint initialization process &lt;strong&gt;can also install the peer dependencies&lt;/strong&gt; our styling guide requires. This is really helpful because the popular guides depend on quite a lot of packages. So let’s initialize ESLint and answer some questions:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn eslint --init&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#or&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;npx eslint --init&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the first question we answer &lt;strong&gt;“Use a popular style guide”&lt;/strong&gt; and then we select &lt;strong&gt;“Airbnb”&lt;/strong&gt;. We’ll be using React so answer &lt;strong&gt;“y”&lt;/strong&gt; to that question and then we’ll select the &lt;strong&gt;”&lt;abbr title=&quot;JavaScript Object Notation&quot;&gt;JSON&lt;/abbr&gt;”&lt;/strong&gt; format for our configuration. ESLint will then ask if we want it to install the peer dependencies with &lt;abbr title=&quot;Node Package Manager&quot;&gt;NPM&lt;/abbr&gt; and we’ll respond with “yes please!“. After that’s done this should be the content of our &lt;strong&gt;package.json&lt;/strong&gt; file:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;package.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint-with-prettier&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;version&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;1.0.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;main&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;index.js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;license&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;MIT&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;devDependencies&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^5.11.1&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint-config-airbnb&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^17.1.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint-plugin-import&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^2.14.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint-plugin-jsx-a11y&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^6.1.2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint-plugin-react&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^7.12.2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can see that it installed &lt;strong&gt;3 plugins&lt;/strong&gt; and of course the &lt;strong&gt;Airbnb config&lt;/strong&gt;. Those are the two types of packages that you encounter when using ESLint, configurations and plugins. Keep in mind that if we didn’t need React, we would have installed the &lt;strong&gt;eslint-config-airbnb-base&lt;/strong&gt; instead, not &lt;strong&gt;eslint-config-airbnb&lt;/strong&gt;. Just saying… And this should be our .eslintrc.json file:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;eslintrc.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;extends&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;airbnb&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Note here, that you can omit the &lt;strong&gt;.json&lt;/strong&gt; extension from the ESLint configuration file name. So we’ll take advantage of that because it looks better and because I’m lazy and I want to write fewer things if possible.&lt;/p&gt;&lt;p&gt;Cool! Let’s now create some scripts in our package.json to help us &lt;strong&gt;run ESLint&lt;/strong&gt; a bit easier. The first script will run ESLint in our &lt;strong&gt;src&lt;/strong&gt; directory on &lt;strong&gt;.js&lt;/strong&gt; or &lt;strong&gt;.jsx&lt;/strong&gt; files and point out lint errors in the &lt;strong&gt;console&lt;/strong&gt;. The second one will do the same thing after it tries to fix them first (with the –fix flag):&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;package.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint-with-prettier&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;version&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;1.0.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;main&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;index.js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;license&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;MIT&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;scripts&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;lint&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint --ext js,jsx src&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;lint:fix&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint --ext js,jsx src --fix&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;devDependencies&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^5.11.1&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint-config-airbnb&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^17.1.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint-plugin-import&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^2.14.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint-plugin-jsx-a11y&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^6.1.2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint-plugin-react&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^7.12.2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Before we proceed further with ESLint and Prettier we’ll take a setback to create a simple react project. I know this sucks, but we have to do it because we need some code to test our tools against. If you already have a project you’ll probably good to go. Also if you are familiar with Babel and Webpack you can skim through the content or &lt;a href=&quot;#eslint-plugin-for-vs-code&quot;&gt;go directly to the installation of ESLint VS Code plugin&lt;/a&gt;.&lt;/p&gt;&lt;h2 id=&quot;a-simple-react-project-with-webpack-and-babel&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#a-simple-react-project-with-webpack-and-babel&quot;&gt;A simple React project with Webpack and Babel&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;As you can imagine, for a React project we’ll need to install &lt;strong&gt;react&lt;/strong&gt; and &lt;strong&gt;react-dom&lt;/strong&gt; packages. We’ll also need &lt;strong&gt;Babel&lt;/strong&gt; and &lt;strong&gt;Webpack&lt;/strong&gt; to transpile and bundle our code respectively. Let’s begin installing our dependencies:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# regular project dependencies&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add react react-dom&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# webpack dev dependencies&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add -D webpack webpack-cli webpack-dev-server babel-loader&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;# babel dev dependencies&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add -D @babel/core @babel/preset-env @babel/preset-react&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We’ll start by configuring Babel first. We’ll create for that a &lt;strong&gt;.babelrc&lt;/strong&gt; file in the root of our project. We’ll use 2 presets (think of them as a collection of plugins), &lt;strong&gt;env&lt;/strong&gt; and &lt;strong&gt;react&lt;/strong&gt;. The first is for transpiling regular JavaScript and the second is… for React.&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.babelrc&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;7&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;presets&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;@babel/env&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;@babel/react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And we’re done with Babel. Notice how we are omitting the “preset-” in the preset declaration, because they are already declared under the “presets” property. Now lets configure Webpack by creating a simple &lt;strong&gt;webpack.config.js&lt;/strong&gt; configuration file:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;webpack.config.js&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;8&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;CleanWebpackPlugin&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;clean-webpack-plugin&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;HtmlWebpackPlugin&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;html-webpack-plugin&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  entry: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./src/index.jsx&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  output: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    path: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(__dirname, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dist&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    filename: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;bundle.js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  mode: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;development&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  module: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    rules: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        test:&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\.&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;(js&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;jsx)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        exclude:&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk28&quot;&gt;(node_modules)&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        use: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;babel-loader&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        resolve: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;          extensions: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.jsx&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;        },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;      },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  plugins: [&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;CleanWebpackPlugin&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;dist&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;HtmlWebpackPlugin&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;({ template: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;./src/index.html&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; }),&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  ],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As you can see, we are using the &lt;strong&gt;clean-webpack-plugin&lt;/strong&gt; to clean our dist folder when building or when running the dev server. In addition to that, we’re using the &lt;strong&gt;html-webpack-plugin&lt;/strong&gt; to append the bundle Webpack creates in our html. Let’s install both of those plugins:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;9&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add -D clean-webpack-plugin html-webpack-plugin&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now let’s create the &lt;strong&gt;index.html&lt;/strong&gt; file in our src folder that will reference our JavaScript bundle:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/index.html&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;html&quot; data-index=&quot;10&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;!&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;DOCTYPE&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;en&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;charset&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;UTF-8&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;meta&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;viewport&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;width=device-width, initial-scale=1.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;    /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;meta&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;http-equiv&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;X-UA-Compatible&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;ie=edge&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;ESLint with Prettier&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After that’s done, we’ll create the entry point of our React application which is the &lt;strong&gt;index.jsx&lt;/strong&gt; file. We’ll place it inside the &lt;strong&gt;src&lt;/strong&gt; directory:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;src/index.jsx&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;jsx&quot; data-index=&quot;11&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; React &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; ReactDOM &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-dom&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Configuring ESLint with Prettier!&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;ReactDOM&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;At this point, if you have the ESLint plugin for VS Code installed (we’ll install it in a bit), you may see a linting error that says “document is not defined”. To solve that we’ll go back to our &lt;strong&gt;.eslintrc&lt;/strong&gt; file and add the “browser” as the environment:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.eslintrc&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;12&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;extends&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;airbnb&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;env&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;browser&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;One last thing we have to do is to add 2 Webpack scripts in our &lt;strong&gt;package.json&lt;/strong&gt; file. One will be for &lt;strong&gt;building&lt;/strong&gt; our app in production and one for &lt;strong&gt;starting a Webpack development server&lt;/strong&gt; to test our app locally:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;package.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;13&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;name&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint-with-prettier&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;version&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;1.0.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;main&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;index.js&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;license&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;MIT&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;scripts&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;start&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;webpack-dev-server --hot --open --port=6000&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;build&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;webpack --mode=production&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;lint&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint --ext js,jsx src&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;lint:fix&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint --ext js,jsx src --fix&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;dependencies&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;react&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^16.7.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;react-dom&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^16.7.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;devDependencies&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;@babel/core&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^7.2.2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;@babel/preset-env&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^7.2.3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;@babel/preset-react&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^7.0.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;babel-loader&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^8.0.4&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;clean-webpack-plugin&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^1.0.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^5.11.1&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint-config-airbnb&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^17.1.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint-plugin-import&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^2.14.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint-plugin-jsx-a11y&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^6.1.2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;eslint-plugin-react&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^7.12.2&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;html-webpack-plugin&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^3.2.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;webpack&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^4.28.3&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;webpack-cli&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^3.2.0&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;webpack-dev-server&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;^3.1.14&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And we’re done! We’ve successfully set up our React project. You came here to learn about ESLint and Prettier and you ended up making a custom boilerplate for React. But anyway, now we are able to run &lt;strong&gt;lint&lt;/strong&gt; or &lt;strong&gt;lint:fix&lt;/strong&gt; from our terminal and target some actual code:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;14&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn lint&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;#or&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn lint:fix&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;By running the &lt;strong&gt;lint&lt;/strong&gt; script from the console we’re now able to see some possible ESLint errors/warnings. If you see some, you can run the &lt;strong&gt;lint:fix&lt;/strong&gt; script and hopefully the ESLint will fix them. That’s nice, but you can only see the lint errors in the &lt;strong&gt;console&lt;/strong&gt;. If you want to see errors and warnings inside VS Code editor you’ll need a plugin for that.&lt;/p&gt;&lt;h2 id=&quot;eslint-plugin-for-vs-code&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#eslint-plugin-for-vs-code&quot;&gt;ESLint plugin for VS Code&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The plugin we need is called &lt;a href=&quot;https://github.com/Microsoft/vscode-eslint&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;vscode-eslint&lt;/a&gt; and you can &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;install it from the marketplace&lt;/a&gt;. You click the “extensions” icon on your left navigation bar inside VS Code and then you search for “eslint”. It should be the first result. You’ll need to reload the VS Code after you install in order to take effect. Now if you have lint errors in your code, you can see them highlighted inside the editor. Let’s now &lt;strong&gt;combine ESLint with Prettier&lt;/strong&gt; by following the first and my personal favorite method.&lt;/p&gt;&lt;h2 id=&quot;1-format-with-prettier-then-fix-with-eslint&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#1-format-with-prettier-then-fix-with-eslint&quot;&gt;1) Format with Prettier then fix with ESlint.&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The good news is that in order to use Prettier, we don’t necessarily need an additional dependency in our project. On the contrary, we’ll use another VS code plugin that’s called &lt;a href=&quot;https://github.com/prettier/prettier-vscode&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;prettier-vscode&lt;/a&gt;. We can install it the same way, from the “Extensions” area inside VS Code. &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;This is the marketplace link&lt;/a&gt;. At this point, remember what we’re trying to achieve. We want to &lt;strong&gt;first run Prettier&lt;/strong&gt; to format our code and &lt;strong&gt;the run ESLint with the –fix&lt;/strong&gt; option to fix our linting errors. The &lt;strong&gt;prettier-vscode&lt;/strong&gt; plugin does exactly that by using the &lt;a href=&quot;https://github.com/prettier/prettier-eslint&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;prettier-eslint&lt;/a&gt; package under the hood. If we want those 2 plugins (vscode-eslint and prettier-vscode) to work nicely together, we’ll have to add some workspace options for VS Code in our project. We’ll do that by creating a folder named &lt;strong&gt;.vscode&lt;/strong&gt; at the root of our project and inside that, we’ll add a &lt;strong&gt;settings.json&lt;/strong&gt; file that looks like this:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.vscode/settings.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;15&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;prettier.eslintIntegration&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;editor.formatOnSave&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;false&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The first option instructs the Prettier plugin to read our &lt;strong&gt;.eslintrc&lt;/strong&gt; configuration and format the code with respect to the linting rules. The second disables the formatting of our code on save which is my personal preference. We are now able to press &lt;code&gt;Alt+Shift+F&lt;/code&gt; or &lt;strong&gt;right-click&lt;/strong&gt; inside a file and then select the “Format Document” option and format our code! Objective completed. We configured ESLint and Prettier and we are ready to write some high-quality code.&lt;/p&gt;&lt;p&gt;Before we proceed any further, I want to add a final touch. I want to install as dev dependencies two libraries that are being used in the background by &lt;strong&gt;prettier-vscode&lt;/strong&gt; plugin. Why do you want to do that, you may ask. I want to do it because the prettier-vscode plugin is &lt;a href=&quot;https://www.google.com/search?q=prettier-vscode+inconsistent&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;not considered the most stable plugin&lt;/a&gt; ever (check the numerous Github issues). Sometimes it seems to ignore the ESLint configuration and doesn’t format the document from within the editor correctly (with &lt;code&gt;Alt+Shift+F&lt;/code&gt;). As a result, we’ll install &lt;a href=&quot;https://github.com/prettier/prettier-eslint&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;prettier-eslint&lt;/a&gt; and &lt;a href=&quot;https://github.com/prettier/prettier-eslint-cli&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;prettier-eslint-cli&lt;/a&gt; and create a script that’ll do the same thing the prettier-vscode plugin does. The only difference is that we’ll run that script from the terminal as opposed to formatting the files from the editor. Of course, if the prettier-vscode plugin works fine for us, we can use both of these methods. So let’s install those 2 dependencies:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;16&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add -D prettier-eslint prettier-eslint-cli&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and create a “format” script inside our &lt;strong&gt;package.json&lt;/strong&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;package.json&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;17&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping stuff....&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;scripts&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;start&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;webpack-dev-server --hot --open --port=6000&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;build&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;webpack --mode=production&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;lint&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint --ext js,jsx src&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;lint:fix&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;eslint --ext js,jsx src --fix&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;format&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;prettier-eslint --write &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;src/**/*.{js,jsx}&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;\&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;// skipping more stuff...&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can type &lt;strong&gt;yarn format&lt;/strong&gt; in our terminal and see that it works as intended. Another use case for our format script is as &lt;a href=&quot;/create-a-pre-commit-hook-with-husky-and-lint-staged/&quot;&gt;a pre-commit script&lt;/a&gt; that can be used by tools like &lt;a href=&quot;https://github.com/typicode/husky&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;husky&lt;/a&gt; or &lt;a href=&quot;https://github.com/pre-commit/pre-commit&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;pre-commit&lt;/a&gt;. This way we can prevent “bad code” from entering in our code base. Imagine someone forgetting to format the code from within the VS Code editor and only running the lint script. If we had only the &lt;strong&gt;lint&lt;/strong&gt; script as a safety barrier in a pre-commit script, we would not have been able to prevent that commit.&lt;/p&gt;&lt;p&gt;At this point, &lt;strong&gt;let’s recap our first approach&lt;/strong&gt;. We want to:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;write code&lt;/li&gt;&lt;li&gt;run Prettier to format our code&lt;/li&gt;&lt;li&gt;run ESLint with the –fix flag to fix our linting errors&lt;/li&gt;&lt;li&gt;end up with pretty code that will not report any errors if we run our lint scripts.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;We saw that we can achieve that by using the prettier-vscode plugin with the “format document” option inside the code editor. We also saw that we can create a format script and do the same thing from the terminal with the excellent &lt;strong&gt;prettier-eslint&lt;/strong&gt; package directly. Let’s now see an alternative method which is to tell ESLint to run Prettier.&lt;/p&gt;&lt;h2 id=&quot;2-run-prettier-with-eslint&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#2-run-prettier-with-eslint&quot;&gt;2) Run Prettier with ESLint.&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;I don’t really recommend this approach&lt;/strong&gt; because it doesn’t respect 100% the coding style we chose to follow. This happens because Prettier, as we said, is a highly opinionated tool and regularly comes into conflict with the linting rules of our style guide.&lt;/p&gt;&lt;p&gt;With this method, we can keep whatever packages we have installed so far. There is no need to uninstall something. But we’re going to need some more!&lt;/p&gt;&lt;p&gt;We’ll follow the &lt;a href=&quot;https://prettier.io/docs/en/eslint.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;official guide&lt;/a&gt; from prettier documentation of “integrating ESLint with Prettier”. We see that the first option is to &lt;strong&gt;tell ESLint to run Prettier and show us the prettier errors the same way it shows us the ESLint errors.&lt;/strong&gt; For that reason, we need the &lt;strong&gt;eslint-plugin-prettier&lt;/strong&gt; and the original &lt;strong&gt;prettier&lt;/strong&gt; package. Let’s install them:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;18&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add -D prettier eslint-plugin-prettier&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And our &lt;strong&gt;.eslintrc&lt;/strong&gt; becomes:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.eslintrc&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;19&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;extends&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;airbnb&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;plugins&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;prettier&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;rules&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;prettier/prettier&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now if you try to run the lint script with &lt;strong&gt;yarn lint&lt;/strong&gt; you’ll see the Prettier errors in the console. And probably now they are a few… For example, these are mine:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;20&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  1:19  error  Replace &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;`&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; with &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;`&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;          prettier/prettier&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  2:22  error  Replace &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;`&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-dom&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; with &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;`&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;react-dom&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;  prettier/prettier&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  4:38  error  Replace &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;`&amp;#x27;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;#x27;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; with &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;`&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;`&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;            prettier/prettier&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That’s because we now have conflicting rules like the above. We see that Prettier wants double quotes for strings but Airbnb wants single quotes. Additionally, if you try to “format” the &lt;strong&gt;index.jsx&lt;/strong&gt; with the Prettier VS Code plugin, probably nothing will happen. To fix that we’ll have to use another configuration package in addition to our original &lt;strong&gt;eslint-config-airbnb&lt;/strong&gt;. That package is called &lt;strong&gt;eslint-config-prettier&lt;/strong&gt; and we can install it with:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;bash&quot; data-index=&quot;21&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;yarn add -D eslint-config-prettier&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This configuration turns off the conflicting rules from ESLint and keeps those of Prettier. You can configure it in your &lt;strong&gt;.eslintrc&lt;/strong&gt;:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.eslintrc&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;22&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;extends&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;airbnb&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;prettier&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;plugins&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;prettier&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;rules&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;prettier/prettier&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;At this point you can configure it further in your .eslintrc file, to extend more things:&lt;/p&gt;&lt;div class=&quot;gatsby-code-title&quot;&gt;.eslintrc&lt;/div&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;json&quot; data-index=&quot;23&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;extends&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;airbnb&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;prettier&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;plugin:prettier/recommended&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;], &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;plugins&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: [&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;prettier&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;],&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;rules&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;quot;prettier/prettier&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk39&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To be honest, I don’t really get the difference between just extending the “prettier” config versus extending the config &lt;strong&gt;AND&lt;/strong&gt; the plugin. The result seems the same to me even with more “challenging” code. We can fix the errors from the console by running the &lt;strong&gt;lint:fix&lt;/strong&gt; script or by right-clicking in the code and “Formatting the document” with the prettier-vscode plugin.&lt;/p&gt;&lt;h2 id=&quot;conclusion&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;We saw that is not always easy to integrate ESLint with Prettier and get the best out of these tools. We demonstrated 2 different methods. In the first method, we format our code with Prettier and then fix the linting errors with ESLint. We do that with the help of the prettier-vscode plugin from inside VS Code or by using an &lt;abbr title=&quot;Node Package Manager&quot;&gt;NPM&lt;/abbr&gt; script with prettier-eslint package. The second method is to run Prettier from ESLint. We do that by using eslint-config-prettier and eslint-plugin-prettier. We can again format our code with the prettier-vscode plugin or by running the lint script with the –fix flag.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk39 { color: #C789D6; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk28 { color: #5CA7E4; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk12 { color: #FFCB8B; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item><item><title><![CDATA[Deploy a local WordPress site with the UpDraftPlus (free) plugin]]></title><description><![CDATA[In this post, we’ll see how you can use the popular UpDraftPlus plugin, to deploy a local WordPress site to a remote installation.]]></description><link>https://markoskon.com/deploy-a-local-wordpress-site-with-updraft-plugin/</link><guid isPermaLink="false">https://markoskon.com/deploy-a-local-wordpress-site-with-updraft-plugin/</guid><pubDate>Wed, 28 Nov 2018 22:12:03 GMT</pubDate><content:encoded>&lt;p&gt;We know that you can easily deploy a local WordPress site to a remote server by using software like &lt;a href=&quot;https://cpanel.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;CPanel&lt;/a&gt;. But sometimes CPanel may not be available on the server. Additionally, imagine a scenario where you &lt;strong&gt;don’t have access&lt;/strong&gt; to the &lt;strong&gt;&lt;abbr title=&quot;File Transfer Protocol&quot;&gt;FTP&lt;/abbr&gt;&lt;/strong&gt; server or to the &lt;strong&gt;MySQL database&lt;/strong&gt; (or both). In this case, if you have access only to a &lt;strong&gt;clean WordPress installation&lt;/strong&gt;, you can &lt;strong&gt;deploy&lt;/strong&gt; your &lt;strong&gt;local site&lt;/strong&gt; with the &lt;a href=&quot;https://wordpress.org/plugins/updraftplus/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;UpDraftPlus plugin&lt;/a&gt;. The paid version of UpDraftPlus gives you that option out of the box. Here we’ll see how you can do the same thing (kinda) with the free version. UpDraftPlus is a popular (1 million + installations) plugin that’s used for taking &lt;strong&gt;backups&lt;/strong&gt; on a WordPress site. It also gives you the ability to &lt;strong&gt;restore&lt;/strong&gt; a site from the backups. What we want to do here is to &lt;strong&gt;backup the local site&lt;/strong&gt; and then &lt;strong&gt;“restore” it&lt;/strong&gt; at the remote server.&lt;/p&gt;&lt;p&gt;I want to point out here, that the database backup file that’s generated from UpDraftPlus, contains &lt;abbr title=&quot;Structured Query Language&quot;&gt;SQL&lt;/abbr&gt; commands. If something goes wrong or you misconfigure something along the way, your site may not work properly and lose access to it. I tested this method successfully on only a couple of sites. So it’s obvious that &lt;strong&gt;you’ll have to proceed at your own risk&lt;/strong&gt;. I can’t help you if something goes wrong. So I suggest to &lt;strong&gt;first do the procedure locally&lt;/strong&gt; (between two local sites) or do it in a &lt;strong&gt;remote test site&lt;/strong&gt; to see if everything goes well.&lt;/p&gt;&lt;p&gt;Another thing I want to mention is that I’m using the &lt;a href=&quot;https://wordpress.org/themes/oceanwp/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;OceanWP&lt;/a&gt; theme and the &lt;a href=&quot;https://wordpress.org/plugins/elementor/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Elementor Page Builder plugin&lt;/a&gt;. If you don’t use those, you can skip the related steps. But you may have to see &lt;strong&gt;how your themes/plugins work&lt;/strong&gt; and replace those steps with your own steps. To give you an example, the OceanWP theme saves the customizer settings in a .json file, not in the database like for example the &lt;a href=&quot;https://wordpress.org/plugins/polylang/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Polylang&lt;/a&gt; plugin. Your theme or a plugin you use may do something similar. So you’ll have to check how that plugin or theme saves your settings.&lt;/p&gt;&lt;p&gt;We saw what we want to achieve (and the dangers) so let’s now see what we’ll have to do to make this work:&lt;/p&gt;&lt;h2 id=&quot;1-install-updraftplus-to-the-local-site&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#1-install-updraftplus-to-the-local-site&quot;&gt;1. Install UpDraftPlus to the local site&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The first thing we have to do is to &lt;strong&gt;install UpDraftPlus&lt;/strong&gt; to our &lt;strong&gt;local WordPress site&lt;/strong&gt;. We do that by going to &lt;strong&gt;Plugins - Add New&lt;/strong&gt; inside the Dashboard’s side menu. We type &lt;strong&gt;“updraft”&lt;/strong&gt; and we &lt;strong&gt;install/activate&lt;/strong&gt; the UpDraftPlus plugin (it should be the first result).&lt;/p&gt;&lt;h2 id=&quot;2-backup-the-local-site&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#2-backup-the-local-site&quot;&gt;2. Backup the local site&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Then we go to &lt;strong&gt;Settings - UpDraftPlus BackUps&lt;/strong&gt; and we press the &lt;strong&gt;“Backup Now”&lt;/strong&gt; button. We check the &lt;strong&gt;include the database&lt;/strong&gt; and &lt;strong&gt;include any files&lt;/strong&gt; (plugins, themes, uploads, any other directories found inside wp-content) options and we press the &lt;strong&gt;backup now&lt;/strong&gt; button. After a while, we’ll see at the bottom of the screen our newly created backup. The backup files are gzip archives (.gz extension) and they are saved inside the wp-content/updraft folder. &lt;strong&gt;They should be 5&lt;/strong&gt; in total (db, plugins, themes, uploads, other).&lt;/p&gt;&lt;h2 id=&quot;3-backup-the-oceanwp-theme-settings&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#3-backup-the-oceanwp-theme-settings&quot;&gt;3. Backup the OceanWP theme settings&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;We now go to the OceanWP’s &lt;strong&gt;Theme Panel - Import/Export&lt;/strong&gt; option and we &lt;strong&gt;export&lt;/strong&gt; the local site’s settings. It creates a .json file that we’ll need later.&lt;/p&gt;&lt;h2 id=&quot;4-install-7zip--visual-studio-code&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#4-install-7zip--visual-studio-code&quot;&gt;4. Install 7zip &amp;amp; Visual Studio Code&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Now you’ll need to &lt;strong&gt;install 2 really popular programs&lt;/strong&gt; if you don’t have them already on your machine. The first is the &lt;a href=&quot;https://www.7-zip.org/download.html&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;7zip file archiver&lt;/a&gt; and the other is the &lt;a href=&quot;https://code.visualstudio.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Visual Studio Code editor&lt;/a&gt;. We’ll &lt;strong&gt;extract&lt;/strong&gt; the backup file for the database we created earlier with 7zip and we’ll &lt;strong&gt;open it&lt;/strong&gt; with Vs Code.&lt;/p&gt;&lt;h2 id=&quot;5-replace-the-local-urls-with-the-remote-urls&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#5-replace-the-local-urls-with-the-remote-urls&quot;&gt;5. Replace the local &lt;abbr title=&quot;Uniform Resource Locators&quot;&gt;URLs&lt;/abbr&gt; with the remote &lt;abbr title=&quot;Uniform Resource Locators&quot;&gt;URLs&lt;/abbr&gt;&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;The file we open is not something special, just a MySQL script that recreates our local database. What we want to achieve in this step and in the following two is to &lt;strong&gt;replace the occurrences of our local &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt; in the &lt;abbr title=&quot;Database&quot;&gt;DB&lt;/abbr&gt; file with the remote &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;&lt;/strong&gt;. Let’s assume that our local &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt; is &lt;code&gt;http://localhost/my-local-site&lt;/code&gt; and our remote &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt; is &lt;code&gt;https://myawesomesite.com&lt;/code&gt;. We first search, by pressing &lt;code&gt;ctrl+F&lt;/code&gt;, for our &lt;strong&gt;local &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;&lt;/strong&gt;. Then, we press the &lt;strong&gt;arrow symbol&lt;/strong&gt; at the left of the search box. If we do that we’ll see another input field below our search field. We type the remote address, we press &lt;strong&gt;“Replace All”&lt;/strong&gt; and we save the file.&lt;/li&gt;&lt;li&gt;After we do that, we search for our &lt;strong&gt;local escaped &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;&lt;/strong&gt; which looks like the following: &lt;code&gt;localhost\\/my-local-site&lt;/code&gt;. We replace it with our remote “escaped” &lt;abbr title=&quot;Uniform Resource Locator&quot;&gt;URL&lt;/abbr&gt;. In our case is &lt;code&gt;myawesomesite.com&lt;/code&gt;. When we’re done, we save the file.&lt;/li&gt;&lt;li&gt;Next, we check for &lt;code&gt;localhost&lt;/code&gt; occurrences and they shouldn’t be any by now. Then we search for our &lt;strong&gt;local site path&lt;/strong&gt;. If our local site is available at &lt;code&gt;http://localhost/my-local-site&lt;/code&gt; we search for &lt;code&gt;my-local-site&lt;/code&gt; and we replace it with… nothing. That means that we leave the replace field empty and we save the file. Note that if your local site is available on &lt;code&gt;http://localhost&lt;/code&gt; you can skip this step.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;6-re-compress-the-edited-db-script-file&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#6-re-compress-the-edited-db-script-file&quot;&gt;6. Re-compress the edited &lt;abbr title=&quot;Database&quot;&gt;DB&lt;/abbr&gt; script file&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;After we replace all the &lt;abbr title=&quot;Uniform Resource Locators&quot;&gt;URLs&lt;/abbr&gt;, we &lt;strong&gt;close&lt;/strong&gt; the Vs Code. You can keep the old gzip db file (create a new folder and move it there) or delete it. We &lt;strong&gt;right click&lt;/strong&gt; the db file we edited and from the context menu we select &lt;strong&gt;7zip - Add to archive&lt;/strong&gt;. Inside the 7zip &lt;abbr title=&quot;User Interface&quot;&gt;UI&lt;/abbr&gt;, we select the &lt;strong&gt;gzip&lt;/strong&gt; option in the “archive format” and &lt;strong&gt;press ok&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;And we’re done with the local site! Let’s now move to the remote.&lt;/p&gt;&lt;h2 id=&quot;7-install-updraftplus-to-remote-site&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#7-install-updraftplus-to-remote-site&quot;&gt;7. Install UpDraftPlus to remote site&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;We &lt;strong&gt;login&lt;/strong&gt; to our &lt;strong&gt;remote&lt;/strong&gt; WordPress site and we &lt;strong&gt;install&lt;/strong&gt; the &lt;strong&gt;UpDraftPlus&lt;/strong&gt; plugin.&lt;/p&gt;&lt;h2 id=&quot;8-restore-the-remote-site-from-the-backup-files&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#8-restore-the-remote-site-from-the-backup-files&quot;&gt;8. Restore the remote site from the backup files&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;We go to the &lt;strong&gt;UpDraft settings&lt;/strong&gt;, we select &lt;strong&gt;“Upload backup files”&lt;/strong&gt; and we &lt;strong&gt;throw&lt;/strong&gt; the &lt;strong&gt;5 backup files&lt;/strong&gt; we created earlier. After this is done, we should see the backup in the list at the bottom of the screen. We select &lt;strong&gt;restore&lt;/strong&gt; and we &lt;strong&gt;check all the 5 fields&lt;/strong&gt;. We should see a message that says “all backup files have been successfully processed” and &lt;strong&gt;no errors or warnings&lt;/strong&gt;. If you see a warning that talks about “migrations” and that “you should use the migrate plugin (paid version)”, it probably means that you made an error with the &lt;abbr title=&quot;Uniform Resource Locators&quot;&gt;URLs&lt;/abbr&gt; and &lt;strong&gt;you should stop here&lt;/strong&gt;. We press &lt;strong&gt;“Restore”&lt;/strong&gt; and wait until the site is successfully restored.&lt;/p&gt;&lt;h2 id=&quot;9-re-configure-the-oceanwp-theme-and-elementor-plugin&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#9-re-configure-the-oceanwp-theme-and-elementor-plugin&quot;&gt;9. Re-configure the OceanWP theme and Elementor plugin&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;After the site is successfully restored, we go to &lt;strong&gt;Elementor - Tools&lt;/strong&gt; and we click &lt;strong&gt;“regenerate css”&lt;/strong&gt; and &lt;strong&gt;“sync library”&lt;/strong&gt;.&lt;/li&gt;&lt;li&gt;Then we go to &lt;strong&gt;Theme Panel - Import/Export&lt;/strong&gt; and we &lt;strong&gt;import&lt;/strong&gt; the .json file we exported earlier with the OceanWP’s settings.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;And that’s it! You’ve migrated a local WordPress site to a remote server. You did that by using only a clean WordPress installation and the UpDraftPlus plugin. If you found this helpful, please share the post link! If you broke your WordPress site, please go away.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Four methods to keep a navbar at the top of the screen.]]></title><description><![CDATA[See four methods you can use to keep a navigation bar at the top of the screen when the user scrolls down the page.]]></description><link>https://markoskon.com/fixed-navbar-on-top-with-position-sticky/</link><guid isPermaLink="false">https://markoskon.com/fixed-navbar-on-top-with-position-sticky/</guid><pubDate>Sun, 25 Nov 2018 22:12:03 GMT</pubDate><content:encoded>&lt;p&gt;In this post, you’ll see 4 methods you can use to keep a navigation bar at the top of the screen while the user scrolls down the page. It’s useful for single-page applications where the pages tend to get long, and you want to give the user the option to jump from section to section without having to go all the way up.&lt;/p&gt;&lt;p&gt;See a &lt;a href=&quot;https://github.com/MarkosKon/sticky-navbar-example&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;GitHub repository&lt;/a&gt; with the examples.&lt;/p&gt;&lt;h2 id=&quot;position-fixed&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#position-fixed&quot;&gt;Position fixed&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;In the past, the easier way to achieve this was to give the element a &lt;code&gt;position: fixed&lt;/code&gt; and place it at the top-left of the screen. For example:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;0&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.navbar&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;fixed&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;left&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This code removes the navbar from the &lt;em&gt;normal content flow&lt;/em&gt; and places it at the top of the screen. As a result, the rest of the content tries to fill up the space the navbar leaves and goes under it. If you want to avoid hiding elements behind the navbar, you can either add a top margin to the rest of the content—equal to the navbar height—or make the navbar transparent.&lt;/p&gt;&lt;h2 id=&quot;scroll-event&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#scroll-event&quot;&gt;Scroll event&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;If you want some kind of transition/animation, you can give the navbar a default &lt;code&gt;relative&lt;/code&gt; &lt;code&gt;position&lt;/code&gt; and then create a listener for the scroll event. Inside the scroll listener, you implement the following: if the distance from the top of the screen is greater than the navbar height (we moved passed the navbar), you add a scrolling class to the navbar. That class changes (with &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; code) the &lt;code&gt;position&lt;/code&gt; to &lt;code&gt;fixed&lt;/code&gt; and the other properties you want to transition. Consider the following &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt; code:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;1&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* default state */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.navbar&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;relative&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* default colors + transition */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;all&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0.3&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;s&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;ease-out&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;/* scrolling state */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.navbar.fixed-top&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;fixed&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;mtk11&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk6&quot;&gt;/* scrolling colors */&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;black&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.navbar.fixed-top&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;white&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and the JavaScript code:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;2&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;scroll&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;navbar&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.navbar&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;navbarHeight&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;distanceFromTop&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;abs&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;getBoundingClientRect&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;top&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;distanceFromTop&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;navbarHeight&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;) &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;navbar&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;classList&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fixed-top&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;navbar&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;classList&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;remove&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fixed-top&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;intersection-observer&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#intersection-observer&quot;&gt;Intersection observer&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;A more modern and &lt;em&gt;performant&lt;/em&gt; alternative is to use an &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;intersection observer&lt;/a&gt; instead of a scroll listener. First, you add a zero-height &lt;code&gt;div&lt;/code&gt; below the navbar, and you give it a &lt;code&gt;.spot&lt;/code&gt; class.&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;html&quot; data-index=&quot;3&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;nav&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;navbar&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;ul&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Position fixed&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/scroll.html&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Scroll event&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/observer.html&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Intersection observer&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;/sticky.html&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;Position sticky&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;ul&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;nav&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk5&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;spot&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;mtk14&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, you initialize an &lt;code&gt;IntersectionObserver&lt;/code&gt; and start observing that spot element with &lt;code&gt;observer.observe(spot)&lt;/code&gt;:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;4&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// element references&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;navbar&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.navbar&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;spot&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.spot&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// initialize and start the observer.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;observer&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;IntersectionObserver&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;handleScroll&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;observer&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;observe&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;spot&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When you initialize the observer, you pass some options and a &lt;code&gt;handleScroll&lt;/code&gt; method:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;js&quot; data-index=&quot;5&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// element references&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;navbar&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.navbar&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;spot&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;.spot&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// handler&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;handleScroll&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;entries&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; =&amp;gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;spotIsVisible&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;entries&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;isIntersecting&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  if &lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;spotIsVisible&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;navbar&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;classList&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;remove&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fixed-top&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  else &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;navbar&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk45&quot;&gt;classList&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;fixed-top&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  root: &lt;/span&gt;&lt;span class=&quot;mtk10&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  rootMargin: &lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk19&quot;&gt;0px&lt;/span&gt;&lt;span class=&quot;mtk37&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;  threshhold: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk6&quot;&gt;// initialize and start the observer.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk3&quot;&gt;const &lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;observer&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; = &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mtk12&quot;&gt;IntersectionObserver&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;handleScroll&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk9&quot;&gt;observer&lt;/span&gt;&lt;span class=&quot;mtk3&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mtk7&quot;&gt;observe&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mtk46&quot;&gt;spot&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The handler and the options give the following behavior: If the spot is completely hidden (not intersecting), we add a scrolling class to the navbar; if even 1px is visible (intersecting), we remove that class. The &lt;code&gt;handleScroll&lt;/code&gt; method is called in both cases.&lt;/p&gt;&lt;h3 id=&quot;caveats&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#caveats&quot;&gt;Caveats&lt;/a&gt;&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;Both of the last two methods (intersection observer/scroll listener) can cause the page to momentary jump when the transition happens, due to the removal/addition of the navbar from the normal content flow.&lt;/li&gt;&lt;li&gt;If the &lt;code&gt;.spot&lt;/code&gt; div has a &lt;code&gt;height&lt;/code&gt; other than &lt;code&gt;0&lt;/code&gt;, or if you &lt;code&gt;observe&lt;/code&gt; the navbar instead of the spot, you may get stuck in an &lt;em&gt;infinite loop&lt;/em&gt; where you add/remove the &lt;code&gt;fixed-top&lt;/code&gt; class from the navbar.&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;position-sticky&quot;&gt;&lt;a class=&quot;heading-link&quot; href=&quot;#position-sticky&quot;&gt;Position sticky&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;The last option you have is my favorite. It’s easy as the first method but without the margin drawback (the rest of the content doesn’t go behind the navbar). Additionally, the transition is smooth and doesn’t cause that jump I described earlier. You achieve that by giving the navbar a &lt;code&gt;position: sticky;&lt;/code&gt; and by placing it at the top of the screen:&lt;/p&gt;&lt;div class=&quot;pre-container&quot;&gt;&lt;pre class=&quot;grvsc-container grvsc-has-line-highlighting night-owl-no-italics&quot; data-language=&quot;css&quot; data-index=&quot;6&quot; style=&quot;position:static&quot;&gt;&lt;code class=&quot;grvsc-code&quot;&gt;&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk5&quot;&gt;.navbar&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;sticky&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line grvsc-line-highlighted&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;top&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk8&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk16&quot;&gt;transparent&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk21&quot;&gt;#content&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt; {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;mtk15&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;: &lt;/span&gt;&lt;span class=&quot;mtk9&quot;&gt;aquamarine&lt;/span&gt;&lt;span class=&quot;mtk1&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;grvsc-line&quot;&gt;&lt;span class=&quot;grvsc-source&quot;&gt;&lt;span class=&quot;mtk1&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;button type=&quot;button&quot; class=&quot;MDXComponents__Button-sc-2vjnjt-0 iCMGch&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I also made the navbar transparent and the content aquamarine to prove that the content doesn’t go under the navbar. If you want to add a transition, you can register an intersection observer, but this time, you don’t have to change the &lt;code&gt;position&lt;/code&gt; when the navbar is “fixed-top”.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;https://caniuse.com/css-sticky&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Position sticky is supported&lt;/a&gt; by all the major browsers.&lt;/p&gt;&lt;style class=&quot;grvsc-styles&quot;&gt;
  
  .night-owl-no-italics {
    background-color: #011627;
    color: #d6deeb;
  }
  .night-owl-no-italics .mtk5 { color: #C5E478; }
  .night-owl-no-italics .mtk1 { color: #D6DEEB; }
  .night-owl-no-italics .mtk15 { color: #80CBC4; }
  .night-owl-no-italics .mtk16 { color: #FF6363; }
  .night-owl-no-italics .mtk8 { color: #F78C6C; }
  .night-owl-no-italics .mtk11 { color: #FFEB95; }
  .night-owl-no-italics .mtk6 { color: #637777; }
  .night-owl-no-italics .mtk9 { color: #7FDBCA; }
  .night-owl-no-italics .mtk3 { color: #C792EA; }
  .night-owl-no-italics .mtk7 { color: #82AAFF; }
  .night-owl-no-italics .mtk37 { color: #D9F5DD; }
  .night-owl-no-italics .mtk19 { color: #ECC48D; }
  .night-owl-no-italics .mtk45 { color: #FAF39F; }
  .night-owl-no-italics .mtk46 { color: #D7DBE0; }
  .night-owl-no-italics .mtk14 { color: #CAECE6; }
  .night-owl-no-italics .mtk12 { color: #FFCB8B; }
  .night-owl-no-italics .mtk10 { color: #FF5874; }
  .night-owl-no-italics .mtk21 { color: #FAD430; }
  .night-owl-no-italics .grvsc-line-highlighted::before {
    background-color: var(--grvsc-line-highlighted-background-color, rgba(255, 255, 255, 0.1));
    box-shadow: inset var(--grvsc-line-highlighted-border-width, 4px) 0 0 0 var(--grvsc-line-highlighted-border-color, rgba(255, 255, 255, 0.5));
  }
&lt;/style&gt;</content:encoded></item></channel></rss>