<?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>DEV Community: Ineza Bonté Grévy</title>
    <description>The latest articles on DEV Community by Ineza Bonté Grévy (@inezabonte).</description>
    <link>https://dev.to/inezabonte</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%2F393135%2F2478242a-3cb4-445f-9be2-6f9bbe69bbac.jpeg</url>
      <title>DEV Community: Ineza Bonté Grévy</title>
      <link>https://dev.to/inezabonte</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/inezabonte"/>
    <language>en</language>
    <item>
      <title>Rebuilding My Blog: From Next.js to Astro</title>
      <dc:creator>Ineza Bonté Grévy</dc:creator>
      <pubDate>Fri, 24 May 2024 04:04:44 +0000</pubDate>
      <link>https://dev.to/inezabonte/rebuilding-my-blog-from-nextjs-to-astro-31pb</link>
      <guid>https://dev.to/inezabonte/rebuilding-my-blog-from-nextjs-to-astro-31pb</guid>
      <description>&lt;p&gt;For quite some time the thought of whether my site may be a bit too over-engineered lingered my mind. For a website that just displays blogs I definitely had a ton of javascript&lt;/p&gt;

&lt;p&gt;I've recently undertaken the task of rebuilding my site, transitioning from Next.js to Astro, and I couldn't be more pleased with the results. One of the most noticeable improvements is the significant reduction in JavaScript bloat. My pages are now much lighter and faster.&lt;/p&gt;

&lt;p&gt;With Next.js, I found myself incorporating more JavaScript than necessary, especially for a simple blog like mine. Switching to Astro allowed me to strip away the unnecessary JavaScript.&lt;/p&gt;

&lt;p&gt;This transition also reinforces a growing consensus: JavaScript has become one of the heaviest assets on the web today. By minimizing its usage, we can create faster, more efficient websites.&lt;/p&gt;

&lt;p&gt;To better illustrate the improvements, here are some screenshots of my site before and after the switch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Before (Next.js):&lt;br&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%2Ft9dpj99kawd8wexf0ht2.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%2Ft9dpj99kawd8wexf0ht2.png" alt="A before image showing networks logs with nextjs"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After (Astro):&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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%2Fgp3yrdvnqry2kcn89m75.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%2Fgp3yrdvnqry2kcn89m75.png" alt="An after image showing network logs after moving to astro"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>astro</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Notifications in progressive web apps using web push</title>
      <dc:creator>Ineza Bonté Grévy</dc:creator>
      <pubDate>Tue, 09 May 2023 17:29:46 +0000</pubDate>
      <link>https://dev.to/inezabonte/notifications-in-progressive-web-apps-using-web-push-593l</link>
      <guid>https://dev.to/inezabonte/notifications-in-progressive-web-apps-using-web-push-593l</guid>
      <description>&lt;p&gt;Notifications are an essential part of any web application. They help to keep users informed about important updates, events, and offers. In a Progressive Web App (PWA), notifications can be used to engage users and enhance their experience. In this article we'll go over the APIs depended on by PWAs and how to implement push notifications in your own web application. Let's get started!&lt;/p&gt;

&lt;p&gt;Notifications in PWAs depend on these 3 technologies in order to work.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Push_API"&gt;Push API&lt;/a&gt; - gives web applications the ability to receive messages pushed to them from a server, whether or not the web app is in the foreground, or even currently loaded, on a user agent&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/notification"&gt;Notifications API&lt;/a&gt; - allows web pages to control the display of system notifications to the end user. It is designed to be compatible with existing notification systems, across different platforms.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API"&gt;Service Workers&lt;/a&gt; - Service workers are special javascript files that act as proxies between web browsers and web servers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In addition to these 3 technologies we will also be using the &lt;a href="https://www.npmjs.com/package/web-push"&gt;web-push&lt;/a&gt; library. This library allows us to generate application server keys and it also abstracts all the complexity that comes with pushing data via the Web Push Protocol&lt;/p&gt;

&lt;p&gt;To send Notifications in a PWA there are several steps we have to go through to make it possible;&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature Detection
&lt;/h2&gt;

&lt;p&gt;It’s advisable to ensure that the necessary technologies are available in the user's browser before going any further. Specifically, we need to check for support of the Push API, the Notifications API, and Service Workers. If any of these features are not supported, we should provide a fallback experience or notify the user that notifications are not available.&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="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Notification&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Notification API isn't supported&lt;/span&gt;
&lt;span class="p"&gt;}&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="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;serviceWorker&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Service Workers aren't supported&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&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="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;PushManager&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Push API isn't supported&lt;/span&gt;
  &lt;span class="k"&gt;return&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;h2&gt;
  
  
  Register a service worker
&lt;/h2&gt;

&lt;p&gt;Registering a service worker is our way of telling the browser where the service worker file is. After registering a service worker the browser will give it access to service worker APIs including Push.&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;function&lt;/span&gt; &lt;span class="nf"&gt;registerServiceWorker&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="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;serviceWorker&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/worker.js&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="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;registration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Service worker successfully registered.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;registration&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;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&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;Unable to register service worker.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;err&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;h2&gt;
  
  
  Request Permission
&lt;/h2&gt;

&lt;p&gt;The next step would be to ask for permission from the user to display notifications. The &lt;code&gt;Notification.requestPermission()&lt;/code&gt; recently changed from using callbacks to promises that is why we cover both callbacks and promises in the example below (we never know which version of the api a browser implemented). &lt;/p&gt;

