<?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: Angelo Dias</title>
    <description>The latest articles on DEV Community by Angelo Dias (@angelod1as).</description>
    <link>https://dev.to/angelod1as</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%2F33282%2F6762dd37-a3c8-4991-8189-0dd7032ca86e.jpg</url>
      <title>DEV Community: Angelo Dias</title>
      <link>https://dev.to/angelod1as</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/angelod1as"/>
    <language>en</language>
    <item>
      <title>Navigating Careers</title>
      <dc:creator>Angelo Dias</dc:creator>
      <pubDate>Tue, 17 Sep 2024 15:00:00 +0000</pubDate>
      <link>https://dev.to/seasonedcc/navigating-careers-24o1</link>
      <guid>https://dev.to/seasonedcc/navigating-careers-24o1</guid>
      <description>&lt;p&gt;I was invited by &lt;a href="https://seasoned.cc" rel="noopener noreferrer"&gt;Seasoned&lt;/a&gt; to work towards the growth of a new enterprise, and it's been a &lt;em&gt;challenging&lt;/em&gt; experience.&lt;/p&gt;

&lt;p&gt;Writing, per se, has never been something I had a hard time with (you'll understand why in a few paragraphs), but describing how it is to work with something I'm &lt;em&gt;not quite experienced in&lt;/em&gt; makes me shiver.&lt;/p&gt;

&lt;p&gt;It's not the first time I’ve moved careers — and it won't be the last — and I want to share a bit of how things are going, and how I moved from journalism to graphic design, then to coding, then to &lt;em&gt;tech-leading&lt;/em&gt;, then to growth marketing.&lt;/p&gt;

&lt;p&gt;First, some context.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2p54377t5kodxbz7c2ld.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2p54377t5kodxbz7c2ld.png" alt="Juggler. Photo from Matheus Bertelli" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A proud generalist
&lt;/h2&gt;

&lt;p&gt;My professional life can be summarized as &lt;em&gt;filling the gaps&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I started studying journalism in 2009 — I loved writing and taking pictures — but soon noticed every journalism student could write (better than me, even), but not one of them could put the text + photos on a pretty page. I saw a gap, I studied it, and I filled it. I finished college as a &lt;em&gt;graphic journalist&lt;/em&gt;, a position that didn't exist and that I made for myself. This landed me a job at Latin America's biggest newspaper, Folha de S.Paulo.&lt;/p&gt;

&lt;p&gt;Then, as a full-time graphic designer — doing layout, infographics, and the occasional journalistic writing — I realized everyone had a great taste for &lt;em&gt;print&lt;/em&gt;, but they had a terrible understanding of the internet and how things could be displayed there. I started studying simple HTML and CSS, then moved to JavaScript, and before I knew it, I was, again, &lt;em&gt;filling a gap&lt;/em&gt;. My new job had a simple description (and a fairly complicated execution): to build tools and ways of moving print material to the internet in a beautiful, usable, and even interactive way.&lt;/p&gt;

&lt;p&gt;The designers couldn't code. I could. Soon I was not only moving stuff from print to the web but doing stuff &lt;em&gt;web first&lt;/em&gt; — damn, I fought to do stuff &lt;em&gt;mobile first&lt;/em&gt;! People liked working with me because I &lt;em&gt;knew&lt;/em&gt; journalism, I &lt;em&gt;knew&lt;/em&gt; design, and I &lt;em&gt;knew&lt;/em&gt; the internet and how to work around it.&lt;/p&gt;

&lt;p&gt;Then, after moving on from Folha, I started working with heavy-duty programmers and, guess what? Found a &lt;em&gt;gap&lt;/em&gt;. They were great coders, way better than I ever was, but terrible communicators. They could make any computer do their bidding, but trembled and sweated in a client meeting. They had conflicts while talking to product people, and a real struggle understanding how the design process worked.&lt;/p&gt;

&lt;p&gt;They needed someone that had the &lt;em&gt;technical knowledge&lt;/em&gt;, understood how &lt;em&gt;designers&lt;/em&gt; work, and also had a love for &lt;em&gt;communication&lt;/em&gt;. Well, I could absolutely fill this gap. So I did it.&lt;/p&gt;

&lt;p&gt;Since then, this has been my (very hard to advertise) job description — a proud generalist that links developers, designers, and non-technical people. A kind of &lt;em&gt;tech lead&lt;/em&gt; that's not just &lt;em&gt;tech&lt;/em&gt;. I would code, of course, but mainly get the team processes oiled up so they could do what they knew best, and everyone could be on the same page. I put this on the &lt;a href="https://angelodias.com.br" rel="noopener noreferrer"&gt;first part of my website&lt;/a&gt;, so that every recruiter could see it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm552bqijor5lw2rn61y1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm552bqijor5lw2rn61y1.png" alt="Printscreen of my website" width="688" height="497"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Movin' on up
&lt;/h2&gt;

&lt;p&gt;After my last project ended, &lt;a href="https://www.linkedin.com/in/danielweinmann" rel="noopener noreferrer"&gt;Daniel Weinmann&lt;/a&gt; (Seasoned's CEO) called me and invited me to a new — and novel — position. I was coding for the last, &lt;em&gt;hmm&lt;/em&gt;, 8 or 9 years, but he wanted something more. When I worked for him as a coder some years ago, he always said stuff like, "I think you're more than just a programmer, but &lt;em&gt;right now&lt;/em&gt; we don't have any way of testing that — because the job requires a coder and you &lt;em&gt;are&lt;/em&gt; a coder." This time, he had a &lt;em&gt;great&lt;/em&gt; team of coders — like, really, people with &lt;em&gt;amazing&lt;/em&gt; skills. What he didn't have was someone with the knack for tackling new things, studying stuff from scratch, and doing their best to communicate all that.&lt;/p&gt;

&lt;p&gt;For him, I was the guy. He insisted, more than once, that I should try to face this new challenge.&lt;/p&gt;

&lt;p&gt;If there's one person I deem &lt;em&gt;persuasive&lt;/em&gt;, it's Daniel. I accepted this role and here I am, now, learning a &lt;em&gt;bunch&lt;/em&gt; of stuff, going from &lt;em&gt;zero&lt;/em&gt; to &lt;em&gt;hero&lt;/em&gt;, and doing my best to share all of that. My new position? &lt;em&gt;Head of Growth&lt;/em&gt;, someone to tackle all obstacles in growing a new product they are working hard on.&lt;/p&gt;

&lt;p&gt;This is not a publicity post, so I won't talk much about what we're building — if you want to check it out, you can visit &lt;a href="https://getflashboard.com" rel="noopener noreferrer"&gt;Flashboard's website&lt;/a&gt; — but this is an introduction to whatever will come next. This is the first of (hopefully) a series of articles on how things have been going and what I've been learning.&lt;/p&gt;

&lt;p&gt;I hope that, if you find yourself in the same career-moving journey, you find this &lt;em&gt;at least&lt;/em&gt; interesting. Let me know if my path has resonated with you below, in the comments. I would love to hear about it.&lt;/p&gt;

</description>
      <category>career</category>
      <category>learning</category>
      <category>management</category>
    </item>
    <item>
      <title>5 Common Pain Points in PostgreSQL</title>
      <dc:creator>Angelo Dias</dc:creator>
      <pubDate>Tue, 10 Sep 2024 18:30:00 +0000</pubDate>
      <link>https://dev.to/seasonedcc/5-common-pain-points-in-postgresql-admin-panels-40na</link>
      <guid>https://dev.to/seasonedcc/5-common-pain-points-in-postgresql-admin-panels-40na</guid>
      <description>&lt;p&gt;Before building Flashboard (our PostgreSQL admin app), our development team had struggled with a lot of stuff that you might've encountered in your PostgreSQL journey. &lt;/p&gt;

&lt;p&gt;I'm not just talking about tracking foreign keys or building extra-complex SQL queries, but also finding a way to make data editable for non-technical folks without needing to build an entire new software to support the &lt;em&gt;main thing&lt;/em&gt; — after all, the &lt;em&gt;main thing&lt;/em&gt; is where the core of the work should be, right, Project Owners? &lt;/p&gt;

&lt;p&gt;Well, here are the most common pain points in PostgreSQL (and, being honest, a bit about how Flashboard solves them at the end of the article).&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Time-Consuming Query Creation
&lt;/h2&gt;

&lt;p&gt;Building SQL queries is fun — until it isn't. It's like RegEx — you get that big, broad smile when it works, but after the 10th time you just hit ChatGPT and ask it to build it for you. It becomes tiresome, error-prone, and, mainly, time-consuming. The &lt;em&gt;f-in-fun&lt;/em&gt; becomes &lt;em&gt;f-in-frustration&lt;/em&gt; when you have to redo it all because you got a new client.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Navigating Foreign Keys
&lt;/h2&gt;

&lt;p&gt;A good PostgreSQL database probably has a lot of foreign keys — and that's a green flag in architecture design... or at least that's what the architects say. When the developers need to navigate the schema, jumping from one related table to the other, things get confusing — you gain database-performance in exchange for developer-speed.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Handling JSON Data
&lt;/h2&gt;

&lt;p&gt;I know the feeling of working with JSON in PostgreSQL. Saving data this way saves time and space, but it's waaaay too difficult to query it. You need special operators and functions, and when you’re working with nested structures, it’s easy to mess something up.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Creating Secure Interfaces for Non-Tech Teams
&lt;/h2&gt;

&lt;p&gt;You might need to give access to the database to non-technical users — sometimes there's no time to build a feature in the &lt;em&gt;main app&lt;/em&gt; or there's no proper admin panel setup for them. This is hard work — it’s not just about making sure they don’t break anything, but also ensuring sensitive data stays locked down. Building a secure admin interface means juggling encryption, access control, and usability — when you notice it, you are building a secondary software as hard to maintain as the primary one.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Scaling Custom Admin Solutions
&lt;/h2&gt;

&lt;p&gt;Continuing from the last topic: what starts as a simple admin panel for a small team can quickly balloon into a mess as your user base or data grows. Suddenly, you’re dealing with performance issues, broken queries, and features that no longer work as expected. Scaling a custom solution is a beast of a task, and unless you planned for it from day one, you’ll probably need to rebuild a good chunk of it down the road.&lt;/p&gt;

&lt;h2&gt;
  
  
  It would be awesome if a tool existed to solve all of these problems, right?
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;(read the next sentence as if a TV host from the 80s was saying it)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Well, I have some good news! &lt;strong&gt;&lt;a href="https://getflashboard.com" rel="noopener noreferrer"&gt;Flashboard&lt;/a&gt;&lt;/strong&gt; to the rescue!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcx2dpqmoylao2u07rk2y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcx2dpqmoylao2u07rk2y.png" alt="Screenshot of the Flashboard app" width="800" height="511"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(ok, serious now)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We got tired of sidetracking our &lt;em&gt;main things&lt;/em&gt; to build complicated admin panels, so we made admin panels our main thing. I know this next paragraph might sound a little sale-y, but I promise we're just devs recommending good software for other devs. Yeah, we believe in what we're building — and you know this feeling.&lt;/p&gt;

&lt;p&gt;Flashboard instantly generates admin panels, so no more hand-coding complex queries. It simplifies foreign key navigation and JSON querying, so you can breathe easy. Security? Encrypted credentials and tailored user access are built in. And it’s scalable, so whether you're a startup or scaling up, it’ll grow with you.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(now, back with the TV host's voice)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Say goodbye to PostgreSQL admin pain points and focus on what you do best — &lt;strong&gt;building awesome stuff&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Comment below what other pain points you find in PostgreSQL! We're &lt;em&gt;totally&lt;/em&gt; not going to add that to our backlog 😉&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>database</category>
    </item>
    <item>
      <title>How to run an open-source design project?</title>
      <dc:creator>Angelo Dias</dc:creator>
      <pubDate>Sat, 26 Nov 2022 10:49:51 +0000</pubDate>
      <link>https://dev.to/angelod1as/how-to-run-an-open-source-design-project-2mbd</link>
      <guid>https://dev.to/angelod1as/how-to-run-an-open-source-design-project-2mbd</guid>
      <description>&lt;p&gt;&lt;em&gt;Disclaimer: no links in this article are NSFW, but they aren't SFW exactly. Please read further&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I'm working with the BDSMtest team to open-source and modernize it. This work is a personal endeavor — doing something many peers have talked about but never actually started.&lt;/p&gt;

&lt;p&gt;A quick introduction: &lt;a href="//bdsmtest.org/"&gt;BDSMtest.org&lt;/a&gt; is a website where you can test how kinky you are and what kinds of kinks you are mainly into. It's not precisely NSFW — there are no images or explicit wording — but as the theme is sexuality and kink, your work might not approve of you clicking the link during your shift. I'd recommend taking the test, even if you are vanilla.&lt;/p&gt;

&lt;p&gt;Don't know what &lt;em&gt;vanilla&lt;/em&gt; is? Then, well, take the test.&lt;/p&gt;

&lt;p&gt;The website has been up since 2014. Every kinky friend — quite a lot — and even non-kinky people have been using it as an essential source of information on their kinky preferences.&lt;/p&gt;

&lt;p&gt;I am a front-end developer looking forward to redesigning the website and modernizing its codebase. After doing that, the idea is to revisit the test structure, questions, and results with the help of data scientists (not my area, but that's what open-source is for, right?)&lt;/p&gt;

&lt;h2&gt;
  
  
  The question
&lt;/h2&gt;

&lt;p&gt;The first part of any modernization project is to think about architecture: how is the current website organized, and what's the goal of the modernization. In this project, one of my goals is to make it look &lt;em&gt;better&lt;/em&gt;. It's not exactly ugly; it's just... old. So, it would need a new design.&lt;/p&gt;

&lt;p&gt;I, as a front-end developer, have some knowledge of how open-source coding happens: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;you find a GitHub repository;&lt;/li&gt;
&lt;li&gt;fork it;&lt;/li&gt;
&lt;li&gt;work;&lt;/li&gt;
&lt;li&gt;open a PR respecting the &lt;code&gt;CONTRIBUTING&lt;/code&gt; guidelines;&lt;/li&gt;
&lt;li&gt;Answer comments;&lt;/li&gt;
&lt;li&gt;Make requested changes;&lt;/li&gt;
&lt;li&gt;(Hopefully) get it approved;&lt;/li&gt;
&lt;li&gt;...&lt;/li&gt;
&lt;li&gt;(Not) profit!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But, as a designer... how could that work?&lt;/p&gt;

&lt;h2&gt;
  
  
  Tools
&lt;/h2&gt;

&lt;p&gt;First, design does not have straightforward collaboration tools like GitHub, with granular versioning. There's Figma, of course, but having multiple collaborators in it costs money, and someone can just come and erase everything, right?&lt;/p&gt;

&lt;p&gt;It would be necessary to have a clear conduct guideline on how to work on that shared project and also be sure no one is breaking those rules — which would be a manual task, as there are no automated tests or way to compare the current work with the former.&lt;/p&gt;

&lt;p&gt;There are also no PRs: any work done happens in the same space. If someone deletes something or changes a component, we'd only be able to notice it after they already done it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In Figma, all the commits are in &lt;em&gt;main&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, how to collaborate knowing the source will be preserved while making it possible for new people to add work?&lt;/p&gt;

&lt;h2&gt;
  
  
  Behavior
&lt;/h2&gt;

&lt;p&gt;If you are a professional programmer, you may know how to group code. The whole GitHub — or GitLab, or whatever tool you prefer — ecosystem is natural to us, as we've been using it forever.&lt;/p&gt;

&lt;p&gt;There are straightforward tools inside GitHub, for instance, to prevent commits on main, block PRs if the workflows fail, require specific approvals when merging, etc. There's nothing like that in Figma, for instance.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A quick thought&lt;/em&gt;: I'm using Figma as an example because there are no other collaborative design tools in my mind right now. After Figma's acquisition by Adobe, XD isn't even on the table anymore.&lt;/p&gt;

&lt;p&gt;How to guide the behavior of new collaborators in an open-source design project? How to avoid destructive workflows? How to maintain project structure while allowing collaboration?&lt;/p&gt;

&lt;h2&gt;
  
  
  Blocked
&lt;/h2&gt;

&lt;p&gt;This situation blocks my progress with this task. I will start my design process by myself, but I would love for it to be public and collaborative — I don't know where to begin to make this happen.&lt;/p&gt;

&lt;p&gt;Do you know the answer? Could you share this with designer friends or start this discussion with your colleagues? Will Figma ever get their hands on this and make it free for open-source software?&lt;/p&gt;

&lt;p&gt;I can only kneel and pray — oops, new kink unlocked.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>design</category>
      <category>collaboration</category>
      <category>question</category>
    </item>
    <item>
      <title>Create Markdown blog posts automatically</title>
      <dc:creator>Angelo Dias</dc:creator>
      <pubDate>Sat, 30 Jul 2022 18:17:16 +0000</pubDate>
      <link>https://dev.to/angelod1as/create-markdown-blog-posts-automatically-2npm</link>
      <guid>https://dev.to/angelod1as/create-markdown-blog-posts-automatically-2npm</guid>
      <description>&lt;p&gt;&lt;em&gt;This was originally published on my &lt;a href="https://www.angelodias.com.br/blog" rel="noopener noreferrer"&gt;personal blog&lt;/a&gt; — yeah, they exist. What do you think about &lt;a href="https://www.angelodias.com.br/blog" rel="noopener noreferrer"&gt;going there&lt;/a&gt; and subscribing to my 100% non-spammy newsletter?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I had to go through the following process whenever I wanted to create a &lt;strong&gt;new blog post&lt;/strong&gt; in my blog — powered by &lt;strong&gt;local Markdown&lt;/strong&gt; files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Get inside the "content" folder&lt;/li&gt;
&lt;li&gt;Navigate to the "blog" folder&lt;/li&gt;
&lt;li&gt;Create a "year" folder&lt;/li&gt;
&lt;li&gt;Create a "month" folder&lt;/li&gt;
&lt;li&gt;Create a "publication" folder&lt;/li&gt;
&lt;li&gt;Add the &lt;code&gt;md&lt;/code&gt; file with the blog post slug&lt;/li&gt;
&lt;li&gt;Open the &lt;code&gt;md&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Open an old, published &lt;code&gt;md&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Copy the frontmatter from the old post&lt;/li&gt;
&lt;li&gt;Paste it on the new post&lt;/li&gt;
&lt;li&gt;Clear the data&lt;/li&gt;
&lt;li&gt;Write the metadata&lt;/li&gt;
&lt;li&gt;Update createdAt field&lt;/li&gt;
&lt;li&gt;Start writing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ugh, that's a &lt;strong&gt;long&lt;/strong&gt; (and &lt;strong&gt;boring&lt;/strong&gt; list).&lt;/p&gt;

&lt;p&gt;This was making me feel not much &lt;em&gt;programmery&lt;/em&gt;, so I created a &lt;strong&gt;simple script&lt;/strong&gt; to automate it. Let's go through it together?&lt;/p&gt;

&lt;p&gt;You will be able to do the following at the end of this tutorial:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write a CLI command&lt;/li&gt;
&lt;li&gt;Have a &lt;code&gt;.md&lt;/code&gt; file automatically created&lt;/li&gt;
&lt;li&gt;Have the correct &lt;code&gt;frontmatter&lt;/code&gt; in this file&lt;/li&gt;
&lt;li&gt;Be in a new &lt;code&gt;git&lt;/code&gt; branch&lt;/li&gt;
&lt;li&gt;Automatically open &lt;code&gt;VS Code&lt;/code&gt; (or other) to edit this file&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  This tutorial is good for:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;New developers&lt;/strong&gt; that need to lose &lt;code&gt;terminal&lt;/code&gt; fear&lt;/li&gt;
&lt;li&gt;Anyone who wants to make their workflow &lt;strong&gt;faster&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;People who have locally-hosted MD(X) blogs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setting up the environment
&lt;/h2&gt;

&lt;p&gt;For this small project, you only need to have a project that reads &lt;code&gt;md&lt;/code&gt; files and that uses &lt;code&gt;node&lt;/code&gt;. It can be &lt;code&gt;mdx&lt;/code&gt; or anything else you'd like, honestly. It's not framework specific, so feel free to adapt to your system. My Node version is &lt;code&gt;v16.14.2&lt;/code&gt; at the moment writing.&lt;/p&gt;

&lt;p&gt;Requirements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node&lt;/li&gt;
&lt;li&gt;Node-running project (package.json)&lt;/li&gt;
&lt;li&gt;Yarn (or NPM, your choice)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Willpower&lt;/strong&gt; and &lt;strong&gt;patience&lt;/strong&gt; to research and try/error if something does not match exactly your folder structure and project configuration.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Concept
&lt;/h2&gt;

&lt;p&gt;Requirements for the script:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Usable from the &lt;strong&gt;CLI&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;Two &lt;strong&gt;types&lt;/strong&gt; of content (blog or project, in my case);&lt;/li&gt;
&lt;li&gt;Pass the &lt;strong&gt;file name&lt;/strong&gt; so the folders and files are created correctly;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatically&lt;/strong&gt; fill &lt;code&gt;frontmatter&lt;/code&gt; in the new files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pseudo usage&lt;/strong&gt;: &lt;code&gt;{script name} {type} {filename}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example with yarn&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Input: &lt;code&gt;yarn content blog tutorial&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Output: folders and files for &lt;code&gt;tutorial.md&lt;/code&gt; are created in the &lt;code&gt;blog&lt;/code&gt; section, with the &lt;code&gt;blog&lt;/code&gt; frontmatter.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Creating the files
&lt;/h2&gt;

&lt;p&gt;At the &lt;strong&gt;root&lt;/strong&gt; of the project, I created a &lt;code&gt;scripts&lt;/code&gt; folder and put a few files we will be using — I prefer to split my code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;content.mjs&lt;/li&gt;
&lt;li&gt;frontmatter.mjs&lt;/li&gt;
&lt;li&gt;getFilename.mjs&lt;/li&gt;
&lt;li&gt;getToday.mjs&lt;/li&gt;
&lt;li&gt;gitNewBranch.mjs&lt;/li&gt;
&lt;li&gt;openInVsCode.mjs&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  .mjs?
&lt;/h3&gt;

&lt;p&gt;This file is not a simple javascript file, it is a javascript &lt;strong&gt;module&lt;/strong&gt; (hence the &lt;code&gt;m&lt;/code&gt;). This makes &lt;code&gt;node&lt;/code&gt; understand the syntax we are using without the need to compile each file before running it.&lt;/p&gt;

&lt;p&gt;Inside the &lt;code&gt;mjs&lt;/code&gt; is plain &lt;code&gt;javascript&lt;/code&gt; code, so if your IDE complains about the file extensions, &lt;strong&gt;adapt&lt;/strong&gt; this to your usage.&lt;/p&gt;

&lt;p&gt;PS: There &lt;em&gt;might&lt;/em&gt; be some configuration needed in your project. Do a little &lt;strong&gt;research&lt;/strong&gt; if some error show up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Main file
&lt;/h2&gt;

&lt;p&gt;Let's build a function and call it at the end of the &lt;code&gt;content.mjs&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

&lt;span class="nf"&gt;newContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to test this, we will use &lt;code&gt;nodemon&lt;/code&gt; — a tool that runs &lt;code&gt;node&lt;/code&gt; scripts in watch mode.&lt;/p&gt;

&lt;p&gt;I have it installed &lt;strong&gt;globally&lt;/strong&gt; using &lt;code&gt;yarn global add nodemon&lt;/code&gt;, or you can add it to your project by &lt;code&gt;yarn add -D nodemon&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In your console, navigate to the &lt;strong&gt;root&lt;/strong&gt; of your project and run &lt;code&gt;nodemon scripts/content.mjs&lt;/code&gt;. You will see the console waiting for you to &lt;strong&gt;save&lt;/strong&gt; the file so it can re-run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;nodemon] 2.0.19
&lt;span class="o"&gt;[&lt;/span&gt;nodemon] to restart at any &lt;span class="nb"&gt;time&lt;/span&gt;, enter &lt;span class="sb"&gt;`&lt;/span&gt;rs&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;nodemon] watching path&lt;span class="o"&gt;(&lt;/span&gt;s&lt;span class="o"&gt;)&lt;/span&gt;: &lt;span class="k"&gt;*&lt;/span&gt;.&lt;span class="k"&gt;*&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;nodemon] watching extensions: js,mjs,json
&lt;span class="o"&gt;[&lt;/span&gt;nodemon] starting &lt;span class="sb"&gt;`&lt;/span&gt;node scripts/content.mjs&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;nodemon] clean &lt;span class="nb"&gt;exit&lt;/span&gt; - waiting &lt;span class="k"&gt;for &lt;/span&gt;changes before restart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Name and Type
&lt;/h2&gt;

