<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="https://kaeru-1224.github.io//feed.xml" rel="self" type="application/atom+xml" /><link href="https://kaeru-1224.github.io//" rel="alternate" type="text/html" hreflang="en" /><updated>2021-11-25T07:16:55+00:00</updated><id>https://kaeru-1224.github.io//feed.xml</id><title type="html">Frog!</title><subtitle>Just Frog💚</subtitle><author><name>Songzi Vong</name><email>vszhub@gmail.com</email></author><entry><title type="html">갯츠비찍먹! Part 7:Add Dynamic Images from Data</title><link href="https://kaeru-1224.github.io//2021/11/25/part7/" rel="alternate" type="text/html" title="갯츠비찍먹! Part 7:Add Dynamic Images from Data" /><published>2021-11-25T06:41:00+00:00</published><updated>2021-11-25T06:41:00+00:00</updated><id>https://kaeru-1224.github.io//2021/11/25/part7</id><content type="html" xml:base="https://kaeru-1224.github.io//2021/11/25/part7/">&lt;p&gt;이전 파트3에서 정적 이미지를 추가하기위해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-image&lt;/code&gt;를 사용해주었던 것처럼, 이번에는 계속해서 변하는 동적 이미지를 추가하기위해서&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-image&lt;/code&gt;를 사용해볼 예정이다.이번 파트에서는 각 블로그 게시물에 동적&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GatsbyImage&lt;/code&gt;컴포넌트를 이용해서 데이터로부터 이미지를 추가하는 작업을 진행해볼 것이다.&lt;/p&gt;

&lt;p&gt;🤔 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GatsbyImage&lt;/code&gt; - &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;StaticImage&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GatsbyImage&lt;/code&gt; 와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;StaticImage&lt;/code&gt;의 차이는 무엇일까?. 둘의 차이는 결국 컴포넌트가 랜더링 될때 마다 매번 같은 이미지가 오는지 아니면 다른 이미지가 오는지에서 온다.&lt;br /&gt;
후자의 경우 컴포넌트가 랜더링될때마다 같은 이미지 자원이 오는 경우를 의미하고 후자의 경우 이미지 자원이 하나의 속성으로 전달이된다.&lt;br /&gt;
(즉 하나의 속성으로 전달되기 때문에 동적으로 바뀔수 있음을 의미하는 것이다)&lt;/p&gt;

&lt;h3&gt;Add hero images to blog post frontmatter&lt;/h3&gt;

&lt;p&gt;(hero images= 배너이미지, 대형이미지, 게시글에서 가장 위에 오는 이미지)&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/f7150a9cc0e9f60b6d51c544ecc79117/5df5d/reorganize-blog-directory.png&quot; alt=&quot;dynamicimage_ex&quot; /&gt;&lt;/p&gt;

&lt;p&gt;1.mdx게시글마다 각각의 폴더를 만들어 줍니다. 그런데 그때 각 폴더의 명은 URL로 사용되었던 이름으로 작성하되, mdx의 경우 index로 파일명을 변경해주어야합니다.&lt;br /&gt;
👉 파일명을 변경하지 않는 경우 route가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;blog/my-post/my-post/&lt;/code&gt;같은 형태가 될수있으므로 변경해주는 것이 용이합니다&lt;/p&gt;

&lt;p&gt;✔ 파일명 변경 후, 갯츠비를 재 실행해주어야한다&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/5cc60b117349ec93e6f1b59b34917a8e/5df5d/folder-structure-with-images.png&quot; alt=&quot;dynamicimage_ex&quot; /&gt;&lt;/p&gt;

&lt;p&gt;2.원하는 이미지를, 해당 게시글 폴더에 각각 넣어준다&lt;/p&gt;

&lt;p&gt;✔ 가끔 이미지 자체의 크기가 너무 커서, 랜더링되는데 속도가 좀더 걸릴수있는데 이는 사이트가 빌드되는 속도 역시 늦어지게 만드므로, 이미지를 미리 최적화해주는 것을 추천한다&lt;/p&gt;

&lt;p&gt;3.각 블로그 게시글에 추가적인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frontmatter&lt;/code&gt;요소를 추가해줍니다&lt;/p&gt;

&lt;p&gt;(🤔&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frontmatter&lt;/code&gt;?: 게시물에 대한 환경설정을 주로 적어주는 공간)&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hero_image: 게시글 내 이미지의 경로
hero_image_alt: 접근성을 위해 이미지를 대체할 텍스트
hero_image_credit_text: 사진 원작자이름
hero_image_credit_link: 사진 원작자의 sns 등
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;👉 위 세개의 작업을 마무리 했을 경우, 데이터 레이어와 연결해 템플릿으로 사진들을 가져올 수있을 것이다&lt;/p&gt;

&lt;h3&gt;Install and configure gatsby-transformer-sharp&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GatsbyImage&lt;/code&gt;를 이용해주려면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-transformer-sharp&lt;/code&gt; 플러그인을 추가해 주어야한다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/d710adc16d08d60f8919c62468ec0e8f/a5262/data-layer-with-imagesharp-nodes.png&quot; alt=&quot;ImageSharp_ex&quot; /&gt;&lt;/p&gt;

&lt;p&gt;갯츠비는 빌드해줄때 데이터레이어에 노드를 추가해주는데,&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-transformer-sharp&lt;/code&gt;플러그인은 이미지 확장자(.png,.jpg 등)으로 끝나는 파일 노드를 찾아 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ImageSharp&lt;/code&gt;노드를 만들어주는 작업을 해준다.&lt;/p&gt;

&lt;p&gt;✔&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-transformer-sharp&lt;/code&gt;플러그인 추가방법&lt;/p&gt;

&lt;p&gt;1.플러그인 설치&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm install gatsby-transformer-sharp
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2.갯츠비 설정파일에 추가&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;siteMetadata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;My First Gatsby Site&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;plugins&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// ...existing plugins&lt;/span&gt;
    &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby-transformer-sharp&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;✔서버 재시작 잊지말고 해주자!&lt;/p&gt;

&lt;h3&gt;Render hero image in the blog post page template&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Use GraphiQL to build the query&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;블로그 템플릿레 쿼리를 이용해 주기 위해서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GraphiQL&lt;/code&gt;의 hero image frontmatter 필드를 이용해주자&lt;/p&gt;

