Repository: nuxt/create-nuxt-app
Pull request #540 (2020-06-05 13:36:42)

feat: add content module

Atinux: Would be nice to also add a content/hello.md file (with a quick getting started inside)
Atinux: I think you can directly add into the `cna-template` and add a filter here: https://github.com/nuxt/create-nuxt-app/blob/master/packages/create-nuxt-app/lib/saofile.js#L56

Patch:
diff --git a/packages/cna-template/template/nuxt/components/Logo.vue b/packages/cna-template/template/nuxt/components/Logo.vue
index 2134e93..7d127d7 100644
--- a/packages/cna-template/template/nuxt/components/Logo.vue
+++ b/packages/cna-template/template/nuxt/components/Logo.vue
@@ -1,20 +1,17 @@
 <template>
   <svg class="NuxtLogo" width="245" height="180" viewBox="0 0 452 342" xmlns="http://www.w3.org/2000/svg">
-    <g fill="none" fill-rule="evenodd">
-      <path
-        d="M139 330l-1-2c-2-4-2-8-1-13H29L189 31l67 121 22-16-67-121c-1-2-9-14-22-14-6 0-15 2-22 15L5 303c-1 3-8 16-2 27 4 6 10 12 24 12h136c-14 0-21-6-24-12z"
-        fill="#00C58E"
-      />
-      <path
-        d="M447 304L317 70c-2-2-9-15-22-15-6 0-15 3-22 15l-17 28v54l39-67 129 230h-49a23 23 0 0 1-2 14l-1 1c-6 11-21 12-23 12h76c3 0 17-1 24-12 3-5 5-14-2-26z"
-        fill="#108775"
-      />
-      <path
-        d="M376 330v-1l1-2c1-4 2-8 1-12l-4-12-102-178-15-27h-1l-15 27-102 178-4 12a24 24 0 0 0 2 15c4 6 10 12 24 12h190c3 0 18-1 25-12zM256 152l93 163H163l93-163z"
-        fill="#2F495E"
-        fill-rule="nonzero"
-      />
-    </g>
+    <path
+      d="M139 330l-1-2c-2-4-2-8-1-13H29L189 31l67 121 22-16-67-121c-1-2-9-14-22-14-6 0-15 2-22 15L5 303c-1 3-8 16-2 27 4 6 10 12 24 12h136c-14 0-21-6-24-12z"
+      fill="#00C58E"
+    />
+    <path
+      d="M447 304L317 70c-2-2-9-15-22-15-6 0-15 3-22 15l-17 28v54l39-67 129 230h-49a23 23 0 0 1-2 14l-1 1c-6 11-21 12-23 12h76c3 0 17-1 24-12 3-5 5-14-2-26z"
+      fill="#108775"
+    />
+    <path
+      d="M376 330v-1l1-2c1-4 2-8 1-12l-4-12-102-178-15-27h-1l-15 27-102 178-4 12a24 24 0 0 0 2 15c4 6 10 12 24 12h190c3 0 18-1 25-12zM256 152l93 163H163l93-163z"
+      fill="#2F495E"
+    />
   </svg>
 </template>
 <style>
@@ -27,9 +24,5 @@
   0% {
     opacity: 0;
   }
-
-  100% {
-    opacity: 1;
-  }
 }
 </style>
diff --git a/packages/cna-template/template/nuxt/content/hello.md b/packages/cna-template/template/nuxt/content/hello.md
new file mode 100644
index 0000000..d377a41
--- /dev/null
+++ b/packages/cna-template/template/nuxt/content/hello.md
@@ -0,0 +1,18 @@
+---
+title: Getting started
+description: 'Empower your NuxtJS application with @nuxt/content module: write in a content/ directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a Git-based Headless CMS.'
+---
+
+Empower your NuxtJS application with `@nuxtjs/content` module: write in a `content/` directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a **Git-based Headless CMS**.
+
+## Writing content
+
+Learn how to write your `content/`, supporting Markdown, YAML, CSV and JSON: https://content.nuxtjs.org/writing.
+
+## Fetching content
+
+Learn how to fetch your content with `$content`: https://content.nuxtjs.org/fetching.
+
+## Displaying content
+
+Learn how to display your Markdown content with the `<nuxt-content>` component directly in your template: https://content.nuxtjs.org/displaying.
\ No newline at end of file
diff --git a/packages/cna-template/template/nuxt/nuxt.config.js b/packages/cna-template/template/nuxt/nuxt.config.js
index ab69ebb..ab3c6b3 100644
--- a/packages/cna-template/template/nuxt/nuxt.config.js
+++ b/packages/cna-template/template/nuxt/nuxt.config.js
@@ -110,6 +110,10 @@ export default {
     <%_ if (pwa) { _%>
     '@nuxtjs/pwa',
     <%_ } _%>
+    <%_ if (content) { _%>
+    // Doc: https://github.com/nuxt/content
+    '@nuxt/content',
+    <%_ } _%>
   ],
   <%_ if (axios) { _%>
   /*
@@ -118,6 +122,13 @@ export default {
   */
   axios: {},
   <%_ } _%>