&lt;p&gt;We need to get the file type and name from the CLI (see "Concept", above). &lt;code&gt;node&lt;/code&gt; gets ,in the &lt;code&gt;process.argv&lt;/code&gt; property, all that is passed after the script name as items in an array.&lt;/p&gt;

&lt;p&gt;So, if I pass &lt;code&gt;yarn scriptname first second&lt;/code&gt;, I'll get an array with &lt;code&gt;[node-path, script-path, 'first', 'second']&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That said, let's add a function to &lt;code&gt;getFilename.mjs&lt;/code&gt; file and get the filename and type &lt;strong&gt;destructuring&lt;/strong&gt; the &lt;code&gt;process.argv&lt;/code&gt; array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// getFilename.mjs&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getFilename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Here we omit the two first argument. We don't need them.&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[,&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;argv&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also want to make sure that the script &lt;strong&gt;stops&lt;/strong&gt; here if any of these two arguments are not passed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// getFilename.mjs&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getFilename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[,&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;argv&lt;/span&gt;

  &lt;span class="c1"&gt;// In my project, I need the type property to match "blog"&lt;/span&gt;
  &lt;span class="c1"&gt;// or "projects" because of the way my folders are organized&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;blog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;projects&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Invalid type: should be "blog" or "projects"&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;You need to pass a filename&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will need to tell our script &lt;strong&gt;what's the folder&lt;/strong&gt; it will save the files we will create in.&lt;/p&gt;

