1 March, 2021

Start a NuxtJS Project

I started rebuilding this website in January 2021 with NuxtJS. So far it the most pleasant to work with. It is a framework based on Vue.js allowing to use it with SSR (Server Side Rendering), go to the official documentation of NuxtJS at https://nuxtjs.org/

npm init nuxt-app teach

Here are my choices for the project:

  • JavaScript
  • No CSS framework
  • Axios and Content NuxtJS modules because I intent to use them in the project.
  • ESLint for some help checking my code.
  • I know Jest and use it as testing framework.
  • Universal SSR
  • Server (Node.js hosting)
  • jsconfig.json as it is recommended for VS Code
  • No CI as this is a personal project
  • Use git with repository on local network or usb-stick

Project Build

Download nmp packages and start in dev mode to test the:

npm run install
npm run dev

Open the browser to visit the site: http://localhost:3000

Check if some packages can be updated:

npm outdated

Update packages:

npm update -S

Embed markdown file as content

When you did not choose content module in the beginning, add it with npm install @nuxt/content

Between the template tags add <nuxt-content :document="page" />

In script tag add the async function asyncData:

export default {
  async asyncData ({ $content }) {
    const page = await $content('start-nuxtjs-project').fetch()
    return { page }
  }
}