&lt;p&gt;The promise resolves to a string with the possible values being &lt;code&gt;granted&lt;/code&gt;, &lt;code&gt;denied&lt;/code&gt; or &lt;code&gt;default&lt;/code&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;function&lt;/span&gt; &lt;span class="nf"&gt;requestPermission&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="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;permissionResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Notification&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;requestPermission&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;result&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="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;});&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;permissionResult&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;permissionResult&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reject&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="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;permissionResult&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;permissionResult&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;granted&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="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&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;Permission denied&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="nf"&gt;subscribeUserToPush&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;You should only request consent to display notifications in response to a user gesture (e.g. clicking a button. This is the best practice. &lt;/p&gt;

&lt;h2&gt;
  
  
  Subscribe a user with PushManager
&lt;/h2&gt;

&lt;p&gt;After registering our service worker and getting user permission we can now subscribe the user to the Push API by calling &lt;code&gt;registration.pushManager.subscribe()&lt;/code&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="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;subscribeUserToPush&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;registration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;registerServiceWorker&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;subscribeOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;userVisibleOnly&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;applicationServerKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PUBLIC_VAPID_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;pushSubscription&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;registration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pushManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;subscribeOptions&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;axios&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/subscription&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pushSubscription&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;response&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&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;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;pushSubscription&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 the example above several things are happening:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We are calling the &lt;code&gt;registerServiceWorker()&lt;/code&gt; function for the second time, this is to activate the service worker. A service worker won't receive events like &lt;code&gt;fetch&lt;/code&gt; and &lt;code&gt;push&lt;/code&gt; until it successfully finishes installing and becomes "active".&lt;/li&gt;
&lt;li&gt;Within the &lt;code&gt;registration.pushManager.subscribe()&lt;/code&gt; function we are passing an object with two properties

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;userVisibleOnly&lt;/strong&gt; - A boolean that must be set to &lt;code&gt;true&lt;/code&gt; indicating that the user will be notified every time a push message is sent. Silent messages are not allowed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;applicationServerKey -&lt;/strong&gt; This is a public key generated in a pair along with a private key and are unique to your app. Application server keys otherwise knowns as VAPID keys are used by a push service to identify the application subscribing a user and ensure that the same application is messaging that user. &lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt;After subscribing the user we get a subscription object that we can then send to our server to save in our database. This subscription is what we will be using to send push messages from the server. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is an example of what the subscription object looks like.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"endpoint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://some.pushservice.com/something-unique"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"keys"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"p256dh"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"CeXl1dn18gSJ1WAkAPIxr4gK0_dQds4yiI="&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"auth"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"QyGdcjWInHVndSTdbKFw=="&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Send messages from server
&lt;/h2&gt;

&lt;p&gt;After saving a client's push subscription we are now ready to send messages with &lt;a href="https://www.npmjs.com/package/web-push"&gt;web-push&lt;/a&gt; library. Since web-push is a node library this part of the application will be implemented on the server. Frameworks like Next and Gatsby allow you to create api routes which are easy to configure.&lt;/p&gt;

&lt;p&gt;We start by adding our vapid keys to web-push along with a &lt;code&gt;mailto:&lt;/code&gt; string. The string can be a mailto email address or a URL. This is done so that if the push service needs to get in contact with the sender, they have information that enables them to.&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;webpush&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;web-push&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;vapidKeys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PUBLIC_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;privateKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PRIVATE_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;webpush&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setVapidDetails&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mailto:ineza@ineza.codes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;vapidKeys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;publicKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;vapidKeys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;privateKey&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&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;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;subscription&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;dataToSend&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;webpush&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendNotification&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;subscription&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dataToSend&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
      &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Notification sent!&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="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;err&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Method not allowed&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;Through the api route we created above, we are able to receive the subscription that we saved somewhere (a database for example) alongside the message we would like to send to the user. Using the &lt;code&gt;sendNotification()&lt;/code&gt; method from web-push we are able to send our request.&lt;/p&gt;

&lt;h2&gt;
  
  
  Display Notification
&lt;/h2&gt;

&lt;p&gt;Inside our Service worker we add a push event listener that listens for the &lt;code&gt;push&lt;/code&gt; event. We need to display the notification to the user, and to tell the event to wait until the browser has shown it before the function can terminate. In the code snippet below we are using the Notification API to display notifications to the user’s device.&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="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;push&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&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="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;promiseChain&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;registration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;showNotification&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;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;body&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;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;icon&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/icons/manifest-icon-192.maskable.png&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;badge&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/icons/badge_72x72.png&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;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;waitUntil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;promiseChain&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 extend the event lifetime until the browser has done displaying the notification (until the promise has been resolved), otherwise the Service Worker could be stopped in the middle of your processing.&lt;/p&gt;

&lt;p&gt;And there you go. Your notifications are ready to go. 🙂&lt;/p&gt;

&lt;p&gt;If you are looking to learn more or dive deeper into this topic. I highly recommend the &lt;a href="https://web.dev/push-notifications-overview/"&gt;Push Notification overview&lt;/a&gt; by web.dev&lt;/p&gt;

&lt;h3&gt;
  
  
  NB
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;As of March 27th &lt;a href="https://webkit.org/blog/13966/webkit-features-in-safari-16-4/"&gt;Web Push is now supported in WebKit&lt;/a&gt; in Safari 16.4. At the time of writing the features are still experimental, so you have to dig into Safari settings to enable the Push and Notification APIs. Also worth noting that push notifications are supported in apps that are added to the Home screen.&lt;/li&gt;
&lt;li&gt;It should also be noted that the &lt;code&gt;Notification.requestPermission()&lt;/code&gt; is available only in secure contexts (HTTPS).&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>node</category>
      <category>webpush</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Setting up a MySQL database using Prisma</title>
      <dc:creator>Ineza Bonté Grévy</dc:creator>
      <pubDate>Sun, 31 Oct 2021 20:20:25 +0000</pubDate>
      <link>https://dev.to/inezabonte/setting-up-a-mysql-database-using-prisma-2869</link>
      <guid>https://dev.to/inezabonte/setting-up-a-mysql-database-using-prisma-2869</guid>
      <description>&lt;h2&gt;
  
  
  What is Prisma?
&lt;/h2&gt;

&lt;p&gt;Prisma is an open-source Node.js and Typescript ORM (Object Relational Mapper) it acts as a sort of middleware between your application and the database helping you to manage and work with your database. It currently supports PostgreSQL, MySQL, SQL Server, SQLite and some of its features also support MongoDB.&lt;/p&gt;

&lt;p&gt;I was recently tasked with setting up a MySQL database with a Next.js application. My goal was to connect the database using Next.js’ serverless capabilities.&lt;/p&gt;

&lt;p&gt;Below are the steps I followed to achieve that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install and invoke Prisma
&lt;/h2&gt;

&lt;p&gt;In order to use Prisma in a project, first install its CLI as a dev dependency.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;prisma &lt;span class="nt"&gt;--save-dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next step is to initialize Prisma. You only need to do this once during the setup process.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx prisma init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, the Prisma CLI created some files in your root directory. The &lt;code&gt;schema.prisma&lt;/code&gt; file in the &lt;code&gt;prisma&lt;/code&gt;folder is where we define our datasource provider and the schema of the tables in our database. However if you already have an existing database, you don’t need to create a schema from scratch, cause Prisma handles that for you 😉. I’ll show you how shortly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect to the database
&lt;/h2&gt;

&lt;p&gt;The first step is to modify the datasource provider in the &lt;code&gt;schema.prisma&lt;/code&gt; file to look like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I set &lt;code&gt;provider&lt;/code&gt; to the type of database I’m using. In my case it’s &lt;code&gt;mysql&lt;/code&gt;. The &lt;code&gt;url&lt;/code&gt; property will take the value of the connection url which is defined in the &lt;code&gt;.env&lt;/code&gt;file created by Prisma.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DATABASE_URL="mysql://USER:PASSWORD@HOST:PORT/DATABASE"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above is the format of how to write your connection url.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generate data models
&lt;/h2&gt;

&lt;p&gt;The next step is to generate the data models/schema. How this happens is; Prisma uses the connection url you provided to connect to the database. Prisma and the database have a short chat, then Prisma comes back with models of your database’s structure i.e data types, relationships and whatever else it needs to know about your database 😄&lt;/p&gt;

&lt;p&gt;To do this we run the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx prisma db pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the command has run successfully Prisma will generate models from MySQL into Prisma data model which is saved in the &lt;code&gt;prisma.schema&lt;/code&gt; file. If the Prisma schema is new to you, have a look at their &lt;a href="https://www.prisma.io/docs/concepts/components/prisma-schema/data-model"&gt;documentation&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Read data from the database
&lt;/h2&gt;

&lt;p&gt;In order to perform CRUD (Create, Read, Update, Delete) operations with Prisma we need to install the &lt;code&gt;@prisma/client&lt;/code&gt; package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; @prisma/client
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a Prisma instance
&lt;/h3&gt;

&lt;p&gt;After installing the package the next important step is to create a single Prisma instance that will be imported wherever we need to use it. The reason we need a single instance is because every time we initialize Prisma client in a file it creates a connector to the database, if initialized in multiple files it could exhaust the database connection limit.&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;// utils/prisma.js&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;PrismaClient&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@prisma/client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;;&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;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NODE_ENV&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;production&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;prisma&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PrismaClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// `stg` or `dev`&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&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;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prisma&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PrismaClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;prisma&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Fetch data from the database
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;N/B&lt;/strong&gt; Prisma Client works from the backend so we have to call it from a serverless function or a Nodejs application.&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;// /pages/api/fetchUsers.js&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;../../utils/prisma&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findMany&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&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;Above is a simple example of fetching all records from the users table. I start by calling the prisma instance followed by the table name and finally the function I’d like to run.&lt;/p&gt;

&lt;p&gt;Super easy and clean compared to writing raw sql queries. You can learn more prisma functions by looking at their docs which I have included in the reference section below.&lt;/p&gt;

&lt;p&gt;I tested the above with Next.js api routes, however the same can be applied to Gatsby serverless functions or a Nodejs application..&lt;/p&gt;

&lt;p&gt;Thank you for reading ❤️&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.prisma.io/docs/concepts/components/prisma-client/crud"&gt;CRUD operations with prisma client&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/prisma/prisma/issues/5007#issuecomment-618433162"&gt;Invoking a single prisma instance&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.prisma.io/docs/getting-started/setup-prisma/add-to-existing-project"&gt;Add Prisma to an existing project&lt;/a&gt;&lt;/p&gt;

</description>
      <category>prisma</category>
      <category>serverless</category>
      <category>nextjs</category>
    </item>
    <item>
      <title>Introduction to Open Graph Meta tags</title>
      <dc:creator>Ineza Bonté Grévy</dc:creator>
      <pubDate>Sat, 17 Jul 2021 11:14:55 +0000</pubDate>
      <link>https://dev.to/inezabonte/introduction-to-open-graph-meta-tags-49l8</link>
      <guid>https://dev.to/inezabonte/introduction-to-open-graph-meta-tags-49l8</guid>
      <description>&lt;h3&gt;
  
  
  What are Open Graph meta tags?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="~https://ogp.me/~"&gt;Open Graph&lt;/a&gt; is a an internet protocol that was developed by Facebook &lt;br&gt;
back in 2010. They allow you to control what is displayed when a url of your page&lt;br&gt;
is shared on social media networks like Twitter, Facebook, LinkedIn, etc.&lt;/p&gt;
&lt;h3&gt;
  
  
  Basics of Open Graph
&lt;/h3&gt;

&lt;p&gt;The four basic properties used are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;og:title&lt;/code&gt; - The title of the content on the page&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;og:description&lt;/code&gt; - A description of the content on the page you are sharing&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;og:image&lt;/code&gt; - An image url which will be used to represent your content&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;og:url&lt;/code&gt; - The url of the current page&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;og:type&lt;/code&gt; - The type of page you are describing e.g. article, website&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: For the images; the minimum recommended dimensions are 1200 x 630 for optimal clarity across different platforms and devices.  &lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Usage
&lt;/h3&gt;

&lt;p&gt;Open Graph meta tags are usually placed in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; section of a website.&lt;br&gt;
They are identified by the prefix  &lt;code&gt;og:&lt;/code&gt; which is in the &lt;code&gt;property&lt;/code&gt; attribute of a meta tag accompanied by the &lt;code&gt;content&lt;/code&gt; attribute with a value.&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;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:title"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"TailwindCSS setup tutorial"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:type"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"article"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:url"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"https://url-of-currentpage.com"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:image"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"https://url-of-image.png"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:description"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"A description about your content"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UcLYZzhr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://res.cloudinary.com/tizzertuna/image/upload/v1626517824/Articles/Custom_Size_1_2x_n6emyb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UcLYZzhr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://res.cloudinary.com/tizzertuna/image/upload/v1626517824/Articles/Custom_Size_1_2x_n6emyb.png" alt="A screenshot of a link shred on twitter" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why should we use open graph tags?
&lt;/h3&gt;

&lt;p&gt;Their purpose is to make your content eye-catching at the same time providing an&lt;br&gt;
overview of the content the user should expect when they visit the url. This can help to&lt;br&gt;
grow your brand by increasing visibility.&lt;/p&gt;

&lt;h3&gt;
  
  
  Additional Social Media tags
&lt;/h3&gt;

&lt;p&gt;Some social media sites like twitter have their own open graph tags that help&lt;br&gt;
to customize the look of the content shared within their ecosystem.&lt;/p&gt;

&lt;p&gt;For instance Twitter has a &lt;code&gt;twitter:card&lt;/code&gt; property which can be used to&lt;br&gt;
specify the type of card twitter uses to display your content. It takes the following&lt;br&gt;
values;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;summary&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;summary_large_image&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;app&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;player&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also has the &lt;code&gt;twitter:creator&lt;/code&gt; property which can be used to specify&lt;br&gt;
the username of the content creator/author&lt;/p&gt;

&lt;p&gt;Here is a &lt;a href="https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started"&gt;link&lt;/a&gt; to the documentation with more details.&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing Open Graph tags
&lt;/h3&gt;

&lt;p&gt;There are tools available that can help you test your url, to know&lt;br&gt;
whether the Open Tags are working and also get a preview of how they &lt;br&gt;
will look once posted on social media.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://cards-dev.twitter.com/validator"&gt;Twitter Card Validator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.linkedin.com/post-inspector/inspect/"&gt;LinkedIn Post Inspector&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;p&gt;For more information about Open Graph meta tags here is a list of resources&lt;br&gt;
that helped me in the writing of this article.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://ogp.me/"&gt;The Open Graph protocol&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ahrefs.com/blog/open-graph-meta-tags/"&gt;Open Graph Meta Tags: Everything You Need to Know&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.computerhope.com/jargon/o/open-graph.htm"&gt;What is Open Graph?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.freecodecamp.org/news/what-is-open-graph-and-how-can-i-use-it-for-my-website/"&gt;What is Open Graph and how can I use it for my website?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thank you for reading ❤️&lt;/p&gt;

</description>
      <category>opengraph</category>
    </item>
    <item>
      <title>How to use the tailwindcss/typography plugin</title>
      <dc:creator>Ineza Bonté Grévy</dc:creator>
      <pubDate>Sat, 05 Jun 2021 13:50:27 +0000</pubDate>
      <link>https://dev.to/inezabonte/how-to-use-the-tailwindcss-typography-plugin-3ogo</link>
      <guid>https://dev.to/inezabonte/how-to-use-the-tailwindcss-typography-plugin-3ogo</guid>
      <description>&lt;p&gt;I recently came across the &lt;a href="https://github.com/tailwindlabs/tailwindcss-typography"&gt;tailwindcss-typography&lt;/a&gt;.&lt;br&gt;
This plugin provides a beautiful set of &lt;code&gt;prose&lt;/code&gt; classes which you can use to add styling to HTML that you have no control of (such as rendered HTML from Markdown).&lt;/p&gt;

&lt;p&gt;This article assumes you have basic knowledge in TailwindCSS. If you are new to TailwindCSS you can have a look at their &lt;a href="https://tailwindcss.com/docs/installation"&gt;installation guide&lt;/a&gt;&lt;br&gt;
and here is a great course from &lt;a href="https://scrimba.com/learn/tailwind"&gt;Scrimba&lt;/a&gt; that can help you learn the basics.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Install the tailwindcss/typography plugin
&lt;/h3&gt;

&lt;p&gt;To install the plugin you can either use yarn or npm&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; @tailwindcss/typography

&lt;span class="c"&gt;#or&lt;/span&gt;

yarn add @tailwindcss/typography
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Add the plugin to your tailwind config file
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// tailwind.config.js&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;purge&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
  &lt;span class="na"&gt;darkMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;extend&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="na"&gt;variants&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;extend&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="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@tailwindcss/typography&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;h3&gt;
  
  
  Add prose class to your html
&lt;/h3&gt;

&lt;p&gt;Start by adding the base &lt;code&gt;prose&lt;/code&gt; class then followed by the size-modifiers for example  &lt;code&gt;prose-sm&lt;/code&gt;,  &lt;code&gt;prose-lg&lt;/code&gt;,  &lt;code&gt;prose-xl&lt;/code&gt; and &lt;code&gt;prose-2xl&lt;/code&gt;.&lt;br&gt;
Without the base &lt;code&gt;prose&lt;/code&gt; class it will not work.&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;article&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"prose prose-lg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
    Pellentesque nec lacued eu odio nec nisl varius placerat. 
    In dapibus a lacus vitae fringilla.
    &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    Donec condimentum tellus augue, eu lacinia est facilisis eu.
    Suspent ipPris a, cursus augue. Sed vitae dictum diam, id interdum ex.
    &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    Nunc in nunc sed urna congue facilisis. In ullamcorper,
    nunc eget convallis imperdiet, quam felis rhoncus leo, id rhoncus erat leo vel 
    &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/article&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that’s pretty much it. You will now have styled content and not have to worry about styling each element individually.&lt;/p&gt;

&lt;p&gt;Here is a live &lt;a href="https://tailwindcss-typography.netlify.app/"&gt;demo&lt;/a&gt; of content that is styled using this plugin.&lt;/p&gt;

&lt;p&gt;Thank you for reading ❤️&lt;/p&gt;

</description>
      <category>tailwindcss</category>
    </item>
    <item>
      <title>Sorting RSS feeds by year using Next.js</title>
      <dc:creator>Ineza Bonté Grévy</dc:creator>
      <pubDate>Sun, 23 May 2021 22:40:00 +0000</pubDate>
      <link>https://dev.to/inezabonte/sorting-rss-feeds-by-year-using-next-js-36gl</link>
      <guid>https://dev.to/inezabonte/sorting-rss-feeds-by-year-using-next-js-36gl</guid>
      <description>&lt;p&gt;One of the &lt;a href="https://github.com/inezabonte/inezabonte/issues/81"&gt;issues&lt;/a&gt; I created for my portfolio’s repo was to sort my blog feeds according to the year they were created in.&lt;/p&gt;

&lt;p&gt;The inspiration came from &lt;a href="https://www.taniarascia.com/blog"&gt;Tania Rascia's&lt;/a&gt; blog section which is one of the most impressive portfolios I've come across. &lt;/p&gt;

&lt;p&gt;Assuming you already have your project setup. I'll skip right to the essential steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Create a function to parse your RSS feed
&lt;/h2&gt;

&lt;p&gt;To parse RSS feeds we will make use of the &lt;a href="https://www.npmjs.com/package/rss-parser"&gt;rss-parser&lt;/a&gt; library. For this I'll be using dev.to’s RSS feed which you can get by using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://dev.to/feed/{username}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We start by importing the parsing library and then we create a function whose work will be to parse the RSS feed and return the results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// lib/rss.js&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Parser&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rss-parser&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getFeed&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;parser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Parser&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parseURL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://dev.to/feed/inezabonte&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;h2&gt;
  
  
  2. Create a getStaticProps function
&lt;/h2&gt;

&lt;p&gt;In the &lt;code&gt;pages/blog.js&lt;/code&gt; page we add the &lt;code&gt;getStaticProps()&lt;/code&gt; function to fetch our articles. It will be using the exported function we just created above.&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;// pages/blog.js&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getFeed&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;..lib/rss.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;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getStaticProps&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;detailedFeed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;getFeed&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;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;detailedFeed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;revalidate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;60&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;After fetching the articles we return them inside the props object which will add them to the default export of the &lt;code&gt;/blog.js'&lt;/code&gt; file. The purpose of &lt;code&gt;revalidate&lt;/code&gt; is to regenerate the page after the time given (in seconds). In our case after 60 seconds the page will regenerate. This could be useful if your RSS feed or API gets new data frequently, which you want to add on the website to keep it updated.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Get available years
&lt;/h2&gt;

&lt;p&gt;The next step is to get the span of years across which our articles have been written. We will store the available years as strings in an 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="c1"&gt;// pages/blog.js&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getFeed&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;..lib/rss.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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;format&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;date-fns&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Blog&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;years&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;uniqueYear&lt;/span&gt;&lt;span class="p"&gt;;&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;items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&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="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&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;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;isoDate&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;y&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="nx"&gt;years&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nx"&gt;uniqueYear&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;years&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="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getStaticProps&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;



&lt;p&gt;I make use of the &lt;code&gt;format&lt;/code&gt; method from the &lt;a href="https://www.npmjs.com/package/date-fns"&gt;date-fns&lt;/a&gt; library to extract the year from the date on which the article was created.&lt;/p&gt;

&lt;p&gt;Since this is a loop. It will basically run through all the articles' &lt;code&gt;isoDate&lt;/code&gt; property and extract the year. Articles created in the same year might have their year added more than once. This introduces duplicates in the array. To prevent this we convert the array of duplicate years to a &lt;code&gt;Set&lt;/code&gt;. This will implicitly remove duplicate elements then convert back to an array.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Filter and render the blog articles
&lt;/h2&gt;

&lt;p&gt;After obtaining the years, we then map them and use the year element to filter the &lt;code&gt;items&lt;/code&gt; array for articles that belong to that specific year.&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;// pages/blog.js&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getFeed&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;..lib/rss.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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;format&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;date-fns&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Blog&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;years&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;uniqueYear&lt;/span&gt;&lt;span class="p"&gt;;&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;items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&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="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&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;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;isoDate&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;y&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;years&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nx"&gt;uniqueYear&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;years&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;&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="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;uniqueYear&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;year&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="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;h2&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;year&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;/h2&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;
                    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isoDate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;article&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="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="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* display data from article */&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="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="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="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getStaticProps&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c1"&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 can then go ahead and render data for each of your articles depending on what you want to show. &lt;/p&gt;

&lt;p&gt;I managed to solve the issue on &lt;a href="https://ineza.codes/blog"&gt;my portfolio&lt;/a&gt;. You can view my code on my &lt;a href="https://github.com/inezabonte/inezabonte"&gt;GitHub repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Thank you for reading ❤️. Feel free to leave any suggestions as to how you would have approached this issue. If you have a question as well feel free to leave it in the comment section below.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>rss</category>
    </item>
    <item>
      <title>How to make your footer stay at the bottom of the page.</title>
      <dc:creator>Ineza Bonté Grévy</dc:creator>
      <pubDate>Sun, 09 May 2021 10:30:28 +0000</pubDate>
      <link>https://dev.to/inezabonte/how-to-make-footer-stay-at-the-bottom-298b</link>
      <guid>https://dev.to/inezabonte/how-to-make-footer-stay-at-the-bottom-298b</guid>
      <description>&lt;p&gt;I recently met an issue with positioning a footer. After finding a solution, I decided to document it in this post.&lt;/p&gt;

&lt;p&gt;Our goal is to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make the footer stay at the bottom even when the content is not filling the screen.&lt;/li&gt;
&lt;li&gt;Make the footer appear at the end of the document when the screen is full of content (instead of overlapping the bottom section)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  1. Give your container a min-height of 100vh
&lt;/h4&gt;

&lt;p&gt;The body tag which holds your content should be given a minimum height of 100vh. This will ensure that the body will always take full height of the page even when its content is not filling the page. You can apply this to the body or the container which has the footer as the last tag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&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;h4&gt;
  
  
  2. Make your body a flexbox
&lt;/h4&gt;

&lt;p&gt;Make your body a flexbox by giving it a &lt;code&gt;display&lt;/code&gt; property with the value of &lt;code&gt;flex&lt;/code&gt; and also change its direction by using &lt;code&gt;flex-direction&lt;/code&gt; set to column&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;flex-direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;column&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;h4&gt;
  
  
  3. Give the footer a margin-top of auto
&lt;/h4&gt;

&lt;p&gt;Assuming your body has a similar layout to this;&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;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;header&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/header&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;main&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/main&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can give your footer tag a &lt;code&gt;margin-top&lt;/code&gt; property with the value of &lt;code&gt;auto&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;footer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&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 three simple steps :)&lt;/p&gt;