&lt;p&gt;Here lies a small &lt;strong&gt;quirk&lt;/strong&gt; in &lt;code&gt;node&lt;/code&gt;. I'm used to getting my directory as &lt;code&gt;__dirname&lt;/code&gt; in some projects but, by some unknown reason I needed to create my own &lt;code&gt;__dirname&lt;/code&gt; variable using &lt;code&gt;fileURLToPath&lt;/code&gt; from the native &lt;code&gt;url&lt;/code&gt; package, some functions from &lt;code&gt;path&lt;/code&gt;, and the global &lt;code&gt;import.meta.url&lt;/code&gt;. This is not the focus of this tutorial, so please just do as I do 🤓&lt;/p&gt;

&lt;p&gt;Inside &lt;code&gt;join&lt;/code&gt; you should put the &lt;strong&gt;relative path&lt;/strong&gt; to where you want your files to be saved. In my case, I want them in the &lt;code&gt;content&lt;/code&gt; folder, then inside a folder corresponding to the type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// getFilename.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;join&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;fileURLToPath&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;url&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getFilename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[,&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;argv&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;blog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;projects&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Invalid type: should be "blog" or "projects"&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;You need to pass a filename&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;__dirname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;dirname&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;fileURLToPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;contentFolder&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;content&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;contentFolder&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function returns an object with the &lt;strong&gt;three&lt;/strong&gt; necessary variables we need to continue. We will import this function (and destructure it) in our &lt;strong&gt;main&lt;/strong&gt; file.&lt;/p&gt;