&lt;p&gt;✔처음부터 쿼리를 작성할 필요 없이 기존, 블로그 쿼리를 이용해서 작성해 주는 것에서 시작해보자&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;query ($id: String) {
  mdx(id: {eq: $id}) {
    frontmatter {
      title
      date(formatString: &quot;MMMM D, YYYY&quot;)
    }
    body
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;(🤔 id를 사용해주는게 id와 일치하는 게시물을 찾기에 용이하니까 인데, 어케 찾아주는거지? 그냥 일치하는거로 찾아주나?궁그매 )&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;query ($id: String) {
  mdx(id: {eq: $id}) {
    frontmatter {
      title
      date(formatString: &quot;MMMM D, YYYY&quot;)
      hero_image_alt
      hero_image_credit_link
      hero_image_credit_text
    }
    body
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GraphiQL&lt;/code&gt;의 Explorer창에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hero_image_alt&lt;/code&gt;,&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hero_image_credit_link&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hero_image_credit_text&lt;/code&gt; 필드를 체크해준다. 체크후 쿼리를 실행해보면 이전에 추가했던 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frontmatter&lt;/code&gt;요소들을 JSON으로 받아오는 것을 볼 수있을 것이다&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;🤔그런데 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GraphiQL&lt;/code&gt;는 어떻게 이전에 추가해준 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frontmatter&lt;/code&gt;요소들을 필드에 추가해주는 걸까?&lt;br /&gt;
👉 갯츠비가 사이트를 빌드해줄때, 데이터 레이어에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GraphQL&lt;/code&gt;스키마를 만들어 준다.이때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;schema inference&lt;/code&gt;를 통해 갯츠비가 스키마를 만들어줄때 각 필드의 데이터 타입을 예측해 진행해준다.&lt;br /&gt;
그래서 튜토리얼의 경우 갯츠비가 MDX의 frontmatter로 부터 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hero_image&lt;/code&gt;필드가 파일노드라는 것을 알기때문에 자연스럽게 파일 필드 쿼리를 이용해줄 수있도록 한다.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;??&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;schema inference&lt;/code&gt; 정확히뭐지???필드의 데이터 타입을 예측해주는 칭구정도인가???&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;query ($id: String) {
  mdx(id: {eq: $id}) {
    frontmatter {
      title
      date(formatString: &quot;MMMM D, YYYY&quot;)
      hero_image_alt
      hero_image_credit_link
      hero_image_credit_text
      hero_image {
        childImageSharp {
          gatsbyImageData
        }
      }
    }
    body
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;추가적으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hero_image&lt;/code&gt;필드의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;childImageSharp&lt;/code&gt;필드를 이용해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsbyImageData&lt;/code&gt;를 이용해준다. 그런데 위와같은 필드들을 이용해주는 이유는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsbyImageData&lt;/code&gt;에 각 게시글에서 이용될 헤더 이미지들의 정보를 얻어올 수있기 때문이다. 이러한 정보들은 빌드될 때 (데이터들은) &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-sharp&lt;/code&gt;에 의해 생성된다.&lt;/p&gt;

&lt;p&gt;(🤔&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsbyImageData&lt;/code&gt;객체는 이미지를 랜더링 하기위해 필요했던 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GatsbyImage&lt;/code&gt;컴포넌트와 동일한 구조를 지닌다. 이게 어떤의미지?????)&lt;/p&gt;

&lt;p&gt;✔GraphiQL에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsbyImageData&lt;/code&gt;필드에 일부 전달 인자들을 통해 이미지 최적화 작업에 이용할 수있다&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Add hero image using GatsbyImage component&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;1) 이전에 만들어 놓았던 쿼리에, 새롭게 만들어 준 쿼리를 대체해줍니다&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;export const query = graphql`
  query($id: String) {
    mdx(id: {eq: $id}) {
      body
      frontmatter {
        title
        date(formatString: &quot;MMMM DD, YYYY&quot;)
        hero_image_alt
        hero_image_credit_link
        hero_image_credit_text
        hero_image {
          childImageSharp {
            gatsbyImageData
          }
        }
      }
    }
  }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;-&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GatsbyImage&lt;/code&gt;와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getImage&lt;/code&gt;을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-image&lt;/code&gt;에서 import해줍니다&lt;br /&gt;
 (??helper function:다른 함수의 계산을 일부 수행해주는 함수,여기서는 getImage가 헬퍼함수로 쓰인다 )&lt;/p&gt;

&lt;p&gt;-&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getImage&lt;/code&gt; 헬퍼함수를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hero_image&lt;/code&gt;필드로부터 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsbyImageData&lt;/code&gt;객체를 가져오기위해 사용해줍니다&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// imports&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPost&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;image&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;getImage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;hero_image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;🤔getImage가 어떻게 작용이되어서 저걸 받는건지가 궁금한데 …알려하면 안될것가틈 ㅋㅋㅋ&lt;/p&gt;

&lt;p&gt;✔ &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getImage&lt;/code&gt;는 헬퍼 함수로 파일 노드나 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ImageSharp&lt;/code&gt;노드를 받아 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsbyImageData&lt;/code&gt;로 되돌려주어, 조금더 말끔한 코드를 이용할 수있도록 도와줍니다.&lt;br /&gt;
만약 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;getImage&lt;/code&gt;가 없다면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data.mdx.frontmatter.hero_image.childImageSharp.gatsbyImageData&lt;/code&gt;와 같이 길게 처리를 해주어야 할것입니다&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;헤더 이미지 데이터를 렌더링 해주기 위해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GatsbyImage&lt;/code&gt;를 사용해주는데 이때 두개의 props(속성)을 전달해주어야합니다.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Posted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/p&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;GatsbyImage&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;hero_image_alt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;sr&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;MDXRenderer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/MDXRenderer&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Layout&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;image: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hero_image&lt;/code&gt;필드로 부터 받아온 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsbyImageData&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;alt: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hero_image_alt&lt;/code&gt; 필드로 부터 받아온 대체 텍스트&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;! 짠 다시 서버를 재실행하면 이미지가 무사히 업로드되었습니다~!&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Add image credit after hero image&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;이제 사용한 사진의 출처를 이야기하고 마무리를 하면됩니다!&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// imports&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPost&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;image&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;getImage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;hero_image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/p&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;GatsbyImage&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;hero_image_alt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;sr&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;Photo&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Credit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:{&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;hero_image_credit_link&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;hero_image_credit_text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/a&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/p&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;MDXRenderer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/MDXRenderer&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Layout&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`
  ...
`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPost&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;그런데 이때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;a&amp;gt;&lt;/code&gt;를 써주어야할지 아니면 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;Link&amp;gt;&lt;/code&gt;컴포넌트를 이용해 주어야할지 고민이라면,이동해야할 사이트가 블로그 내의 사이트가 아니라면 a태그를 만약 갯츠비 내의 사이트라면 링크태그를 이용해주는 것을 추천합니다&lt;/p&gt;</content><author><name>Songzi Vong</name><email>vszhub@gmail.com</email></author><category term="Gatsby" /><summary type="html">이전 파트3에서 정적 이미지를 추가하기위해 gatsby-plugin-image를 사용해주었던 것처럼, 이번에는 계속해서 변하는 동적 이미지를 추가하기위해서gatsby-plugin-image를 사용해볼 예정이다.이번 파트에서는 각 블로그 게시물에 동적GatsbyImage컴포넌트를 이용해서 데이터로부터 이미지를 추가하는 작업을 진행해볼 것이다.</summary></entry><entry><title type="html">갯츠비찍먹!-Part 6:Create Pages Programmatically</title><link href="https://kaeru-1224.github.io//2021/11/22/part6-copy/" rel="alternate" type="text/html" title="갯츠비찍먹!-Part 6:Create Pages Programmatically" /><published>2021-11-22T07:43:00+00:00</published><updated>2021-11-22T07:43:00+00:00</updated><id>https://kaeru-1224.github.io//2021/11/22/part6%20copy</id><content type="html" xml:base="https://kaeru-1224.github.io//2021/11/22/part6-copy/">&lt;h3&gt;Create Pages Programmatically&lt;/h3&gt;

&lt;p&gt;파트5에서 우리는 블로그 게시글을 블로그 페이지에 넣는 작업을 진행해 주었습니다. 그런데 여기서 각 블로그 게시글을 분리되어 있지 않기 때문에 한개의 페이지가 계속해서 길어질 수있다는 문제점을 만나게 될 수 있습니다. 그래서 한 게시글- 한페이지로 분리해보는 작업을 여기 파트 6에서 진행해볼 예정입니다.&lt;/p&gt;

&lt;p&gt;이전까지는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/pages&lt;/code&gt;폴더에 페이지 파일을 추가하는 방식으로 새로운 페이지를 만들어 주었습니다. 하지만 각 게시물에 일일이 새 페이지를 만들어주는 것은 상당히 반복적인 일이 되기 때문에,이전과는 다른 방향으로 진행 해줍니다.&lt;/p&gt;

&lt;h3&gt;Create new routes dynamically with Gatsby’s File System Route API&lt;/h3&gt;

&lt;p&gt;갯츠비 사이트를 만들때 갯트비는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/pages&lt;/code&gt; 폴더 내의 각 요소를 위해 새로운 라우터를 형성해줍니다. 현재까지는 폴더 내의 한개의 파일마다 한개의 페이지가 만들어져 있는 상태입니다.&lt;br /&gt;
사용자는 하나의 각 파일마다 한개의 페이지로 형성되는 방식이 아닌, 페이지의 기본틀을 기반으로 페이지를 형성해 줄때마다 특정 데이터를 더해주는 방식으로 여러개의 페이지를 만들어줄 수있습니다. 이를 위해서는 Gatsby의 File System Route API를 사용해주어야 합니다.&lt;/p&gt;

&lt;p&gt;✔ File System Route API?&lt;br /&gt;
-API는 개별 블로그 게시물을 만드는 것을 도와주는데, 파일 이름 을 이용하여 GraphQL 데이터에서 경로를 만들 수있습니다.&lt;/p&gt;

&lt;p&gt;🤔GaphQL 데이터에서 경로를 만들 수있습니다?&lt;br /&gt;
-아마도 파일 이름에 따라서 라우터를 만들어주고 그에 따른 경로를 형성에 줄 수있다는 이야기 인것 같다!&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;collection route&lt;/code&gt;를 만들기위해 확인해야할 두가지 사항이 있습니다&lt;/p&gt;

&lt;p&gt;🤔그런데 여기서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;collection route&lt;/code&gt;의 의미가 뭘까했는데&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Gatsby supports multiple templated pages based on a single component&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;하나의 컴포넌트를 기반으로 여러개의 템플릿 페이지를 만들도록 도와준다는 이야기같다.예를 들어 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/pages/products/{Product.name}.js&lt;/code&gt;에 있는 파일을 통해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/products/burger&lt;/code&gt;거나 혹은 더 다른 페이지를 만들수 있도록해준다는 이야기인 듯하다!&lt;/p&gt;

&lt;p&gt;-페이지를 만들 노드의 유형&lt;br /&gt;
-노드 유형에서 URL에 사용할 필드&lt;/p&gt;

&lt;p&gt;현재 블로그 게시글이 MDX형태로 되어있기 때문에, 노드 타입은 MDX가 되겠지만, MDX 노드에서 어떤 필드를 사용해 주어야할까?&lt;br /&gt;
(🤔노드의 필드라했을때 어떤의미일까 하는 생각이 들었는데,GaphQL 쿼리를 받기위해서 사용하는 필드인것같다..?)&lt;/p&gt;

&lt;p&gt;튜토리얼에서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-mdx&lt;/code&gt;라는 플러그인을 MDX노드들에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;slug&lt;/code&gt; 필드를 자동적으로 더해준후 이를 사용해준다.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-GaphQL&quot;&gt;{
  allMdx {
    nodes {
      slug
    }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;slug&lt;/code&gt;는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.mdx&lt;/code&gt;로 끝나는 파일들의 파일명을 문자열로 받아 아래와 같은 결과물을 보여준다&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;allMdx&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;nodes&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;slug&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;my-first-post&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;slug&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;yet-another-post&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;slug&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;another-post&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;extensions&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;🤔그런데 여기서 slug필드를 이용해주는건 왜지?&lt;br /&gt;
튜토리얼에서는 슬러그자체가 사람이 이해하기에 용이하디 때문이라고 설명해주고있다. 이해는 가지만 다른 방법으로하면 어케되길래,,&lt;br /&gt;
–&amp;gt; ㅇㅎ, slug는 url의 한 부분으로 사람이 읽기쉬운 키워드로 페이지를 구분하게 해주는 키워드라서, 페이지에 대해서 간단하게 이해하기에도 용이하군아 ㅇㅋ
(url를 몰라서 이런거일지도 모르겟다 ㅇㅇ..)&lt;/p&gt;

&lt;h3&gt; Create blog post page template&lt;/h3&gt;

&lt;p&gt;이제 페이지를 만들 노드의 유형 (mdx)와 노드 유형에서 URL에 사용할 필드(slug)를정해 주었으니 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/pages/{mdx.slug}.js&lt;/code&gt;라는 파일을 형성해 슬러그를 이용해보자&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/788c82cbe6f0a4268e313808e0aab9d2/5df5d/file-system-routes.png&quot; alt=&quot;slug_ex&quot; /&gt;&lt;/p&gt;

&lt;p&gt;위와같은 다이어그램을 통해 겟츠비가 사이트를 만들어줄때, 라우트가 어떤식으로 달라지는지를 볼 수있다&lt;/p&gt;

&lt;p&gt;-&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/pages&lt;/code&gt;폴더에 게시글의 기본 템플릿이 될 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{mdx.slug}.js&lt;/code&gt;라는 파일을 만들어 기존에 만들어 놓았던 레이아웃 템플릿을 import 해줍니다&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;React&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;../components/layout&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPost&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Super Cool Blog Posts&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;My&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;blog&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;post&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;contents&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;will&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;go&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;here&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;eventually&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/p&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Layout&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPost&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3&gt;Update route to include a /blog path parameter
&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/e70b7a09cd907e792a797ce2afde10f1/5df5d/file-system-routes-with-blog-subdirectory.png&quot; alt=&quot;slug_ex&quot; /&gt;&lt;/p&gt;

&lt;p&gt;이후 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;localhost:8000/my-first-post&lt;/code&gt;라는 페이지에 들어갔을때, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{mdx.slug}.js&lt;/code&gt;로 만들어준 파일의 내용인 것을 확인할 수 있습니다.그런데 이경우 우리가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/pages&lt;/code&gt;폴더에 만들어주었기 때문에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/&lt;/code&gt;뒤에 페이지명으로 url이 형성된것을 확인할 수있습니다. 만약
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;localhost:8000/blog/my-first-post&lt;/code&gt; 의 형태로 URL을 얻고 싶다면 어떻게 해주어야할까요?&lt;/p&gt;

&lt;p&gt;-&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/pages&lt;/code&gt;폴더에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;blog&lt;/code&gt;라는 이름의 폴더를 하나 더 만들어 줍니다&lt;br /&gt;
-이전에 만들어 놓았던 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/pages/{mdx.slug}.js&lt;/code&gt;파일을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;blog&lt;/code&gt;폴더로 이동해줍니다. 이때 기존에 import해주었던 파일들의 경로를 수정해 주어야합니다&lt;/p&gt;

&lt;p&gt;이후 겟츠비가 자동적으로 서버를 업데이트 해주니, 정확히 업데이트가 되었는지 확인해 주면됩니다.예를 들어 기존경로였던 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;localhost:8000/my-first-post&lt;/code&gt;에 접속을 하면 404에러가 나는 것을 확인 할 수있습니다.&lt;br /&gt;
기존에 만들어 놓았던 블로그템플렛을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;blog&lt;/code&gt;폴더로 이동하는데 이때 주소명이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;localhost:8000/blog/blog&lt;/code&gt;가 되는 것을 방지하기위해서 파일명을 index로 변경해 줍니다&lt;/p&gt;

&lt;h3&gt;Render post contents in the blog post page template&lt;/h3&gt;

&lt;p&gt;1.GraphiQL를 이용해서 블로그 템플릿에 이용해줄 페이지 쿼리를 만들어줍니다&lt;/p&gt;

&lt;p&gt;이전 파트 4에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GrahpQL&lt;/code&gt;쿼리를 통해서 진행을 해준 것 처럼 여기서도 유사하게 진행 될 예정인데, 대신 파트6에서는 쿼리 변수를 사용해줄 예정이다.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;File System Route API&lt;/code&gt;을 통해서 자동적으로 몇개의 props들이 템플릿에 추가 됩니다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;id:페이지를 생성하는데 사용됩니다&lt;/li&gt;
  &lt;li&gt;slug필드: 경로형성을 위해 사용됩니다&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;query MyQuery($id: String) {
  mdx(id: {eq: $id}) {
    frontmatter {
      title
      date(formatString: &quot;MMMM D, YYYY&quot;)
    }
    body
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;` GraphiQL&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;를 이용해 게시글을 위한 쿼리를 만들어줍니다.그런데 이때 별개의 MDX노드 하나만 필요로 하기 때문에 &lt;/code&gt;mdx`필드를 이용해 진행해줍니다.이전에 slug를 통해서 노드를 찾아주었지만 id를 이용해서 사용해주는 것이 더빠르므로 id를 이용해 진행해줍니다&lt;/p&gt;

&lt;p&gt;🤔id를 이용해주는 이유는 결국 id가 독립적인 친구라 그런거겟지?&lt;/p&gt;

&lt;p&gt;2.생성된 페이지 쿼리를 블로그 템플릿에 넣어줍니다&lt;/p&gt;

&lt;p&gt;✔&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;graphql&lt;/code&gt;태그를 immport해주는 것을 잊지말아주세요&lt;/p&gt;

&lt;p&gt;✔쿼리 생성시 자동적으로 붙여진 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MyQuery&lt;/code&gt;라는 이름을 지워주거나 특정한 이름으로 대체해주어야합니다&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;React&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;graphql&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;MDXRenderer&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby-plugin-mdx&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;../../components/layout&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPost&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/p&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;MDXRenderer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;body&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/MDXRenderer&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Layout&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`
  query ($id: String) {
    mdx(id: { eq: $id }) {
      frontmatter {
        title
        date(formatString: &quot;MMMM D, YYYY&quot;)
      }
      body
    }
  }
`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPost&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;쿼리로 전달해준 데이터prop들을&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{data.mdx.frontmatter.title}&lt;/code&gt;와 같은 형태로 사용해줍니다
여기까지 진행을해주면, 이전 파트4와 같은 결과를 얻게됩니다.이전과의 차이점은 한개의 블로그 게시글당 한개의 페이지를 얻게 되었다는 것 입니다!. 하지만 일일이 페이지를 URL을 작성해 이동하기 어려우므로 블로그페이지에 각 게시글의 링크를 넣어주는 작업을 진행!&lt;/p&gt;

&lt;h3&gt;Update Blog page to link to each post
&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/pages/blog/index.js&lt;/code&gt;에서 쿼리내의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;body&lt;/code&gt;필드를 지워주고, 기존에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;body&lt;/code&gt;필드를 랜더링 해주었던 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MDXRenderer&lt;/code&gt;컴포넌트도 지워줍니다&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;React&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;graphql&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;../../components/layout&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;My Blog Posts&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;allMdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;article&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/h2&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Posted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/p&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/article&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;p&quot;&gt;))}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Layout&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`
  query {
    allMdx(sort: { fields: frontmatter___date, order: DESC }) {
      nodes {
        frontmatter {
          date(formatString: &quot;MMMM D, YYYY&quot;)
          title
        }
        id
      }
    }
  }
`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;게시글의 제목을 이용해주고 게시글 페이지로 이동하기위해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;slug&lt;/code&gt;필드를 사용해줍니다.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;React&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;graphql&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;../../components/layout&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;My Blog Posts&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;allMdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;article&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Link&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`/blog/&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;slug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Link&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/h2&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Posted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/p&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/article&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;p&quot;&gt;))}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Layout&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`
  query {
    allMdx(sort: { fields: frontmatter___date, order: DESC }) {
      nodes {
        frontmatter {
          date(formatString: &quot;MMMM D, YYYY&quot;)
          title
        }
        id
        slug
      }
    }
  }
`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;✔튜토리얼에서는 갯츠비의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Link&lt;/code&gt; 컴포넌트를 활용해 연결해줄 것을 권유합니다&lt;/p&gt;

&lt;p&gt;✔절대경로를 사용한다면,&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;slug&lt;/code&gt;는 게시글의 제목만 가져오기 때문에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/blog/&lt;/code&gt;를 앞에 붙여주어야합니다&lt;/p&gt;</content><author><name>Songzi Vong</name><email>vszhub@gmail.com</email></author><category term="Gatsby" /><summary type="html">Create Pages Programmatically</summary></entry><entry><title type="html">갯츠비찍먹!-Part 5:Transform Data to Use MDX</title><link href="https://kaeru-1224.github.io//2021/11/15/part5/" rel="alternate" type="text/html" title="갯츠비찍먹!-Part 5:Transform Data to Use MDX" /><published>2021-11-15T15:04:00+00:00</published><updated>2021-11-15T15:04:00+00:00</updated><id>https://kaeru-1224.github.io//2021/11/15/part5</id><content type="html" xml:base="https://kaeru-1224.github.io//2021/11/15/part5/">&lt;h3&gt;Transform Data to Use MDX&lt;/h3&gt;

&lt;p&gt;파트4에서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-source-filesystem&lt;/code&gt;이라는 플러그인을 통해서, 블로그 게시글 파일의 이름을 리스트로 데려오는 작업을 진행했습니다. 하지만, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-source-filesystem&lt;/code&gt;은 파일 자체 데이터에 접근해, 랜더링까지 해주는 플러그인이 아니기 때문에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;transformer plugin&lt;/code&gt;이라 불리는 다른 종류의 플러그인을 사용해야합니다.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;🤔갯츠비에서는 여러 타입의 플러그인을 이야기하는데, 갯츠비에서만 그러는건지 아니면 다른곳에서도 동일하게 진행이되는지 궁금함..&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;튜토리얼에서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;transformer plugin&lt;/code&gt;중 하나인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-mdx&lt;/code&gt;를 이용할 예정입니다. 이 플러그인의 경우 마크다운과 jsx 를 블로그 파일에 함께 사용할 수있도록 도와줄 것이고,블로그 페이지를 랜더링하기위해 사용할 것입니다.&lt;/p&gt;

&lt;p&gt;-갯츠비의 데이터레이어를 확인해보자!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/04384c192391ebeac3b63ea42872f3f2/5df5d/data-layer-with-nodes.png&quot; alt=&quot; datalayer_ex&quot; /&gt;&lt;/p&gt;

&lt;p&gt;갯츠비의 데이터 레이어 에서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nodes&lt;/code&gt;라는 객체로 저장이됩니다. 노드는 데이터 레이어에서 가장 작은 데이터의 단위로 각 소스 플러그인들은 다른 종류의 노드를 생성합니다.&lt;br /&gt;
(✔gatsby-source-filesystem 는 File nodes를 생성한다)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;transformer plugin&lt;/strong&gt;은 노드를 또 다른 노드로 변형시킵니다.예를들어 이번에 사용하는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-mdx&lt;/code&gt;의 경우 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.mdx&lt;/code&gt;확장자를 가진 파일 노드를 MDX 노드(MDX노드는 GraphQL을 사용시 다른 필드를 지니고 있습니다. )로 변환해줍니다.&lt;/p&gt;

&lt;p&gt;✔ &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;transformer plugin&lt;/code&gt;의 경우 이름 자체에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;transformer&lt;/code&gt;가 들어가서 원본 노드가 변경이 되는 것처럼 들리지만, 사실 원본 노드를 기반으로 새로운 노드를 만들어서 사용해주는 방식으로 진행됩니다. 그래서 기존에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-source-filesystem.&lt;/code&gt;으로 만들어 두었던 파일 노드들에도 여전히 접근이 가능합니다!&lt;/p&gt;

&lt;h3&gt;Add some MDX content to your blog posts&lt;/h3&gt;

&lt;p&gt;이전 part4에서 만들어 놓았던 블로그파일에 mdx 문법에 따라서 글을 작성해 줍니다.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-mdx&quot;&gt;---
title: &quot;My First Post&quot;
date: &quot;2021-07-23&quot;
---

This is my first blog post! Isn't it _great_?
Some of my **favorite** things are:

- Petting dogs
- Singing
- Eating potato-based foods
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Install and configure the MDX transformer plugin (and dependencies)&lt;/h3&gt;

&lt;p&gt;작성이 끝났다면 앞에서 언급해준 플러그인들을 설치해줍니다.&lt;/p&gt;

&lt;p&gt;-&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-mdx&lt;/code&gt;&lt;br /&gt;
이 플러그인의 경우 GraphQL 쿼리에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;allMdx&lt;/code&gt;그리고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mdx&lt;/code&gt;필드를 추가해주고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MDXRenderer&lt;/code&gt;컴포넌트를 제공해줍니다.&lt;/p&gt;

&lt;p&gt;그런데 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-mdx&lt;/code&gt;은 플러그인 자체 뿐만아니라 추가적인 dependencies들을 필요로 합니다. 그래서 설치시 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@mdx-js/mdx&lt;/code&gt;(MDX를 구현해줍니다)와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@mdx-js/react&lt;/code&gt; (구현한 MDX를 리액트의 컴포넌트들에 배치해줍니다)를 함께 설치해주어야합니다&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm install gatsby-plugin-mdx @mdx-js/mdx @mdx-js/react
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;플러그인을 추가한 후에 갯츠비에게 플러그인 사용을 알리기위해 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-config.js&lt;/code&gt;파일을 수정해줍니다.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;siteMetadata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;My Super Cool Blog&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;plugins&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby-plugin-image&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby-plugin-sharp&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;`gatsby-source-filesystem`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;`blog`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;__dirname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/blog/`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
    &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby-plugin-mdx&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3&gt;Update the Blog page query to use the allMdx field instead of allFile&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-mdx&lt;/code&gt; 플러그인은 GraphQL쿼리에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;allMdx &lt;/code&gt;와&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt; mdx&lt;/code&gt; 영역을 추가해주는데, 튜토리얼에서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;allMdx &lt;/code&gt;를 사용하게됩니다.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;🤔 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;allMdx &lt;/code&gt;와&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt; mdx&lt;/code&gt; 의 차이는 뭐지?&lt;br /&gt;
단어그대로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;allMdx &lt;/code&gt; MDX노드 전체로 부터 데이터를 요청하고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mdx&lt;/code&gt;는 특정 mdx노드에서 받아오는걸까??????&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;GraphiQL를 이용해 새로운 쿼리를 만들어 블로그 게시글의 데이터를 받아와줍니다.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;query&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;MyQuery&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;allMdx&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;nodes&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;formatString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;MMMM D, YYYY&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;title&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;🤔frontmatter?
마크다운에 파일에 대한 추가 데이터를 제공해주며 이때 key와 value를 포함하고 있다&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;✅formatString?&lt;br /&gt;
frontmatter에서 date를 이용할때 formatString으로 날짜의 형태(2021.인지 2021/인지 등등)를 바꿔줄 수있다&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;---
date: &quot;2021-07-23&quot;
---
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;위의 형태의 mdx를 아래의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;formatString: &quot;MMMM D, YYYY&quot;&lt;/code&gt;으로 진행을 해주면&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;query MyQuery {
  allMdx {
    nodes {
      frontmatter {
        date(formatString: &quot;MMMM D, YYYY&quot;)
      }
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;July 23, 2021&lt;/code&gt;와 같은 결과를 얻게된다&lt;/p&gt;

&lt;p&gt;또한 쿼리에 id값을 추가해 줄 수있는데, 이 id 값의 경우 겟츠비가 자동적으로 데이터 레이어의 모든 노드에 추가해주며, 문자열의 모습을 하고 있다. 이후에 이 id값을 리액트의 key로 사용이 가능하다&lt;/p&gt;

&lt;p&gt;✅sort&lt;/p&gt;

&lt;p&gt;쿼리를 진행했을때, 게시글이 날짜 순서대로 나오지 않는 것을 확인 할 수있다&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{
  &quot;data&quot;: {
    &quot;allMdx&quot;: {
      &quot;nodes&quot;: [
        {
          &quot;frontmatter&quot;: {
            &quot;date&quot;: &quot;July 25, 2021&quot;,
            &quot;title&quot;: &quot;Yet Another Post&quot;
          },
          &quot;id&quot;: &quot;c4b5ae6d-f3ad-5ea4-ab54-b08a72badea1&quot;
        },
        {
          &quot;frontmatter&quot;: {
            &quot;date&quot;: &quot;July 23, 2021&quot;,
            &quot;title&quot;: &quot;My First Post&quot;
          },
          &quot;id&quot;: &quot;11b3a825-30c5-551d-a713-dd748e7d554a&quot;
        },
        {
          &quot;frontmatter&quot;: {
            &quot;date&quot;: &quot;July 24, 2021&quot;,
            &quot;title&quot;: &quot;Another Post&quot;
          },
          &quot;id&quot;: &quot;560896e4-0148-59b8-9a2b-bf79bee68fba&quot;
        }
      ]
    }
  },
  &quot;extensions&quot;: {}
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/sort.png&quot; alt=&quot; sort_ex&quot; /&gt;&lt;/p&gt;

&lt;p&gt;이런경우 GraphiQL의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sort&lt;/code&gt;를 이용해서 오름차순 혹은 내림 차순으로 나열해 줄 수 있다. 필요한 필드와 오름/내림 차순을 선택후 진행해주면 아래와 같은 결과를 얻을 수있다.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{
          &quot;frontmatter&quot;: {
            &quot;date&quot;: &quot;July 25, 2021&quot;,
            &quot;title&quot;: &quot;Yet Another Post&quot;
          },
          &quot;id&quot;: &quot;c4b5ae6d-f3ad-5ea4-ab54-b08a72badea1&quot;
        },
        {
          &quot;frontmatter&quot;: {
            &quot;date&quot;: &quot;July 24, 2021&quot;,
            &quot;title&quot;: &quot;Another Post&quot;
          },
          &quot;id&quot;: &quot;560896e4-0148-59b8-9a2b-bf79bee68fba&quot;
        },
        {
          &quot;frontmatter&quot;: {
            &quot;date&quot;: &quot;July 23, 2021&quot;,
            &quot;title&quot;: &quot;My First Post&quot;
          },
          &quot;id&quot;: &quot;11b3a825-30c5-551d-a713-dd748e7d554a&quot;
        }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;✅body&lt;/p&gt;

&lt;p&gt;쿼리에 게시글의 내용을 첨가하기위해서 body 필드를 이용해주면된다. 그런데 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;body&lt;/code&gt; 필드를 통해 나온 데이터를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{node.body}&lt;/code&gt;로 확인하게되면, 이해하기 어려운 많은 데이터가 나오는것을 확인할 수 있습니다.&lt;br /&gt;
바디필드의 경우 mdx내용이 포함되어 있으며, 그 내용을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MDXRenderer&lt;/code&gt;를 통해 사용할 수있습니다.&lt;/p&gt;

&lt;p&gt;기존에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;allFile&lt;/code&gt;로 진행해 주었던 쿼리를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;allMdx&lt;/code&gt;로 바꾸어 진행을해주면 아래와 같은 코드를 얻게됩니다&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// imports&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;My Blog Posts&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;allMdx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;article&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;h2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/h2&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Posted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/p&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/article&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;p&quot;&gt;))}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Layout&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`
  query {
    allMdx(sort: { fields: frontmatter___date, order: DESC }) {
      nodes {
        frontmatter {
          title
          date(formatString: &quot;MMMM DD, YYYY&quot;)
        }
        id
        body
      }
    }
  }
`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;최종적으로 아래와 같은 결과를 얻게된다&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/da73b53b1e6817bfcdd4a840275a107b/078fe/blog-page-with-frontmatter.png&quot; alt=&quot;page_ex&quot; /&gt;&lt;/p&gt;</content><author><name>Songzi Vong</name><email>vszhub@gmail.com</email></author><category term="Gatsby" /><summary type="html">Transform Data to Use MDX</summary></entry><entry><title type="html">Second Posting:갯츠비찍먹!-Part 4:Gatsby’s GraphQL data layer</title><link href="https://kaeru-1224.github.io//2021/11/12/part4/" rel="alternate" type="text/html" title="Second Posting:갯츠비찍먹!-Part 4:Gatsby’s GraphQL data layer" /><published>2021-11-12T06:42:00+00:00</published><updated>2021-11-12T06:42:00+00:00</updated><id>https://kaeru-1224.github.io//2021/11/12/part4</id><content type="html" xml:base="https://kaeru-1224.github.io//2021/11/12/part4/">&lt;h3&gt;Meet Gatsby’s GraphQL data layer&lt;/h3&gt;

&lt;p&gt;이전까지 리액트 컴포넌트에 바로 이미지나 문장을 적어왔지만 종종 마크다운 파일의 폴더나 CMS (content managemebt system)등을 활용해서 데이터를 만들고 유지한다음 필요에따라 컴포넌트에 넣어주는 방법 역시 용이하다.&lt;/p&gt;

&lt;p&gt;✅Data layer&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/e45422900475b86807bc002fb6863b85/5df5d/data-layer.png&quot; alt=&quot;datalayer_ex&quot; /&gt;&lt;/p&gt;

&lt;p&gt;갯츠비는 어디로부터나 데이터를 데려올 수 있는 데이터 레이어를 지니고 있다.
그런데 여기서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;어디로부터&lt;/code&gt;는 단어 그대로 데이터를 Shopify나 Airtable에 넣어도 여러 데이터 소스들을 결합해서 사용할 수있도록 한다는 의미로 GraphQL이 이러한 작업을 할수있도롣 우리를 도와줄 것이다.&lt;/p&gt;

&lt;p&gt;🤔 그러면 GraphQL이 어떤식으로 작동할까?&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;한개 혹은 그이상의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;공간(source)&lt;/code&gt;에 데이터가 저장된다. 이때 그
공간은 사용자의 컴퓨터의 파일 시스템일수도 있고 CMS일수도 있으며 혹은 데이터 베이스 일수도 있다.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🤔 그러면 그 공간으로부터 데이터레이아웃까지 데이터는 어떻게 얻을 수있을까.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;갯츠비의 경우 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;source plugin&lt;/code&gt;을 사용함으로써 데이터를 얻어올 수있도록 도와준다.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✔ 갯츠비 튜토리얼의 경우 유명 플러그인인 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-source-filesystem&lt;/code&gt;나 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-source-contentful&lt;/code&gt;를 예시로 들고 있다.&lt;/p&gt;

&lt;p&gt;🤔그러면 그 데이터를 어떻게 사용하지?&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;GraphQL 쿼리문을 이용해서 원하는 컴포넌트에 데이터를 활용할 수있도록 해준다.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Use GraphiQL to explore the data layer and write GraphQL queries&lt;/h3&gt;

&lt;p&gt;🤔 사용자가 어떻게 자신의 사이트의 GraphQL 데이터 레이어를 알 수 있을까?&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/c6b53975530da3347f0e0d12fc175208/84a90/graphiql.png&quot; alt=&quot; GraphiQL_ex&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;갯츠비 에서는 개발자 서버를 실행할때 자동적으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GrahpiQL&lt;/code&gt;이라는 브라우저 틀을 만들어주는데,&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GrahpiQL&lt;/code&gt;를 통해서 데이터를 확인하고 쿼리를 만들어 볼 수있다.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby develop.&lt;/code&gt;이나 ` npm run start`등으로 시작&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;You can now view frog in the browser.
⠀
  http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
  http://localhost:8000/___graphql
⠀
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;-위와 같이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://localhost:8000/___graphql&lt;/code&gt;(= &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GrahpiQL&lt;/code&gt;의 주소)라는 주소를 얻게된다.&lt;/p&gt;

&lt;p&gt;🤔&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GrahpiQL&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;-&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GrahpQL&lt;/code&gt;쿼리를 코드에 추가하기전 시험하기에 용이하다&lt;/p&gt;

&lt;h3&gt;Queries in building-block components: Pull the site title into the Layout component&lt;/h3&gt;

&lt;p&gt;컴포넌트의 종류에 따라 GraphQL쿼리를 다르게 이용해주는데, 튜토리얼 상에서는 building-block 컴포넌트의 경우로 쿼리문을 진행해 볼 예정이다.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Use GraphiQL to build the query&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;-일단 이전에 사용했던 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-config.js&lt;/code&gt;파일의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;siteMetadata&lt;/code&gt;객체를 확인해보자.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;siteMetadata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;siteUrl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;https://www.yourdomain.tld&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Frog with Gatsby&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;👉 이 데이터는 파트1에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;new&lt;/code&gt;라는 커멘드를 활용해서 갯츠비 파일을 처음 설정해주었을때 만들어진 것으로, GraphQL의 데이터 레이어에 자동적으로 추가되어 사용자가 추가적으로 plugin을 설치해줄 필요가 없다.&lt;/p&gt;

&lt;p&gt;-&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;localhost:8000/___graphiql&lt;/code&gt;에 들어가 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GrahpiQL&lt;/code&gt;의 인터페이스를 확인해보자&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/explorer.png&quot; alt=&quot; GraphiQL_ex&quot; /&gt;&lt;/p&gt;

&lt;p&gt;-위와같은 창을 볼 수있는데 여기서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;site&lt;/code&gt;필드를 열어주자.&lt;br /&gt;
-다음에 푸른색의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;siteMetadata&lt;/code&gt;를 넣어주면, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-config.js&lt;/code&gt;파일의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;siteMetadata&lt;/code&gt;와 대응하게된다&lt;/p&gt;

&lt;p&gt;🤔 활용하는건 그럭저럭 이해가되었는데 다른 경우를 아직 만나지 못해서 이것저것 해봐야지 이해가 확실할것같음..&lt;/p&gt;

&lt;div class=&quot;language-jsx highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;query&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;MyQuery&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;site&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;siteMetadata&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;title&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;쿼리를 진행하는 경우 아래와 같은 결과를 얻을 수있다.&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;site&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;siteMetadata&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;My First Gatsby Site&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;extensions&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;✔ 이때 파일을 수정하는 경우 다시 갯츠비를 실행해 새로운 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GrahpiQL&lt;/code&gt;페이지를 열어주어야한다.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Use useStaticQuery to pull the site title into the Layout component&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;building-block 컴포넌트에 데이터를 넣어주어야하는 경우 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;useStaticQuery&lt;/code&gt;를 활용해 주어야한다.&lt;/p&gt;

&lt;p&gt;가. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;useStaticQuery&lt;/code&gt;와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;graphql&lt;/code&gt;를 import해준다&lt;/p&gt;

&lt;div class=&quot;language-jsx highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;React&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Link&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;useStaticQuery&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;graphql&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;heading&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;navLinks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;navLinkItem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;navLinkText&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;./layout.module.css&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;children&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt;

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

&lt;p&gt;나.GraphiQL에서 받아온 쿼리를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;useStaticQuery&lt;/code&gt;로 받아준다. 이때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;graphql&lt;/code&gt;를 이용해 GraphQL 쿼리를 이용해준다는 것을 명시해주고 변수에 저장해준다.&lt;/p&gt;

&lt;div class=&quot;language-jsx highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;useStaticQuery&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`
  query {
    site {
      siteMetadata {
        title
      }
    }
  }
`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;✔ 이때 GraphiQL에서 얻은 쿼리문에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MyQuery&lt;/code&gt;가 있는데, 사용할때 이를 삭제해주는 이유는 이름이 충돌이 나면 안되어서 !라는데 맞는지 모르겟음 누가 제발 알려줘바 ,,&lt;/p&gt;

&lt;p&gt;다. 이렇게 객체에 값을 얻게되면, 레이아웃 컴포넌트에 넣어 사용할 수있다.&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data.site.siteMetadata.title&lt;/code&gt; 와같이 작성해 이용해 줄 수있다.&lt;/p&gt;

&lt;div class=&quot;language-jsx highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;children&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;useStaticQuery&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`
    query {
      site {
        siteMetadata {
          title
        }
      }
    }
  `&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt; | &lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;site&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;siteMetadata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;site&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;siteMetadata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;header&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
      ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3&gt;Queries in page components: Create a blog page with a list of post filenames&lt;/h3&gt;

&lt;p&gt;블로그페이지를 만들어보면서 페이지 컴포넌트를 활용해보자!&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;블로그 파일을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/pages/blog.js&lt;/code&gt;에 만들어주자!&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-jsx highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;React&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;../components/layout&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;My Blog Posts&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;My cool posts will go in here&lt;span class=&quot;p&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;✔ 이전에 만들어 주었던 파일들과 유사하게 layout과 필요한 친구들을 받아주고 레이아웃에 BLOG 링크를 추가해주자!&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;mdx 블로그 포스팅을 만들어주자!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/54dd7a9f2f7d387ff78ebbc5e1f2f566/89a37/blog-posts-folder-structure.png&quot; alt=&quot; GraphiQL_ex&quot; /&gt;&lt;/p&gt;

&lt;p&gt;가. blog 폴더 형성&lt;/p&gt;

&lt;p&gt;나.&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.mdx&lt;/code&gt;확장자로 세개의 블로그 파일을 만들어줍니다&lt;/p&gt;

&lt;p&gt;(폴더명이나,게시물의 이름은 마음대로 하지만 확장자의 이름을 잘지켜주고 폴더명을 바꿀경우 제발 기억해주자^^…)&lt;/p&gt;

&lt;p&gt;다. 게시글을 저장해주기위해서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-source-filesystem&lt;/code&gt; 플러그인을 활용해주자&lt;/p&gt;

&lt;div class=&quot;language-zsh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;gatsby-source-filesystem
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;이 플러그인의 경우 추가적인 설정을 필요로 하기 때문에 설치 후 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-config.js&lt;/code&gt;에 설정을 진행해주자.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;resolve&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby-source-filesystem&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;nx&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nl&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;`blog`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;__dirname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/blog`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;이러한 설정을 통해, 파일들을 데이터 레이어에 넣어줄 수 있다.&lt;br /&gt;
(???? 이게 어케 넣어주는건데요 ㅠㅠ )&lt;/p&gt;

&lt;p&gt;👉 사이트가 구축되면 플러그인은 경로 옵션(&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;${__dirname}/blog&lt;/code&gt;)에 저장된 폴더의 모든 파일을 데이터 레이어에 추가해준다&lt;/p&gt;

&lt;p&gt;➕ &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;__dirname&lt;/code&gt;는 Node.js의 변수로 현재 실행중인 파일이 포함된 디렉터리의 절대 경로를 저장해준다&lt;/p&gt;

&lt;p&gt;라. 리액트를 재시작해서 설정해준 것을 저장해준다&lt;/p&gt;

&lt;p&gt;마. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GrahpiQL&lt;/code&gt;에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;allFile&lt;/code&gt;을 이용해서 데이터를 요청해주자&lt;/p&gt;

&lt;p&gt;🤔&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;allFile&lt;/code&gt;을 이용해주는 이유가뭐지??&lt;/p&gt;

&lt;div class=&quot;language-graphql highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MyQuery&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;allFile&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;이렇게 진행을 해주면 이전에 만들어 놓았던 블로그의 이름을 얻게된다.&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;data&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;allFile&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;nodes&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;my-first-post&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;another-post&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;yet-another-post&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;nl&quot;&gt;&quot;extensions&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;바. 페이지 쿼리를 이용해 데이터를 보내주자&lt;/p&gt;

&lt;p&gt;이전의 빌딩 컴포넌트와 유사하지만 이번에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;graphql&lt;/code&gt;만 import 해주어 진행해준다.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;graphql&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;GraphiQL에서 받아온 쿼리를 이용해주는데 이때,이전에 다른 함수 내부에 변수를 만들어 쿼리를 넣어주었던것과 달리 외부에 독립적인 변수를 만들어 export해주는 방식으로 진행해준다&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;query&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;graphql&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;`
  query {
    allFile {
      nodes {
        name
      }
    }
  }
`&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;그런데 이때 이전에 GraphiQL에서 3개의 배열의 형태로 나오므로 map을 이용해서 사용해주자&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;BlogPage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;My Blog Posts&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ul&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;allFile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;nodes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;li&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/li&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;        &lt;span class=&quot;p&quot;&gt;))}&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/ul&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Layout&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;✔ 리액트에서의 map의 경우각 엘리먼트마다 특정한 key를 주어야한다
(?key를 왜쓰는건지 절대 공부해야할것같아…)
또한 리턴시에 각 노드를 루프해주고 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;li&amp;gt;&lt;/code&gt;로 감싸주어야한다&lt;/p&gt;</content><author><name>Songzi Vong</name><email>vszhub@gmail.com</email></author><category term="Gatsby" /><summary type="html">Meet Gatsby’s GraphQL data layer</summary></entry><entry><title type="html">갯츠비찍먹!-Part 3:PLUGIN?</title><link href="https://kaeru-1224.github.io//2021/11/09/part3/" rel="alternate" type="text/html" title="갯츠비찍먹!-Part 3:PLUGIN?" /><published>2021-11-09T19:22:00+00:00</published><updated>2021-11-09T19:22:00+00:00</updated><id>https://kaeru-1224.github.io//2021/11/09/part3</id><content type="html" xml:base="https://kaeru-1224.github.io//2021/11/09/part3/">&lt;ol&gt;
  &lt;li&gt;What is a plugin?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/32e5b9ab0e4b8b65d4ed5683f5e7130b/5df5d/cooking-accessories.png&quot; alt=&quot;plugin_ex&quot; /&gt;&lt;/p&gt;

