{"componentChunkName":"component---src-templates-blog-post-js","path":"/blog/2021-03-23-migrating-portfolio-and-blog-to-gatsby-pt1/","result":{"data":{"markdownRemark":{"html":"<p>Hi there! I have been ausent for a while now.</p>\n<p>I would like to document here about migrating my portfolio and blog from vanilla JavaScript and Jekyll to GatsbyJS.</p>\n<!-- more -->\n<p>At the beginning of 2020, when the Covid-19's pandemic started unfolding, we had our beautiful daughter.\nAs many people, our family (wife, boy and girl) spent a lot of time together.\nOur kid with remote schooling, and the adults taking kare of our baby while working also remotelly.</p>\n<p>Today I decided to rebuild my site almost from scratch.</p>\n<p>Its present iteration was built in vanilla JavaScript (the portfolio bit), while the blog was built with Jekyll, using the Minima theme (which is awesome).</p>\n<p>Since I like React quite a bit, and I have created a simple project with GatsbyJS recently, decided to rebuild my personal site using it.</p>\n<p>This is not a mamooth migration in any way, but I thought it would be nice to write about the process and some differences I might find.</p>\n<p>So, to the little differences I found today:</p>\n<h2>Excerpt separator</h2>\n<p>In Jekyll, you could declare an excerpt separator directly in your post's header.</p>\n<p>As far as I know, you can't do this in GatsbyJS.\nInstead, you have to declare the excerpt separator in your <strong>gatsby-confgig.js</strong>, like so:</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\"><span class=\"token punctuation\">{</span>\n  resolve<span class=\"token operator\">:</span> <span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">gatsby-transformer-remark</span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">,</span>\n  options<span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n    excerpt_separator<span class=\"token operator\">:</span> <span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">&lt;!-- more --></span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>You can the use this excerpt separator like you would with Jekyll:</p>\n<div class=\"gatsby-highlight\" data-language=\"markdown\"><pre class=\"language-markdown\"><code class=\"language-markdown\">This is a sample excerpt.\n\n<span class=\"token comment\">&lt;!-- more --></span>\n\nAnd here is the rest of the arcticle.</code></pre></div>\n<h2>Syntax highlighting</h2>\n<p>While Jekyll has built in support for syntax highlighting, GatsbyJS does not.</p>\n<p>I decided to go with <a href=\"https://www.gatsbyjs.com/plugins/gatsby-remark-prismjs/\">gatsby-remark-prismjs</a>, which is neat:</p>\n<div class=\"gatsby-highlight\" data-language=\"language-none\"><pre class=\"language-language-none\"><code class=\"language-language-none\">npm install gatsby-transformer-remark gatsby-remark-prismjs prismjs</code></pre></div>\n<p>Next, in your <strong>gatsby-config.js</strong>:</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\">plugins<span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span>\n  <span class=\"token punctuation\">{</span>\n    resolve<span class=\"token operator\">:</span> <span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">gatsby-transformer-remark</span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">,</span>\n    options<span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n      plugins<span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span>\n        <span class=\"token punctuation\">{</span>\n          resolve<span class=\"token operator\">:</span> <span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">gatsby-remark-prismjs</span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">,</span>\n          options<span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n            <span class=\"token comment\">// These are only some default options values, there are tons of options:</span>\n            classPrefix<span class=\"token operator\">:</span> <span class=\"token string\">\"language-\"</span><span class=\"token punctuation\">,</span>\n            inlineCodeMarker<span class=\"token operator\">:</span> <span class=\"token keyword\">null</span><span class=\"token punctuation\">,</span>\n          <span class=\"token punctuation\">}</span>\n        <span class=\"token punctuation\">}</span>\n      <span class=\"token punctuation\">]</span>\n    <span class=\"token punctuation\">}</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">]</span>    </code></pre></div>\n<p>I reccomend checking out it's <a href=\"https://www.gatsbyjs.com/plugins/gatsby-remark-prismjs/\">documentation</a>, which is great.</p>\n<p>It is <strong>required</strong> that you pick a PrismJS <a href=\"https://github.com/PrismJS/prism/tree/1d5047df37aacc900f8270b1c6215028f6988eb1/themes\">theme</a>, or create your own. You can preview these themes <a href=\"http://prismjs.com/\">here</a>.</p>\n<p>I'm just repeating the documentation now, but to load a theme, just require its CSS file in your gatsby-browser.js, like so:</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\"><span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"prismjs/themes/prism-okaidia.css\"</span><span class=\"token punctuation\">)</span></code></pre></div>\n<p>That is the one I'm using here.</p>\n<p>Finally, to use this super awesome highlighting in your markdown, do the following:</p>\n<div class=\"gatsby-highlight\" data-language=\"markdown\"><pre class=\"language-markdown\"><code class=\"language-markdown\"> ```javascript\n  // In your gatsby-config.js\n  plugins: [\n    {\n      resolve: <span class=\"token code keyword\">`gatsby-transformer-remark`</span>,\n      options: {\n        plugins: [\n          <span class=\"token code keyword\">`gatsby-remark-prismjs`</span>,\n        ]\n      }\n    }\n  ]\n ```</code></pre></div>\n<p>This is all for today, now I should continue the migration.</p>\n<p>This will continue in Part 2, cheers!</p>","frontmatter":{"title":"Migrating portfolio and blog to GatsbyJS - Part 1","date":"March 23rd, 2021","icon":"☕️"},"fields":{"readingTime":{"text":"3 min read"}}}},"pageContext":{"slug":"/2021-03-23-migrating-portfolio-and-blog-to-gatsby-pt1/"}},"staticQueryHashes":["143701507","588331372"]}