<?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: Mario Laurich</title>
    <description>The latest articles on DEV Community by Mario Laurich (@programmierenm).</description>
    <link>https://dev.to/programmierenm</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%2F254357%2Fd3f3c963-cea3-43b3-aeae-96eef6df2e61.jpg</url>
      <title>DEV Community: Mario Laurich</title>
      <link>https://dev.to/programmierenm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/programmierenm"/>
    <language>en</language>
    <item>
      <title>Getting started with Nuxt.js</title>
      <dc:creator>Mario Laurich</dc:creator>
      <pubDate>Thu, 06 Aug 2020 09:08:06 +0000</pubDate>
      <link>https://dev.to/programmierenm/getting-started-with-nuxt-js-2c07</link>
      <guid>https://dev.to/programmierenm/getting-started-with-nuxt-js-2c07</guid>
      <description>&lt;p&gt;If you're building applications with Vue.js, you've probably heard of Nuxt.js. Vue already makes the development of JavaScript applications more convenient, but what's the idea behind Nuxt.js?&lt;/p&gt;

&lt;p&gt;It's a &lt;strong&gt;progressive framework based on Vue.js&lt;/strong&gt;. It simplifies the development of universal or single-page apps.&lt;/p&gt;

&lt;p&gt;And this tutorial is all about, what Nuxt.js in detail is, which features you are getting, and how you can create your first project. Finally, you get an overview of the files and folder structure. There are some differences to a regular Vue.js project.&lt;/p&gt;

&lt;p&gt;Do you prefer to watch a video about this topic?&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/fqGnxrWQUoY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Nuxt.js
&lt;/h2&gt;

&lt;p&gt;Nuxt is based on Vue.js official libraries. That means on Vue, the Vue Router, Vuex. And also on powerful development tools like Webpack or Babel, for example. It extends Vue.js by some helpful features, and only with a few extra kilobytes added to your JavaScript files.&lt;/p&gt;

&lt;p&gt;Nuxt makes creating universal apps easier.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a universal app?
&lt;/h3&gt;

&lt;p&gt;A universal app can execute on both the client and the server-side.&lt;br&gt;
If you create a single page application with Vue.js, you have a lot of benefits.&lt;/p&gt;

&lt;p&gt;For example, you can make very &lt;em&gt;snappy&lt;/em&gt; UIs that updates fast. But, and this is a problem, Google and other search engines struggle with them because there's no content initially on the page to crawl for SEO purposes. &lt;/p&gt;

&lt;p&gt;All the content is rendered with JavaScript after the fact.&lt;/p&gt;

&lt;p&gt;And with a universal app, you have instead of an index.html without content, a preloaded app on a web server that sends rendered HTML for every route to speed up load times and improve SEO by making it easier for search engines to crawl the page.&lt;/p&gt;

&lt;p&gt;The next benefit is you can prerender your app to a static website. That's, in my opinion, the most significant innovation. You can create with the command &lt;code&gt;nuxt generate&lt;/code&gt; a completely static version of your application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run generate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It generates an HTML file for every route, and you have &lt;strong&gt;all the benefits&lt;/strong&gt; of a universal app. But the difference is that you don't need a webserver anymore. Everything gets generated during the deployment period.&lt;/p&gt;

&lt;p&gt;It's mighty because you get the benefits of universal rendering without the need for a server. You can host your app on GitHub Pages or a cloud service like Google Firebase. You could even host your website with Google Drive, without paying a single coin.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You are entirely free&lt;/em&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Create a new Nuxt.js project
&lt;/h2&gt;

&lt;p&gt;You know we can create a new project with &lt;code&gt;vue create&lt;/code&gt; and then the project-name if you use the vue cli service.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vue create project-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But if you want to create a Nuxt project, we have to use another tool - &lt;code&gt;npx&lt;/code&gt;.&lt;br&gt;
The difference to npm is that npx is a tool to execute node.js packages. npm is only a manager for download and installing node packages.&lt;br&gt;
And it's shipped by default since node package manager in version 5, and you don't have to install it separately. &lt;/p&gt;

&lt;p&gt;But if you don't have it for some reason, you can install it with &lt;code&gt;npm install -g npx&lt;/code&gt;, -g to install it globally.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; npx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, you can create a new project with npx, and there is a scaffolding tool you can use, created by the Nuxt team, &lt;code&gt;create-nuxt-app&lt;/code&gt;,&lt;br&gt;
followed by a project name of your choice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-nuxt-app projectname
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have to choose different options, for example, setting which UI Framework you want to use or installing an additional module, like PWA or Axios. You can change everything later; It's totally up to you.&lt;/p&gt;