&lt;p&gt;-갯츠비에서는 &lt;a href=&quot;https://www.gatsbyjs.com/plugins&quot;&gt;plugin&lt;/a&gt;은 추가기능을 받을 수있도록하는 별개의 npm 패키지로 불린다.갯츠비 플러그인은 여러 경우, 다양한 기능에 쓰이며 몇 플러그인은 미리 만들어진 컴포넌트를 죽이도하고 데이터를 가져올 수있도록 도와주기도한다.갯츠비 플러그인의 경우 갯츠비 직원이 만들기도 하고, 갯츠비를 사용하는 커뮤니티원들이 만들기도한다.&lt;/p&gt;

&lt;p&gt;🤔 그러면 결국 플러그인이뭘까?&lt;br /&gt;
👉 플러그인은 무조건적으로 사용할 필요는 없고 사용자가 직접 그 기능을 만들어도 되는 거지만 조금 더 간편하고 사용자의 시간을 단축시켜주는데 도움이되는 일종의 보조도구와 유사한 것이다. 마치 요리에서 보조 도구와 같이 말이다 !&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Add a plugin to your site&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;-&lt;a href=&quot;https://www.gatsbyjs.com/plugins/gatsby-plugin-image/?=gatsby-plugin-i&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-image&lt;/code&gt;&lt;/a&gt;을 통해 플러그인 사용법을 익혀보자&lt;/p&gt;