&lt;p&gt;Thank you for reading this article ♥️. Feel free to ask any questions you may have down below and I'll get back to you.&lt;/p&gt;

</description>
      <category>css</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How to get GitHub notifications on your Discord server.</title>
      <dc:creator>Ineza Bonté Grévy</dc:creator>
      <pubDate>Sat, 01 May 2021 12:52:00 +0000</pubDate>
      <link>https://dev.to/inezabonte/how-to-get-github-notifications-on-your-discord-server-2j9o</link>
      <guid>https://dev.to/inezabonte/how-to-get-github-notifications-on-your-discord-server-2j9o</guid>
      <description>&lt;p&gt;GitHub provides us with a way to allow other applications such as discord to connect it and receive POST requests whenever any action is done on your repository. &lt;/p&gt;

&lt;p&gt;This can be useful if you find the email notifications not as instant as you'd want them to be.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You need to have a GitHub account with a repository.&lt;/li&gt;
&lt;li&gt;You need to have a discord server where we will add the webhook.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1. Create the webhook
&lt;/h3&gt;

&lt;p&gt;A webhook is basically a link that will allow other applications to post into discord.&lt;br&gt;
To create a webhook, head into your &lt;code&gt;server settings&lt;/code&gt; =&amp;gt; &lt;code&gt;integrations&lt;/code&gt; =&amp;gt; &lt;code&gt;New webhook&lt;/code&gt;&lt;br&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%2Fks08crvkapm0zzdke827.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%2Fks08crvkapm0zzdke827.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
You can give your webhook a name and also choose which channel it will be posting to. You can click on &lt;code&gt;Copy Webhook URL&lt;/code&gt; to copy the link which we are going to use on our GitHub repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Add Discord webhook to GitHub
&lt;/h3&gt;

