<?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: Riccardo Bevilacqua</title>
    <description>The latest articles on DEV Community by Riccardo Bevilacqua (@rickdrink).</description>
    <link>https://dev.to/rickdrink</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%2F131057%2F046ce5f0-eaa9-4ace-92d5-f68545c93d68.jpg</url>
      <title>DEV Community: Riccardo Bevilacqua</title>
      <link>https://dev.to/rickdrink</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rickdrink"/>
    <language>en</language>
    <item>
      <title>How to create an RSS feed in Next.js 10</title>
      <dc:creator>Riccardo Bevilacqua</dc:creator>
      <pubDate>Sun, 29 Nov 2020 05:00:00 +0000</pubDate>
      <link>https://dev.to/rickdrink/how-to-create-an-rss-feed-in-next-js-10-12la</link>
      <guid>https://dev.to/rickdrink/how-to-create-an-rss-feed-in-next-js-10-12la</guid>
      <description>&lt;h3&gt;
  
  
  What is an RSS feed?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/RSS" rel="noopener noreferrer"&gt;RSS&lt;/a&gt; (RDF Site Summary or Really Simple Syndication) feed is an XML file used for providing users with frequently updated content in a standardized, computer-readable data format.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why do you need an RSS feed?
&lt;/h3&gt;

&lt;p&gt;Millions of users every day enjoy reading from several websites through a &lt;em&gt;feed reader&lt;/em&gt;, such as &lt;a href="https://feedly.com/" rel="noopener noreferrer"&gt;Feedly&lt;/a&gt;. You need to provide an RSS feed for your blog not to give up a potentially large share of audience.&lt;/p&gt;

&lt;p&gt;Furthermore you can use your RSS feed to cross-post to other websites, such as the popular &lt;a href="https://dev.to/"&gt;dev.to&lt;/a&gt; (see here).&lt;/p&gt;

&lt;h3&gt;
  
  
  The Kessel Run in less than twelve parsecs
&lt;/h3&gt;

&lt;p&gt;Create a file &lt;code&gt;rss.js&lt;/code&gt; in &lt;code&gt;lib&lt;/code&gt; folder, or another directory of your preference other than &lt;code&gt;pages&lt;/code&gt;, which as you probably know is a special directory reserved to routable content.&lt;/p&gt;

&lt;p&gt;The new file would look like this (source &lt;a href="https://gist.github.com/riccardobevilacqua/d3820b80718517448d8ad6c8151fc9ac" rel="noopener noreferrer"&gt;here&lt;/a&gt;):&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%2F8c5kz5jkk6dkuzujsaoo.jpg" 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%2F8c5kz5jkk6dkuzujsaoo.jpg" alt="rss.js" width="718" height="681"&gt;&lt;/a&gt;rss.js&lt;/p&gt;

&lt;p&gt;The mechanism is the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;generateRss&lt;/code&gt;:

&lt;ul&gt;
&lt;li&gt;accepts the full list of posts of your blog as input&lt;/li&gt;
&lt;li&gt;prepares the structure of the RSS feed&lt;/li&gt;
&lt;li&gt;injects a data structure for each post (see below)&lt;/li&gt;
&lt;li&gt;returns the RSS feed as string&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;generateRssItem&lt;/code&gt;:

&lt;ul&gt;
&lt;li&gt;accepts a single post as input&lt;/li&gt;
&lt;li&gt;prepares the structure of an RSS feed item&lt;/li&gt;
&lt;li&gt;returns the RSS feed item as string&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  I will help you, I have spoken
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;"What's going on in here?"&lt;/em&gt; you might be wondering.&lt;/p&gt;

&lt;p&gt;Let's break it down, starting from the imports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { BLOG_URL, BLOG_TITLE, BLOG_SUBTITLE} from '@lib/constants'
import markdownToHtml from '@lib/markdownToHtml'

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

&lt;/div&gt;



&lt;p&gt;I decided to stash some general information about the blog in &lt;code&gt;/lib/constants.js&lt;/code&gt;, it's really up to you where you prefer to store these information.&lt;/p&gt;

&lt;p&gt;The method &lt;code&gt;markdownToHtml&lt;/code&gt; is a helper provided by &lt;a href="https://github.com/vercel/next.js/tree/canary/examples/blog-starter" rel="noopener noreferrer"&gt;Next.js blog starter&lt;/a&gt;, which allows you to convert content from markdown to HTML as you have surely guessed.&lt;/p&gt;