&lt;p&gt;Also, let's include a handy &lt;code&gt;console.log&lt;/code&gt; to tell us the script is starting.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// content.mjs&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getFilename&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./getFilename.mjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;contentFolder&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getFilename&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Trying to create a new &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; content: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.md`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;newContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you save now you should see this message printed in your console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;nodemon] restarting due to changes...
&lt;span class="o"&gt;[&lt;/span&gt;nodemon] starting &lt;span class="sb"&gt;`&lt;/span&gt;node scripts/tutorial.mjs blog filename&lt;span class="sb"&gt;`&lt;/span&gt;
Trying to create a new blog content: filename.md
&lt;span class="o"&gt;[&lt;/span&gt;nodemon] clean &lt;span class="nb"&gt;exit&lt;/span&gt; - waiting &lt;span class="k"&gt;for &lt;/span&gt;changes before restart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Date
&lt;/h2&gt;

&lt;p&gt;To create our &lt;code&gt;md&lt;/code&gt; files in the correct folders, we will get the &lt;strong&gt;current month&lt;/strong&gt; and &lt;strong&gt;year&lt;/strong&gt; from our &lt;code&gt;getToday&lt;/code&gt; function. Let's start it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// getToday.mjs&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getToday&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dateObj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need to get &lt;code&gt;day&lt;/code&gt;, &lt;code&gt;month&lt;/code&gt; and &lt;code&gt;year&lt;/code&gt; from the date object. Let's do it by creating these three variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// getToday.mjs&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getToday&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dateObj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;month&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dateObj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUTCMonth&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;day&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;dateObj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUTCDate&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;dateObj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUTCFullYear&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notes about the code above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In &lt;code&gt;node&lt;/code&gt; &lt;code&gt;Date&lt;/code&gt;, months start in &lt;code&gt;0&lt;/code&gt;, so January is not &lt;code&gt;1&lt;/code&gt;. To circumvent that. we add &lt;code&gt;1&lt;/code&gt; to the function that gets the month.&lt;/li&gt;
&lt;li&gt;We transform every number to string to &lt;strong&gt;avoid errors&lt;/strong&gt; when creating the files and folders.&lt;/li&gt;
&lt;li&gt;Yes, &lt;code&gt;getUTCDate&lt;/code&gt; is different from &lt;code&gt;getUTCDay&lt;/code&gt;. We &lt;strong&gt;all&lt;/strong&gt; end up learning that one day.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There's a &lt;strong&gt;problem&lt;/strong&gt; with the code above: when returning months smaller than October, it returns them with a single digit: &lt;code&gt;5&lt;/code&gt;. In folder organization, it's best to add a &lt;code&gt;0&lt;/code&gt; before this so it orders correctly, &lt;strong&gt;avoiding&lt;/strong&gt; the following ordering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;10&lt;/li&gt;
&lt;li&gt;11&lt;/li&gt;
&lt;li&gt;1&lt;/li&gt;
&lt;li&gt;2&lt;/li&gt;
&lt;li&gt;3&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And &lt;strong&gt;enforcing&lt;/strong&gt; this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;01&lt;/li&gt;
&lt;li&gt;02&lt;/li&gt;
&lt;li&gt;03&lt;/li&gt;
&lt;li&gt;10&lt;/li&gt;
&lt;li&gt;11&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's add a simple helper function that does that for us and return the variables at the end.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// getToday.mjs&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getToday&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addZero&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dateObj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;month&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;addZero&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dateObj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUTCMonth&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;day&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;addZero&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dateObj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUTCDate&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;dateObj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUTCFullYear&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;month&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;day&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I only added the &lt;code&gt;day&lt;/code&gt; to the above function so you could customize your output. I'm &lt;strong&gt;not&lt;/strong&gt; using it, so we'll only destructure &lt;code&gt;month&lt;/code&gt; and &lt;code&gt;year&lt;/code&gt; in the main file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// content.mjs&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getFilename&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./getFilename.mjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getToday&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./getToday.mjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;contentFolder&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getFilename&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Trying to create a new &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; content: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.md`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;month&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getToday&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// &amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;newContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;: This file will get &lt;strong&gt;quite big&lt;/strong&gt;, so I'll try to cut out parts that we don't use from it. Whenever you see &lt;code&gt;// ...&lt;/code&gt;, it means that the code before or after this sign was &lt;strong&gt;untouched&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now, with this data in our hands, we can build our &lt;strong&gt;folder&lt;/strong&gt; path, joining all current information:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// content.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;join&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="c1"&gt;// ...&lt;/span&gt;

&lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;month&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getToday&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;folderPath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;contentFolder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;month&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;newContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Creating folders &amp;amp; files
&lt;/h2&gt;

&lt;p&gt;We split this section into two parts: &lt;strong&gt;folder&lt;/strong&gt; and &lt;strong&gt;file&lt;/strong&gt;, and there's a reason for it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Folder
&lt;/h3&gt;

&lt;p&gt;To create the folders and files in a &lt;strong&gt;safe&lt;/strong&gt; way — not overwriting anything — we have first to check if it &lt;strong&gt;exists&lt;/strong&gt; and, if not, create them using a special option in &lt;code&gt;fs&lt;/code&gt;'s &lt;code&gt;mkdirSync&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;As the name says, &lt;code&gt;mkdirSync&lt;/code&gt; is a &lt;strong&gt;synchronous&lt;/strong&gt; function that creates directories. It can be &lt;strong&gt;recursive&lt;/strong&gt;, creating any non-existant directory in a tree.&lt;/p&gt;

&lt;p&gt;If I pass &lt;code&gt;mkdirSync('src/1/2/3/4/5')&lt;/code&gt; and only &lt;code&gt;src/1&lt;/code&gt; exists, the function will throw an error. But, if I add the &lt;code&gt;{ recursive: true }&lt;/code&gt; option, it will create all missing folders &lt;strong&gt;without&lt;/strong&gt; error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// content.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;mkdirSync&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="c1"&gt;// ...&lt;/span&gt;

&lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;folderPath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;contentFolder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;month&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderPath&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;mkdirSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;recursive&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;newContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, we check if the folder path &lt;strong&gt;exists&lt;/strong&gt;. If it was not created beforehand, it's created now in a &lt;strong&gt;recursive&lt;/strong&gt; way.&lt;/p&gt;

&lt;h3&gt;
  
  
  File
&lt;/h3&gt;

&lt;p&gt;In order to get the file name, we use the already created &lt;code&gt;folderPath&lt;/code&gt; variable.&lt;/p&gt;

&lt;p&gt;The issue is: what if the file &lt;strong&gt;already exists?&lt;/strong&gt; In my use-case, I prefer to &lt;strong&gt;throw&lt;/strong&gt; an error instead of overwriting.&lt;/p&gt;

&lt;p&gt;Imagine I &lt;strong&gt;accidentally&lt;/strong&gt; type &lt;code&gt;yarn scriptname blog amazing&lt;/code&gt; when I already have a file called &lt;code&gt;amazing&lt;/code&gt; in this month? I don't want to lose that content (yeah, I'm using &lt;code&gt;git&lt;/code&gt;, but you get my point).&lt;/p&gt;

&lt;p&gt;So, I add a &lt;strong&gt;failsafe&lt;/strong&gt; to that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// content.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;mkdirSync&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="c1"&gt;// ...&lt;/span&gt;

&lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderPath&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;mkdirSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;recursive&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;folderAndFilename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;folderPath&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.md`&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderAndFilename&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;There's already a file with that name in this month's folder&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;newContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Writing the file
&lt;/h2&gt;

&lt;p&gt;Finally, to (almost) end our struggle, we can &lt;strong&gt;write&lt;/strong&gt; the file. We know that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The folders are created&lt;/li&gt;
&lt;li&gt;The file name is set&lt;/li&gt;
&lt;li&gt;The file does not exist&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We are safe to continue, so let's plop this &lt;code&gt;writeFileSync&lt;/code&gt; from &lt;code&gt;fs&lt;/code&gt; there and get &lt;strong&gt;done&lt;/strong&gt; with this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// content.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;mkdirSync&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="c1"&gt;// ...&lt;/span&gt;

&lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderAndFilename&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;There's already a file with that name in this month's folder&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderAndFilename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;newContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As the &lt;strong&gt;first&lt;/strong&gt; argument, we pass the intended file path. As the &lt;strong&gt;second&lt;/strong&gt;, we pass what we want written in this file — at the moment, &lt;strong&gt;nothing&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Voilá. &lt;strong&gt;Done&lt;/strong&gt;. We have ourselves an automatic &lt;code&gt;md&lt;/code&gt; file written in the correct folder for us.&lt;/p&gt;

&lt;p&gt;But... that's a little... &lt;strong&gt;not that much&lt;/strong&gt;, right? What if we could already populate it with some template?&lt;/p&gt;

&lt;h2&gt;
  
  
  Frontmatter templates
&lt;/h2&gt;

&lt;p&gt;In our &lt;code&gt;frontmatter.mjs&lt;/code&gt; file, we will create an object with our desired &lt;strong&gt;frontmatter&lt;/strong&gt;. At the moment, we have two types: &lt;code&gt;blog&lt;/code&gt; and &lt;code&gt;projects&lt;/code&gt;, so each will have its own frontmatter.&lt;/p&gt;

&lt;p&gt;Another thing we will do with this template is &lt;strong&gt;automatically&lt;/strong&gt; set the &lt;code&gt;createdAt&lt;/code&gt; property filled with... today. My blog uses timestamps, but you can pre-fill anything you want, any way you want.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// frontmatter.mjs&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;frontmatter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;blog&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`---
title:
createdAt: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;getTime&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;
description:
tags: []
---

Write here
`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;projects&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`---
title:
subtitle:
createdAt: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;getTime&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;
tags: []
image:
  src:
  alt:
---

Write here
`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The spacing is weird &lt;strong&gt;on purpose&lt;/strong&gt;, make sure it has no whitespace before each line to avoid &lt;strong&gt;errors&lt;/strong&gt; in your frontmatter.&lt;/p&gt;

&lt;p&gt;Now, on our main file, let's pass this new information to our &lt;code&gt;writeFileSync&lt;/code&gt; function — with a little &lt;code&gt;console.log&lt;/code&gt; telling everyone of our &lt;strong&gt;accomplishments&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// content.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;mkdirSync&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="c1"&gt;// ...&lt;/span&gt;

&lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderAndFilename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;frontmatter&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.md created succesfully!`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;newContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;But Angelo, what happens if we pass a &lt;code&gt;type&lt;/code&gt; that doesn't match the object?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;We won't&lt;/strong&gt;! Remember that this function throws an &lt;strong&gt;error&lt;/strong&gt; if you pass any type other than &lt;code&gt;blog&lt;/code&gt; and &lt;code&gt;projects&lt;/code&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Finale (?)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;This is the end&lt;/strong&gt; of the main part of this tutorial.&lt;/p&gt;

&lt;p&gt;But there's more to be done, because we are developers and we are absolutely &lt;strong&gt;lazy&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;Our computer is doing all of this by itself and we still have to create a branch in git for this new file, and navigate to it &lt;strong&gt;manually&lt;/strong&gt;, like the Aztecs? Oh no, not today.&lt;/p&gt;

&lt;h2&gt;
  
  
  Auto git-branch
&lt;/h2&gt;

&lt;p&gt;In &lt;code&gt;gitNewBranch.mjs&lt;/code&gt; file, we will write a simple function using the powers of &lt;code&gt;simple-git&lt;/code&gt; package. There's nothing much to be said here: if you understand &lt;code&gt;git&lt;/code&gt; a little bit, you will be able to decypher the following code with ease.&lt;/p&gt;