&lt;p&gt;After creating the webhook the next thing is to add it to your github repository from which you would like to get notifications.&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%2Fgedao8zfs6gsagk4d6nb.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%2Fgedao8zfs6gsagk4d6nb.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Head over to your repo then &lt;code&gt;settings&lt;/code&gt; =&amp;gt; &lt;code&gt;Webhooks&lt;/code&gt; =&amp;gt; &lt;code&gt;Add webhook&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Paste the link we copied earlier from discord  in the &lt;code&gt;Payload URL&lt;/code&gt; and make sure to add &lt;code&gt;/github&lt;/code&gt; at the end or it will not work.&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%2F7rl3nyalji68p6ku8s2p.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%2F7rl3nyalji68p6ku8s2p.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Set the &lt;code&gt;Content type&lt;/code&gt; to &lt;code&gt;application/json&lt;/code&gt; and finally choose the events which should trigger the webhook. Personally, I want everything. &lt;/p&gt;

&lt;p&gt;After you are done you can click the green button at the bottom labeled &lt;code&gt;Add webhook&lt;/code&gt; to complete the process.&lt;/p&gt;

&lt;p&gt;If you have done it correctly you should receive a similar notification to this;&lt;br&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%2Fw5zjnmz8qm2f4n0c04qm.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%2Fw5zjnmz8qm2f4n0c04qm.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Test the webhook
&lt;/h3&gt;

