<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Ondrej Polesny</title>
    <description>The latest articles on Forem by Ondrej Polesny (@ondrabus).</description>
    <link>https://forem.com/ondrabus</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F261120%2F16e46e89-6fa4-4468-8305-296e22e8f2f2.jpeg</url>
      <title>Forem: Ondrej Polesny</title>
      <link>https://forem.com/ondrabus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ondrabus"/>
    <language>en</language>
    <item>
      <title>How To Check If Array Is Empty In TypeScript</title>
      <dc:creator>Ondrej Polesny</dc:creator>
      <pubDate>Wed, 08 Dec 2021 09:12:06 +0000</pubDate>
      <link>https://forem.com/kontent_ai/how-to-check-if-array-is-empty-in-typescript-573k</link>
      <guid>https://forem.com/kontent_ai/how-to-check-if-array-is-empty-in-typescript-573k</guid>
      <description>&lt;p&gt;When processing JSON responses in TypeScript, how do you safely check if a variable is an array and is not empty?&lt;/p&gt;

&lt;p&gt;Let's say we get a response from an API (in this example, it's &lt;a href="https://docs.kontent.ai/reference/kontent-apis-overview"&gt;Kontent API&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blogPosts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BlogPost&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;deliveryClient&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;BlogPost&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blog_post&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toPromise&lt;/span&gt;&lt;span class="p"&gt;())?.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We expect that response to be an array of &lt;code&gt;BlogPost&lt;/code&gt; objects. Also, note the &lt;code&gt;?.&lt;/code&gt; notation that allows us to unwind the response and select just the data we need. If the response doesn't have the expected format, we will get &lt;code&gt;null&lt;/code&gt; instead of &lt;code&gt;undefined&lt;/code&gt; error.&lt;/p&gt;

&lt;p&gt;Therefore, we first need to check if the response is a defined array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;blogPosts&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Response has a wrong format&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;Array.isArray&lt;/code&gt; function will catch all possible values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// all these calls return false&lt;/span&gt;
&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;({})&lt;/span&gt;

&lt;span class="c1"&gt;// DON'T DO THIS&lt;/span&gt;
&lt;span class="c1"&gt;// as there is no need for checking the variable separately&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;blogPosts&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;blogPosts&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// DO THIS&lt;/span&gt;
&lt;span class="c1"&gt;// Array.isArray() is doing the null and&lt;/span&gt;
&lt;span class="c1"&gt;// undefined check automatically&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;blogPosts&lt;/span&gt;&lt;span class="p"&gt;)){&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note: Check &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray"&gt;MDN Web Docs&lt;/a&gt; for more information.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Then, we check if the array contains any items via &lt;code&gt;.length&lt;/code&gt; property:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;blogPosts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Response contains no items&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it. 💪&lt;/p&gt;

&lt;p&gt;The full code looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blogPosts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BlogPost&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;deliveryClient&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;BlogPost&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blog_post&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toPromise&lt;/span&gt;&lt;span class="p"&gt;())?.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;blogPosts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;blogPosts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;No data&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// all good here&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;blogPosts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also wrap the code in &lt;code&gt;try/catch&lt;/code&gt; block to make sure you also catch errors from network communication.&lt;/p&gt;

&lt;p&gt;If you need any help with processing your Kontent data, &lt;a href="https://bit.ly/kontent-discord"&gt;join our Discord&lt;/a&gt;! 😎&lt;/p&gt;

</description>
      <category>array</category>
      <category>empty</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Kontent Horizons developers news flash</title>
      <dc:creator>Ondrej Polesny</dc:creator>
      <pubDate>Tue, 09 Nov 2021 08:25:12 +0000</pubDate>
      <link>https://forem.com/kontent_ai/kontent-horizons-developers-news-flash-1c4</link>
      <guid>https://forem.com/kontent_ai/kontent-horizons-developers-news-flash-1c4</guid>
      <description>&lt;p&gt;Hey developers, thank you for attending Kontent Horizons! If you’re excited about our updates, find more information about them below or get in touch with us on &lt;a href="https://bit.ly/kontent-discord"&gt;Discord&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Documentation
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.kontent.ai/tutorials/develop-apps/overview?tech=javascript"&gt;New streamlined overview of tech stacks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  JavaScript + TypeScript
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Kentico/kontent-delivery-sdk-js/tree/vnext"&gt;Delivery SDK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Kentico/kontent-management-sdk-js"&gt;Management SDK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Kentico/kontent-model-generator-js"&gt;Model generator&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  .NET
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Kentico/kontent-delivery-sdk-net"&gt;Delivery SDK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Kentico/kontent-management-sdk-net/tree/vNext"&gt;Management SDK&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Nuxt 3
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/ondrabus/nuxt3-starter-kontent-lumen"&gt;Sample app&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ondrabus/kontent-nuxt3-module"&gt;Kontent module&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Discord
&lt;/h1&gt;