&lt;p&gt;Generally, I highly recommend that if you start with new things, &lt;strong&gt;keep it simple&lt;/strong&gt; and catch up with all the other stuff like test and UI frameworks later when you feel comfortable.&lt;/p&gt;

&lt;p&gt;After that process, you can switch to the new project folder and run it with &lt;code&gt;npm run dev&lt;/code&gt;, instead of serve.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;p&gt;If you look in your new directory structure for the first time, you will immediately notice that you can find a lot of new stuff. For comparison, a regular Vue project looks more comfortable at first. But all of this is justified because there are also some beneficial new patterns with all that stuff.&lt;/p&gt;

&lt;p&gt;First, you have the assets folder. It's entirely the same as with Vue. You can store here all your static assets, your images, for example. But also uncompiled SCSS files, which you are using in the whole application. Also, the components directory sounds familiar. The name suggests, here is the place for all your components. For all? Not entirely. You have here only all the reusable components that you can use in your whole application. Components for the layout and pages have their own directories.&lt;/p&gt;

&lt;p&gt;In the layouts folder is already a &lt;code&gt;default.vue&lt;/code&gt; file with a template and some CSS definitions. New is the &lt;code&gt;&amp;lt;nuxt /&amp;gt;&lt;/code&gt; tag&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;template&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;nuxt&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;  
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;  
&lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's a component provided by Nuxt, which renders the current route of your application. You can compare it to the router view component.&lt;/p&gt;

&lt;p&gt;It's a fantastic pattern, in my opinion, because you can use more than one layout. For example, if you have a blog besides your main website, you can create for each part of your site, different designs based on these layout files. Distinct layouts for mobile and desktop it's also possible. &lt;strong&gt;It's a powerful pattern&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It's also the place where you can use the main navigation, a sidebar or the footer, entirely components, which are used by all routes of your application.&lt;/p&gt;

&lt;p&gt;Next, we have the middleware folder.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Middlewares&lt;/strong&gt; lets you define custom functions that can be run &lt;em&gt;before rendering&lt;/em&gt; a page or a group of pages. Also importantly, the middleware has access to the context, which provides additional objects and params from your application.&lt;/p&gt;

&lt;p&gt;As an example, you could evaluate the user agent according to the keyword &lt;code&gt;mobile&lt;/code&gt; and use a different layout depending on the case. The result is then saved in the context so that it can be used later.&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;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;userAgent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user-agent&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isMobile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sr"&gt;/mobile/i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userAgent&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;You have here also access to the Vuex store and the Vue Router.&lt;br&gt;
&lt;em&gt;That's amazing&lt;/em&gt;. You can create a navigation guard, where you can check an authentication status before the requested route is delivered.&lt;/p&gt;

&lt;p&gt;You can do here a lot of great stuff. Very powerful.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;pages directory&lt;/strong&gt; contains your application views and routes. &lt;br&gt;
Nuxt reads all the .vue files inside this directory and creates the application router automatically.&lt;/p&gt;

&lt;p&gt;And Nuxt provides for each component a bunch of additional attributes you can use. For example, which layout you want to use if you have some.&lt;br&gt;
Or you can also use here the head attribute to define a custom title, description or meta tags for this page, and so on.&lt;br&gt;
Nuxt uses here the plugin &lt;code&gt;vue-meta&lt;/code&gt; for the head attribute, which is also available for a regular Vue.js project.&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;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;head&lt;/span&gt; &lt;span class="p"&gt;()&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="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;webnoob&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;meta&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="na"&gt;hid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&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="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;The &lt;strong&gt;plugins folder&lt;/strong&gt; is the place where you can set up additional libraries like font-awesome, for example. But you can also create your reusable pieces of JavaScript code. Register components globally and to inject functions or constants could also be a possibility.&lt;/p&gt;