&lt;p&gt;To test the webhook we can perform a simple action such as creating an issue on the repo which we just added the webhook.&lt;br&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%2F3lu23pr35fzd0uhkff0f.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%2F3lu23pr35fzd0uhkff0f.png" alt="A screenshot of creating a test issue"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon creating the issue. You should immediately receive a notification from discord on whatever device you have installed it on.&lt;br&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%2Fhkpkhejr84npp7sj37aw.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%2Fhkpkhejr84npp7sj37aw.png" alt="Screen Shot 2021-05-01 at 13.50.28"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It will work the same way when pushing commits, creating PRs ...etc&lt;/p&gt;

&lt;p&gt;Thank You for reading❤️. If you have any questions feel free to drop them in the comments section below and I'll be glad to answer them.&lt;/p&gt;

</description>
      <category>github</category>
      <category>tutorial</category>
      <category>webhooks</category>
      <category>discord</category>
    </item>
    <item>
      <title>My journey so far in web development.</title>
      <dc:creator>Ineza Bonté Grévy</dc:creator>
      <pubDate>Thu, 15 Apr 2021 15:31:26 +0000</pubDate>
      <link>https://dev.to/inezabonte/my-journey-so-far-in-web-development-3d68</link>
      <guid>https://dev.to/inezabonte/my-journey-so-far-in-web-development-3d68</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;It's been a year since I got into web development. It has been a heck of a journey, learning new technology, meeting people with similar ambitions and goals.&lt;/p&gt;

&lt;p&gt;I decided to write this blog post as a reflection as to how I got here and hopefully inspire someone who may be considering starting to code&lt;/p&gt;

&lt;p&gt;Learning to code is definitely not easy. With so many resources one can be confused as to where to start from. I can testify to this because it personally took me a couple of years😅 to make up my mind as to which direction I wanted to take.&lt;/p&gt;

&lt;p&gt;It's never too late to start coding so, take your time and understand the options you have. You can even try a few of them and see which ones you like then identify one that you would be comfortable working in long term.&lt;/p&gt;

&lt;p&gt;One thing you should beware of is, the biased opinions people may have towards certain frameworks or languages. It's always best to try it out yourself and see if you like it and if you do go ahead with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it started 🚀
&lt;/h2&gt;