&lt;p&gt;Join us on &lt;a href="https://bit.ly/kontent-discord"&gt;Discord&lt;/a&gt; to discuss other topics, like GraphQL :-)&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What Gatsby v4 brings to your static site?</title>
      <dc:creator>Ondrej Polesny</dc:creator>
      <pubDate>Tue, 21 Sep 2021 15:11:33 +0000</pubDate>
      <link>https://forem.com/kontent_ai/what-gatsby-v4-brings-to-your-static-site-3bao</link>
      <guid>https://forem.com/kontent_ai/what-gatsby-v4-brings-to-your-static-site-3bao</guid>
      <description>&lt;p&gt;The new version of Gatsby is available in beta and brings many improvements. How are they going to affect you and the development and maintenance of your sites?&lt;/p&gt;

&lt;p&gt;In this article, I summarize the key new features that Gatsby v4 brings and explain how each of them will affect your daily work with a Gatsby site.&lt;/p&gt;

&lt;h1&gt;
  
  
  Gatsby v4 Improvements
&lt;/h1&gt;

&lt;p&gt;Gatsby v4 was officially introduced and made available as a public beta last week during Gatsby Camp and it brought major updates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;New rendering modes for pages&lt;/li&gt;
&lt;li&gt;Parallel query processing&lt;/li&gt;
&lt;li&gt;Improved Gatsby Cloud preview&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's start with the first and see what changes for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  New rendering modes for pages
&lt;/h2&gt;

&lt;p&gt;Gatsby introduced support for two additional modes and now lets you use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SSG - static site generation = pages generated during a build&lt;/li&gt;
&lt;li&gt;DSG - deferred static generation&lt;/li&gt;
&lt;li&gt;SSR - server-side rendered&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SSG is the original concept of static site generators, so let's start with the second one - the deferred static generation. It's not a new concept. We've been successfully using it with &lt;a href="https://vercel.com/docs/next.js/incremental-static-regeneration" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt; and Netlify had already introduced a similar improvement for other static site generators with their &lt;a href="https://www.netlify.com/blog/2021/04/14/distributed-persistent-rendering-a-new-jamstack-approach-for-faster-builds/" rel="noopener noreferrer"&gt;Distributed Persistent Rendering&lt;/a&gt; and &lt;a href="https://docs.netlify.com/configure-builds/on-demand-builders/" rel="noopener noreferrer"&gt;On-Demand Builders&lt;/a&gt;. The idea is, you pre-build only the core parts of a large site and leave the rest to be generated and cached (stored) only after the server receives a request for a specific page from the first visitor. In other words, on-demand.&lt;/p&gt;

&lt;p&gt;Having DSG now available in Gatsby is definitely a great improvement. In the past, it was challenging to use Gatsby for large sites as the build times grew with content significantly. Now, with DSG and Server-Side-Rendering mode (that we all saw coming with the introduction of serverless functions this spring), you now get full control over how each page of your site gets rendered.&lt;/p&gt;

&lt;p&gt;However, there is one downside. From my experience, Gatsby is often used by beginners. Don't get me wrong - many of them are experienced developers, just not with JavaScript. And what they value the most is the low entry barrier. They could get a site up and running very quickly, they didn't have to read any docs as the GraphQL data sourcing allowed them to see every content that's available, and for anything extra, there was always a plugin.&lt;/p&gt;

&lt;p&gt;While all of that is still true, the added rendering modes (SSR, DSG) require developers to make informed decisions that require them to learn more. The time they need to invest to see their new site live increases. And the same applies to onboarding developers.&lt;/p&gt;

&lt;p&gt;Now, you may argue here that they would need to learn that with any framework anyway and that's true. But Gatsby, until now, was a perfect stepping stone into Jamstack on React. Just like Gridsome is on Vue. I've seen many agencies tipping their toe in the Jamstack water with Gatsby and the low entry barrier was the biggest attraction for them.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: See the full explanation of Gatsby's rendering modes in &lt;a href="https://youtu.be/6Eglvixg4eg?t=307" rel="noopener noreferrer"&gt;this video&lt;/a&gt; or in &lt;a href="https://v4.gatsbyjs.com/docs/conceptual/rendering-options/" rel="noopener noreferrer"&gt;their docs&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Parallel query processing
&lt;/h2&gt;

&lt;p&gt;Another great improvement towards decreasing the build time. It's actually not optimizing the build but distributes the computation of page queries to multiple processor cores that work in parallel. The Gatsby team made this possible by moving the content from the Redux store to &lt;a href="https://en.wikipedia.org/wiki/Lightning_Memory-Mapped_Database" rel="noopener noreferrer"&gt;LMDB&lt;/a&gt; that supports concurrent access. So we're getting better build time by efficiently using the hardware. Good thing is, you don't need to take any action besides upgrading to the newest version of Gatsby.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gatsby Cloud preview update
&lt;/h2&gt;

