From 204cbe6fa6770157e8dda14855972d8b00c35c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Ollivier?= Date: Thu, 15 Sep 2022 11:09:59 +0200 Subject: [PATCH 01/11] docs(wip): add views page --- docs/content/1.getting-started/3.views.md | 123 +++++++++++++++++++++- 1 file changed, 119 insertions(+), 4 deletions(-) diff --git a/docs/content/1.getting-started/3.views.md b/docs/content/1.getting-started/3.views.md index 53bf6eb1386..963d0530804 100644 --- a/docs/content/1.getting-started/3.views.md +++ b/docs/content/1.getting-started/3.views.md @@ -1,13 +1,128 @@ +--- +description: "Nuxt provides 4 layers to manage the User Interface of your application. Each View is composed of Vue Single File Components (SFCs)" +--- # Views -::NeedContribution +## `App.vue` + +![The app.vue file is the entry point of your application](/3.x/img/views/app.png) + +By default, Nuxt will treat this file as the **entrypoint** and serve its content at the `/` **route** of our application. + +```vue [App.vue] + +``` + +::alert +💡 If you are familiar with Vue, you might wonder where is the `main.js` file that creates a Vue app. Nuxt does this behind the scene. :: -::ReadMore{link="/guide/directory-structure/components"} +## Components + +![Components are reusable pieces of UI](/3.x/img/views/components.png) + +Unlike `app.vue`, most components are not pages of our application, but reusable pieces of user interface, like buttons or menus. In Nuxt, you can create these components in the `components/` directory for them to be available across your application without having to explicitly import them, contrary to Vue.js. + +::code-group + +```vue [App.vue] + +``` + +```vue [components/AppAlert.vue] + +``` + :: -::ReadMore{link="/guide/directory-structure/pages"} +## Pages + +![Pages are views tied to a specific route](/3.x/img/views/pages.png) + +Pages represent views tied to a specific route. Every file in the `pages/` directory represents a different route displaying its content. + +To use pages, replace the content of `App.vue` with the built-in `` component. + +::code-group + +```vue [App.vue] + +``` + +```vue [pages/about.vue] + +``` + +:: + +::alert +You will learn more about pages in the Routing section +:: + +## Layouts + +![Layouts are wrapper around pages](/3.x/img/views/layouts.png) + +Layouts are wrapper around pages that contain a User Interface that is common to several pages, such as a header and footer display. Layouts are used by adding `` built-in component to your `App.vue` file, and setting a layout property as part of your page metadata. + +::alert +If you only have a single layout in your application, we recommend using app.vue instead. :: -::ReadMore{link="/guide/directory-structure/layouts"} +::code-group + +```vue [App.vue] + +``` + +```vue [layouts/Blog.vue] + +``` + +```vue [pages/Article.vue] + + + +``` + :: From c46c1fc934bcbe5ae5f75c93d9629c2d4e0fd286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Ollivier?= Date: Thu, 15 Sep 2022 14:39:31 +0200 Subject: [PATCH 02/11] chore: lint docs --- docs/content/1.getting-started/3.views.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/1.getting-started/3.views.md b/docs/content/1.getting-started/3.views.md index 963d0530804..ccf454dd8c7 100644 --- a/docs/content/1.getting-started/3.views.md +++ b/docs/content/1.getting-started/3.views.md @@ -53,7 +53,7 @@ Unlike `app.vue`, most components are not pages of our application, but reusable ![Pages are views tied to a specific route](/3.x/img/views/pages.png) -Pages represent views tied to a specific route. Every file in the `pages/` directory represents a different route displaying its content. +Pages represent views tied to a specific route. Every file in the `pages/` directory represents a different route displaying its content. To use pages, replace the content of `App.vue` with the built-in `` component. From c9effe347a641bef5d7ebfd7264fd124d9390061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Ollivier?= Date: Thu, 15 Sep 2022 14:50:29 +0200 Subject: [PATCH 03/11] docs: add description for views page --- docs/content/1.getting-started/3.views.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/content/1.getting-started/3.views.md b/docs/content/1.getting-started/3.views.md index ccf454dd8c7..44971012886 100644 --- a/docs/content/1.getting-started/3.views.md +++ b/docs/content/1.getting-started/3.views.md @@ -1,8 +1,7 @@ ---- -description: "Nuxt provides 4 layers to manage the User Interface of your application. Each View is composed of Vue Single File Components (SFCs)" ---- # Views +Nuxt provides 4 layers to manage the User Interface of your application. Each View is composed of Vue Single File Components (SFCs) + ## `App.vue` ![The app.vue file is the entry point of your application](/3.x/img/views/app.png) From 656646aaaff2ec0601a1e40c60e13d50ae335e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Ollivier?= Date: Thu, 15 Sep 2022 14:56:32 +0200 Subject: [PATCH 04/11] docs: add link to routing section --- docs/content/1.getting-started/3.views.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/1.getting-started/3.views.md b/docs/content/1.getting-started/3.views.md index 44971012886..6d005993a8f 100644 --- a/docs/content/1.getting-started/3.views.md +++ b/docs/content/1.getting-started/3.views.md @@ -77,7 +77,7 @@ To use pages, replace the content of `App.vue` with the built-in `` :: ::alert -You will learn more about pages in the Routing section +You will learn more about pages in the [Routing section](/getting-started/routing) :: ## Layouts From c37769220a4e2730ea324985b52f269b01146ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Ollivier?= Date: Thu, 15 Sep 2022 14:58:13 +0200 Subject: [PATCH 05/11] docs: remove hellonuxt component from example --- docs/content/1.getting-started/3.views.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/1.getting-started/3.views.md b/docs/content/1.getting-started/3.views.md index 6d005993a8f..df2b9772b5c 100644 --- a/docs/content/1.getting-started/3.views.md +++ b/docs/content/1.getting-started/3.views.md @@ -11,7 +11,7 @@ By default, Nuxt will treat this file as the **entrypoint** and serve its conten ```vue [App.vue] ``` From 6caee733ce40b63b94f2056956135fe45c3a51a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Ollivier?= Date: Thu, 15 Sep 2022 15:10:46 +0200 Subject: [PATCH 06/11] docs: update layouts explanation --- docs/content/1.getting-started/3.views.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/content/1.getting-started/3.views.md b/docs/content/1.getting-started/3.views.md index df2b9772b5c..fd0d096e913 100644 --- a/docs/content/1.getting-started/3.views.md +++ b/docs/content/1.getting-started/3.views.md @@ -54,14 +54,14 @@ Unlike `app.vue`, most components are not pages of our application, but reusable Pages represent views tied to a specific route. Every file in the `pages/` directory represents a different route displaying its content. -To use pages, replace the content of `App.vue` with the built-in `` component. +To use pages, delete the `App.vue` file and move its content in a `pages/index.vue` file. You can now create more pages and their corresponding routes by adding new files in the `pages/` directory. ::code-group -```vue [App.vue] +```vue [pages/index.vue] ``` @@ -84,18 +84,20 @@ You will learn more about pages in the [Routing section](/getting-started/routin ![Layouts are wrapper around pages](/3.x/img/views/layouts.png) -Layouts are wrapper around pages that contain a User Interface that is common to several pages, such as a header and footer display. Layouts are used by adding `` built-in component to your `App.vue` file, and setting a layout property as part of your page metadata. +Layouts are wrapper around pages that contain a common User Interface for several pages, such as a header and footer display. Layouts are Vue files using `` components to display the **pages** content. The `layout/default.vue` file will be used by default. Custom layouts can be set as part of your page metadata. ::alert -If you only have a single layout in your application, we recommend using app.vue instead. +If you only have a single layout in your application, we recommend using app.vue with the [`` component](/api/components/nuxt-page) instead. :: ::code-group -```vue [App.vue] +```vue [layouts/default.vue] ``` @@ -103,9 +105,9 @@ If you only have a single layout in your application, we recommend using app.vue ```vue [layouts/Blog.vue] ``` From e972f2842778618bfcaeb99fae21524c7002d396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Ollivier?= Date: Thu, 15 Sep 2022 15:48:03 +0200 Subject: [PATCH 07/11] docs: update layouts section --- docs/.gitignore | 1 + docs/content/1.getting-started/3.views.md | 41 ++++++++++++----------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/docs/.gitignore b/docs/.gitignore index b4a500fb84f..988de6ce14a 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -1,2 +1,3 @@ schema **/*.configuration/nuxt.config.md +**/*.configuration/nuxt-config.md diff --git a/docs/content/1.getting-started/3.views.md b/docs/content/1.getting-started/3.views.md index fd0d096e913..800cb546868 100644 --- a/docs/content/1.getting-started/3.views.md +++ b/docs/content/1.getting-started/3.views.md @@ -11,7 +11,7 @@ By default, Nuxt will treat this file as the **entrypoint** and serve its conten ```vue [App.vue] ``` @@ -31,9 +31,10 @@ Unlike `app.vue`, most components are not pages of our application, but reusable ```vue [App.vue] ``` @@ -61,7 +62,10 @@ To use pages, delete the `App.vue` file and move its content in a `pages/index.v ```vue [pages/index.vue] ``` @@ -102,28 +106,25 @@ If you only have a single layout in your application, we recommend using app.vue ``` -```vue [layouts/Blog.vue] +```vue [pages/index.vue] ``` -```vue [pages/Article.vue] +```vue [pages/about.vue] - - ``` :: + +If you want to create more layouts and learn how to use them in your pages, find more information in the [Layouts section](/guide/directory-structure/layouts). From 32b6083e1ef9deb9df73b3f9362a3157ce000778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Ollivier?= Date: Mon, 19 Sep 2022 12:08:34 +0200 Subject: [PATCH 08/11] docs(views): add images --- docs/content/1.getting-started/3.views.md | 8 ++++---- docs/static/img/getting-started/views/app.svg | 1 + docs/static/img/getting-started/views/components.svg | 1 + docs/static/img/getting-started/views/layouts.svg | 1 + docs/static/img/getting-started/views/pages.svg | 1 + 5 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 docs/static/img/getting-started/views/app.svg create mode 100644 docs/static/img/getting-started/views/components.svg create mode 100644 docs/static/img/getting-started/views/layouts.svg create mode 100644 docs/static/img/getting-started/views/pages.svg diff --git a/docs/content/1.getting-started/3.views.md b/docs/content/1.getting-started/3.views.md index 800cb546868..7d54dfa4d5b 100644 --- a/docs/content/1.getting-started/3.views.md +++ b/docs/content/1.getting-started/3.views.md @@ -4,7 +4,7 @@ Nuxt provides 4 layers to manage the User Interface of your application. Each Vi ## `App.vue` -![The app.vue file is the entry point of your application](/3.x/img/views/app.png) +![The app.vue file is the entry point of your application](/img/getting-started/views/app.svg) By default, Nuxt will treat this file as the **entrypoint** and serve its content at the `/` **route** of our application. @@ -22,7 +22,7 @@ By default, Nuxt will treat this file as the **entrypoint** and serve its conten ## Components -![Components are reusable pieces of UI](/3.x/img/views/components.png) +![Components are reusable pieces of UI](/img/getting-started/views/components.svg) Unlike `app.vue`, most components are not pages of our application, but reusable pieces of user interface, like buttons or menus. In Nuxt, you can create these components in the `components/` directory for them to be available across your application without having to explicitly import them, contrary to Vue.js. @@ -51,7 +51,7 @@ Unlike `app.vue`, most components are not pages of our application, but reusable ## Pages -![Pages are views tied to a specific route](/3.x/img/views/pages.png) +![Pages are views tied to a specific route](/img/getting-started/views/pages.svg) Pages represent views tied to a specific route. Every file in the `pages/` directory represents a different route displaying its content. @@ -86,7 +86,7 @@ You will learn more about pages in the [Routing section](/getting-started/routin ## Layouts -![Layouts are wrapper around pages](/3.x/img/views/layouts.png) +![Layouts are wrapper around pages](/img/getting-started/views/layouts.svg) Layouts are wrapper around pages that contain a common User Interface for several pages, such as a header and footer display. Layouts are Vue files using `` components to display the **pages** content. The `layout/default.vue` file will be used by default. Custom layouts can be set as part of your page metadata. diff --git a/docs/static/img/getting-started/views/app.svg b/docs/static/img/getting-started/views/app.svg new file mode 100644 index 00000000000..9732919e3e2 --- /dev/null +++ b/docs/static/img/getting-started/views/app.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/static/img/getting-started/views/components.svg b/docs/static/img/getting-started/views/components.svg new file mode 100644 index 00000000000..7b14322db1f --- /dev/null +++ b/docs/static/img/getting-started/views/components.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/static/img/getting-started/views/layouts.svg b/docs/static/img/getting-started/views/layouts.svg new file mode 100644 index 00000000000..afe8f72a66c --- /dev/null +++ b/docs/static/img/getting-started/views/layouts.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/static/img/getting-started/views/pages.svg b/docs/static/img/getting-started/views/pages.svg new file mode 100644 index 00000000000..14e5d34fa29 --- /dev/null +++ b/docs/static/img/getting-started/views/pages.svg @@ -0,0 +1 @@ + \ No newline at end of file From decd5e77d2dd6eec44dc2f6d3be88e1596b059de Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Tue, 20 Sep 2022 11:18:33 +0200 Subject: [PATCH 09/11] small tweaks --- docs/content/1.getting-started/3.views.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/content/1.getting-started/3.views.md b/docs/content/1.getting-started/3.views.md index 7d54dfa4d5b..9f97754e4ed 100644 --- a/docs/content/1.getting-started/3.views.md +++ b/docs/content/1.getting-started/3.views.md @@ -1,14 +1,14 @@ # Views -Nuxt provides 4 layers to manage the User Interface of your application. Each View is composed of Vue Single File Components (SFCs) +Nuxt provides several component layers to implement the user interface of your application. -## `App.vue` +## `app.vue` -![The app.vue file is the entry point of your application](/img/getting-started/views/app.svg) +![The `app.vue` file is the entry point of your application](/img/getting-started/views/app.svg) -By default, Nuxt will treat this file as the **entrypoint** and serve its content at the `/` **route** of our application. +By default, Nuxt will treat this file as the **entrypoint** and render it's content for every route of the application. -```vue [App.vue] +```vue [app.vue] @@ -53,9 +53,9 @@ Unlike `app.vue`, most components are not pages of our application, but reusable ![Pages are views tied to a specific route](/img/getting-started/views/pages.svg) -Pages represent views tied to a specific route. Every file in the `pages/` directory represents a different route displaying its content. +Pages represent views use for each specific route pattern. Every file in the `pages/` directory represents a different route displaying it's content. -To use pages, delete the `App.vue` file and move its content in a `pages/index.vue` file. You can now create more pages and their corresponding routes by adding new files in the `pages/` directory. +To use pages, create `pages/index.vue` file and add `` component to the `app.vue` (or remove `app.vue` for default entry). You can now create more pages and their corresponding routes by adding new files in the `pages/` directory. ::code-group From 5842cfb3371bb3ca1b761addb9a1bf3f7d7a592c Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 20 Sep 2022 10:29:28 +0100 Subject: [PATCH 10/11] docs: tweaks --- docs/content/1.getting-started/3.views.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/content/1.getting-started/3.views.md b/docs/content/1.getting-started/3.views.md index 9f97754e4ed..709e2862f6b 100644 --- a/docs/content/1.getting-started/3.views.md +++ b/docs/content/1.getting-started/3.views.md @@ -17,14 +17,14 @@ By default, Nuxt will treat this file as the **entrypoint** and render it's cont ``` ::alert -If you are familiar with Vue, you might wonder where is the `main.js` file that creates a Vue app. Nuxt does this behind the scene. +If you are familiar with Vue, you might wonder where `main.js` is (the file is that normally creates a Vue app). Nuxt does this behind the scene. :: ## Components ![Components are reusable pieces of UI](/img/getting-started/views/components.svg) -Most of the components are reusable pieces of the user interface, like buttons and menus. In Nuxt, you can create these components in the `components/` directory for them to be automatically available across your application without having to explicitly import them. +Most components are reusable pieces of the user interface, like buttons and menus. In Nuxt, you can create these components in the `components/` directory, and they will be automatically available across your application without having to explicitly import them. ::code-group @@ -53,7 +53,7 @@ Most of the components are reusable pieces of the user interface, like buttons a ![Pages are views tied to a specific route](/img/getting-started/views/pages.svg) -Pages represent views use for each specific route pattern. Every file in the `pages/` directory represents a different route displaying it's content. +Pages represent views use for each specific route pattern. Every file in the `pages/` directory represents a different route displaying its content. To use pages, create `pages/index.vue` file and add `` component to the `app.vue` (or remove `app.vue` for default entry). You can now create more pages and their corresponding routes by adding new files in the `pages/` directory. @@ -88,7 +88,7 @@ You will learn more about pages in the [Routing section](/getting-started/routin ![Layouts are wrapper around pages](/img/getting-started/views/layouts.svg) -Layouts are wrapper around pages that contain a common User Interface for several pages, such as a header and footer display. Layouts are Vue files using `` components to display the **pages** content. The `layout/default.vue` file will be used by default. Custom layouts can be set as part of your page metadata. +Layouts are wrappers around pages that contain a common User Interface for several pages, such as a header and footer display. Layouts are Vue files using `` components to display the **page** content. The `layout/default.vue` file will be used by default. Custom layouts can be set as part of your page metadata. ::alert If you only have a single layout in your application, we recommend using app.vue with the [`` component](/api/components/nuxt-page) instead. From 8503bcb9e98a8e60983b3cbec80d5056f1fb4dfc Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Tue, 20 Sep 2022 11:29:38 +0200 Subject: [PATCH 11/11] Update docs/content/1.getting-started/3.views.md Co-authored-by: Daniel Roe --- docs/content/1.getting-started/3.views.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/1.getting-started/3.views.md b/docs/content/1.getting-started/3.views.md index 709e2862f6b..2673172ca07 100644 --- a/docs/content/1.getting-started/3.views.md +++ b/docs/content/1.getting-started/3.views.md @@ -6,7 +6,7 @@ Nuxt provides several component layers to implement the user interface of your a ![The `app.vue` file is the entry point of your application](/img/getting-started/views/app.svg) -By default, Nuxt will treat this file as the **entrypoint** and render it's content for every route of the application. +By default, Nuxt will treat this file as the **entrypoint** and render its content for every route of the application. ```vue [app.vue]