&lt;p&gt;🤔&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-image&lt;/code&gt;는 그러면 어떤 플러그인인거지?&lt;/p&gt;

&lt;p&gt;👉 갯츠비에 다양한 이미지를 추가해주는 것을 도와주는 플러그인으로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;StaticImage&lt;/code&gt;와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GatsbyImage&lt;/code&gt; 라는 두개의 컴포넌트중 하나를 이용한다. 전자의 경우 한개의 반복되는 static이미지(로고와 같은 이미지)에 사용이되고 후자의경우에는 매번 사용할때마다 다른 데이터를 받아오는 경우에( 튜토리얼에서는 dynamic 이미지라 명시하고있다) 사용한다.&lt;/p&gt;

&lt;p&gt;가. npm을 통해 플러그인을 설치해주자&lt;/p&gt;

&lt;p&gt;✅ 이때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-image&lt;/code&gt;와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-plugin-sharp&lt;/code&gt;를 함께 설치해 주어야하며, static 이미지를 사용할 경우에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-source-filesystem&lt;/code&gt;를 dynamic이미지를 사용 할 경우 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-transformer-sharp&lt;/code&gt;를 추가해서 설치해 주어야한다&lt;/p&gt;

&lt;div class=&quot;language-zsh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;gatsby-plugin-image gatsby-plugin-sharp gatsby-source-filesystem
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;우리의 경우 static를 활용할 것이기 때문에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-source-filesystem&lt;/code&gt;만 추가해주어 이용해주었다.&lt;/p&gt;