&lt;p&gt;If you saw &lt;a href="https://www.youtube.com/watch?v=06K_lGH9hrY" rel="noopener noreferrer"&gt;my talk at Gatsby Conf&lt;/a&gt; this spring, you know that editors expect their CMS to generate previews of their content and they expect it to do it instantly. With Gatsby, this was made possible with incremental builds that took only a few seconds. Now, the Gatsby team took the preview experience on Gatsby Cloud one level further and implemented a UI panel that tells the editor in real-time that preview is coming.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4r07oymd4scsvtpyvl8l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4r07oymd4scsvtpyvl8l.png" alt="New Gatsby Cloud Preview panel"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, apart from that, the Gatsby team is constantly working on differentiating Gatsby Cloud from other hosting platforms and now claims that it is capable of 10x faster deploys.&lt;/p&gt;

&lt;h1&gt;
  
  
  Kontent and Gatsby v4
&lt;/h1&gt;

&lt;p&gt;If you're using &lt;a href="https://kontent.ai/" rel="noopener noreferrer"&gt;Kontent by Kentico&lt;/a&gt; as a content source for your Gatsby site, you're probably using both of these packages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/Kentico/kontent-gatsby-packages/blob/master/packages/gatsby-source-kontent#readme" rel="noopener noreferrer"&gt;Gatsby Source Kontent Plugin&lt;/a&gt;&lt;/strong&gt;
Plugin providing data from Kontent REST API to Gatsby GraphQL model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/Kentico/kontent-gatsby-packages/blob/master/packages/gatsby-kontent-components#readme" rel="noopener noreferrer"&gt;Gatsby Kontent Components&lt;/a&gt;&lt;/strong&gt;
Package with React components that process Kontent data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We've prepared the new source plugin version ahead of the Gatsby v4 beta release. However, it will be merged only after the v4 is fully released, so until then, make sure to check out &lt;a href="https://github.com/Kentico/kontent-gatsby-packages/pull/192" rel="noopener noreferrer"&gt;this version&lt;/a&gt; of the source plugin.&lt;/p&gt;

&lt;p&gt;The Gatsby Kontent Components package is fully compatible with both the current and the new versions of the source plugin.&lt;/p&gt;

&lt;h1&gt;
  
  
  Should I upgrade?
&lt;/h1&gt;

&lt;p&gt;The presented changes have one thing in common - Gatsby is trying hard to enable large-scale applications. They constantly work on decreasing build times (which interestingly brought new potential with the move of the content store), providing options to avoid building everything, improving the Gatsby Cloud services, focusing more on the content editor experience, and working closely with strategic partners.&lt;/p&gt;

&lt;p&gt;If your site runs on Gatsby, I'd encourage you to try out the new features as they solve the problems of the majority of sites.&lt;/p&gt;

</description>
      <category>gatsby</category>
      <category>react</category>
      <category>jamstack</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Vue.js cheat sheet: Rendering data into HTML</title>
      <dc:creator>Ondrej Polesny</dc:creator>
      <pubDate>Fri, 07 May 2021 20:14:44 +0000</pubDate>
      <link>https://forem.com/kontent_ai/vue-js-cheat-sheet-rendering-data-into-html-4d8g</link>
      <guid>https://forem.com/kontent_ai/vue-js-cheat-sheet-rendering-data-into-html-4d8g</guid>
      <description>&lt;p&gt;Are you just starting out with Vue.js? Or has it been long since you’ve worked with Vue? This cheat sheet lists the nine most common tasks and solutions when outputting data to HTML.&lt;/p&gt;

&lt;p&gt;In all these samples, the first part shows the syntax, and the second part shows the usage with real data.&lt;/p&gt;

&lt;h1&gt;
  
  
  Outputting data into HTML
&lt;/h1&gt;

&lt;p&gt;The first test of your app or rendering data between HTML elements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;
&lt;span class="err"&gt;↓&lt;/span&gt;
&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subtitle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Adding the standard class attribute
&lt;/h1&gt;

&lt;p&gt;After testing the app, you want to make it look nice with styles:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;classname&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="err"&gt;↓&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sidebar__inner&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Outputting data into HTML attributes
&lt;/h1&gt;

&lt;p&gt;When adding links or rendering images with alt tags, this is how you can fill the elements’ attributes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;variable&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="err"&gt;↓&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;`https://twitter.com/${author.twitter.value}`&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Outputting HTML
&lt;/h1&gt;

&lt;p&gt;In certain cases, like when consuming rich texts from a headless CMS, you need to render already formatted HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;variable&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/...&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
↓&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;article.teaser&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Iterating over data sets
&lt;/h1&gt;

&lt;p&gt;Iterating is useful for creating lists of items, like index pages of blogs or product catalogs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;item in collectionVariable&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;item.uniqueKey&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="err"&gt;↓&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;article&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;article in articles&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;article.id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Iterating over data sets with index
&lt;/h1&gt;