&lt;p&gt;Side note: &lt;code&gt;@lib&lt;/code&gt; resolves to &lt;code&gt;/lib&lt;/code&gt; from anywhere, regardless the depth of the folder structure, thanks to &lt;code&gt;jsconfig.json&lt;/code&gt; in the root folder (see &lt;a href="https://code.visualstudio.com/docs/languages/jsconfig#_using-webpack-aliases" rel="noopener noreferrer"&gt;here&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Since &lt;code&gt;markdownToHTML&lt;/code&gt; is asynchronous, &lt;code&gt;generateRssItem&lt;/code&gt; needs to be asynchronous as well in order to &lt;code&gt;await&lt;/code&gt; for its result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export async function generateRssItem(post) {
  const content = await markdownToHtml(post.content || '')

  // more code here
}

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

&lt;/div&gt;



&lt;p&gt;An RSS feed item, which represents a post on your blog, is structured as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;guid&lt;/code&gt; is a unique identifier for the post, you can generate it the way you see fit&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;title&lt;/code&gt; is the title of the post, of course&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;description&lt;/code&gt; is the excerpt of the post&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;link&lt;/code&gt; is the absolute URL of the post, including protocol and base URL of your blog&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pubDate&lt;/code&gt; is the date published&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;content:encoded&lt;/code&gt; is the full content of your post, which applies the encapsulation &lt;a href="https://en.wikipedia.org/wiki/CDATA" rel="noopener noreferrer"&gt;CDATA&lt;/a&gt; to assure your HTML to be correctly parsed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can find a thorough list of properties &lt;a href="https://www.rssboard.org/rss-profile" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To assemble the whole RSS feed, all posts need to be scanned and converted to RSS items. The trick is using &lt;code&gt;await Promise.all(posts.map(generateRssItem))&lt;/code&gt; in &lt;code&gt;generateRss&lt;/code&gt; to make this happen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export async function generateRss(posts) {
  const itemsList = await Promise.all(posts.map(generateRssItem))

  // more code here
}

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

&lt;/div&gt;



&lt;p&gt;Now that you have all RSS items, you can add some general information to the RSS feed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;rss&lt;/code&gt; is the root element of the XML document&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;channel&lt;/code&gt; is an XML element containing the whole blog data, comprising general information and all posts&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;title&lt;/code&gt; is the title of the blog&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;description&lt;/code&gt; is the description of the blog&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lastBuildDate&lt;/code&gt; is the date of the most recent post&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;atom:link&lt;/code&gt; element needs your absolute blog URL in its &lt;code&gt;href&lt;/code&gt; property&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally you can inject the RSS items generated in the previous step.&lt;/p&gt;

&lt;h3&gt;
  
  
  This is the Way
&lt;/h3&gt;

&lt;p&gt;In &lt;code&gt;/pages/index.js&lt;/code&gt; there's a method &lt;code&gt;getStaticProps&lt;/code&gt;, which is called by &lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt; at build time (see &lt;a href="https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation" rel="noopener noreferrer"&gt;here&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The idea is generating your RSS feed as an XML file precisely at build time.&lt;/p&gt;

&lt;p&gt;To do so, first import &lt;code&gt;generateRss&lt;/code&gt; and &lt;code&gt;fs&lt;/code&gt;, then modify &lt;code&gt;getStaticProps&lt;/code&gt; as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export async function getStaticProps() {
  const allPosts = getAllPosts([
    'title',
    'date',
    'slug',
    'author',
    'coverImage',
    'excerpt',
    'content',
  ])
  const rss = await generateRss(allPosts)

  fs.writeFileSync('./public/rss.xml', rss)

  return {
    props: { allPosts },
  }
}

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

&lt;/div&gt;



&lt;p&gt;A few tweaks have been introduced:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;adding &lt;code&gt;content&lt;/code&gt; to the array of fields passed to &lt;code&gt;getAllPosts&lt;/code&gt;, used by &lt;code&gt;generateRssItem&lt;/code&gt; to inject the full content of a post&lt;/li&gt;
&lt;li&gt;generating your RSS using &lt;code&gt;const rss = await generateRss(allPosts)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;writing the result in an XML file, which &lt;strong&gt;must&lt;/strong&gt; be placed in the &lt;code&gt;public&lt;/code&gt; folder to be reachable by users and applications&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A final touch would be updating your &lt;code&gt;.gitignore&lt;/code&gt; to exclude &lt;code&gt;rss.xml&lt;/code&gt;, which doesn't really need to be versioned.&lt;/p&gt;

&lt;p&gt;An example of the final result is the &lt;a href="https://riccardo.codes/rss.xml" rel="noopener noreferrer"&gt;RSS feed I generated for this very blog&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Who controls the spice controls the universe
&lt;/h3&gt;

&lt;p&gt;You can now add a link to &lt;code&gt;/rss.xml&lt;/code&gt; on your homepage to provide your users with a link they can add to their favorite feed reader.&lt;/p&gt;

&lt;p&gt;Moreover on &lt;a href="https://dev.to/"&gt;dev.to&lt;/a&gt;, in &lt;em&gt;Settings &amp;gt; Extensions&lt;/em&gt;, you can specify your RSS feed URL for &lt;a href="https://dictionary.cambridge.org/dictionary/english/cross-posting" rel="noopener noreferrer"&gt;cross-posting&lt;/a&gt;.&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%2Fu9umij2z93u562kb36ul.jpeg" 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%2Fu9umij2z93u562kb36ul.jpeg" alt="Cross-posting from your blog to dev.to" width="800" height="298"&gt;&lt;/a&gt;Cross-posting from your blog to dev.to&lt;/p&gt;

&lt;p&gt;This way every time you publish on your blog &lt;code&gt;main&lt;/code&gt; branch, a draft will be automatically created on your dev.to dashboard. You might need to re-add the cover image, but your post will be there from top to bottom.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Next.js is still young and is missing some capabilities, such as RSS feed generation. However its design comprises only a handful of moving parts, which makes adjusting the project to meet your needs quite doable.&lt;/p&gt;

&lt;p&gt;I'm fairly sure more features will come in time from Vercel and from Next.js community. Until then, don't be afraid to tinker with it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Somewhere, something incredible is waiting to be known.&lt;br&gt;&lt;br&gt;
― Carl Sagan&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>nextjs</category>
      <category>rss</category>
      <category>blog</category>
    </item>
    <item>
      <title>How to create a blog with Next.js 10</title>
      <dc:creator>Riccardo Bevilacqua</dc:creator>
      <pubDate>Mon, 23 Nov 2020 00:00:00 +0000</pubDate>
      <link>https://dev.to/rickdrink/how-to-create-a-blog-with-next-js-10-3815</link>
      <guid>https://dev.to/rickdrink/how-to-create-a-blog-with-next-js-10-3815</guid>
      <description>&lt;h3&gt;
  
  
  What is Next.js?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt; is a Static Site Generator (SSG) based on &lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;React&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;According to the official website:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Next.js gives you the best developer experience with all the features you need for production: hybrid static &amp;amp; server rendering, TypeScript support, smart bundling, route pre-fetching, and more. No config needed.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Why choosing Next.js over Gatsby?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://vercel.com/" rel="noopener noreferrer"&gt;Vercel&lt;/a&gt; recently released &lt;a href="https://nextjs.org/blog/next-10" rel="noopener noreferrer"&gt;Next.js 10&lt;/a&gt;, a stunning combination of power and simplicity.&lt;/p&gt;

&lt;p&gt;The popular rival &lt;a href="https://www.gatsbyjs.com/" rel="noopener noreferrer"&gt;Gatsby&lt;/a&gt; provides a lot of features and a wide range of plugins, but the overhead and the compulsory use of GraphQL might be considered overengineering by some users.&lt;/p&gt;

&lt;p&gt;Gatsby still represents a valid tool, as usual it's a matter of trade off and personal taste.&lt;/p&gt;

&lt;h3&gt;
  
  
  One small step
&lt;/h3&gt;

&lt;p&gt;Vercel provides several &lt;a href="https://github.com/vercel/next.js/tree/canary/examples/" rel="noopener noreferrer"&gt;examples&lt;/a&gt; to be used as templates for your projects.&lt;/p&gt;

&lt;p&gt;A good starting point is certainly &lt;a href="https://github.com/vercel/next.js/tree/canary/examples/blog-starter" rel="noopener noreferrer"&gt;blog-starter&lt;/a&gt;, which can be seen in action &lt;a href="https://next-blog-starter.now.sh/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It can be installed by executing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app --example blog-starter blog-starter-app
# or
yarn create-next-app --example blog-starter blog-starter-app

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

&lt;/div&gt;



&lt;p&gt;if you prefer TypeScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app --example blog-starter-typescript blog-starter-app
# or
yarn create-next-app --example blog-starter-typescript blog-starter-app

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

&lt;/div&gt;



&lt;p&gt;Just replace &lt;code&gt;blog-starter-app&lt;/code&gt; with the name of your project.&lt;/p&gt;

&lt;p&gt;You can take a look at a local preview as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;cd &amp;lt;your-project-folder&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;npm run dev&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Browsing &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt; you'd see the result.&lt;/p&gt;

&lt;p&gt;It looks pretty nice already, doesn't 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%2Fqwke3ir9xr0rusazwn8r.jpeg" 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%2Fqwke3ir9xr0rusazwn8r.jpeg" alt="Next.js blog starter, local preview" width="800" height="1000"&gt;&lt;/a&gt;Next.js blog starter, local preview&lt;/p&gt;

&lt;h3&gt;
  
  
  One giant leap
&lt;/h3&gt;

&lt;p&gt;Opening the project on your favorite editor (e.g. Visual Studio Code) you'd see this folder structure:&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%2Fuxgiokaw0wc3d66iwut8.jpg" 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%2Fuxgiokaw0wc3d66iwut8.jpg" alt="Next.js blog starter, folder structure" width="351" height="601"&gt;&lt;/a&gt;Next.js blog starter, folder structure&lt;/p&gt;

&lt;p&gt;The most important folders are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;_posts&lt;/code&gt;, your posts in &lt;code&gt;*.md&lt;/code&gt; files (&lt;code&gt;*.mdx&lt;/code&gt; are supported as well)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;components&lt;/code&gt;, React components for the UI&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pages&lt;/code&gt;, a special folder where the magic happens, files and folders here give your project &lt;strong&gt;structure&lt;/strong&gt; as well as &lt;strong&gt;routing&lt;/strong&gt; (more details below)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;public&lt;/code&gt;, where assets are stashed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A post on your blog would be a Markdown file with metadata used by Next.js to build a static page accordingly. Information such as cover image or excerpt published on the homepage would appear here.&lt;/p&gt;

&lt;p&gt;For example, this post...&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%2Fplghgkmov2vk3436bvz5.jpeg" 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%2Fplghgkmov2vk3436bvz5.jpeg" alt="Next.js blog starter, sample post file" width="800" height="351"&gt;&lt;/a&gt;Next.js blog starter, sample post file&lt;/p&gt;

&lt;p&gt;...would be rendered like this:&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%2Fnnpe8cusdl40gs5xi8gh.jpeg" 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%2Fnnpe8cusdl40gs5xi8gh.jpeg" alt="Next.js blog starter, sample post preview" width="800" height="1028"&gt;&lt;/a&gt;Next.js blog starter, sample post preview&lt;/p&gt;

&lt;h3&gt;
  
  
  Second star to the right
&lt;/h3&gt;

&lt;p&gt;Next.js has a file-system based routing, which detects subfolders and files in the special directory called &lt;code&gt;pages&lt;/code&gt; creating routes accordingly.&lt;/p&gt;

&lt;p&gt;Let's take a look at &lt;code&gt;pages&lt;/code&gt;:&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%2Fwy73njr6fdlz6jqeahec.jpg" 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%2Fwy73njr6fdlz6jqeahec.jpg" alt="Next.js blog starter, pages folder" width="349" height="190"&gt;&lt;/a&gt;Next.js blog starter, pages folder&lt;/p&gt;

&lt;p&gt;It comprises the following files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;index.js&lt;/code&gt; is the homepage of the site&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;_app.js&lt;/code&gt; allows to introduce customization, such as styles, to be applied application wide&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;_document.js&lt;/code&gt; allows to restructure the document as in the whole HTML document encapsulating your application&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[slug].js&lt;/code&gt; represents any given post, its name contains &lt;code&gt;[]&lt;/code&gt; because it's leveraging dynamic routing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you create a post as Markdown file in &lt;code&gt;_post&lt;/code&gt; folder, the file name determines implicitly the slug of your post. If your file is called &lt;code&gt;hello-world.md&lt;/code&gt;, then its slug will be &lt;code&gt;hello-world&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Next.js takes the relative path &lt;code&gt;pages/blog/[slug].js&lt;/code&gt; and generates the route &lt;code&gt;/blog/:slug&lt;/code&gt;, which in this case would be &lt;code&gt;/blog/hello-world&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For further information please refer to &lt;a href="https://nextjs.org/docs/routing/introduction" rel="noopener noreferrer"&gt;this documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  And straight on till morning
&lt;/h3&gt;

&lt;p&gt;Feel free to explore the &lt;code&gt;components&lt;/code&gt; folder and make changes to meet your needs. Since they're mere React components they will probably look familiar.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Next.js is quite opinionated and might feel odd at first maybe, but its gracious learning curve and the elegant minimalistic API design make it a phenomenal tool to add to your belt.&lt;/p&gt;

&lt;p&gt;Setting aside personal tastes, Next.js is certainly worth your time.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The mystery of life isn't a problem to solve, but a reality to experience.&lt;br&gt;&lt;br&gt;
― Frank Herbert, Dune&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>react</category>
      <category>nextjs</category>
      <category>vercel</category>
      <category>blog</category>
    </item>
  </channel>
</rss>