&lt;p&gt;🤔 추가되는 플러그인들은 어떤 역할을하지?&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;gatsby-plugin-sharp : gatsby-plugin-image에 의해 사용되는 실제 이미지 처리를 다룬다&lt;/li&gt;
  &lt;li&gt;gatsby-source-filesystem : 컴퓨터 파일 시스템에서 데이터를 가져올 수 있도록 도와준다&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;나. config파일을 형성 ,설정해준다&lt;br /&gt;
-&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-config.js&lt;/code&gt;에서 플러그인 항목을 추가, 설정해준다(gatsby-config.js 파일이 아마 새로 만들어줘야하는거 같다..?)&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;siteMetadata&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;My First Gatsby Site&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;plugins&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby-plugin-image&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby-plugin-sharp&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;✔ &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-config.js&lt;/code&gt;의 경우 갯츠비가 자동적으로 감지하는 특정한 파일로, 플러그 인이나 다른 설정들을 추가할때 사용해준다&lt;br /&gt;
✔&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gatsby-config.js&lt;/code&gt;을 업데이트 해준 후에는 개발 서버가 알아서 재시작된느 경우도 있지만, 예상하지 못한 사태가 발생할 수있으므로 서버를 멈추고 재시작하는 것을 갯츠비에서는 권유하고 있다.&lt;/p&gt;

