<?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: Matthew Weeks</title>
    <description>The latest articles on DEV Community by Matthew Weeks (@weeksling).</description>
    <link>https://dev.to/weeksling</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%2F154237%2F7b66bb63-9b3e-444e-a72d-3a4933799445.jpg</url>
      <title>DEV Community: Matthew Weeks</title>
      <link>https://dev.to/weeksling</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/weeksling"/>
    <language>en</language>
    <item>
      <title>Adding an RSS Feed To My Gatsby Site To Automatically Cross-share New Posts To DEV.to</title>
      <dc:creator>Matthew Weeks</dc:creator>
      <pubDate>Wed, 13 May 2020 12:51:19 +0000</pubDate>
      <link>https://dev.to/weeksling/adding-an-rss-feed-to-my-gatsby-site-to-automatically-cross-share-new-posts-to-dev-to-jfd</link>
      <guid>https://dev.to/weeksling/adding-an-rss-feed-to-my-gatsby-site-to-automatically-cross-share-new-posts-to-dev-to-jfd</guid>
      <description>&lt;p&gt;&lt;a href="" class="article-body-image-wrapper"&gt;&lt;img alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Gatsby's plugin system makes adding and extending functionality SUPER easy. Today I set up an RSS feed for my blog, so that new posts can be automatically distributed to Dev.TO and Medium, in about twenty minutes.&lt;/p&gt;

&lt;p&gt;Here's how you can do it in 10!&lt;/p&gt;

&lt;h1&gt;
  
  
  Wait hold on. Why are we doing this?
&lt;/h1&gt;

&lt;p&gt;An RSS Feed is a structured format for sharing subscribe-able content in an XML feed. It was great the heyday of blogging when folks actually subscribed to blog feeds (RIP Google Reader, 2005–2013 😓).&lt;/p&gt;

&lt;p&gt;But an XML feed can enable more than that. Because with a feed, you can do cool things like automatically cross-post all your blog posts to other platforms like Dev.to, and Medium. Just like how I've shared this post!&lt;/p&gt;

&lt;h2&gt;
  
  
  Will this hurt your SEO? NOPE! The opposite.
&lt;/h2&gt;

&lt;p&gt;Thanks to a concept called canonical links, you can share your blog posts on other platforms like Medium and Dev, but refer back to your site as the original source. You get the benefit of exposing content to other audiences, but you get to keep the page rank.&lt;/p&gt;

&lt;h1&gt;
  
  
  So, how do we add the RSS feed to you Gatsby site?
&lt;/h1&gt;

&lt;p&gt;Thanks to Gatsby's awesome plugin system, we can use &lt;code&gt;gatsby-plugin-feed&lt;/code&gt; to do most of the heavy lifting.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;For this example&lt;/strong&gt; I'm using my site which uses MDX for my blog. If you have the same setup from the &lt;a href="https://github.com/gatsbyjs/gatsby-starter-blog"&gt;Gatsby Blog Starter&lt;/a&gt; or the &lt;a href="https://github.com/netlify-templates/gatsby-starter-netlify-cms"&gt;NetlifyCMS Starter&lt;/a&gt; then this should be about the same, but if not, you may need some customization from the docs.&lt;/p&gt;

&lt;p&gt;Either way, feel free to follow along and ask questions below!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, first off install the plugin:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i --save gatsby-plugin-feed

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



&lt;p&gt;Then, add the following chunks to your &lt;code&gt;gatsby-config.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  siteMetaData: {
    // ....
    siteUrl: 'https://mweeks.dev',
    // ...
  },
  plugins: [
    // ...
    {
      resolve: `gatsby-plugin-feed`,
      options: {
        feeds: [
          {
            serialize: ({ query: { site, allMarkdownRemark } }) =&amp;gt; {
              return allMarkdownRemark.edges.map(edge =&amp;gt; {
                return Object.assign({}, edge.node.frontmatter, {
                  description: edge.node.excerpt,
                  date: edge.node.frontmatter.date,
                  url: site.siteMetadata.siteUrl + edge.node.fields.slug,
                  guid: site.siteMetadata.siteUrl + edge.node.fields.slug,
                  custom_elements: [{ "content:encoded": edge.node.html }]
                });
              });
            },
            query: `
              {
                allMarkdownRemark(
                  sort: { order: DESC, fields: [frontmatter___date] },
                ) {
                  edges {
                    node {
                      excerpt
                      html
                      fields { slug }
                      frontmatter {
                        title
                        date
                      }
                    }
                  }
                }
              }
            `,
            output: "/blog/rss.xml",
            match: "^/blog/"
          }
        ]
      }
    }
  ],
  // ...
}

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



&lt;p&gt;And that's it! Next time I run a &lt;code&gt;gatsby build&lt;/code&gt;, my site will have a shiny new &lt;code&gt;/blog/rss.xml&lt;/code&gt; for all of my blog pages!&lt;/p&gt;

&lt;p&gt;In my case, I simply &lt;code&gt;git commit&lt;/code&gt;, do a &lt;code&gt;git push&lt;/code&gt; and watch Netlify deploy it!&lt;/p&gt;

&lt;h1&gt;
  
  
  How to share your feed automatically on Dev.to
&lt;/h1&gt;

&lt;p&gt;You'll want to head over to &lt;a href="https://dev.to/settings/publishing-from-rss"&gt;https://dev.to/settings/publishing-from-rss&lt;/a&gt; and enter in your fancy new RSS feed URL, and just watch the magic happen!&lt;/p&gt;

