Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

feat: add content module #540

Merged
merged 3 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/cna-template/template/nuxt/content/hello.md
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 11 additions & 0 deletions packages/cna-template/template/nuxt/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export default {
<%_ if (pwa) { _%>
'@nuxtjs/pwa',
<%_ } _%>
<%_ if (content) { _%>
// Doc: https://github.com/nuxt/content
'@nuxt/content',
<%_ } _%>
],
<%_ if (axios) { _%>
/*
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions packages/cna-template/template/nuxt/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions packages/cna-template/template/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 2 additions & 1 deletion packages/create-nuxt-app/lib/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
},
Expand Down
7 changes: 5 additions & 2 deletions packages/create-nuxt-app/lib/saofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -35,7 +36,8 @@ module.exports = {
axios,
edge,
pm,
pmRun
pmRun,
content
}
},
actions () {
Expand All @@ -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")'
}
}]

Expand Down
114 changes: 113 additions & 1 deletion packages/create-nuxt-app/test/snapshots/index.test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -576,13 +578,123 @@ 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␊
** See https://axios.nuxtjs.org/options␊
*/␊
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/␊
*/␊
Expand Down
Binary file modified packages/create-nuxt-app/test/snapshots/index.test.js.snap
Binary file not shown.