+  <%_ if (content) { _%>
+  /*
+  ** Content module configuration
+  ** See https://content.nuxtjs.org/configuration
+  */
+  content: {},
+  <%_ } _%>
   <%_ if (ui === 'vuetify') { _%>
   /*
   ** vuetify module configuration
diff --git a/packages/cna-template/template/nuxt/package.js b/packages/cna-template/template/nuxt/package.js
index 0891fc9..2333d20 100644
--- a/packages/cna-template/template/nuxt/package.js
+++ b/packages/cna-template/template/nuxt/package.js
@@ -64,6 +64,9 @@ module.exports = {
     if (!features.includes('pwa')) {
       delete pkg.dependencies['@nuxtjs/pwa']
     }
+    if (!features.includes('content')) {
+      delete pkg.dependencies['@nuxt/content']
+    }
 
     // TS
     const typescript = language.includes('ts')
diff --git a/packages/cna-template/template/nuxt/package.json b/packages/cna-template/template/nuxt/package.json
index 5868a1a..cbb8076 100644
--- a/packages/cna-template/template/nuxt/package.json
+++ b/packages/cna-template/template/nuxt/package.json
@@ -20,6 +20,7 @@
     "@nuxt/typescript-runtime": "^0.4.9",
     "@nuxtjs/axios": "^5.11.0",
     "@nuxtjs/pwa": "^3.0.0-beta.20",
+    "@nuxt/content": "^1.3.1",
     "nuxt": "^2.12.2"
   },
   "devDependencies": {
diff --git a/packages/create-nuxt-app/lib/prompts.js b/packages/create-nuxt-app/lib/prompts.js
index 739d9a9..895c65f 100644
--- a/packages/create-nuxt-app/lib/prompts.js
+++ b/packages/create-nuxt-app/lib/prompts.js
@@ -62,7 +62,8 @@ module.exports = [
     pageSize: 10,
     choices: [
       { name: 'Axios', value: 'axios' },
-      { name: 'Progressive Web App (PWA) Support', value: 'pwa' }
+      { name: 'Progressive Web App (PWA) Support', value: 'pwa' },
+      { name: 'Content', value: 'content' }
     ],
     default: []
   },
diff --git a/packages/create-nuxt-app/lib/saofile.js b/packages/create-nuxt-app/lib/saofile.js
index 4c19b24..a68f3fb 100644
--- a/packages/create-nuxt-app/lib/saofile.js
+++ b/packages/create-nuxt-app/lib/saofile.js
@@ -18,6 +18,7 @@ module.exports = {
     const lintStaged = eslint && this.answers.linter.includes('lintStaged')
     const stylelint = this.answers.linter.includes('stylelint')
     const axios = this.answers.features.includes('axios')
+    const content = this.answers.features.includes('content')
     const pm = this.answers.pm === 'yarn' ? 'yarn' : 'npm'
     const pmRun = this.answers.pm === 'yarn' ? 'yarn' : 'npm run'
 
@@ -35,7 +36,8 @@ module.exports = {
       axios,
       edge,
       pm,
-      pmRun
+      pmRun,
+      content
     }
   },
   actions () {
@@ -53,7 +55,8 @@ module.exports = {
       files: '**',
       templateDir: join(templateDir, 'nuxt'),
       filters: {
-        'static/icon.png': 'features.includes("pwa")'
+        'static/icon.png': 'features.includes("pwa")',
+        'content/hello.md': 'features.includes("content")'
       }
     }]
 


Test patch:
diff --git a/packages/create-nuxt-app/test/snapshots/index.test.js.md b/packages/create-nuxt-app/test/snapshots/index.test.js.md
index 4981388..8987fe9 100644
--- a/packages/create-nuxt-app/test/snapshots/index.test.js.md
+++ b/packages/create-nuxt-app/test/snapshots/index.test.js.md
@@ -486,7 +486,7 @@ Generated by [AVA](https://avajs.dev).
     }␊
     `
 
-## verify features: Axios, Progressive Web App (PWA) Support
+## verify features: Axios, Progressive Web App (PWA) Support, Content
 
 > Generated files
 
@@ -497,6 +497,7 @@ Generated by [AVA](https://avajs.dev).
       'assets/README.md',
       'components/Logo.vue',
       'components/README.md',
+      'content/hello.md',
       'layouts/README.md',
       'layouts/default.vue',
       'middleware/README.md',
@@ -515,6 +516,7 @@ Generated by [AVA](https://avajs.dev).
 
     {
       dependencies: {
+        '@nuxt/content': '^1.3.1',
         '@nuxtjs/axios': '^5.11.0',
         '@nuxtjs/pwa': '^3.0.0-beta.20',
         nuxt: '^2.12.2',
@@ -576,6 +578,8 @@ Generated by [AVA](https://avajs.dev).
         // Doc: https://axios.nuxtjs.org/usage␊
         '@nuxtjs/axios',␊
         '@nuxtjs/pwa',␊
+        // Doc: https://github.com/nuxt/content␊
+        '@nuxt/content',␊
       ],␊
       /*␊
       ** Axios module configuration␊
@@ -583,6 +587,114 @@ Generated by [AVA](https://avajs.dev).
       */␊
       axios: {},␊
       /*␊
+      ** Content module configuration␊
+      ** See https://content.nuxtjs.org/configuration␊
+      */␊
+      content: {},␊
+      /*␊
+      ** Build configuration␊
+      ** See https://nuxtjs.org/api/configuration-build/␊
+      */␊
+      build: {␊
+      }␊
+    }␊
+    `
+
+## verify features: Content
+
+> Generated files
+
+    [
+      '.editorconfig',
+      '.gitignore',
+      'README.md',
+      'assets/README.md',
+      'components/Logo.vue',
+      'components/README.md',
+      'content/hello.md',
+      'layouts/README.md',
+      'layouts/default.vue',
+      'middleware/README.md',
+      'nuxt.config.js',
+      'package.json',
+      'pages/README.md',
+      'pages/index.vue',
+      'plugins/README.md',
+      'static/README.md',
+      'static/favicon.ico',
+      'store/README.md',
+    ]
+
+> package.json
+
+    {
+      dependencies: {
+        '@nuxt/content': '^1.3.1',
+        nuxt: '^2.12.2',
+      },
+      devDependencies: {},
+      private: true,
+      scripts: {
+        build: 'nuxt build',
+        dev: 'nuxt',
+        generate: 'nuxt generate',
+        start: 'nuxt start',
+      },
+    }
+
+> Generated nuxt.config.js
+
+    `␊
+    export default {␊
+      /*␊
+      ** Nuxt rendering mode␊
+      ** See https://nuxtjs.org/api/configuration-mode␊
+      */␊
+      mode: 'universal',␊
+      /*␊
+      ** Headers of the page␊
+      ** See https://nuxtjs.org/api/configuration-head␊
+      */␊
+      head: {␊
+        title: process.env.npm_package_name || '',␊
+        meta: [␊
+          { charset: 'utf-8' },␊
+          { name: 'viewport', content: 'width=device-width, initial-scale=1' },␊
+          { hid: 'description', name: 'description', content: process.env.npm_package_description || '' }␊
+        ],␊
+        link: [␊
+          { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }␊
+        ]␊
+      },␊
+      /*␊
+      ** Global CSS␊
+      */␊
+      css: [␊
+      ],␊
+      /*␊
+      ** Plugins to load before mounting the App␊
+      ** https://nuxtjs.org/guide/plugins␊
+      */␊
+      plugins: [␊
+      ],␊
+      /*␊
+      ** Nuxt.js dev-modules␊
+      */␊
+      buildModules: [␊
+      ],␊
+      /*␊
+      ** Nuxt.js modules␊
+      */␊
+      modules: [␊
+        // Doc: https://github.com/nuxt/content␊
+        '@nuxt/content',␊
+      ],␊
+      /*␊
+      ** Content module configuration␊
+      ** See https://content.nuxtjs.org/configuration␊
+      */␊
+      content: {},␊
+      /*␊
       ** Build configuration␊
       ** See https://nuxtjs.org/api/configuration-build/␊
       */␊