&lt;p&gt;The same use case as before, but this way, you can access an index of each item:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;(item, index) in collectionVariable&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;item.id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="err"&gt;↓&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;article&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;(article, index) in articles&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;article.id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Rendering conditional markup
&lt;/h1&gt;

&lt;p&gt;Conditions allow you to hide or display specific parts of markup based on data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;variable !== null&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="err"&gt;↓&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;data.length &amp;gt; 0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Rendering conditional markup including else branch
&lt;/h1&gt;

&lt;p&gt;They can also be used to display preloaders in case of async data fetching to let your visitors know that something is happening:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;variable !== null&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="err"&gt;↓&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;data.length &amp;gt; 0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Loading&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Passing data to child components
&lt;/h1&gt;

&lt;p&gt;When you start using components, this is how you can provide them with data from the parent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;component&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;componentVariable&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;variable&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="err"&gt;↓&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;links&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;author&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;author&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also download this cheat sheet in &lt;a href="https://ondrabus.com/react-vue-angular-cheatsheet"&gt;printable form&lt;/a&gt; and check out its &lt;a href="https://ondrabus.com/react-vue-angular-cheatsheet"&gt;alternatives for React and Angular&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>javascript</category>
      <category>html</category>
      <category>cheatsheet</category>
    </item>
    <item>
      <title>Animating multiple elements with Vue transitions (and CSS var() function)</title>
      <dc:creator>Ondrej Polesny</dc:creator>
      <pubDate>Thu, 29 Apr 2021 18:06:49 +0000</pubDate>
      <link>https://forem.com/kontent_ai/animating-multiple-elements-with-vue-transitions-and-css-var-function-5el2</link>
      <guid>https://forem.com/kontent_ai/animating-multiple-elements-with-vue-transitions-and-css-var-function-5el2</guid>
      <description>&lt;p&gt;Transitions are a great way to make your app interactive. Vue.js allows us to animate any dynamic events on elements with the &lt;code&gt;&amp;lt;transition&amp;gt;&lt;/code&gt; component. But what if you need to animate multiple elements that are related to each other?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F633se7z9bj4xtgajrod2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F633se7z9bj4xtgajrod2.gif" alt="Bars animation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codepen.io/ondrabus/pen/GRraYoo" rel="noopener noreferrer"&gt;TLDR: CodePen link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I stumbled upon this problem when I wanted to animate graph bars. Each bar needed to have a specific width and had to be animated right after the previous one. Also, I did not want to hardcode the number of bars, so it all needed to be data-driven.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the data and template
&lt;/h2&gt;

&lt;p&gt;So let's isolate the problem, this is how the bars are defined in a Vue app:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="nf"&gt;data&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;bars&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;75&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And they are rendered in a for loop:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;(bar, i) in bars&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;i&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="nx"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;%&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Animating the bars using 
&lt;/h2&gt;

&lt;p&gt;The first step in animating them is to add a  component and a single root as that's what Vue requires:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;transition&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bars&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;appear&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;(bar, i) in bars&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;i&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="nx"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;%&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/transition&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Note the &lt;code&gt;appear&lt;/code&gt; attribute. It instructs Vue to animate the first (and only) child element when it appears in the DOM. Vue is clever enough to search the applied styles for transition and it will add a few special classes to the element for the duration of the transition:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;bars-enter-active&lt;/code&gt; for the whole duration&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bars-enter-from&lt;/code&gt; at the start to define CSS to animate from, e.g. &lt;code&gt;width: 0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;bars-enter-to&lt;/code&gt; at the end to define CSS to animate to, e.g. &lt;code&gt;width: 75%&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The problem is, we need to define these properties on a more granular level - for each bar.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting data with CSS using var()
&lt;/h2&gt;

&lt;p&gt;The CSS &lt;code&gt;var()&lt;/code&gt; function allows us to nicely connect dynamic data with CSS. We configure the data just like any other style definition of the element:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;--variableName: variableValue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And use &lt;code&gt;var(variableName)&lt;/code&gt; in the actual stylesheet:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;selector&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;CSS&lt;/span&gt; &lt;span class="nx"&gt;property&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;variableName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In this case, we'll need each bar to define its width and calculate the animation delay using the item's index:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;(bar, i) in bars&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;i&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;`--width: ${bar}%; --delay: ${i}s`&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="nx"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;%&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And add the accompanying styles:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bar&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bars&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;enter&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bar&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bars&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;enter&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;active&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bar&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;all&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="nx"&gt;s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;transition&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The last thing to keep in mind is that Vue will only keep the special CSS classes on the root element for the amount of time defined in its transition. So let's add the expected animation time as transition duration:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;`transition: all ${(bars.length-1)+2}s`&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The animation will take exactly N+2 seconds if N is the number of bars and each bar takes 2s to render. If you set it to a lower value than needed, the animation of some bars will not finish and just skip to the final position.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codepen.io/ondrabus/pen/GRraYoo" rel="noopener noreferrer"&gt;See the functional sample on CodePen.&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;The combination of &lt;code&gt;--variableName: variableValue&lt;/code&gt; and &lt;code&gt;var(--variableName)&lt;/code&gt; is a nice way to avoid generating too many style definitions (that are even then limited) through &lt;code&gt;for&lt;/code&gt; loops.&lt;/p&gt;