&lt;p&gt;다. 설치한 플러그인을 사용해보자&lt;br /&gt;
(✔ 현재 우리는 static 이미지와 관련된 플러그인만 사용하고있다 )&lt;/p&gt;

&lt;p&gt;-프로젝트에 이미지 추가&lt;br /&gt;
-&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;StaticImage&lt;/code&gt; 컴포넌트를 템플릿에 추가해준다&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;StaticImage&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby-plugin-image&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;👉 import로 템플릿에 추가해준다&lt;/p&gt;

&lt;p&gt;-추가해준 컴포넌트를 사용해주자&lt;/p&gt;

&lt;div class=&quot;language-jsx highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;React&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;../components/layout&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;StaticImage&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby-plugin-image&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;IndexPage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Home Page&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;I'm making this by following the Gatsby Tutorial.&lt;span class=&quot;p&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StaticImage&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Clifford, a reddish-brown pitbull, posing on a couch and looking stoically at the camera&quot;&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;https://pbs.twimg.com/media/E1oMV3QVgAIr1NT?format=jpg&amp;amp;name=large&quot;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;IndexPage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;✔ 이때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;StaticImage&lt;/code&gt;는 셀프 클로징태그로, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;/StaticImage&amp;gt;&lt;/code&gt;와 같은 것을 작성해줄 필요없다.&lt;br /&gt;
✔ &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;StaticImage&lt;/code&gt;는 HTML와 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;img&amp;gt;&lt;/code&gt;태그와 유사한 props를 지니고 있다.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src&lt;/code&gt;(string): 사용하고자하는 사진의 저장위치 및 URL&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;alt&lt;/code&gt;(string): 사진에 대한 설명 텍스트로 접근성을 향상 시키기위해 사용된다&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 만약 이미지를 외부주소를 통해 가져오는 경우, 그 이미지가 다른 서버에서 변경될 때 이미지가 재구성될때까지 사이트에 업데이트 되지 않는다.&lt;/p&gt;

&lt;p&gt;➕ -이미지를 설정하자&lt;/p&gt;

&lt;div class=&quot;language-jsx highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;StaticImage&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby-plugin-image&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Dino&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;StaticImage&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;../images/dino.png&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;A dinosaur&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;placeholder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;blurred&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;fixed&quot;&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;👉 이미지 설정시 &lt;a href=&quot;https://www.gatsbyjs.com/docs/reference/built-in-components/gatsby-plugin-image&quot;&gt;API &lt;/a&gt;를 확인해 사용해주면된다&lt;/p&gt;</content><author><name>Songzi Vong</name><email>vszhub@gmail.com</email></author><category term="Gatsby" /><summary type="html">What is a plugin?</summary></entry><entry><title type="html">갯츠비찍먹!-Part 2:React?</title><link href="https://kaeru-1224.github.io//2021/11/05/part2/" rel="alternate" type="text/html" title="갯츠비찍먹!-Part 2:React?" /><published>2021-11-05T06:24:00+00:00</published><updated>2021-11-05T06:24:00+00:00</updated><id>https://kaeru-1224.github.io//2021/11/05/part2</id><content type="html" xml:base="https://kaeru-1224.github.io//2021/11/05/part2/">&lt;ul&gt;
  &lt;li&gt;What is React?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-리액트는 UI를 만들기위해서 갯츠비가 기반으로 사용하는 자바스크립트 라이브러리로, 리액트로 사용자는 ui를 컴포넌트라는 재사용할 수 있는 조각으로 나눌 수있게된다.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/e956cd45d790934484f0d93643c87cc7/5df5d/ui-built-from-components.png&quot; alt=&quot;component_ex&quot; /&gt;&lt;/p&gt;

&lt;p&gt;-다른 컴포넌트로부터 컴포넌트를 만들 수있다. 예를들어 현재 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;ProducGrid&amp;gt;&lt;/code&gt;라는 컴포넌트에서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;PostCard&amp;gt;&lt;/code&gt;라는 여러개이 컴포넌트 리스트를 만들어줄 수있는데, 이 리스트는 한 제품의 여러 디테일을 보여주는데 이용된다. 이러한 패턴을 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;composition&lt;/code&gt;이라 부른다&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;What is a React Component?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-리액트 컴포넌트는 리액트 요소를 리턴해주는 함수로, 리액트 요소는 DOM 요소를 랜더링해주는 객체이다.&lt;/p&gt;

&lt;p&gt;( 🤔 DOM/그리고 정확히 elements를 뭐라 정의내릴까?)&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;const Greeting = () =&amp;gt; {
  return (
    &amp;lt;h1&amp;gt;Hello world!&amp;lt;/h1&amp;gt;
  )
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;리액트 요소는 위와같이 JSX로 작성이된다.JSX는 HTML이 자바 스크립트 파일 안에 있는것 같은 모양을 지니고 있다&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🤔 JSX?&lt;br /&gt;
 👉 JSX(=Java Script syntax)는 자바 스크리트를 확장한 문법으로 React 엘리먼트를 생성해줍니다&lt;/p&gt;

&lt;p&gt;😧 리액트 공식문서에서 JSX 설명이 꽤 길어서 이건 따로 공부를 해주어야할 것 같다)&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Create a page component&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-겟츠비 사이트에서는 두 타입의 컴포넌트가 있는데, 그중하나가 바로 페이지 컴포넌트 이다.페이지 컴포넌트는 특정 페이지의 모든 UI요소들을 포함하고 있다.&lt;/p&gt;

&lt;p&gt;🤔 그러면 React 컴포넌트를 어떻게 작성하는걸까?: 공식 사이트에서는 3스텝으로 이야기해준다&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;import React!&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// Step 1: 리액트를 import해주어서 js파일내에서  jsx를 사용할 수있게해준다.&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;React&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;Define your component: 컴포넌트를 정의해준다&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Mycomponent&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Hi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;welcome&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;site&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/h1&amp;gt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;!! 이때 컴포넌트의 이름은 대문자로 시작해야한다, 리턴하는 값은 한개의 값만 가능하며 아래의 예시는 진행시 에러가 난다.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;InvalidComponent&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;This&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;won&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;t work.&amp;lt;/h1&amp;gt;
    &amp;lt;p&amp;gt;Because there are two elements at the top level.&amp;lt;/p&amp;gt;
  )
}
/*-Adjacent JSX elements must be wrapped in an enclosing tag.
Did you want a JSX fragment와같은 에러를 받게된다*/
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;이러한 경우 두가지 방법으로 해결이 가능하다.&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;//1.div나 상위 엘리먼트로 감싸주기&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;InvalidComponent&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;This&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;won&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;t work.&amp;lt;/h1&amp;gt;
      &amp;lt;p&amp;gt;Because there are two elements at the top level.&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};