&lt;p&gt;But, before, &lt;strong&gt;install&lt;/strong&gt; the package using &lt;code&gt;yarn add -D simple-git&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// gitNewBranch.mjs&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;simpleGit&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;simple-git&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;gitNewBranch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Creating branch and commiting...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;simpleGit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;checkout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;main&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;checkoutLocalBranch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./*&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Add starter MD&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Important&lt;/strong&gt;: see the little &lt;code&gt;async&lt;/code&gt; in the first line? Yeah, &lt;code&gt;simpleGit&lt;/code&gt; is &lt;strong&gt;asynchronous&lt;/strong&gt; so we will use &lt;code&gt;async/await&lt;/code&gt; here to make it work &lt;strong&gt;perfectly&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Before the &lt;code&gt;simpleGit&lt;/code&gt; function, plop that &lt;code&gt;await&lt;/code&gt; there.&lt;/p&gt;

&lt;p&gt;We need to make two changes in our main function: add an &lt;code&gt;async&lt;/code&gt; flag and add &lt;code&gt;await&lt;/code&gt; before calling the &lt;code&gt;gitNewBranch&lt;/code&gt; function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// content.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;gitNewBranch&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./gitNewBranch.mjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="c1"&gt;// ...&lt;/span&gt;

&lt;span class="c1"&gt;//...&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//...&lt;/span&gt;

  &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.md created succesfully!`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;gitNewBranch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;newContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Opening VS Code
&lt;/h2&gt;

&lt;p&gt;To &lt;strong&gt;finalize&lt;/strong&gt; our script, we will command our terminal to open the file in our &lt;strong&gt;favorite&lt;/strong&gt; IDE — in my case, VS Code.&lt;/p&gt;

&lt;p&gt;This is the &lt;strong&gt;most obfuscated&lt;/strong&gt; of all of the files. It takes advantage of &lt;code&gt;exec&lt;/code&gt; from node's &lt;code&gt;child-process&lt;/code&gt;. It's &lt;strong&gt;hard&lt;/strong&gt; to read and to explain. What it does is simple: it runs in your terminal whatever you pass on the &lt;code&gt;exec&lt;/code&gt; first argument.&lt;/p&gt;

&lt;p&gt;We will use the &lt;code&gt;code&lt;/code&gt; command, as if we were opening a file from our &lt;strong&gt;terminal&lt;/strong&gt;. If something goes wrong, an &lt;strong&gt;error&lt;/strong&gt; will be logged.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// openInVsCode.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;exec&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;child_process&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;openInVSCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pathAndFileName&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`code &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;pathAndFileName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stdout&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stderr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yeah, I know, &lt;strong&gt;not&lt;/strong&gt; the best file. But, if you can open &lt;code&gt;code&lt;/code&gt; using your terminal, you can also use it this way. We will add it to the &lt;strong&gt;end&lt;/strong&gt; of our main file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// content.mjs&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;openInVSCode&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./openInVsCode.mjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="c1"&gt;// ...&lt;/span&gt;

&lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;gitNewBranch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="nf"&gt;openInVSCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderAndFilename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;newContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Package.json
&lt;/h2&gt;

&lt;p&gt;I &lt;strong&gt;promise&lt;/strong&gt; this is the last step! I swear!&lt;/p&gt;

&lt;p&gt;We will add two scripts in our &lt;code&gt;package.json&lt;/code&gt; to make this even &lt;strong&gt;easier&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"post"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node ./scripts/content.mjs blog"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"project"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node ./scripts/content.mjs projects"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way, when we &lt;code&gt;yarn post tutorial&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Our script will create a folder with today's year and month&lt;/li&gt;
&lt;li&gt;It will add a &lt;code&gt;tutorial&lt;/code&gt; folder&lt;/li&gt;
&lt;li&gt;Inside it, it will create a &lt;code&gt;tutorial.md&lt;/code&gt; file&lt;/li&gt;
&lt;li&gt;It will populate this file with &lt;code&gt;frontmatter.blog&lt;/code&gt; content&lt;/li&gt;
&lt;li&gt;It will create a new branch in &lt;code&gt;git&lt;/code&gt; and checkout there: &lt;code&gt;blog/tutorial&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;It will open VS Code for you to write your file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Want proof? There you go.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JDufGvKd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.angelodias.com.br/_next/image%3Furl%3D%252Fcontent%252Fblog%252F2022%252F07%252Fautopost%252Fproof.gif%26w%3D1080%26q%3D75" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JDufGvKd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://www.angelodias.com.br/_next/image%3Furl%3D%252Fcontent%252Fblog%252F2022%252F07%252Fautopost%252Fproof.gif%26w%3D1080%26q%3D75" alt="Screencast of me running the script and it working flawlessly" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Finale!
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/angelod1as/portfolio/tree/main/scripts" rel="noopener noreferrer"&gt;See the source code in this website's repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all of it.&lt;/p&gt;

&lt;p&gt;Thanks for reading and let me know if you end up implementing this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't forget to share this post with everyone!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Final content of our main file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;mkdirSync&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;writeFileSync&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;join&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;frontmatter&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./frontmatter.mjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getFilename&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./getFilename.mjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;getToday&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./getToday.mjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;gitNewBranch&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./gitNewBranch.mjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;openInVSCode&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./openInVsCode.mjs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;contentFolder&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getFilename&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Trying to create a new &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; content: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.md`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;month&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getToday&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;folderPath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;contentFolder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;month&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderPath&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;mkdirSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;recursive&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;folderAndFilename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;folderPath&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.md`&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderAndFilename&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;There's already a file with that name in this month's folder&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderAndFilename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;frontmatter&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.md created succesfully!`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;gitNewBranch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nf"&gt;openInVSCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;folderAndFilename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;newContent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>markdown</category>
      <category>javascript</category>
      <category>node</category>
      <category>md</category>
    </item>
    <item>
      <title>Let others judge you</title>
      <dc:creator>Angelo Dias</dc:creator>
      <pubDate>Thu, 09 Jun 2022 17:08:27 +0000</pubDate>
      <link>https://dev.to/angelod1as/let-others-judge-you-105b</link>
      <guid>https://dev.to/angelod1as/let-others-judge-you-105b</guid>
      <description>&lt;p&gt;The only line of this whole article you need to read is this one, although it goes against much of what other people tell me every day:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Let others, not you, judge how capable you are of doing something.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I'll explain.&lt;/p&gt;

&lt;h2&gt;
  
  
  First: friends know better
&lt;/h2&gt;

&lt;p&gt;I'd love to say this was smooth and natural, but &lt;strong&gt;it wasn't&lt;/strong&gt;. There was a specific point in time at which I decided to change &lt;strong&gt;the way I saw my work&lt;/strong&gt;. It was a mix of &lt;strong&gt;&lt;em&gt;fake it till you make it&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;shoot the imposter down&lt;/em&gt;&lt;/strong&gt;, a conscient action of looking at my professional journey and giving more to it than what I imagined it was worth.&lt;/p&gt;

&lt;p&gt;Some could say this is lying, or even embellishing my CV, but I disagree completely (more on lying later). It's more about a &lt;strong&gt;shift of responsibility&lt;/strong&gt; than anything else.&lt;/p&gt;

&lt;p&gt;I was trying to do freelance work and, well, I &lt;strong&gt;suck&lt;/strong&gt; at it. I don't know exactly how to get new clients, how to keep them, how to &lt;strong&gt;charge enough&lt;/strong&gt; money to pay my bills but not too much so they'll run away.&lt;/p&gt;

&lt;p&gt;Being for five years on a regular 9-to-5 (or, many times, 5-to-midnight) made me &lt;strong&gt;improve other characteristics&lt;/strong&gt; than having to market myself and my job. I was already employed, all I needed to do was &lt;strong&gt;work&lt;/strong&gt;, not sell what I did every day to different people.&lt;/p&gt;