&lt;p&gt;If you want to share your experience or get in touch, join the &lt;a href="https://bit.ly/kontent-discord" rel="noopener noreferrer"&gt;Kontent Discord&lt;/a&gt; and ping me a message 😊&lt;/p&gt;

</description>
      <category>css</category>
      <category>transition</category>
      <category>var</category>
      <category>vue</category>
    </item>
    <item>
      <title>How to use Kontent Delivery SDK with native ESM and Vite</title>
      <dc:creator>Ondrej Polesny</dc:creator>
      <pubDate>Wed, 31 Mar 2021 12:11:40 +0000</pubDate>
      <link>https://forem.com/kontent_ai/how-to-use-kontent-delivery-sdk-with-native-esm-and-vite-1j00</link>
      <guid>https://forem.com/kontent_ai/how-to-use-kontent-delivery-sdk-with-native-esm-and-vite-1j00</guid>
      <description>&lt;h2&gt;
  
  
  Why native ESM and Vite?
&lt;/h2&gt;

&lt;p&gt;When working on JavaScript projects, we are used to bundling every bit of functionality into a JS bundle that is then served to all visitors of our sites. With native ESM we can get around the bundling and serve modular JS code to modern browsers directly and dynamically.&lt;/p&gt;

&lt;p&gt;One of the tools that help us with this task is &lt;a href="https://vitejs.dev/guide/why.html"&gt;Vite&lt;/a&gt;. It effectively replaces Webpack and allows for instant cold-start of your development server as well as ensures optimal output for production. In turn, it asks for all code to be compatible with ES2015 and newer, so no CommonJS anymore.&lt;/p&gt;

&lt;p&gt;If you try to build your site with Vite and your code does not comply, you will most likely see the following error:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;❌ Uncaught ReferenceError: exports is not defined at ...&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The error occurs after you generate the production build and comes from your Vite-optimized code bundle. It means there is some unsupported functionality left in your code or in the packages that you use.&lt;/p&gt;

&lt;p&gt;The Kontent JS Delivery SDK may be one of them. To configure it to work with Vite you need to do the following:&lt;/p&gt;

&lt;h2&gt;
  
  
  Target ESNext version of the Delivery SDK
&lt;/h2&gt;

&lt;p&gt;The Kontent JS Delivery SDK from version 10.4.1 comes with the ESNext version in a subfolder _esNext so you just need to ensure your code uses it. But to make it a bit more complicated, you also need to use _es2015 (the newest) version of &lt;code&gt;kontent-core&lt;/code&gt; package that the &lt;code&gt;kontent-delivery&lt;/code&gt; depends on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ywzZ1lC9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7lj3oh8vmll2azlcodke.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ywzZ1lC9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7lj3oh8vmll2azlcodke.png" alt="ESNext version in a subfolder of the Kontent JS Delivery SDK"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So you see, you can't just adjust all your imports to use a subfolder _esNext. To solve this issue, you need to &lt;a href="https://vitejs.dev/config/#resolve-alias"&gt;tell Vite to redirect&lt;/a&gt; all relevant imports to that specific subfolder. Vite passes this information to Rollup - the module bundler it uses internally. The &lt;em&gt;vite.config.ts&lt;/em&gt; looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;vue&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="na"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt;    &lt;/span&gt;&lt;span class="na"&gt;alias&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt;      &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@kentico/kontent-core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@kentico/kontent-core/_es2015&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="err"&gt;      &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@kentico/kontent-delivery&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@kentico/kontent-delivery/_esNext&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="err"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are redirecting all &lt;code&gt;kontent-core&lt;/code&gt; and &lt;code&gt;kontent-delivery&lt;/code&gt; imports to the respective subfolders.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: If you're not using Vite and need to do the same with Webpack, see &lt;a href="https://webpack.js.org/configuration/resolve/"&gt;this page in their docs&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Add BrowserRichTextParser to DeliveryClient config
&lt;/h2&gt;

&lt;p&gt;The SDK may be used in both browser and Node environments. Because Node.js does not feature browser API, the SDK is capable of dynamically loading a (much larger) Node.js parser based on the runtime context. However, some compatibility issues with Angular required the use of CommonJS's &lt;code&gt;require&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You're building a website, so you can get around this by defining the browser-specific parser in the &lt;code&gt;DeliveryClient&lt;/code&gt; config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;BrowserRichTextParser&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@kentico/kontent-delivery&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;DeliveryClient&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
&lt;span class="err"&gt;      &lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="err"&gt;      &lt;/span&gt;&lt;span class="na"&gt;richTextParserAdapter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;BrowserRichTextParser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="err"&gt;    &lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it. You're good to go 🤗 Try &lt;code&gt;npm run build&lt;/code&gt; and &lt;code&gt;npm run serve&lt;/code&gt; and your console should be nice and clean.&lt;/p&gt;

