<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jinay Jain</title>
    <description>The latest articles on DEV Community by Jinay Jain (@jinayjain).</description>
    <link>https://dev.to/jinayjain</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F390782%2F12ea14e6-e926-4872-b9b7-76658b8ea5df.jpeg</url>
      <title>DEV Community: Jinay Jain</title>
      <link>https://dev.to/jinayjain</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jinayjain"/>
    <language>en</language>
    <item>
      <title>How I Built My Blog</title>
      <dc:creator>Jinay Jain</dc:creator>
      <pubDate>Wed, 20 May 2020 14:06:35 +0000</pubDate>
      <link>https://dev.to/jinayjain/how-i-built-my-blog-81g</link>
      <guid>https://dev.to/jinayjain/how-i-built-my-blog-81g</guid>
      <description>&lt;h2&gt;
  
  
  My Final Project
&lt;/h2&gt;

&lt;p&gt;In the end, I built a small static site generator to build and deploy my Markdown-based blog to GitHub Pages.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo Link
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://jinayjain.github.io/blog/"&gt;https://jinayjain.github.io/blog/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Link to Code
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vWogaON8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-28d89282e0daa1e2496205e2f218a44c755b0dd6536bbadf5ed5a44a7ca54716.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/JinayJain"&gt;
        JinayJain
      &lt;/a&gt; / &lt;a href="https://github.com/JinayJain/blog"&gt;
        blog
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;h1&gt;
  
  
  How It Works
&lt;/h1&gt;

&lt;p&gt;The main idea behind this project is to build a &lt;strong&gt;static site generator&lt;/strong&gt;,&lt;br&gt;
something that will compile my blogposts into a single, deployable website.&lt;br&gt;
The term, though, can mean many different things depending on how the system&lt;br&gt;
is implemented, so I had to answer some questions before I started building.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How will I write my blogposts?&lt;/li&gt;
&lt;li&gt;What tools will I use to compile the blog?&lt;/li&gt;
&lt;li&gt;How will I deploy the blog?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What I ended up choosing was to use Markdown as my syntax for writing, NodeJS&lt;br&gt;
to build the project, and GitHub pages to deploy (using the &lt;code&gt;gh-pages&lt;/code&gt; NPM&lt;br&gt;
package). These initial choices outlined the general series of steps needed to assemble my blog generator.&lt;/p&gt;
&lt;h2&gt;
  
  
  Rendering Markdown Files
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Markdown"&gt;Markdown&lt;/a&gt; (the syntax language for&lt;br&gt;
GitHub README's and many texting platforms), has a relatively simple syntax&lt;br&gt;
that enables a writer to define very basic text editing features: headers,&lt;br&gt;
bolding/italics, links, or code. This allows programmers to easily convert Markdown into other formats like LaTeX documents, Beamer presentations, and HTML pages. In fact, the &lt;a href="https://pandoc.org/"&gt;pandoc&lt;/a&gt; tool includes native support for converting markdown into a plethora of other file formats, allowing the user to control much of the styling and formatting of the document.&lt;/p&gt;

&lt;p&gt;If I wanted to, I might have created a simple parser for Markdown myself.&lt;br&gt;
But---of course---there was a neat NPM package that did the work for me,&lt;br&gt;
&lt;a href="https://github.com/markdown-it/markdown-it"&gt;markdown-it&lt;/a&gt;. In my code, I&lt;br&gt;
simply read the desired Markdown file as a string and the simple&lt;br&gt;
&lt;code&gt;md.render(source)&lt;/code&gt; would parse the document and convert it into HTML tags. &lt;code&gt;markdown-it&lt;/code&gt; has several extensions that add extra syntax support for more specific needs. I added the &lt;code&gt;markdown-it-katex&lt;/code&gt; package to include math equation rendering.&lt;/p&gt;

&lt;p&gt;While rendering, a line like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$$ f(x)=\int_{0}^{1} x^2 dx $$
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;is converted into actual LaTeX-rendered math equations.&lt;/p&gt;

&lt;p&gt;

&lt;/p&gt;
&lt;div class="katex-element"&gt;
  &lt;span class="katex-display"&gt;&lt;span class="katex"&gt;&lt;span class="katex-mathml"&gt;f(x)=∫01x2dx
f(x)=\int_{0}^{1} x^2 dx
&lt;/span&gt;&lt;span class="katex-html"&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mord mathdefault"&gt;f&lt;/span&gt;&lt;span class="mopen"&gt;(&lt;/span&gt;&lt;span class="mord mathdefault"&gt;x&lt;/span&gt;&lt;span class="mclose"&gt;)&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mrel"&gt;=&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="base"&gt;&lt;span class="strut"&gt;&lt;/span&gt;&lt;span class="mop"&gt;&lt;span class="mop op-symbol large-op"&gt;∫&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t vlist-t2"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;&lt;span class="mord mtight"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-s"&gt;​&lt;/span&gt;&lt;/span&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mspace"&gt;&lt;/span&gt;&lt;span class="mord"&gt;&lt;span class="mord mathdefault"&gt;x&lt;/span&gt;&lt;span class="msupsub"&gt;&lt;span class="vlist-t"&gt;&lt;span class="vlist-r"&gt;&lt;span class="vlist"&gt;&lt;span&gt;&lt;span class="pstrut"&gt;&lt;/span&gt;&lt;span class="sizing reset-size6 size3 mtight"&gt;&lt;span class="mord mtight"&gt;2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="mord mathdefault"&gt;d&lt;/span&gt;&lt;span class="mord mathdefault"&gt;x&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/div&gt;



&lt;p&gt;which makes life much easier than trying to explain a loss function with convoluted notation like &lt;code&gt;(y_i - p_i)^2&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I plan on adding some other syntax features as my needs evolve, but the ability to extend the core funcitonality of Markdown is why it's such an appealing language for developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Capturing Post Metadata
&lt;/h2&gt;

&lt;p&gt;Some information about the posts---the title, creation date, URL,&lt;br&gt;
etc.---shouldn't be directly shown to the user, so I created a way to handle&lt;br&gt;
that data first before feeding it into &lt;code&gt;markdown-it&lt;/code&gt;. Most SSG systems either&lt;br&gt;
include this metadata in separate files or within a special section in their&lt;br&gt;
Markdown called the front matter. I chose to use the latter, which meant my&lt;br&gt;
Markdown files would have a small section above the Markdown storing the&lt;br&gt;
metadata. For example, here's the front matter for this post:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
title: How I Built My Blog
author: Jinay Jain
description: A reflection on how I created the static site generator behind this blog.
date: 1588601471
---
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Those are only a few of the things I've added to the blog and I hope to keep updating the system as my requirements change, but for now, these few features are all I need to get started with blogging.&lt;/p&gt;

</description>
      <category>octograd2020</category>
    </item>
  </channel>
</rss>