&lt;p&gt;So, while freelancing, I saw the necessity to go back to the regular market. The &lt;strong&gt;imposter syndrome&lt;/strong&gt;, everlasting and overwhelming, made me think a thousand times that I'd never see the happy face of a fixed monthly income in my life, so &lt;strong&gt;I asked for help&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This became the whole subject of &lt;strong&gt;weekly therapy sessions&lt;/strong&gt;, and I'm very happy that my therapist didn't give me a ready answer. She made me think a lot about &lt;strong&gt;what I was searching for&lt;/strong&gt;, where I wanted to go, and, especially, &lt;strong&gt;who I am&lt;/strong&gt; (which is the point of therapy after all). Then, one sunny afternoon (maybe not sunny either afternoon, but bear with me), I decided to try something new. I decided to advertise myself as to how my peers &lt;strong&gt;said&lt;/strong&gt; I was instead of what &lt;strong&gt;I thought&lt;/strong&gt; I was.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feeback is a &lt;strong&gt;massive&lt;/strong&gt; weapon
&lt;/h2&gt;

&lt;p&gt;I started asking my old coworkers what strengths and weaknesses I had. I asked for honest feedback and crushing truths, and asked them from people I trust. They said a good amount of things for me to get better at but, mostly, they said good things. "They are obviously being dishonest", I thought to myself. It's &lt;strong&gt;impossible&lt;/strong&gt; I have all those strengths and so little amount of flaws.&lt;/p&gt;

&lt;p&gt;But, as the point of the exercise &lt;strong&gt;was judging myself less&lt;/strong&gt; and letting others do it, I continued. If you, like me, aren't used to getting compliments, you might understand the &lt;strong&gt;pain&lt;/strong&gt; of doing this and getting praise from people. If I'm sounding a little prepotent to you, I &lt;strong&gt;propose a challenge&lt;/strong&gt;. Stop reading, get your phone and ask your three &lt;strong&gt;most trusted coworkers&lt;/strong&gt; for honest, straight, and direct feedback. Ask them to tell you your strengths and weaknesses, and be prepared to understand better what I'm talking about. People will probably praise you more than highlight your issues. If they get to the bad parts, they'll probably not only say you're shit but tell you &lt;strong&gt;how to improve&lt;/strong&gt;. The map is there, we just never asked for it.&lt;/p&gt;

&lt;p&gt;I decided to act as if everything my colleagues said was true. I refactored my resumé, highlighted the strengths, and removed the flaws. So, if people said I was good at communication, even though &lt;strong&gt;I think&lt;/strong&gt; I'm a lousy journalist and petty writer? Great, let's put that feature, the one &lt;strong&gt;people talked about&lt;/strong&gt;, way above the others. Do they think I'm a good coder, with quality, readable code, and great with multidisciplinary teams? Let's put &lt;strong&gt;that&lt;/strong&gt; on spots two and three on the list. The list of things I thought was valuable, but that no one even mentioned, were &lt;strong&gt;lowered in priority&lt;/strong&gt; or even scrapped.&lt;/p&gt;

&lt;h3&gt;
  
  
  A parenthesis about removing the flaws
&lt;/h3&gt;

&lt;p&gt;I've been in enough interviews to know recruiters will find out about your flaws. They might even ask you to talk about them, knowing &lt;strong&gt;most people&lt;/strong&gt; will lie or, at least, make the flaws lighter than they are.&lt;/p&gt;

&lt;p&gt;So, I do advocate taking them off your written resumé at all. It's not lying, its &lt;strong&gt;editing&lt;/strong&gt;, showing the important things, and putting the less important out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;End of parenthesis&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Storytelling
&lt;/h2&gt;

&lt;p&gt;There is, of course, some &lt;strong&gt;narrative building&lt;/strong&gt; here. I've studied about this, read books, watched documentaries, and done courses. I know that a good story sells, so I had this knowledge beforehand and decided to put that to use. What could be my tagline, my sales pitch, my &lt;strong&gt;one-liner&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;I tried writing this a hundred, maybe a &lt;strong&gt;thousand&lt;/strong&gt; times. It always sounded one of two: either &lt;strong&gt;posh and entitled&lt;/strong&gt;, or &lt;strong&gt;bland and not interesting&lt;/strong&gt;. I either could present myself as this &lt;em&gt;very interesting gentleman with varied taste in the finest things of the industry&lt;/em&gt; or an &lt;em&gt;XYZ language coder with knowledge of ABC and DEF technologies&lt;/em&gt;, like many I see around. So, again, I &lt;strong&gt;aimed outwards&lt;/strong&gt; and begin &lt;strong&gt;asking questions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Most of the people I talked to gave me this one-liner on a plate, almost ready to use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"You do a lot of stuff"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Some of them said it in a good way, as in "you are &lt;strong&gt;versatile&lt;/strong&gt; and find many ways to solve problems, even outside your area". Others highlighted this as a warning: "you spread &lt;strong&gt;too thin&lt;/strong&gt;, knowing a little about a lot and not a lot about anything". Both of them ended up with the same commonality: I was a &lt;strong&gt;generalist&lt;/strong&gt;, not a specialist.&lt;/p&gt;

&lt;p&gt;With &lt;em&gt;lots&lt;/em&gt; of therapy and some &lt;strong&gt;editorial tailoring&lt;/strong&gt;, I got to where I am now. &lt;strong&gt;I am a proud generalist&lt;/strong&gt;, can understand most of the problems and, if not solve them, find someone who can.&lt;/p&gt;

&lt;p&gt;The best part of this &lt;strong&gt;whole process&lt;/strong&gt; (aside from having tripled my salary in a year, of course) was: if at any time, someone found out &lt;strong&gt;I'm not&lt;/strong&gt; all that I claimed (hello imposter syndrome), I could always rely on this simple idea: it was &lt;strong&gt;not me&lt;/strong&gt; that built that persona, it was &lt;strong&gt;everyone else&lt;/strong&gt;. I could tackle anxiety simply by &lt;strong&gt;blaming others&lt;/strong&gt; for my shortcomings, because it's not my fault if someone saw something in me that I'm not, it's &lt;strong&gt;their&lt;/strong&gt; problem. I'm not bad at describing myself, &lt;strong&gt;they&lt;/strong&gt; are the ones that need to &lt;strong&gt;tweak their expectations&lt;/strong&gt; of me.&lt;/p&gt;

&lt;p&gt;This took a huge weight off my shoulders, especially the famous "you are not that much" that kept pushing me down and down. This might sound as if I was cheating the system but... well, it works, so &lt;em&gt;sorry, not sorry, society&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting practical
&lt;/h2&gt;

&lt;p&gt;After getting a nice idea of &lt;strong&gt;what people thought of me&lt;/strong&gt;, I organized those thoughts (I had noted everything down, as this was a conscient research action), got some tea, and jotted down (in paper! And pen!) the main characteristics they saw in me. From there, I started building this &lt;strong&gt;character&lt;/strong&gt;, like in a Roleplaying Game sheet, of who this Angelo everyone saw was.&lt;/p&gt;

&lt;p&gt;I put up bullet points of strengths and weaknesses, highlighted points of improvement, added technical information about the existing topics (eg. they said I was good at coding, but coding &lt;em&gt;what&lt;/em&gt; exactly?) and, before I could let the imposter kick in, I had a nice and clear outline of a resumé. I selected some works in which I had put some of those strengths to practice and bam, resumé ready.&lt;/p&gt;

&lt;h3&gt;
  
  
  A parenthesis about lying in your CV
&lt;/h3&gt;

&lt;p&gt;In short: &lt;strong&gt;don't&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If there's something all your colleagues say you excel at, there are good chances they are right. But, if someone says something you know deep down it's a lie, don't consider it.&lt;/p&gt;

&lt;p&gt;For instance: let's suppose a friend said I was good at languages. They claim to have seen me speaking to people in Spanish, English, and even some Italian or German. That's a nice thing to put in a resumé, "being good at languages", right?&lt;/p&gt;

&lt;p&gt;The problem is: that's a lie.&lt;/p&gt;