&lt;p&gt;If you're using only ES2015+ compatible packages, using Vite you can get a much better development experience with zero waits and more effective production bundles.&lt;/p&gt;

&lt;p&gt;Follow my &lt;a href="https://twitter.com/ondrabus"&gt;Twitter&lt;/a&gt; if you don't want to miss any new articles 🐤&lt;/p&gt;

</description>
      <category>kontent</category>
      <category>vite</category>
      <category>es2015</category>
      <category>esnext</category>
    </item>
    <item>
      <title>How to use Highlight.js on a Next.js site</title>
      <dc:creator>Ondrej Polesny</dc:creator>
      <pubDate>Mon, 16 Nov 2020 11:47:33 +0000</pubDate>
      <link>https://forem.com/kontent_ai/how-to-use-highlight-js-on-a-next-js-site-f9</link>
      <guid>https://forem.com/kontent_ai/how-to-use-highlight-js-on-a-next-js-site-f9</guid>
      <description>&lt;p&gt;Is your blog built using Next.js and you want to use syntax highlighting on code samples? This short guide will show you how to plug Highlight.js into your Next.js site.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is Highlight.js?
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://highlightjs.org"&gt;Highlight.js&lt;/a&gt; is a Javascript library that turns code samples into highlighted code. You can get the whole bundle from CDN and plug it into your website, however, it's rather large as it supports tens of programming languages including Javascript, C#, CSS, Ruby, PHP, and many more.&lt;/p&gt;

&lt;p&gt;A better approach is to &lt;a href="https://highlightjs.org/download/"&gt;select only the languages&lt;/a&gt; you will need on your site. I'm using just Javascript bundle currently, but it's possible to have any combination that fits your programming interests and focus.&lt;/p&gt;

&lt;p&gt;Highlight.js &lt;a href="https://highlightjs.org/usage/"&gt;is activated when your site loads&lt;/a&gt; and adjusts the look and feel of your code samples using its own CSS.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to use syntax highlighting on a Next.js site
&lt;/h1&gt;

&lt;p&gt;Using Highlight.js on an HTML page is easy using global bundles. On a Next.js site built with React and JSX, it gets a bit more complicated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Highlight.js
&lt;/h2&gt;

&lt;p&gt;First, you need to install Highlight.js using Node:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm i highlight.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then open the page you want to use code highlighting on. This would typically be a blog post template. First, add the stylesheet to your template markup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;React.Fragment&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Head&amp;gt;&lt;/span&gt;
        ...
        &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.3.2/build/styles/default.min.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/link&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/Head&amp;gt;&lt;/span&gt;
...
&lt;span class="nt"&gt;&amp;lt;/React.Fragment&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also add the styles locally if you want to avoid using an external resource by importing them into your &lt;em&gt;_app.tsx&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import 'highlight.js/styles/default.css';&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Add your code samples into JSX
&lt;/h2&gt;

&lt;p&gt;To add your code into JSX, follow this simple pattern:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;pre&amp;gt;&amp;lt;code&lt;/span&gt; &lt;span class="na"&gt;className=&lt;/span&gt;&lt;span class="s"&gt;"js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
{`
your code
`}
&lt;span class="nt"&gt;&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As long as your code does not contain backticks, this will nicely escape all special characters. Take a look at this simple Javascript example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;pre&amp;gt;&amp;lt;code&lt;/span&gt; &lt;span class="na"&gt;className=&lt;/span&gt;&lt;span class="s"&gt;"js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
{`fetch('{url}')
    .then(response =&amp;gt; console.log(response));
`}
&lt;span class="nt"&gt;&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The class name helps Highlight.js recognize the used programming language and adjust the highlighted color scheme.&lt;/p&gt;

&lt;h2&gt;
  
  
  Initialize Highlight.js
&lt;/h2&gt;

&lt;p&gt;The final step is to plug Highlight.js in and let it scan and adjust all the code samples. Add the following code to the top of your template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;hljs&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;highlight.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;javascript&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;highlight.js/lib/languages/javascript&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;hljs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;registerLanguage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;javascript&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;javascript&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to use multiple languages, repeat the bottom two lines for all of them.&lt;/p&gt;

&lt;p&gt;Highlight.js needs to be activated when the page is rendered. You can use React Hooks to do so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
    &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;hljs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;initHighlighting&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nx"&gt;JSX&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it 😊. Compile your site and check if syntax highlighting works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Light &amp;amp; dark modes
&lt;/h2&gt;