&lt;p&gt;As an example, you can set up a new filter for displaying a date. If you register this plugin in your &lt;code&gt;nuxt.config.js&lt;/code&gt; file, then you can use it easily in your templates with &lt;code&gt;{{ date | formatdate }}&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Vue&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;formatdate&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&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;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;numeric&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;month&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;long&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;day&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;numeric&lt;/span&gt;&lt;span class="dl"&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;today&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;today&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toLocaleDateString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;en-US&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;options&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 &lt;strong&gt;static directory&lt;/strong&gt; is directly mapped to the root folder from your application. So that's the place for your robot or sitemap files and so on.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;store directory&lt;/strong&gt; contains your Vuex store files and comes with Nuxt.js out of the box but is disabled by default. Creating a javascript file in this directory enables the store. Nuxt.js lets you decide between 2 store modes at this time. The first one is with the &lt;code&gt;index.js&lt;/code&gt; file, the classic way, which is also deprecated. So I highly recommend using the second mode with unique names, like &lt;code&gt;todo.js&lt;/code&gt; or &lt;code&gt;blog.js&lt;/code&gt;, which gets transferred to the Vuex namespace modules.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;nuxt.config.js&lt;/strong&gt; file is the control center of your entire application.&lt;br&gt;
You can change the mode, from universal to single page application and back. You are entirely free to change that on any time.&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="nx"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;universal&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But keep in mind, if you are using the &lt;code&gt;spa&lt;/code&gt; mode, you can't use server-side rendering or any other special server handling.&lt;br&gt;
On the other hand, in combination with the generate feature, it gives you a &lt;em&gt;powerful&lt;/em&gt; deployment mechanism.&lt;/p&gt;

&lt;p&gt;Furthermore, you have the default set up from the page head, which you can customize with additional meta tags or external resources like Google Fonts.&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="nx"&gt;head&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;title&lt;/span&gt;&lt;span class="p"&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;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;npm_package_name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;''&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="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;charset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;utf-8&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;viewport&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;width=device-width, initial-scale=1&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="na"&gt;hid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&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;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;npm_package_description&lt;/span&gt; &lt;span class="o"&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="nx"&gt;link&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="na"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;icon&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;image/png&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/favicon.ico&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;Nuxt gives you out of the box a loading progress bar component that's shown between routes. You can customize it, disable it, or create your own. Excellent feature, in my opinion.&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="nx"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#fff&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below you can register additional global CSS files, plugins, and modules.&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="nx"&gt;css&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="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@fortawesome/fontawesome-svg-core/styles.css&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="nx"&gt;plugins&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="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;~/plugins/font-awesome&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="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;~/plugins/format-date&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="nx"&gt;modules&lt;/span&gt;&lt;span class="p"&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;@nuxtjs/pwa&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;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;You have probably already noticed that we don't have here a &lt;code&gt;main.js&lt;/code&gt; file or an App root component, right?&lt;/p&gt;

&lt;p&gt;Well, &lt;em&gt;you don't need it&lt;/em&gt;. Each component in the pages directory is basically a root component from a specific route. And the fantastic thing is you can for each route set up a different layout if you want.&lt;/p&gt;

&lt;p&gt;Additional libraries and other javascript pieces, to register global components and other stuff, can you set up as a plugin.&lt;br&gt;
To me, it all seems well organized and tidy. &lt;/p&gt;

&lt;p&gt;Now it's your turn. Create your first Nuxt project today and play around with the new possibilities.&lt;br&gt;
And if you want to see more, I already have a video tutorial about how you can create distinct layouts for mobile and desktop.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/xh_OrVwgh4M"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>vue</category>
      <category>nuxt</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>I open-sourced my Nuxt.js blog</title>
      <dc:creator>Mario Laurich</dc:creator>
      <pubDate>Tue, 04 Aug 2020 13:30:48 +0000</pubDate>
      <link>https://dev.to/programmierenm/i-open-sourced-my-nuxt-js-blog-53nc</link>
      <guid>https://dev.to/programmierenm/i-open-sourced-my-nuxt-js-blog-53nc</guid>
      <description>&lt;p&gt;I've implemented my new website/blog using Nuxt.js and deployed it on Netlify. &lt;a href="https://twitter.com/telmo"&gt;Telmo&lt;/a&gt; inspired me with his fantastic clean-coded project to create my own. He built the blog &lt;a href="https://telmo.im"&gt;telmo.im&lt;/a&gt; with Next.js(React) and markdown files. &lt;br&gt;
Which is really sexy in my opinion. That's the short story.&lt;/p&gt;

&lt;p&gt;In detail, I wanted my personal blog and with &lt;strong&gt;zero knowledge about React&lt;/strong&gt; I looked into Telmo's &lt;a href="https://github.com/telmogoncalves/telmo"&gt;GitHub&lt;/a&gt; Repo like a cow would look into the clockwork. But ok, it can't be that difficult, so I was curious about which dependencies he used and decided for me to start from scratch with a new Nuxt.js project. &lt;/p&gt;

&lt;p&gt;Of course, there are some excellent headless CMS that I could use. But I found it a little over the top for a small blog like mine. It was also my wish to write new blog articles with markdown files, which then appear automatically. I chose &lt;a href="https://content.nuxtjs.org/"&gt;@nuxt/content&lt;/a&gt; for this kind of job.&lt;/p&gt;

