<?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: Silas Getachew</title>
    <description>The latest articles on DEV Community by Silas Getachew (@silogecho97).</description>
    <link>https://dev.to/silogecho97</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%2F542677%2F4cd0793e-cf17-46ed-b612-f4fe099156a7.jpeg</url>
      <title>DEV Community: Silas Getachew</title>
      <link>https://dev.to/silogecho97</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/silogecho97"/>
    <language>en</language>
    <item>
      <title>Importing JSON data to Storyblok using API</title>
      <dc:creator>Silas Getachew</dc:creator>
      <pubDate>Wed, 01 Jun 2022 14:59:31 +0000</pubDate>
      <link>https://dev.to/silogecho97/importing-json-data-to-storyblok-1i0n</link>
      <guid>https://dev.to/silogecho97/importing-json-data-to-storyblok-1i0n</guid>
      <description>&lt;h3&gt;
  
  
  Using &lt;strong&gt;Storyblok Management API&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The Storyblok Management API is organized around REST. Our API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP query parameters and HTTP verbs, which are understood by off-the-shelf HTTP clients. We support cross-origin resource sharing, allowing you to interact securely with our API from a client-side web application (though you should never expose your secret API key in any public website's client-side code). JSON is returned by all API responses, including errors, although our API libraries convert responses to appropriate language-specific objects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stories&lt;/strong&gt; &lt;br&gt;
The stories endpoint will let you manage all content entries of your Storyblok space. You can use it to import, export or modify content.&lt;/p&gt;

&lt;p&gt;You can create Story using REST API&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Storyblok.post('spaces/606/stories/', {
  "story": {
    "name": "Story Name",
    "slug": "story-name",
    "content": {
      "component": "page",
      "body": []
    }
  },
  "publish": 1
}).then(response =&amp;gt; {
  console.log(response)
}).catch(error =&amp;gt; { 
  console.log(error)
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example Above coding using Javascript.&lt;/p&gt;

&lt;p&gt;You can also do with CURL easily&lt;/p&gt;

&lt;p&gt;Something 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;curl "https://mapi.storyblok.com/v1/spaces/606/stories/" \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: YOUR_OAUTH_TOKEN" \
-d "{\"story\":{\"name\":\"Story Name\",\"slug\":\"story-name\",\"content\":{\"component\":\"page\",\"body\":[]}},\"publish\":1}"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You also create, update, delete components. E.g this below to create component in Storyblok using API&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Storyblok.post('spaces/656/components/', {
  "component": {
    "name": "teaser",
    "display_name": "Teaser",
    "schema": {
      "title": {
        "type": "text",
        "pos": 0
      },
      "image": {
        "type": "image",
        "pos": 1
      }
    },
    "is_root": false,
    "is_nestable": true
  }
}).then(response =&amp;gt; {
  console.log(response)
}).catch(error =&amp;gt; { 
  console.log(error)
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Let's read JSON file and import to Storyblok.
&lt;/h3&gt;

&lt;p&gt;I use nodejs for import, So First make sure to install the package&lt;br&gt;
&lt;code&gt;yarn add storyblok-js-client&lt;/code&gt; or &lt;code&gt;npm i storyblok-js-client&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;then &lt;br&gt;
&lt;code&gt;const StoryblokClient = require('storyblok-js-client')&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Initialize the client with the oauth token
const Storyblok = new StoryblokClient({
  oauthToken: '&amp;lt;yourPersonalToken&amp;gt;', // can be found in your My account section
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add Storyblok config&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const config = {
  spaceId: '&amp;lt;SpaceId', // can be found in the space settings.
  parentFolder: '&amp;lt;parentFolder&amp;gt;', // navigate into your folder and copy the id from the URL at app.storyblok.com &amp;lt;- last one
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then&lt;/p&gt;

&lt;p&gt;Read the json file using &lt;code&gt;fs&lt;/code&gt; module.&lt;br&gt;
make sure to &lt;code&gt;createReadStream&lt;/code&gt; incase the json file is large.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const data = fs.createReadStream('data.json')

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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;data
  .on('data', function (data) {{
     data = JSON.parse(data)
     Object.entries(data).forEach(([key, value]) =&amp;gt; {
     const story = {
        slug:value.slug,
        name: value.name,
        parent_id: config.parentFolder,
        content: {
          component: 'partner',
          name: value.name,
          description: value.content.en,
          description__i18n__de: value.content.de // if you have i18n.
       }



   Storyblok.post(`spaces/${config.spaceId}/stories/`, {
        story,
      })
        .then((res) =&amp;gt; {
          console.log(`Success: ${res.data.story.name} was created.`)
        })
        .catch((err) =&amp;gt; {
          console.log(`Error: ${err}`)
        })
    })
  })
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>storyblok</category>
      <category>vue</category>
      <category>nuxt</category>
    </item>
    <item>
      <title>How to Deploy NuxtJS to S3 through cloudfront?</title>
      <dc:creator>Silas Getachew</dc:creator>
      <pubDate>Wed, 01 Jun 2022 14:44:20 +0000</pubDate>
      <link>https://dev.to/silogecho97/how-to-deploy-nuxtjs-to-s3-through-cloudfront-4n4l</link>
      <guid>https://dev.to/silogecho97/how-to-deploy-nuxtjs-to-s3-through-cloudfront-4n4l</guid>
      <description></description>
      <category>nuxt</category>
    </item>
    <item>
      <title>Static Site using Nuxt.js with Storyblok CMS</title>
      <dc:creator>Silas Getachew</dc:creator>
      <pubDate>Wed, 25 May 2022 15:54:18 +0000</pubDate>
      <link>https://dev.to/silogecho97/static-site-using-nuxtjs-with-storyblok-cms-7ac</link>
      <guid>https://dev.to/silogecho97/static-site-using-nuxtjs-with-storyblok-cms-7ac</guid>
      <description>&lt;h2&gt;
  
  
  You want to build fast and secure website?
&lt;/h2&gt;

&lt;p&gt;This guide show how to develop full-blown website using Nuxt.js, Storyblok and Tailwind CSS. &lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;**What is Jamstack?&lt;/p&gt;

&lt;p&gt;Jamstack is an architecture designed to make the web faster, more secure, and easier to scale. It builds on many of the tools and workflows which developers love, and which bring maximum productivity.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Better Performance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Higher Security&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cheaper, Easier Scaling&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Better Developer Experience&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Site Generators&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;**Nuxt.js **is a free and open source JavaScript library based on Vue.js,&lt;/p&gt;

&lt;p&gt;BTW: Easy to learn. Easy to master, Zero Configuration, SEO friendly&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Headless CMS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A headless CMS is any type of back-end content management system where the content repository “body” is separated or decoupled from the presentation layer “head.” Content that is housed in a headless CMS is delivered via APIs for seamless display across different devices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;StoryBlok&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first component-based headless CMS with Visual Editor.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's Start coding
&lt;/h3&gt;

&lt;p&gt;Installation&lt;/p&gt;

&lt;p&gt;Requirement&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nuxt.js v2.14.0
Nodejs v12.3.1
Npm v6.9.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn create nuxt-app my-nuxt-app // npx create-nuxt-app my-nuxt-app
cd my-nuxt-app
yarn dev // npm run dev

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

&lt;/div&gt;



&lt;p&gt;I prefer yarn. &lt;/p&gt;

&lt;p&gt;Install Storyblok package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add @storyblok/nuxt //for nuxt v3
yarn add  @storyblok/nuxt-2 //for nuxt-2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next step is add to nuxt module in  nuxt.config.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;['@storyblok/nuxt/module', { accessToken: process.env.YOUR_STORYBLOK_API_KEY }],

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

&lt;/div&gt;



&lt;p&gt;To get this stroyblok API key get to your space in Storyblok and copy the preview api key.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;From Storyblok side&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create Space in Storyblok&lt;br&gt;
&lt;a href="https://media2.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%2Fe5c8851gikt8y3p57sfa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fe5c8851gikt8y3p57sfa.png" alt="Image description" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create component&lt;br&gt;
&lt;a href="https://media2.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%2Fe64mf8xaepgclkb1g2uy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fe64mf8xaepgclkb1g2uy.png" alt="Image description" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Define component schema&lt;br&gt;
&lt;a href="https://media2.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%2Fv0u1amijjgndjqheydfe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fv0u1amijjgndjqheydfe.png" alt="Image description" width="800" height="1356"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the Code(Nuxt.js)&lt;/p&gt;

&lt;p&gt;Create Page component in &lt;code&gt;components/Page.vue&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;
  &amp;lt;div
    v-editable="blok"
    class="px-6"&amp;gt;
    &amp;lt;component
      v-for="blok in blok.body"
      :key="blok._uid"
      :blok="blok"
      :is="blok.component" /&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
export default {
  props: {
    blok: {
      type: Object,
      required: true
    }
  }
}
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make access component to globaly&lt;br&gt;
Add component to  &lt;code&gt;plugins/components.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Page from '~/components/Page.vue'

Vue.component('Page', Page)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then add this plugin to nuxt.config&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plugins: ['~/plugins/components']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's create index page and fetch the content from Storyblok&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;component :is="story.content.component" v-if="story.content.component" :key="story.content._uid" :blok="story.content" /&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
import { useStoryblokBridge } from '@storyblok/nuxt'

export default {
  middleware: 'fetchGlobalLayout',
  asyncData: (context) =&amp;gt; {
    const version = context.query._storyblok || context.isDev ? 'draft' : 'published'

    const language = context.app.i18n.locale // this i18n, i will get back this. 

    return context.app.$storyapi
      .get('cdn/stories/home', {
        language,
        version,
      })
      .then((res) =&amp;gt; {
        return res.data
      })
      .catch((res) =&amp;gt; {
        if (!res.response) {
          context.error({
            statusCode: 404,
            message: 'Failed to receive content from api',
          })
        } else {
          context.error({
            statusCode: res.response.status,
            message: res.response.data,
          })
        }
      })
  },

  mounted() {
    useStoryblokBridge(this.story.id, (newStory) =&amp;gt; (this.story = newStory))
  },
}
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  To be continued
&lt;/h2&gt;

</description>
      <category>nuxt</category>
      <category>storyblok</category>
      <category>staticsite</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to enhance performance SQL join query?</title>
      <dc:creator>Silas Getachew</dc:creator>
      <pubDate>Fri, 18 Dec 2020 06:50:17 +0000</pubDate>
      <link>https://dev.to/silogecho97/how-to-enhance-performance-sql-join-query-5a74</link>
      <guid>https://dev.to/silogecho97/how-to-enhance-performance-sql-join-query-5a74</guid>
      <description></description>
    </item>
  </channel>
</rss>