//2.fragment이용해주기
const InvalidComponent = () =&amp;gt; {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;h1&amp;gt;This won&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;work&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/h1&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Because&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;there&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;are&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;two&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;elements&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;at&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;the&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;top&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;level&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/p&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;만들어준 컴포넌트를 export해준다!&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Mycomponent&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Hi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;welcome&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;site&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/h1&amp;gt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Mycomponent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;🤔그런데 왜 export default만 사용이 가능한거지?&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Create a new page component for an About page&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;페이지를 새로 만들때에는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/src&lt;/code&gt; 폴더에 새로운 js파일을 추가해 위의 세가지 단계를 밟아주면된다.&lt;/p&gt;

&lt;p&gt;–&amp;gt; 그런데 개인적으로 신기했던게 이전에 express를 사용하면서 라우트하는 작업을 하고 진행을하던게 여기에서는 쉽게 진행이되는게 신기해서, 이게 왜 이렇게 되는지도 궁금하기도했음..🤔&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Building-block components.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;blockquote&gt;
    &lt;p&gt;여기서 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Building-block components&lt;/code&gt; 라는 단어는 겟츠비 내에서만 특정 컴포넌트를 묘사할때만 쓰는 단어로, 기술적인 용어는 아니다. Building-block의 경우 전체 페이지가 아닌 ui의 일부를 이야기하며 Building-block이 모여서 하나의 page component가 된다.&lt;/p&gt;
  &lt;/blockquote&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
  &lt;li&gt;Components with props(properties)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;-ex1) Link components&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Link components는 갯츠비 패키지에서 미리 만들어진 components로 , 링크는 겟츠비 사이트에 단어 그대로 링크를 추가할 수있도록해준다.&lt;/p&gt;

    &lt;p&gt;🤔그런데 그러면 HTML에서의 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;a&amp;gt;&lt;/code&gt;태그와의 차이가 무엇일까?&lt;br /&gt;
 👉 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;href=&lt;/code&gt;를 사용해주는 a태그와는 달리 링크 컴포넌트는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;to=&lt;/code&gt;를 이용한다.to의 뒤에도 href와 동일하게 이동하고자하는 URL을 작성해주면된다.&lt;br /&gt;
 또한 링크의 경우 사용자가 마우스를 링크위에 놓았을대 미리 링크된 페이지에 대한 리소스가 요청이되는 사전 로딩이되어 a태그와는 달리 조금더 빠른 로딩이 가능하다.
(??preloading에 대한 설명을 좀더보기)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;사용법&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;React&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Link&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;추가되는&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;부분&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;IndexPage&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Home&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Page&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/title&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Welcome&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Gatsby&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;site&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/h1&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Link&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/about&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;About&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Link&amp;gt;  &amp;lt;&amp;lt; 추가되는 부&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;분
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;I&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;m making this by following the Gatsby Tutorial.&amp;lt;/p&amp;gt;
    &amp;lt;/main&amp;gt;
  );
};

export default IndexPage;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;그런데 link 사용하는 방법이 엄청 신기해서 리액트는 대부분 이렇게 진행이되는건가하는 생각도 들었음.ㅇㅇ..
아닐수도 잇겟지만 ㅋㅋㅋ,, 동시에 이게 왜 이렇게 되는지도 궁금하긴한것같다ㅋㅋ.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Using layout&lt;/p&gt;

    &lt;p&gt;1)왜 레이아웃을 이용해주는걸까?&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;레이아웃의 경우 반복을 방지하고 재사용에 용이하기 때문이다. 다양한 사이트를 이용해보면 우리는 몇몇 컴포넌트들이 계속해서 사용된다는 것을 볼수있다. 그리고 몇개의 페이지의 경우 반복이 가능하지만 만약에 그게 천개가 넘는다면? 이라는 극단적인 가정을 해보면,이 반복 작업을 최대한 줄여 나가고 싶을 것이다. 그래서 우리는 레이아웃 컴포넌트를 만들어서 반복에서 탈출해볼것이다.&lt;/p&gt;

    &lt;p&gt;2)Children&lt;/p&gt;

    &lt;p&gt;😧 이전 실습(?)을 개인적으로 진행하면서 레이아웃을 만들고 내부에 요소를 넣었는데 굴러가지 않아서 당황했는데 어제 다시해보니 children 속성을 넣지 않아서! 라는 것을 알수있었다. ㅋㅋ ㅠㅠ 개똥벌레 노래 불러야한다 정말&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;! 레이아웃을 만들어보자&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/components/layout.js&lt;/code&gt;파일을 만들어주자&lt;/li&gt;
  &lt;li&gt;props를 이용해 코드를 작성한다&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;React&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Link&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;children&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/title&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;nav&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ul&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Link&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Home&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Link&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/li&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Link&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/about&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;About&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Link&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/li&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/ul&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/nav&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/h1&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/main&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/div&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;위와 같이 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;const Layout = ({ PageTitle , children })&lt;/code&gt;를 통해서 반복되는 부분에 변수를 지정해 줄 수있다.&lt;/p&gt;

&lt;div class=&quot;language-jsx highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;HomepageMain&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;PageTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Home&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;I'm making this by following Gatsby Tutorial. &lt;span class=&quot;p&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;사용은 위의 코드와 같이 사용되는데, 이때 지정해준 변수를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PageTitle=&quot;Home&quot;&lt;/code&gt;와 같이 사용해주는데, children의 경우는 새로운 태그로 작성하면 사용이 가능하다.그런데 이때 레이아웃에서의 children을 제외한 태그들의경우 부모태그로 큰틀이되어 유지되고,children의 경우 다양하게 바꿔주며 사용이 가능하다&lt;/p&gt;

&lt;p&gt;🤔그러면 여러 위치에 children 태그가 여러개 들어갈수있는건가?&lt;/p&gt;

&lt;p&gt;!CSS를 사용해보자!&lt;/p&gt;

&lt;blockquote&gt;
  &lt;blockquote&gt;
    &lt;p&gt;갯츠비에서는 페이지 스타일링에 대해서 엄격한 기준이 적기 때문에,무엇이든 개인이 사용하기 좋은것을 사용하라 이야기하고 있다!, 튜토리얼에서는 css 모듈을 이용하고 있기 때문에 나도 그대로 진행을 해보기로 결정했다&lt;/p&gt;
  &lt;/blockquote&gt;
&lt;/blockquote&gt;