&lt;p&gt;Towards the end of March 2020, the spread of COVID had forced many institutions to close and cities to go under lockdown, and that's when I took the initiative of learning JavaScript. I started off with a friend of mine (&lt;a href="https://twitter.com/zadock_254"&gt;@zadock&lt;/a&gt;) and we committed ourselves to #100DaysfCode. &lt;/p&gt;

&lt;p&gt;The daily challenges we did came from sites such as &lt;a href="https://www.codewars.com/"&gt;CodeWars&lt;/a&gt; and &lt;a href="https://edabit.com/"&gt;Edabit&lt;/a&gt; which helped quite a lot in understanding the syntax of JavaScript.&lt;/p&gt;

&lt;p&gt;At around 60 days into the challenges we decided to go bigger and start working on larger projects which of course were taking more than a day to complete, nevertheless they were essential in helping us test our skills in coding and in the process we got to learn a lot from the projects.&lt;/p&gt;

&lt;p&gt;Some of the projects we worked on are a &lt;a href="https://inezaweatherapp.vercel.app/"&gt;Weather App&lt;/a&gt; and also a Twitter bot which is probably the first Nodejs Application I worked on.&lt;/p&gt;

&lt;p&gt;After completing 100 Days. I had developed a deeper understanding in JavaScript and was motivated to keep growing and learning.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lessons I learnt ✍🏽
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Help others grow&lt;/strong&gt;&lt;br&gt;
When you share your work publicly there is a high chance that it could help someone else who may be learning the similar topic. My good friend &lt;a href="https://layer8.space/@RyunoKi"&gt;André Jaenisch&lt;/a&gt; always emphasizes on documenting your learning. It could be through a blog or youtube channel where you breakdown what you have learnt or what problem you faced and how you were able to solve it. This will help you retain what you learnt and you will always have a reference to look at if you ever run into the same issue.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The basics are enough to get you started&lt;/strong&gt;&lt;br&gt;
A question I often get from friends who are starting out in coding is "How long will it take me to learn x?" The answer is that it depends on the learner. We all have different methods that we use when learning, some may be quick and others may be slow and also most of these languages are always evolving, aiming to learn a language 100% is quite unnecessary😅. You may find yourself rarely using some of the features these languages have to offer. &lt;br&gt;
The best advice I'd give is, understand the basics of the language/framework and apply whatever you learned on projects and that will help you gain a deeper understanding on what you are working with. When you come across a new term you can always look it up and you will find so many resources online explaining it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Getting help on blockers&lt;/strong&gt;&lt;br&gt;
Whenever you run into an error, it's always a good practice to try and figure it out yourself before asking for help. Most of the time if you copy and paste the error in your search engine you will most likely find the first link going to StackOverFlow or another website where someone found the solution to your problem.&lt;br&gt;
If it seems quite difficult you can then ask for assistance followed by stating the different methods that you tried in solving the issue. This will help whoever is assisting you to get a background on the problem and be in a better position to help you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Maintain a habit of coding regularly&lt;/strong&gt;&lt;br&gt;
Coding like any other skill you may want to learn requires you to do it regularly in order to get good at it. Basically practice makes perfect. And I believe that helped me a lot when I started learning JavaScript. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Take care of yourself&lt;/strong&gt;&lt;br&gt;
Your health contributes greatly to your performance as a developer. It should therefore be your first priority.&lt;br&gt;
As developers we often experience burnout, anxiety, fatigue or loss of motivation. This can be attributed to the fact that we spend so many hours on our computers without taking a break.&lt;br&gt;
It's a good practice to schedule time to relax away from the computer by doing some exercise, taking a walk or a fun activity to relax your mind.&lt;br&gt;
When you resume your work you will feel refreshed and motivated.&lt;/p&gt;

&lt;p&gt;This are some of the lessons I have learnt in my journey. Feel free to share yours in the comments below.&lt;/p&gt;

&lt;p&gt;Thank You for reading ❤️&lt;/p&gt;

</description>
      <category>devjournal</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Layers Of Web Development for beginners</title>
      <dc:creator>Ineza Bonté Grévy</dc:creator>
      <pubDate>Sat, 19 Sep 2020 08:27:22 +0000</pubDate>
      <link>https://dev.to/inezabonte/layers-of-web-development-for-beginners-2gab</link>
      <guid>https://dev.to/inezabonte/layers-of-web-development-for-beginners-2gab</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The development of websites consists of two main layers which are frontend and backend. Each layer has its purpose to fulfil and are both dependent on each other to produce a product which a user can interact with. My goal in this article is to expound on these two layers and their significance in the development of a website.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What is frontend?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Frontend also known as client side refers to what the user of your website sees and interacts with. This refers to things like forms, buttons, animations, menus and so on. &lt;/p&gt;

&lt;p&gt;The main objective when designing the frontend part of a website is to make sure that the website is user-friendly in terms of how the user will be interacting and accessing different components of your website. For example the use of background colours that are in contrast with the text in order to improve legibility&lt;/p&gt;

&lt;p&gt;It is also important to ensure that the website is responsive in order to improve user experience which will translate into a positive perception of your brand and business. &lt;/p&gt;

&lt;h4&gt;
  
  
  Frontend languages
&lt;/h4&gt;

&lt;p&gt;When designing the frontend part of a website there are three main languages which are commonly used i.e Html, css and Javascript&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%2Fi%2Flf5kno0q3bbiztrxvlm4.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%2Fi%2Flf5kno0q3bbiztrxvlm4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;HTML&lt;/strong&gt; &lt;br&gt;
HTML is the standard markup language for creating websites. It is used to describe the structure of your website. It's basically the skeleton of your website.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CSS&lt;/strong&gt;&lt;br&gt;
CSS is used to describe how the content in your HTML document will look like on a webpage. You can use it to define font-families, colours, animations and so much more.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;JavaScript&lt;/strong&gt;&lt;br&gt;
JavaScript is a scripting language that allows you to add functionality to your website. It is basically the brains of your website. It is in charge of dynamically updating the content of your website and other backend processes&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What is backend?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Backend development also known as server-side refers to the activities of a website that happen behind-the-scenes unseen by the user. &lt;/p&gt;

&lt;p&gt;It handles functions such as retrieving data from the database, updating data that has been modified, authentication of users when logging in and many other important tasks.&lt;/p&gt;

&lt;h4&gt;
  
  
  Backend languages
&lt;/h4&gt;

&lt;p&gt;Some of the languages that are used when working with the backend are Java, Python, Ruby, PHP. In the recent years JavaScript has become a commonly used language used in the backend through a runtime environment called &lt;code&gt;Node.js&lt;/code&gt;, Node.js allows us to execute JavaScript code outside the browser.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;NB: Node.js is not a framework nor is it a programming language. It is simply an environment that allows you to run JavaScript outside the browser.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Being able to use JavaScript both on frontend and backend has made the work of developers easier as they do not need to go through the stress of learning a new language and maintaining different codebases. This is why we have seen the use of Node.js increase among many web developers&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;How does it add up?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;As you begin your journey into web development you may wonder where you'll start or which areas will you concentrate on. A good rule of thumb would be to try both fields and see which one you prefer. &lt;/p&gt;

