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 000000000..d377a4136 --- /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 `` 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 ab69ebb43..ab3c6b383 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 0891fc9ef..2333d20c6 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 5868a1a2b..cbb8076b1 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 739d9a9a3..895c65ffc 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 4c19b244f..a68f3fb73 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")' } }] 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 498138832..8987fe998 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/␊ */␊ diff --git a/packages/create-nuxt-app/test/snapshots/index.test.js.snap b/packages/create-nuxt-app/test/snapshots/index.test.js.snap index bf00752b1..4ae121276 100644 Binary files a/packages/create-nuxt-app/test/snapshots/index.test.js.snap and b/packages/create-nuxt-app/test/snapshots/index.test.js.snap differ