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

Commit 9aba2f6

Browse files
feat: add content module (#540)
1 parent e250e14 commit 9aba2f6

File tree

8 files changed

+153
-4
lines changed

8 files changed

+153
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: Getting started
3+
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.'
4+
---
5+
6+
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**.
7+
8+
## Writing content
9+
10+
Learn how to write your `content/`, supporting Markdown, YAML, CSV and JSON: https://content.nuxtjs.org/writing.
11+
12+
## Fetching content
13+
14+
Learn how to fetch your content with `$content`: https://content.nuxtjs.org/fetching.
15+
16+
## Displaying content
17+
18+
Learn how to display your Markdown content with the `<nuxt-content>` component directly in your template: https://content.nuxtjs.org/displaying.

packages/cna-template/template/nuxt/nuxt.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ export default {
110110
<%_ if (pwa) { _%>
111111
'@nuxtjs/pwa',
112112
<%_ } _%>
113+
<%_ if (content) { _%>
114+
// Doc: https://github.com/nuxt/content
115+
'@nuxt/content',
116+
<%_ } _%>
113117
],
114118
<%_ if (axios) { _%>
115119
/*
@@ -118,6 +122,13 @@ export default {
118122
*/
119123
axios: {},
120124
<%_ } _%>
125+
<%_ if (content) { _%>
126+
/*
127+
** Content module configuration
128+
** See https://content.nuxtjs.org/configuration
129+
*/
130+
content: {},
131+
<%_ } _%>
121132
<%_ if (ui === 'vuetify') { _%>
122133
/*
123134
** vuetify module configuration

packages/cna-template/template/nuxt/package.js

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ module.exports = {
6464
if (!features.includes('pwa')) {
6565
delete pkg.dependencies['@nuxtjs/pwa']
6666
}
67+
if (!features.includes('content')) {
68+
delete pkg.dependencies['@nuxt/content']
69+
}
6770

6871
// TS
6972
const typescript = language.includes('ts')

packages/cna-template/template/nuxt/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@nuxt/typescript-runtime": "^0.4.9",
2121
"@nuxtjs/axios": "^5.11.0",
2222
"@nuxtjs/pwa": "^3.0.0-beta.20",
23+
"@nuxt/content": "^1.3.1",
2324
"nuxt": "^2.12.2"
2425
},
2526
"devDependencies": {

packages/create-nuxt-app/lib/prompts.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ module.exports = [
6262
pageSize: 10,
6363
choices: [
6464
{ name: 'Axios', value: 'axios' },
65-
{ name: 'Progressive Web App (PWA) Support', value: 'pwa' }
65+
{ name: 'Progressive Web App (PWA) Support', value: 'pwa' },
66+
{ name: 'Content', value: 'content' }
6667
],
6768
default: []
6869
},

packages/create-nuxt-app/lib/saofile.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
const lintStaged = eslint && this.answers.linter.includes('lintStaged')
1919
const stylelint = this.answers.linter.includes('stylelint')
2020
const axios = this.answers.features.includes('axios')
21+
const content = this.answers.features.includes('content')
2122
const pm = this.answers.pm === 'yarn' ? 'yarn' : 'npm'
2223
const pmRun = this.answers.pm === 'yarn' ? 'yarn' : 'npm run'
2324

@@ -35,7 +36,8 @@ module.exports = {
3536
axios,
3637
edge,
3738
pm,
38-
pmRun
39+
pmRun,
40+
content
3941
}
4042
},
4143
actions () {
@@ -53,7 +55,8 @@ module.exports = {
5355
files: '**',
5456
templateDir: join(templateDir, 'nuxt'),
5557
filters: {
56-
'static/icon.png': 'features.includes("pwa")'
58+
'static/icon.png': 'features.includes("pwa")',
59+
'content/hello.md': 'features.includes("content")'
5760
}
5861
}]
5962

packages/create-nuxt-app/test/snapshots/index.test.js.md

+113-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ Generated by [AVA](https://avajs.dev).
486486
}␊
487487
`
488488

489-
## verify features: Axios, Progressive Web App (PWA) Support
489+
## verify features: Axios, Progressive Web App (PWA) Support, Content
490490

491491
> Generated files
492492
@@ -497,6 +497,7 @@ Generated by [AVA](https://avajs.dev).
497497
'assets/README.md',
498498
'components/Logo.vue',
499499
'components/README.md',
500+
'content/hello.md',
500501
'layouts/README.md',
501502
'layouts/default.vue',
502503
'middleware/README.md',
@@ -515,6 +516,7 @@ Generated by [AVA](https://avajs.dev).
515516
516517
{
517518
dependencies: {
519+
'@nuxt/content': '^1.3.1',
518520
'@nuxtjs/axios': '^5.11.0',
519521
'@nuxtjs/pwa': '^3.0.0-beta.20',
520522
nuxt: '^2.12.2',
@@ -576,13 +578,123 @@ Generated by [AVA](https://avajs.dev).
576578
// Doc: https://axios.nuxtjs.org/usage␊
577579
'@nuxtjs/axios',␊
578580
'@nuxtjs/pwa',␊
581+
// Doc: https://github.com/nuxt/content␊
582+
'@nuxt/content',␊
579583
],␊
580584
/*␊
581585
** Axios module configuration␊
582586
** See https://axios.nuxtjs.org/options␊
583587
*/␊
584588
axios: {},␊
585589
/*␊
590+
** Content module configuration␊
591+
** See https://content.nuxtjs.org/configuration␊
592+
*/␊
593+
content: {},␊
594+
/*␊
595+
** Build configuration␊
596+
** See https://nuxtjs.org/api/configuration-build/␊
597+
*/␊
598+
build: {␊
599+
}␊
600+
}␊
601+
`
602+
603+
## verify features: Content
604+
605+
> Generated files
606+
607+
[
608+
'.editorconfig',
609+
'.gitignore',
610+
'README.md',
611+
'assets/README.md',
612+
'components/Logo.vue',
613+
'components/README.md',
614+
'content/hello.md',
615+
'layouts/README.md',
616+
'layouts/default.vue',
617+
'middleware/README.md',
618+
'nuxt.config.js',
619+
'package.json',
620+
'pages/README.md',
621+
'pages/index.vue',
622+
'plugins/README.md',
623+
'static/README.md',
624+
'static/favicon.ico',
625+
'store/README.md',
626+
]
627+
628+
> package.json
629+
630+
{
631+
dependencies: {
632+
'@nuxt/content': '^1.3.1',
633+
nuxt: '^2.12.2',
634+
},
635+
devDependencies: {},
636+
private: true,
637+
scripts: {
638+
build: 'nuxt build',
639+
dev: 'nuxt',
640+
generate: 'nuxt generate',
641+
start: 'nuxt start',
642+
},
643+
}
644+
645+
> Generated nuxt.config.js
646+
647+
`␊
648+
export default {␊
649+
/*␊
650+
** Nuxt rendering mode␊
651+
** See https://nuxtjs.org/api/configuration-mode␊
652+
*/␊
653+
mode: 'universal',␊
654+
/*␊
655+
** Headers of the page␊
656+
** See https://nuxtjs.org/api/configuration-head␊
657+
*/␊
658+
head: {␊
659+
title: process.env.npm_package_name || '',␊
660+
meta: [␊
661+
{ charset: 'utf-8' },␊
662+
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },␊
663+
{ hid: 'description', name: 'description', content: process.env.npm_package_description || '' }␊
664+
],␊
665+
link: [␊
666+
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }␊
667+
]␊
668+
},␊
669+
/*␊
670+
** Global CSS␊
671+
*/␊
672+
css: [␊
673+
],␊
674+
/*␊
675+
** Plugins to load before mounting the App␊
676+
** https://nuxtjs.org/guide/plugins␊
677+
*/␊
678+
plugins: [␊
679+
],␊
680+
/*␊
681+
** Nuxt.js dev-modules␊
682+
*/␊
683+
buildModules: [␊
684+
],␊
685+
/*␊
686+
** Nuxt.js modules␊
687+
*/␊
688+
modules: [␊
689+
// Doc: https://github.com/nuxt/content␊
690+
'@nuxt/content',␊
691+
],␊
692+
/*␊
693+
** Content module configuration␊
694+
** See https://content.nuxtjs.org/configuration␊
695+
*/␊
696+
content: {},␊
697+
/*␊
586698
** Build configuration␊
587699
** See https://nuxtjs.org/api/configuration-build/␊
588700
*/␊
Binary file not shown.

0 commit comments

Comments
 (0)