&lt;p&gt;(🤔 그런데 왜 모듈을 이용해준걸가 추가적인 설치나 구성이 필요없기 때문인걸까? 그리고 정확히 모듈이뭘까?)&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;사용법!&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;새로운 파일을 만들어준다&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/components/layout.module.css&lt;/code&gt;이라는 이름으로 만들어주는데 이때 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.module.css&lt;/code&gt;라고 적어주어야지 겟츠비 역시 현재 사용자가 css 모듈을 사용하고 있는 것을 알기 때문에 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.module.css&lt;/code&gt;이라 정확히 적어주어야한다&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.container&lt;/code&gt; class 하나를 적어주자&lt;/li&gt;
    &lt;/ol&gt;

    &lt;div class=&quot;language-css highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nc&quot;&gt;.container&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;max-width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;500px&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nl&quot;&gt;font-family&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sans-serif&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;🤔 아마도 튜토리얼에서는 콘테이너라는 이름의 클래스를 만들어주자!라서, 결국 html에서의 class명을 이용해주는 방식으로 작성해주세요~ 하는 내용인것같..다?&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;스타일을 적용할 곳에 className으로 적용해주자&lt;/li&gt;
    &lt;/ol&gt;

    &lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;React&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;react&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Link&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;gatsby&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;container&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;./layout.module.css&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;모듈을&lt;/span&gt;  &lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;해준다&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;({&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;children&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;div&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;className&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;container&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;css적용할&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;곳에&lt;/span&gt;  &lt;span class=&quot;nx&quot;&gt;className으로&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;지정해준다&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/title&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;nav&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ul&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Link&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Home&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Link&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/li&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Link&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;/about&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;About&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/Link&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;          &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/li&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/ul&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/nav&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;pageTitle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/h1&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;        &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;children&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/main&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/div&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Layout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;😧html에서 쓰이는 태그와 jsx에서 사용되는 것이 class/ className의 형식으로 다르기 때문에 조심해 주어야한다.&lt;br /&gt;
이후로는 동일하게 css을 작성해서 필요한 곳에 사용해주면되지만, 이때 css에서는 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-&lt;/code&gt;가 사용이 가능하지만 리액트에서는 불가능하므로 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nav-links&lt;/code&gt;를 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;navLinks&lt;/code&gt; 의 형태로 활용해주면된다&lt;/p&gt;

    &lt;p&gt;🤔그런데 저렇게 바꿔서 적용이된다는 걸 어떻게 인식하는건지 넘신기…&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;</content><author><name>Songzi Vong</name><email>vszhub@gmail.com</email></author><category term="Gatsby" /><summary type="html">What is React?</summary></entry><entry><title type="html">갯츠비찍먹!-튜토리얼 파트1 진행기</title><link href="https://kaeru-1224.github.io//2021/11/04/part1/" rel="alternate" type="text/html" title="갯츠비찍먹!-튜토리얼 파트1 진행기" /><published>2021-11-04T19:12:00+00:00</published><updated>2021-11-04T19:12:00+00:00</updated><id>https://kaeru-1224.github.io//2021/11/04/part1</id><content type="html" xml:base="https://kaeru-1224.github.io//2021/11/04/part1/">&lt;p&gt;1.갯츠비가뭐지?
&lt;img src=&quot;https://www.gatsbyjs.com/static/0fd27b745c1de708f034eaf97c4416e0/5df5d/deployment-workflow.png&quot; alt=&quot;site_ex&quot; class=&quot;align-center&quot; /&gt;&lt;/p&gt;

&lt;p&gt;👉 갯츠비는 오픈소스 프레임워크로 정적사이트 생성기로 이전에 사용해보았던 Jekyll와 비슷한 역할을 해주는 친구로 결국에는 웹사이트를 쉽게 만들 수 있도록 도와주는 도구!라고 생각하기로했다.
그리고 진행 순서는 위의 그림과 같은데, 아직은 이런느낌이구나하는 생각이들었다, 그래도 그림도 설명도 친절해서 진입장벽이 정말 높지않게 느껴졌다!&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;갯츠비를 사용해보자!&lt;/p&gt;

    &lt;p&gt;&lt;a href=&quot;https://www.gatsbyjs.com/docs/tutorial/part-0/&quot;&gt;갯츠비홈페이지&lt;/a&gt;에 들어가보면 튜토리얼이 상세히 나와있는데, 그중에서 겟츠비를 사용하기위해 필요한 지식들이 언급되어있다.&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HTML&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CSS&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;JavaScript&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;command-line&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;React&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GraphQL&lt;/code&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;👉 그런데 나는 다행히(?) 리액트 찍먹을 목적으로 겟츠비를 시작한 것이기때문에 1~3까지의 얼레벌레함으로 비벼보기로했다^^..&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;게츠비를 다운받아보자&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;👉 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm init gatsby&lt;/code&gt; 을 통해서 겟츠비를 바로 다운 , 다운이 완료되었을 경우 질문이 순차적으로 등장한다.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  1.  What would you to call your site: 사이트명을 무엇으로할지
  2.  What would you like to name the folder where your site will be created?: 사이트가 만들어질 폴더명
  3.  Will you be using a CMS &amp;gt;No
  4.  Would you like to install a styling system?&amp;gt; No (or I’ll add it later)
  5.  Would you like to install additional features with other plugins? &amp;gt; Done
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;👉 설명 상에서는 1,2 만 설정후 3-5의경우 추후 설정이 가능하니 넘어갔었어서 그대로 진행해주었다.그렇게 진행을 해주면 아래와같은 답을 얻게된다.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;🎉  Your new Gatsby site My First Gatsby Site has been successfully
created at ~/Desktop/my-first-gatsby-site.
Start by going to the directory with

  cd my-first-gatsby-site

Start the local development server with

  npm run develop

See all commands at

  https://www.gatsbyjs.com/docs/gatsby-cli/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;🤔 나는 이때 설치후 바로 npm run~ 을 통해 진행을 해주려했는데, 명령어가 없다는 에러를 만나게되었는데 알고보니 명령어를 실행한 위치가 잘못되었던 것이어서 cd~를 통해서 내가 사용할 곳으로 이동해서 해결해주었다&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;와! 겟츠비! 그리고 클라우드!&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;/localhost-new-site.png&quot; alt=&quot;site_ex&quot; class=&quot;align-center&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;👉 이와같은 사이트를 얻게되었다!, 이제 사이트 관리를 조금더 용이하기위해서 깃허브와 연결해주자&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git remote add origin 깃허브HTTPS
git branch -M main
git push -u origin main
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;연결이 무사히 되었다면 이제 클라우드와 연결 해 줄 수 있다&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/9c130998b561f1770834309715c99d5b/5df5d/01-create-a-site-button.png&quot; alt=&quot;cloud_ex&quot; class=&quot;align-center&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;👉 나는 전부 무료 플랜으로 가입을 해주었고, 가입시 처음에는 위와같은 화면이 등장한데 Add a site 버튼을 클릭해보자&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/4fd11cb2e4af910ca099f70d12aa8421/5df5d/05-github-gatsby-cloud-permissions.png&quot; alt=&quot;cloud_ex2&quot; class=&quot;align-center&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;👉 게츠비 클라우드에 설치해주는데, 나는 지금하는 프로젝트에만 추가하고 싶어서 only select repositories로 선택해주었다.&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://www.gatsbyjs.com/static/4c20fbda1fdeea993b3c0ce797a3e7b2/5df5d/07-add-site-details.png&quot; alt=&quot;cloud_ex2&quot; class=&quot;align-center&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;👉 설명을 보며 순차적으로 진행을 해주다가 여기서 조금 궁금했던데, 두번째의 Site Detail부분이 새로운게있어서 다시확인을 해줘야할것같다ㅇㅇ.. 하지만 일단 디폴트로 진행해 주라해서 넘겨주었다!
이후에도 설명을 참고하면서 쭉 진행을 해주니까 오류 없이 지나갈 수있었다 ㅇㅇ..&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;</content><author><name>Songzi Vong</name><email>vszhub@gmail.com</email></author><category term="Gatsby" /><summary type="html">1.갯츠비가뭐지?</summary></entry><entry><title type="html">First Posting:BLOG’S B-DAY!</title><link href="https://kaeru-1224.github.io//2021/11/01/first/" rel="alternate" type="text/html" title="First Posting:BLOG’S B-DAY!" /><published>2021-11-01T17:12:00+00:00</published><updated>2021-11-01T17:12:00+00:00</updated><id>https://kaeru-1224.github.io//2021/11/01/first</id><content type="html" xml:base="https://kaeru-1224.github.io//2021/11/01/first/">&lt;h1 id=&quot;깃허브-블로그제작&quot;&gt;깃허브 블로그제작&lt;/h1&gt;

&lt;hr /&gt;

&lt;p&gt;1.참고사이트&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://pages.github.com/&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;깃허브공식문서&lt;/code&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://zeddios.tistory.com/1222&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Zedd0202님 블로그&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.진행흐름&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;repository 만들기&lt;br /&gt;
&lt;img src=&quot;/re.png&quot; alt=&quot;repository_ex&quot; class=&quot;align-center&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;제작시 repository의 이름은 &lt;strong&gt;반드시 {username}.github.io&lt;/strong&gt;의 형태가되어야한다.&lt;/p&gt;

    &lt;p&gt;🤔그런데 왜 저형태가 되어야하는걸까?&lt;/p&gt;

    &lt;blockquote&gt;
      &lt;p&gt;If the first part of the repository doesn’t exactly match your username, it won’t work, so make sure to get it right.&lt;/p&gt;
    &lt;/blockquote&gt;

    &lt;p&gt;😧저렇게 하면 안되니까라는 정확한 이유였다..마쟈 규칙을 따르는 사회구성원이됩시다..&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Clone the repository&lt;br /&gt;
&lt;img src=&quot;/clone.png&quot; alt=&quot;repository_ex2&quot; class=&quot;align-center&quot; /&gt;&lt;/p&gt;

    &lt;div class=&quot;language-zsh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/username/username.github.io
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;👉 이때 위의 주소는 사용자 repository의 HTTPS를 복사하면된다&lt;/p&gt;

    &lt;p&gt;🤔Clone the repository?&lt;/p&gt;

    &lt;blockquote&gt;
      &lt;p&gt;프로젝트의 모든 파일 및 폴더 버전을 포함하여 해당 시점에 GitHub.com에 있는 모든 리포지토리 데이터의 전체 복사본이 풀다운됩니다. GitHub.com의 원격 리포지토리에 변경 내용을 푸시하거나 GitHub.com에서 다른 사용자의 변경 내용을 가져올 수 있습니다.&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;프로젝트 폴더로 들어가 파일생성해주기&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-zsh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;username.github.io
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hello World&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; index.html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;4.&lt;a href=&quot;https://jekyllrb-ko.github.io/docs/&quot;&gt;jekyll&lt;/a&gt;를 이용해 블로그를 더꾸며보자!&lt;/p&gt;

&lt;p&gt;🤔하지만 놀랍게도 깔려고했지만 루비가 없어서 루비를 설치하는 것부터 시작해야했다 ^^…&lt;/p&gt;

&lt;p&gt;1)우분투에서 &lt;a href=&quot;https://www.ruby-lang.org/ko/documentation/installation/&quot;&gt; 루비 &lt;/a&gt;설치&lt;/p&gt;

&lt;div class=&quot;language-zsh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;ruby-full
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;😧그런데 이후에 gem을 업데이트하려고보니 &lt;hilight&gt; `Ruby: You don't have write permissions for the /var/lib/gems/2.7.0 directory.` 라는 에러가 등장했다.&lt;/hilight&gt;&lt;/p&gt;

&lt;p&gt;👉 그래서 전체를 검색을 해보니 위와같은&lt;a href=&quot;https://int-i.github.io/linux/2020-09-07/ruby-no-permission/&quot;&gt;결과&lt;/a&gt;를 얻게되었다. 그런데 따라서 해결을 하던 도중에 다시 문제가 발생했는데, 오류가계속 나왔던건데 알고보니 나는 &lt;a href=&quot;https://goyunji.tistory.com/23&quot;&gt;zsh라서 .bashrc로 진행&lt;/a&gt;을해서 그런거였다. 이걸 기록해주신분께 감사를감사를 …&lt;/p&gt;

&lt;p&gt;2)이후에 문서를 보며 다시진행&lt;/p&gt;

&lt;div class=&quot;language-zsh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gem &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;jekyll bundler
jekyll new myblog
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;기존 깃 클론을하며 만들어놓았던 html을 삭제후 , 번들러설치 new를 이용해 새 사이트를 생성해주려했는데is not empty ~라는 에러?를 만나게되었다.&lt;/p&gt;

&lt;p&gt;👉 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jekyll new . --force&lt;/code&gt;를 이용해서 해결해주었는데, 여기서 왜 비어있어야하지?하는 의문점이 좀 들었음&lt;/p&gt;</content><author><name>Songzi Vong</name><email>vszhub@gmail.com</email></author><category term="회고" /><summary type="html">깃허브 블로그제작</summary></entry><entry><title type="html">Testing MathJax</title><link href="https://kaeru-1224.github.io//2020/10/02/testing-mathjax/" rel="alternate" type="text/html" title="Testing MathJax" /><published>2020-10-02T07:32:00+00:00</published><updated>2020-10-02T07:32:00+00:00</updated><id>https://kaeru-1224.github.io//2020/10/02/testing-mathjax</id><content type="html" xml:base="https://kaeru-1224.github.io//2020/10/02/testing-mathjax/">&lt;p&gt;Not Pure Poole supports &lt;a href=&quot;https://www.mathjax.org/&quot;&gt;MathJax&lt;/a&gt;. You can enable it on a page by setting &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;math: true&lt;/code&gt; in the front matter.&lt;/p&gt;

&lt;p&gt;An inline math: \(E=mc^2\).&lt;/p&gt;

&lt;p&gt;A display math:&lt;/p&gt;

\[i\hbar \frac{\partial \Psi}{\partial t} = -\frac{\hbar^2}{2m}
\frac{\partial^2 \Psi}{\partial x^2} + V \Psi\]</content><author><name>Songzi Vong</name><email>vszhub@gmail.com</email></author><category term="mathjax" /><summary type="html">Not Pure Poole supports MathJax. You can enable it on a page by setting math: true in the front matter.</summary></entry><entry><title type="html">Releasing Not Pure Poole v0.1.0</title><link href="https://kaeru-1224.github.io//2020/10/01/releasing-not-pure-poole-v0-1-0/" rel="alternate" type="text/html" title="Releasing Not Pure Poole v0.1.0" /><published>2020-10-01T05:56:00+00:00</published><updated>2020-10-01T05:56:00+00:00</updated><id>https://kaeru-1224.github.io//2020/10/01/releasing-not-pure-poole-v0-1-0</id><content type="html" xml:base="https://kaeru-1224.github.io//2020/10/01/releasing-not-pure-poole-v0-1-0/">&lt;p&gt;The Jekyll theme &lt;strong&gt;Not Pure Poole&lt;/strong&gt; v0.1.0 was released!&lt;/p&gt;

&lt;p&gt;Not Pure Poole is a simple, beautiful, and powerful Jekyll theme for blogs. It is built on &lt;a href=&quot;https://github.com/poole/poole&quot;&gt;Poole&lt;/a&gt; and &lt;a href=&quot;https://purecss.io/&quot;&gt;Pure&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For more information about this theme, you can read the &lt;a href=&quot;https://github.com/vszhub/not-pure-poole/blob/master/README.md&quot;&gt;README&lt;/a&gt; file.&lt;/p&gt;</content><author><name>Songzi Vong</name></author><category term="jekyll theme" /><category term="jekyll" /><summary type="html">The Jekyll theme Not Pure Poole v0.1.0 was released!</summary></entry></feed>