&lt;p&gt;If you feel you can handle both frontend and backend you can become what's called a &lt;code&gt;Fullstack&lt;/code&gt; developer. Which means that you are well equipped in both areas, thus giving you a higher bargaining power when looking for employment&lt;/p&gt;

&lt;p&gt;Thank You for reading this article😊. Feel free to leave your questions/comments in the Discussions section below, I'll be sure to respond to them.&lt;/p&gt;

</description>
      <category>beginners</category>
    </item>
    <item>
      <title>Introduction to Branches and Pull Requests for Beginners.</title>
      <dc:creator>Ineza Bonté Grévy</dc:creator>
      <pubDate>Sun, 23 Aug 2020 18:18:45 +0000</pubDate>
      <link>https://dev.to/inezabonte/introduction-to-branches-and-pull-requests-for-beginners-3kjc</link>
      <guid>https://dev.to/inezabonte/introduction-to-branches-and-pull-requests-for-beginners-3kjc</guid>
      <description>&lt;p&gt;Branches and pull requests are essential to the GitHub workflow, they help developers collaborate on projects simultaneously.&lt;br&gt;
If you’ve never heard of them that’s okay. My goal in this tutorial is to help you understand what they are and how they are used when working on repositories.&lt;/p&gt;
&lt;h3&gt;
  
  
  What are Branches?
&lt;/h3&gt;

&lt;p&gt;A branch simply put is an isolated environment that is created from the main branch.&lt;br&gt;
It allows you to experiment on new ideas or makes bug fixes without affecting the main branch or being affected by the changes committed by others.&lt;/p&gt;

&lt;p&gt;You can use branches to safely develop and test new features.&lt;br&gt;
When the features are ready, a &lt;code&gt;pull request&lt;/code&gt; is opened to review the changes you made before being approved and merged into the main branch.&lt;/p&gt;
&lt;h3&gt;
  
  
  What are pull requests?
&lt;/h3&gt;

&lt;p&gt;A pull request is a feature that allows you to inform others of the changes you’ve made to the repository through your branch.&lt;br&gt;
It allows you to share screenshots and general ideas or seek help when you’re stuck.&lt;/p&gt;

&lt;p&gt;A reviewer assigned to the pull request reviews the work you’ve done on your branch and they can get back to you either for more info or to point out a bug you may have missed.&lt;br&gt;
Once the pull request has been reviewed and approved, the branch is merged with the main default branch.&lt;/p&gt;
&lt;h3&gt;
  
  
  Creating a branch
&lt;/h3&gt;

&lt;p&gt;In order to create a branch. Open the repository on your computer and then open terminal or git cli and use the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git branch readme-edits
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;git branch&lt;/code&gt; is a git command used to create branches; This command creates a branch from the current branch you’re working from.&lt;/p&gt;

&lt;p&gt;It is followed by the name you’d like to assign your new branch. In this case I’ll call it &lt;code&gt;readme-edits&lt;/code&gt; since I want to edit the README.md file.&lt;br&gt;
Branch names cannot include spaces, the command will fail if you do so.&lt;/p&gt;
&lt;h3&gt;
  
  
  Switch to the branch
&lt;/h3&gt;

&lt;p&gt;To switch to the branch you just created use the command&lt;br&gt;
 &lt;code&gt;git checkout&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout readme-edits
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;git checkout&lt;/code&gt; is followed by the name of the branch you would like to switch to. If you want to confirm what branch you’re on, use the &lt;code&gt;git branch&lt;/code&gt; command.&lt;br&gt;
The branch highlighted in green with an asterisk is your current working branch.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6duBfcx1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://res.cloudinary.com/tizzertuna/image/upload/v1683934625/Articles/Screenshot_2023-05-12_at_19.36.25_zo5xua.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6duBfcx1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://res.cloudinary.com/tizzertuna/image/upload/v1683934625/Articles/Screenshot_2023-05-12_at_19.36.25_zo5xua.png" alt="Alt Text" width="800" height="259"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Commit changes
&lt;/h3&gt;

&lt;p&gt;Open the README.md file make some changes then save the file.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frfj10c5gf32pn1obreht.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frfj10c5gf32pn1obreht.png" alt="Alt Text" width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After editing the file, we can now push the new branch we just created to GitHub along with the changes  we just made to the README file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add the file to staging.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;git add README.md
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Commit the changes with a message&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Updated the readme file"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Push the changes to GitHub&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since we are pushing a new branch to the repo we will use the &lt;code&gt;--set-upstream&lt;/code&gt; flag to create a new branch on our &lt;code&gt;origin&lt;/code&gt; remote.&lt;br&gt;
Lastly we specify the name of the branch which should be the same as the one created locally.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;git push &lt;span class="nt"&gt;--set-upstream&lt;/span&gt; origin readme-edits
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;This command is used when pushing changes in a branch for the first time. You only need to set the upstream once, afterwards you can just use &lt;code&gt;git push&lt;/code&gt;.&lt;/p&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Opening a Pull Request
&lt;/h3&gt;

&lt;p&gt;After your changes have been pushed, open a pull request, so that the repository owner (in this case it’s you) can review your work and merge it with the main branch.&lt;/p&gt;

&lt;p&gt;In the top pane click on the &lt;code&gt;Pull requests&lt;/code&gt; tab.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqkd4k1zmmdgd6hnp3658.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqkd4k1zmmdgd6hnp3658.png" alt="Alt Text" width="800" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Immediately after opening you will receive a prompt to &lt;code&gt;Compare &amp;amp; pull request&lt;/code&gt; since GitHub has noticed new changes that are not in the main branch.&lt;br&gt;
Click on the &lt;strong&gt;Compare &amp;amp; pull request&lt;/strong&gt; button.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcx1869yt0cq9k5rmbqog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcx1869yt0cq9k5rmbqog.png" alt="Alt Text" width="800" height="89"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After clicking the button you will see the window below, here you can add a more in-depth explanation of the changes you made,&lt;br&gt;
you can also add images, emojis, links using &lt;a href="~https://www.markdownguide.org/getting-started/~"&gt;markdown&lt;/a&gt;.&lt;br&gt;
This will be visible to those reviewing your pull request. Finally click on &lt;code&gt;create pull request&lt;/code&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnhy06rwj3x84weptiife.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnhy06rwj3x84weptiife.png" alt="Alt Text" width="800" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you’ve created a pull requests, you are free to continue making more changes to the same branch and pushing them.&lt;br&gt;
All your commits to that branch will be added to the pull request, the changes made will be visible within the &lt;code&gt;Files changed&lt;/code&gt; tab.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Favfrvx0uo0ytyfhqbrda.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Favfrvx0uo0ytyfhqbrda.png" alt="Alt Text" width="800" height="526"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Merging a pull request
&lt;/h3&gt;

&lt;p&gt;Once your changes have been verified, you may merge them into your main branch. Click &lt;code&gt;Merge pull request&lt;/code&gt; then click &lt;code&gt;confirm merge&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Seeing the box down below confirms that it has been merged. You can also delete the branch as well.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv525w6itiuuk750x7grr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv525w6itiuuk750x7grr.png" alt="Alt Text" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Update your local setup
&lt;/h3&gt;