&lt;p&gt;I'm good at English (and not even consider myself fluent). All the other languages are just attempts at communication, German being something I just started learning and Spanish and Italian being close enough to my mother language that I could do some mix-and-match and eventually get some stuff right.&lt;/p&gt;

&lt;p&gt;Putting that in my resumé would lead me to interviews that might need those skills and, adding embarrassment to the plate, I would just smile and deny it when they asked me if I spoke those languages. After that, what in my resumé was true? It would become completely not trustworthy.&lt;/p&gt;

&lt;p&gt;A real example: I've been working with code for (way too many) years now, and I sure had a few experiences with backend development. I'm absolutely not a backend developer, though. I learned, with time, to actively say that in interviews so that the recruiter knows I might not be the best fit for a full-stack position.&lt;/p&gt;

&lt;p&gt;Even though I've got a colleague that praised me for being able to put up a backend for some services with no prior knowledge, I did not describe it like this in my CV. I preferred saying I was &lt;strong&gt;versatile&lt;/strong&gt; and could tackle some challenges &lt;strong&gt;outside my field&lt;/strong&gt; of work, as long as everyone knew I was not a specialist in these new explorations and that &lt;strong&gt;things might break&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead of lying, &lt;strong&gt;I chose the truth&lt;/strong&gt;, and that has brought me to good places. Maybe it'll lead you too.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;End of parenthesis&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With this character sheet — my own, made from parts of me I didn't know or even agree with — I was able to design a resumé, with an attached cover letter from this "character", and started sending it everywhere.&lt;/p&gt;

&lt;p&gt;Every. Where.&lt;/p&gt;

&lt;h2&gt;
  
  
  Second: recruiters are professionals
&lt;/h2&gt;

&lt;p&gt;Go to LinkedIn. Browse to "job search". Put a position you'd like to be in. Be reasonable: don't &lt;strong&gt;sabotage&lt;/strong&gt; yourself with lesser positions than you want (because "you are not good enough"). Some would say "don't apply for positions higher than what you think you can do", but &lt;strong&gt;I disagree&lt;/strong&gt;. Do exactly that, apply for stuff you think you are not capable of. Apply to &lt;strong&gt;a lot of things&lt;/strong&gt;. Trust me, even those positions of leadership, high salary, corner office.&lt;/p&gt;

&lt;p&gt;The main point of this section is to &lt;strong&gt;repeat to yourself&lt;/strong&gt; that &lt;strong&gt;recruiters are professionals&lt;/strong&gt;. They are amazing at their jobs and can &lt;strong&gt;smell talent&lt;/strong&gt; from afar. As good professionals they are, they won't turn down a good fit for the company because it does not match exactly the position. Maybe they are looking for a Chief Technical Officer and you do not have the required experience, but your knowledge of making balloon animals or your interest in entomology might make them want you in their company nonetheless.&lt;/p&gt;

&lt;p&gt;Their job description is: &lt;strong&gt;find and recruit talents&lt;/strong&gt;. So, my simple question to you is: who do you think is better in knowing who's a fit for a position? You, &lt;strong&gt;zero recruiting knowledge&lt;/strong&gt;, or a person who &lt;strong&gt;does that for a living&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;So, please, &lt;strong&gt;let them do their jobs&lt;/strong&gt;. Apply for positions. All of them you'd like to try. Again, be reasonable, don't apply for "circus manager" if you don't like traveling and are afraid of clowns, save the recruiter's time. Also, if you start a process and don't feel like continuing, quit it and let them know. &lt;strong&gt;Put yourself in their skins&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We are, usually, &lt;strong&gt;far too traditional&lt;/strong&gt; (oh, in so many things) and we do things from tradition without much questioning. What I'm encouraging you to do is &lt;strong&gt;challenge&lt;/strong&gt; whatever tradition pushes you from not applying to the jobs you want. Let &lt;strong&gt;the recruiters&lt;/strong&gt; choose and let &lt;strong&gt;them&lt;/strong&gt; evaluate if you are a fit or not. Be truthful in interviews, know what you want in a job (through exercises or, well, therapy) and go out there, hunt, and be hunted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Third: your boss knows best
&lt;/h2&gt;

&lt;p&gt;That shiny contract is signed and you are working in this shiny new environment, with a lot of new responsibilities and a good amount of pressure on your shoulders? Nice. I hope the paycheck is as big as the trouble you just find yourself into (if not, back to step 1).&lt;/p&gt;

&lt;p&gt;Now, maybe the problem is not "I'll never find a job" or even "I wont apply for fancy positions". The issue at this point of the process is something I'm still living and, well, trying to tell you to do something I have to do myself.&lt;/p&gt;

&lt;p&gt;I always (I mean, &lt;strong&gt;daily&lt;/strong&gt;) think &lt;strong&gt;I'm not enough&lt;/strong&gt; at my job. Of course, they will find out I did all that embellishment of my resumé and that, in truth, I'm a loser and an incompetent and &lt;strong&gt;a really bad professional&lt;/strong&gt;. This, as you might know, is &lt;strong&gt;imposter syndrome&lt;/strong&gt; at its best, eating your brain inside out like &lt;a href="https://www.youtube.com/watch?v=7OPg-ksxZ4Y" rel="noopener noreferrer"&gt;that terrifying amoeba&lt;/a&gt;. It's easy to say "don't care about that" because I know I do care. My mind (to which I trust most of my decisions) is constantly reminding me I might be in the &lt;strong&gt;wrong place&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;What I've learned to do is: evaluate your surroundings and count how &lt;strong&gt;many people failed in their jobs&lt;/strong&gt; if you end up being the fraud you believe to be. Start from the last section of this article: if you are this bad of a professional, &lt;strong&gt;your recruiter sucks&lt;/strong&gt;. If any of your colleagues ever praised you, they are &lt;strong&gt;bad at judging people&lt;/strong&gt; --- personally and professionally. If you have been through a probation period and passed it, keeping safely employed, &lt;strong&gt;your boss is bad at their job&lt;/strong&gt; and just accepted an unfit professional in the company ranks.&lt;/p&gt;

&lt;p&gt;A few people, whose jobs are to make sure the company runs smoothly, might have made &lt;strong&gt;horrible mistakes&lt;/strong&gt; to keep you there, and the coworkers might be blind and/or amazing liars by saying good things about you to yourself.&lt;/p&gt;

&lt;p&gt;Put things in &lt;strong&gt;perspective&lt;/strong&gt; whenever the imposter hits. Are you ready to tell all of these people they are &lt;strong&gt;bad at their jobs&lt;/strong&gt;? They might be good at it, right? So, maybe, you are not as unfit as you think. You might be even &lt;strong&gt;good at your job&lt;/strong&gt;if you let these "inside" thoughts off and just focus on what comes from outside.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fourth: improve to improve
&lt;/h2&gt;

&lt;p&gt;The whole point of this philosophy of letting others judge you, not yourself, for your professional growth, is &lt;strong&gt;exactly&lt;/strong&gt; to take advantage of their professionalism and skills in finding capable people. You, instead, must focus on getting your goods &lt;strong&gt;better&lt;/strong&gt; or your bads at least at &lt;strong&gt;medium&lt;/strong&gt;. Instead of trying to &lt;strong&gt;fit in&lt;/strong&gt; what you think you should be, work towards &lt;strong&gt;improving&lt;/strong&gt;. Tell them you want to get better, &lt;strong&gt;be open&lt;/strong&gt; about your weaknesses, and be true about what you wouldn't want to pursue.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It's hard to be true to yourself&lt;/strong&gt;, I &lt;em&gt;do&lt;/em&gt; know. Being true to others, though, brings a paycheck home. We think so many bad things about ourselves and never, for once, think we are bad at judging our ability. We might see ourselves as the worse professionals, but never as lousy judges of capacity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let the professionals do their jobs&lt;/strong&gt;: let others judge your value, not yourself, and be surprised by how much people might think highly of you.&lt;/p&gt;

</description>
      <category>career</category>
      <category>jobs</category>
      <category>market</category>
    </item>
  </channel>
</rss>