&lt;p&gt;If you're using multiple stylesheets on your site to adjust its colors, it's possible to also switch themes of syntax highlighting. Take a look at &lt;a href="http://jmblog.github.io/color-themes-for-highlightjs/"&gt;this project&lt;/a&gt; which contains stylesheets fitted for respective color schemes.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;In this article, I showed you how to plug Highlight.js into your Next.js site. This approach can be also used on plain React sites or sites implemented using other static site generators like Gatsby. You can also check out the full implementation on my &lt;a href="https://github.com/ondrabus/personal-site/blob/master/pages/fetch-api-cheatsheet.tsx"&gt;personal site on GitHub&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>highlight</category>
      <category>nextjs</category>
      <category>react</category>
      <category>code</category>
    </item>
    <item>
      <title>🤦‍♂️ How to fail to record a conference presentation</title>
      <dc:creator>Ondrej Polesny</dc:creator>
      <pubDate>Tue, 10 Nov 2020 14:18:53 +0000</pubDate>
      <link>https://forem.com/kontent_ai/how-to-fail-to-record-a-conference-presentation-3kh9</link>
      <guid>https://forem.com/kontent_ai/how-to-fail-to-record-a-conference-presentation-3kh9</guid>
      <description>&lt;p&gt;Last week I was recording a presentation for the conference &lt;a href="https://horizons.kontent.ai/"&gt;Kontent Horizons&lt;/a&gt;. I did not want to just use a webcam and laptop mic, so I had borrowed a Sony Alpha II camera.&lt;/p&gt;

&lt;p&gt;I cleaned up the stage, which means mess everywhere but where the camera looks, and used my wife as a model to set up the camera aperture and focal point. I even did a test video and everything looked good.&lt;/p&gt;

&lt;p&gt;I changed the battery pack to get a nice hour of recording window and talked through the whole presentation. You know the feeling when you have all the footage you need? I had that, for about a minute.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P7RP7zAT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vykc1ttotx6x0743wwd7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P7RP7zAT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vykc1ttotx6x0743wwd7.png" alt="Out of focus and dark image from the camera"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I plugged the SD card into the computer only to find out that I am completely out of focus and the frame is missing a lot of light 😫. I ended up re-recording the next morning.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xM3V5fFo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/axpamlr8ruxrs2p15jwe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xM3V5fFo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/axpamlr8ruxrs2p15jwe.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Lesson learned:&lt;/em&gt; &lt;strong&gt;The focal point of a camera may be reset if you exchange a battery pack. Always do a test video BEFORE recording a presentation.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Bonus:&lt;/em&gt; As I'm using my iPhone to record the sound from a clip-on mic, I also found out that if someone calls you in the middle of the recording, the phone stops recording. And you have no idea as it's on MUTE! There went another 45mins of my life 🥱. I hope the presentation will be worth it, it's about choosing the right Jamstack tool, and you can see it on &lt;a href="https://horizons.kontent.ai/"&gt;Kontent Horizons&lt;/a&gt; for free 😊.&lt;/p&gt;

</description>
      <category>fail</category>
      <category>lessonslearned</category>
      <category>conference</category>
      <category>presentation</category>
    </item>
    <item>
      <title>🎈 Weekly Win (44/2020)</title>
      <dc:creator>Ondrej Polesny</dc:creator>
      <pubDate>Tue, 27 Oct 2020 09:49:13 +0000</pubDate>
      <link>https://forem.com/kontent_ai/weekly-wins-44-2020-3k87</link>
      <guid>https://forem.com/kontent_ai/weekly-wins-44-2020-3k87</guid>
      <description>&lt;p&gt;Did you attend the &lt;a href="https://jamstackconf.com/2020/october/"&gt;Jamstackconf&lt;/a&gt; a few weeks ago? If you did, I hope you visited our virtual booth too. We had many interesting conversations and got to live coding too.&lt;/p&gt;

&lt;p&gt;Around that time I have just finished my new &lt;a href="https://ondrabus.com"&gt;personal site&lt;/a&gt; on Jamstack. You know, to have it nice and fast. But what I observed on other, mainly Gatsby-powered, sites were these nice transitions between pages. No visible flick and reload in the browser when navigating to other pages, but a seamless transition.&lt;/p&gt;

&lt;p&gt;When we discussed that on Jamstackconf, there was a guest in our booth that encouraged me and helped me to do the same on my website using &lt;a href="https://github.com/framer/motion"&gt;Framer Motion&lt;/a&gt;. It took literally just an hour including finding and fixing one bug in routing 😄&lt;/p&gt;