&lt;p&gt;Even though we have merged the branch on GitHub, locally the changes haven’t been updated.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;1. Switch to main branch&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout main
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;2. Pull in the changes from GitHub&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;git pull
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;3. Delete the merged branch locally&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Delete the branch locally using &lt;code&gt;git branch&lt;/code&gt; followed by the &lt;code&gt;-d&lt;/code&gt; flag and lastly the name of the branch to delete.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;git branch &lt;span class="nt"&gt;-d&lt;/span&gt; readme-edits
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are the basics you need to know when creating branches and opening pull requests.&lt;/p&gt;

&lt;p&gt;Thank You for Reading ❤️&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>github</category>
      <category>git</category>
    </item>
    <item>
      <title>How to Use GitHub and Git for Beginners</title>
      <dc:creator>Ineza Bonté Grévy</dc:creator>
      <pubDate>Sat, 15 Aug 2020 16:09:49 +0000</pubDate>
      <link>https://dev.to/inezabonte/how-to-use-github-and-git-for-beginners-5dm3</link>
      <guid>https://dev.to/inezabonte/how-to-use-github-and-git-for-beginners-5dm3</guid>
      <description>&lt;h1&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;If you are a beginner in the field of programming you must have come across the term &lt;code&gt;GitHub&lt;/code&gt; and &lt;code&gt;Git&lt;/code&gt; from blogs or even tutorials and wondered what they are🤔, in this blog I intend to explain them and hopefully you will get an idea of what they are and how they work.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What is GitHub?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;GitHub is a code hosting platform for &lt;code&gt;version control&lt;/code&gt; and &lt;code&gt;collaboration&lt;/code&gt;. Simply put, GitHub is a cloud storage platform like Google Drive or OneDrive but is built and centred around code.&lt;/p&gt;

&lt;p&gt;Apart from just storing your code. GitHub allows you to collaborate with other programmers on projects simultaneously and remotely making it accessible from anywhere in the world.&lt;/p&gt;

&lt;p&gt;In my intro I used the word &lt;code&gt;version control&lt;/code&gt;. And this is where Git comes in. GitHub not only just stores your code. It keeps track of every single change you make and commit, that way if you ever need to go back to a specific point in time of your project you can easily do so.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What is Git?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Git is a version control system(VCS), it is in charge of tracking your source code or files for any changes made during development. Git operates locally, therefore has to be installed and linked with your GitHub account through a remote in order for it to access your projects and update them accordingly.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Let's get started&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this tutorial I will teach you some of the basics you need when using Git or GitHub&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Create a repository on &lt;a href="https://github.com"&gt;GitHub&lt;/a&gt;.&lt;/strong&gt;&lt;br&gt;
Sign in into your account or create one if it's your first time. Click on the &lt;code&gt;+&lt;/code&gt; icon to create a new repository&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgym7lmubo8ixdvo0pjzu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgym7lmubo8ixdvo0pjzu.png" alt="A screenshot of GitHub" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Enter a name for your repository&lt;/strong&gt;. Use hyphens instead of spaces. You can add an optional Description as well. &lt;br&gt;
Check ✅ the &lt;code&gt;initialize this repository with a README&lt;/code&gt;. This will allow you to be able to download/clone the repository to your local computer.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs9rsnw0csp0e96nba799.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs9rsnw0csp0e96nba799.png" alt="creating a repository" width="800" height="552"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After that You will see your new repository with one file that is the README.md file. This file is mostly used when one wants to give more details or give instructions about their projects.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbl287dv215r91c2xd05a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbl287dv215r91c2xd05a.png" alt="Newly created repository" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Clone the repository to your computer&lt;/strong&gt;. To clone your repository. Click on the &lt;code&gt;code&lt;/code&gt; button. Copy the link of your project using the clipboard icon.
&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F53h2pzg7tj15eqed7nwe.png" alt="Alt Text" width="800" height="554"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Cloning a Repository with Git&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;To clone the repository to your computer. Open the terminal or git cli on your computer depending on what OS you use and run &lt;code&gt;git&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;git&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If the command is not recognised then download git from &lt;a href="https://git-scm.com"&gt;https://git-scm.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Navigate to the directory you would like to clone your project in and run &lt;code&gt;git clone&lt;/code&gt; followed by the link to your repository.&lt;br&gt;
&lt;code&gt;Example&lt;/code&gt;  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;git clone https://github.com/inezabonte/first-app.git&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh55swyn2abppchvdrocz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh55swyn2abppchvdrocz.png" alt="Alt Text" width="800" height="559"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Making a Commit&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Commits are snapshots of changes made to your project. Each change you commit is referenced with a unique alphanumeric code that can be used if you ever need to go back to a specific commit.&lt;/p&gt;

&lt;p&gt;In order to make changes to our repository. Open the cloned repository in a text editor and let's make some changes to our README file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5v6u4708ktijgiuc3dl7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5v6u4708ktijgiuc3dl7.png" alt="Alt Text" width="800" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After saving your changes, go back to terminal and navigate to your project. After that run;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;git status&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;git status&lt;/code&gt; shows us which files have been changed, which files are tracked, etc. As you can see below, it tells us that there is a file that has been &lt;code&gt;modified&lt;/code&gt; which is the README.md file&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcbl0jiaajrrska7c1zyr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcbl0jiaajrrska7c1zyr.png" alt="Alt Text" width="800" height="542"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Committing Changes&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In order to push our changes to GitHub, we need to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Stage Changes for commit&lt;/strong&gt;. To do this we use the command &lt;code&gt;git add&lt;/code&gt; followed by the file you want to add.&lt;br&gt;
&lt;code&gt;Example&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;git add README.md&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Commit with a message&lt;/strong&gt;. This is done using the &lt;code&gt;git commit -m&lt;/code&gt; command followed by a short message in quotes explaining the changes you made, to whoever might be looking at the project.&lt;br&gt;
&lt;code&gt;Example&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;git commit -m "My first commit"&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Push to GitHub&lt;/strong&gt;. Finally we can now push our changes to GitHub. To do this we use the command &lt;code&gt;git push origin master&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;git push origin master&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;NB&lt;/code&gt;&lt;/strong&gt; If this is your first push you may be required to enter your GitHub &lt;code&gt;username&lt;/code&gt; and &lt;code&gt;password&lt;/code&gt;. It's a one-time process.&lt;/p&gt;

&lt;p&gt;If you go to your GitHub account you will see a new commit in your project. If you click on it, it will show you more details about the changes you made.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcq1ymdoer63e0y7s1xiv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fcq1ymdoer63e0y7s1xiv.png" alt="Alt Text" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The lines highlighted in green show the additions that you made in your commit. Deletions are highlighted in red.&lt;/p&gt;

&lt;p&gt;Here is a diagram that sums all the steps taken when committing your changes.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwb32benjrqg3hmx51usd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwb32benjrqg3hmx51usd.png" alt="Alt Text" width="800" height="542"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this tutorial has been of help to you. If you find yourself forgetting some of the codes, don't worry you can google them or also use this &lt;a href="https://www.notion.so/Introduction-to-Git-ac396a0697704709a12b6a0e545db049"&gt;Cheatsheet&lt;/a&gt;.&lt;br&gt;
If you need further clarification, you can ask in the comments and I'll be sure to get back to you.&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