&lt;p&gt;If you use the Node Package Manager, then can you inject it directly in your project with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; @nuxt/content
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Here are some features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blazing fast hot reload in development&lt;/li&gt;
&lt;li&gt;Vue components in Markdown&lt;/li&gt;
&lt;li&gt;Full-text search&lt;/li&gt;
&lt;li&gt;Support static site generation with nuxt generate&lt;/li&gt;
&lt;li&gt;Powerful QueryBuilder API (MongoDB like)&lt;/li&gt;
&lt;li&gt;Syntax highlighting to code blocks in markdown files using PrismJS.&lt;/li&gt;
&lt;li&gt;Handles Markdown, CSV, YAML, JSON(5)&lt;/li&gt;
&lt;li&gt;Extend with hooks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That sounds fantastic to me and is more than what I wanted. &lt;br&gt;
I highly recommend taking a look at the official documentation to get the stone rolling.&lt;br&gt;
It's the first time I using it, and let me tell you it's freaking amazing. &lt;strong&gt;Thank you, Telmo for the inspiration&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Repository
&lt;/h2&gt;

&lt;p&gt;You can find the repository here, and if you want to contribute to the project, you are very welcome to open pull requests.&lt;/p&gt;

&lt;p&gt;If you want to use my project to code and build your own website, then go for it.&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/webnoobcodes/webnoob.dev"&gt;Open Github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vue</category>
      <category>nuxt</category>
      <category>opensource</category>
      <category>github</category>
    </item>
    <item>
      <title>Change Navigation Based On View With Vue JS</title>
      <dc:creator>Mario Laurich</dc:creator>
      <pubDate>Mon, 21 Oct 2019 07:43:32 +0000</pubDate>
      <link>https://dev.to/programmierenm/change-navigation-based-on-view-with-vue-js-4a81</link>
      <guid>https://dev.to/programmierenm/change-navigation-based-on-view-with-vue-js-4a81</guid>
      <description>&lt;h1&gt;
  
  
  My thoughts
&lt;/h1&gt;

&lt;p&gt;Imagine, you have a website with a navigation, which is not responsive, and the goal is to build a mobile variation. How can you do this without CSS media queries? And what kind of benefits do you have with Vue JS?&lt;/p&gt;

&lt;p&gt;Should be the mobile version utterly different from the desktop variation, starting from the HTML structure, over the functionality and until to the CSS styling, then, of course, the implementation can be quite difficult.&lt;br&gt;
And if you wanna implement this with CSS media queries and many javascript conditions, for example, that can be a bit annoying and confusing.&lt;/p&gt;

&lt;p&gt;So, in my opinion, it's a better solution to create a different Component for the mobile navigation and use the reactivity from Vue JS to switch between these components, based on the current viewport.&lt;/p&gt;
&lt;h1&gt;
  
  
  Handle the current view
&lt;/h1&gt;

&lt;p&gt;The core idea is to check out the current innerWidth with your specific breakpoint and hold the status (true or false) in a local data attribute. In the App.vue Component or in the Component you want to handle the navigation.&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="nx"&gt;methods&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;handleView&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;mobileView&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerWidth&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;990&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;h1&gt;
  
  
  Use your method
&lt;/h1&gt;

&lt;p&gt;Next, you can use the created lifecycle hook and fire your method if the Component is created. Further, you have the opportunity to bind the method with an eventListener to the browser resize event. &lt;/p&gt;

&lt;p&gt;This will allow you to run the method again if the user changes the browser size.&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="nx"&gt;created&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handleView&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;resize&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;handleView&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;h1&gt;
  
  
  And Now?
&lt;/h1&gt;

&lt;p&gt;Now it's pretty easy to show either the mobile version or the normal navigation in your template depending on your mobileView status.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;NavigationMobile&lt;/span&gt; &lt;span class="na"&gt;v-if=&lt;/span&gt;&lt;span class="s"&gt;"mobileView"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;Navigation&lt;/span&gt; &lt;span class="na"&gt;v-else&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  My YouTube Tutorial about this topic
&lt;/h1&gt;

&lt;p&gt;In this tutorial, I show you step by step, how you can implement this in a Vue JS project. &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/lga-ceawtmw"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;With this solution, you have both cleanly separated and can also use and adapt independently. &lt;/p&gt;

&lt;p&gt;What are your thoughts?&lt;/p&gt;

&lt;p&gt;Would you rather use CSS Media queries?&lt;/p&gt;

&lt;p&gt;Thanks for reading and watching.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>tutorial</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