&lt;p&gt;Be sure to check the &lt;strong&gt;Mark the RSS source as canonical URL by default&lt;/strong&gt; option to get that delicious, delicious Google Juice.&lt;/p&gt;

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

&lt;p&gt;If you wanted to post it on Medium as well, you can copy this Zapier Zap! &lt;a href="https://zapier.com/shared/16969b48fc141b0d85705bc2d7fe2109e64b61ce"&gt;https://zapier.com/shared/16969b48fc141b0d85705bc2d7fe2109e64b61ce&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you've got no barrier to writing, and no need to worry about lock-in!&lt;/p&gt;

&lt;p&gt;Happy hacking, and please like and subscribe!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>More readable commits with semantic commits</title>
      <dc:creator>Matthew Weeks</dc:creator>
      <pubDate>Tue, 12 May 2020 12:13:19 +0000</pubDate>
      <link>https://dev.to/weeksling/more-readable-commits-with-semantic-commits-gf8</link>
      <guid>https://dev.to/weeksling/more-readable-commits-with-semantic-commits-gf8</guid>
      <description>&lt;h1&gt;
  
  
  Why do you want better commits?
&lt;/h1&gt;

&lt;p&gt;Most people don't start thinking about their commits when they first start development (I get it, there's a lot going on and a lot to learn)&lt;/p&gt;

&lt;p&gt;But commits become &lt;strong&gt;especially&lt;/strong&gt; important when you're a part of a team.&lt;/p&gt;

&lt;p&gt;When you enter a new repository, you want to be able to see how the project has developed over time. If you were to see commits like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Fix the thing
Update styles
Add the thing
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;(Note, these are actually not the worst examples—I'm sure you've seen worse)&lt;/p&gt;

&lt;p&gt;You likely won't be able to understand what happened, without reading the code changes in a commit itself.&lt;/p&gt;

&lt;p&gt;However, contrast those with these commits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fix(blog): Imported posts formatted correctly with new styles
feat(blog): Update styles to reflect new design
feat(blog): Add blog feed to site.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Looks great, so how do we do it?&lt;/p&gt;

&lt;h1&gt;
  
  
  How to write a semantic commit
&lt;/h1&gt;

&lt;p&gt;The semantic commit contains 4 parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The type of commit&lt;/li&gt;
&lt;li&gt;The Scope of the commit (optional, but often nice to have)&lt;/li&gt;
&lt;li&gt;The actual content of the commit&lt;/li&gt;
&lt;li&gt;An optional body, for more description. Good for larger commits.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's how it works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;type&amp;gt;(&amp;lt;scope&amp;gt;): &amp;lt;description&amp;gt;
  &amp;lt;Optional Body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So in our first example above, we might create:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;feat(blog): Add blog feed to site
  Add the markdown plugin, generate pages, and create blog template.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  The type
&lt;/h2&gt;

&lt;p&gt;You can use your own types, but here are the defaults: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;feat&lt;/strong&gt;: a new feature, or change to existing feature.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;fix&lt;/strong&gt;: Fixing a bug or known issue in code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;test&lt;/strong&gt;: Adding additional tests for existing features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;chore&lt;/strong&gt;: Updating build tools, like webpack, gulp, ascripts, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;docs&lt;/strong&gt;: Update to documentation like README&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The scope
&lt;/h2&gt;

&lt;p&gt;Your scope can be as granular as you'd like and will likely change based on the complexity of the project. If you're just starting off a project, you could omit the scope, but I highly recommend you consider it, because it forces you to think very clearly about what you're changing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The description
&lt;/h2&gt;

&lt;p&gt;You want to summarize your commit with a single line. If you can't, then you probably want to consider breaking the commit down into smaller pieces to make the work logical and self-contained.&lt;/p&gt;

&lt;h2&gt;
  
  
  The (optional) body
&lt;/h2&gt;

&lt;p&gt;A single line is good for summary, but sometimes you want to add additional detail so that readers can see more about &lt;em&gt;what&lt;/em&gt; you changed now that they know &lt;em&gt;why&lt;/em&gt; you changed it. &lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Writing better commits will help you write better code. Simple practices like this force you into a mindset of craftsmanship and self-documenting projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Want to take it further?
&lt;/h3&gt;

&lt;p&gt;Consider reading the original source &lt;a href="http://karma-runner.github.io/4.0/dev/git-commit-msg.html"&gt;The Karma Commit Message Format&lt;/a&gt; or this newer resource &lt;a href="https://www.conventionalcommits.org/en/v1.0.0-beta.2/"&gt;The Conventional Commits&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once you're going with semantic commits, you might want to enforce it as a standard on your projects! For something like this, you can use &lt;a href="https://github.com/commitizen/cz-cli"&gt;Commitizen&lt;/a&gt;(for validation) and &lt;a href="https://github.com/typicode/husky"&gt;Husky&lt;/a&gt; (for pre-commit hooks).&lt;/p&gt;

&lt;p&gt;I will be following up with a guide on using pre-commit hooks to do linting, testing, and more in a future article.&lt;/p&gt;

&lt;p&gt;Til then, happy coding.&lt;/p&gt;

&lt;p&gt;May your code be functional, readable, and well-used.&lt;/p&gt;

</description>
      <category>git</category>
      <category>bestpractices</category>
      <category>cleancode</category>
    </item>
  </channel>
</rss>