&lt;p&gt;Take a look at &lt;a href="https://ondrabus.com"&gt;ondrabus.com&lt;/a&gt; and if you like the transitions, add them to your website too: &lt;a href="https://github.com/framer/motion"&gt;Framer Motion on Github&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>win</category>
      <category>done</category>
      <category>nextjs</category>
      <category>transition</category>
    </item>
    <item>
      <title>🤦‍♂️ Weekly fail (40/2020)</title>
      <dc:creator>Ondrej Polesny</dc:creator>
      <pubDate>Tue, 29 Sep 2020 08:05:53 +0000</pubDate>
      <link>https://forem.com/kontent_ai/weekly-fail-40-2020-1km4</link>
      <guid>https://forem.com/kontent_ai/weekly-fail-40-2020-1km4</guid>
      <description>&lt;p&gt;Last few weeks I've been working on converting a &lt;a href="https://www.gatsbyjs.com/starters/alxshelepenok/gatsby-starter-lumen"&gt;Gatsby Lumen&lt;/a&gt; sample site to &lt;a href="https://gridsome.org/"&gt;Gridsome&lt;/a&gt; during live &lt;a href="https://www.youtube.com/watch?v=M178GCJnvKs&amp;amp;list=PLZzkyDUUmn_J_9jLG120URla14RDNQYjO&amp;amp;index=7"&gt;YouTube streams&lt;/a&gt;. I stumbled upon a problem when resolving rich text data and images. The images were just not showing up.&lt;/p&gt;

&lt;p&gt;So I used one of my &lt;em&gt;innovation&lt;/em&gt; days to try and debug the Gridsome source plugin for Kontent. I succeeded in finding the issue! This made me so happy that I immediately wanted to add it as an issue to the plugin repository. So I opened the &lt;a href="https://github.com/CMeeg/gridsome-source-kentico-kontent"&gt;plugin repository&lt;/a&gt; on GitHub only to find out someone has &lt;a href="https://github.com/CMeeg/gridsome-source-kentico-kontent/issues/15"&gt;already done that&lt;/a&gt; half a year ago. 🤦‍♂️&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Lesson learned:&lt;/em&gt; &lt;strong&gt;Always check Issues on GitHub before debugging.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But I didn't let this fail win. I went ahead and posted a &lt;a href="https://github.com/CMeeg/gridsome-source-kentico-kontent/pull/19"&gt;pull request&lt;/a&gt; with a workaround! 💪&lt;/p&gt;

</description>
      <category>fail</category>
      <category>lessonslearned</category>
      <category>github</category>
      <category>issue</category>
    </item>
    <item>
      <title>🤦‍♂️ Weekly fail (37/2020)</title>
      <dc:creator>Ondrej Polesny</dc:creator>
      <pubDate>Tue, 08 Sep 2020 11:10:14 +0000</pubDate>
      <link>https://forem.com/kontent_ai/weekly-fail-37-2020-15ok</link>
      <guid>https://forem.com/kontent_ai/weekly-fail-37-2020-15ok</guid>
      <description>&lt;p&gt;Last week I was converting a Gatsby Lumen starter website to Gridsome and got stuck on an error&lt;br&gt;
&lt;code&gt;Error: Cannot get field 'id' from type 'Page'. Field does not exist.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The error occurred only in case a certain page was published in &lt;a href="https://bit.ly/2GAC6tP"&gt;the headless CMS Kentico Kontent&lt;/a&gt; and it was happening in the GraphQL schema generation. So it was quite difficult to debug.&lt;/p&gt;

&lt;p&gt;I tried the try/fail method of debugging only to find out you can't use "Page" as a type name for your nodes. Not sure what the reason is as I was not willing to keep digging after several hours of nail-biting.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Lesson learned:&lt;/em&gt; &lt;strong&gt;Sometimes the tools we use don't have everything documented. If you're experiencing the above error, add a prefix to content item types in the configuration of the Gridsome Kontent plugin:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;
  &lt;span class="nx"&gt;contentItemConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;contentItemTypeNamePrefix&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;_&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>fail</category>
      <category>lessonslearned</category>
      <category>gridsome</category>
      <category>type</category>
    </item>
    <item>
      <title>🤦‍♂️ Weekly fail (35/2020)</title>
      <dc:creator>Ondrej Polesny</dc:creator>
      <pubDate>Tue, 25 Aug 2020 09:35:02 +0000</pubDate>
      <link>https://forem.com/kontent_ai/weekly-fail-35-2020-ao8</link>
      <guid>https://forem.com/kontent_ai/weekly-fail-35-2020-ao8</guid>
      <description>&lt;p&gt;While working on the styles of my site, I decided to hide a background video for mobile devices (bandwidth reasons). The video was placed in a wrapper to ensure it always occupies the whole available space.&lt;/p&gt;

&lt;p&gt;The problem was that later I could not get the video element to be displayed at all. I spent half an hour debugging in multiple browsers and still could not get the element to show up. I was on the edge of calling someone for help when I noticed this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FV8_WUPa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s15ovj1jxqbb4rmt9bu9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FV8_WUPa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s15ovj1jxqbb4rmt9bu9.png" alt="CSS hiding the wrapper element with display:none"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Lesson learned:&lt;/em&gt; &lt;strong&gt;Always pay attention to the most basic styles (often without any media query restriction) that are applied to parent elements and are hiding on the top of your stylesheet files.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>fail</category>
      <category>lessonslearned</category>
      <category>css</category>
      <category>responsive</category>
    </item>
  </channel>
</rss>
