|
| 1 | +# Nuxt.js Generator |
| 2 | + |
| 3 | +The Nuxt.js Client Generator generates components for Server Side Rendered applications using [Nuxt.js](https://nuxtjs.org/) and [Vuetify](https://vuetifyjs.com/). |
| 4 | + |
| 5 | +## Install |
| 6 | + |
| 7 | +### Nuxt |
| 8 | + |
| 9 | +Create a [Nuxt.js application](https://nuxtjs.org/guides/get-started/installation#using-create-nuxt-app). The easiest way is to execute: |
| 10 | + |
| 11 | + $ npx create-nuxt-app your-app-name |
| 12 | + # or |
| 13 | + $ yarn create nuxt-app your-app-name |
| 14 | + |
| 15 | +It will ask you some questions you can use these answers : |
| 16 | + |
| 17 | +``` |
| 18 | +Project name: your-app-name |
| 19 | +Programming language: JavaScript |
| 20 | +Package manager: Yarn |
| 21 | +UI framework: Vuetify.js |
| 22 | +Nuxt.js modules: None |
| 23 | +Linting tools: Prettier, Lint staged files |
| 24 | +Testing framework: None |
| 25 | +Rendering mode: Single Page App |
| 26 | +Deployment target: Static (Static/JAMStack hosting) |
| 27 | +``` |
| 28 | + |
| 29 | +### Installing the Generator Dependencies |
| 30 | + |
| 31 | +Install required dependencies: |
| 32 | + |
| 33 | + $ yarn add moment lodash vue-i18n vuelidate vuex-map-fields |
| 34 | + |
| 35 | +## Generating Routes |
| 36 | + |
| 37 | + $ npx @api-platform/client-generator https://demo.api-platform.com . --generator nuxt |
| 38 | + # Replace the URL by the entrypoint of your Hydra-enabled API |
| 39 | + |
| 40 | +> Note: Omit the resource flag to generate files for all resource types exposed by the API. |
| 41 | +
|
| 42 | +## Updating default layout |
| 43 | + |
| 44 | + |
| 45 | +Update your `layouts/default.vue` with following: |
| 46 | + |
| 47 | +```javascript |
| 48 | +<template> |
| 49 | + <v-app> |
| 50 | + <alert /> |
| 51 | + <v-navigation-drawer v-model="drawer" app> |
| 52 | + <v-list dense> |
| 53 | + <v-list-item> |
| 54 | + <v-list-item-action> |
| 55 | + <v-icon>mdi-home</v-icon> |
| 56 | + </v-list-item-action> |
| 57 | + <v-list-item-content> |
| 58 | + <v-list-item-title>Home</v-list-item-title> |
| 59 | + </v-list-item-content> |
| 60 | + </v-list-item> |
| 61 | + <v-list-item> |
| 62 | + <v-list-item-action> |
| 63 | + <v-icon>mdi-book</v-icon> |
| 64 | + </v-list-item-action> |
| 65 | + <v-list-item-content> |
| 66 | + <v-list-item-title> |
| 67 | + <nuxt-link :to="{ name: 'books' }">Books</nuxt-link> |
| 68 | + </v-list-item-title> |
| 69 | + </v-list-item-content> |
| 70 | + </v-list-item> |
| 71 | + <v-list-item> |
| 72 | + <v-list-item-action> |
| 73 | + <v-icon>mdi-comment-quote</v-icon> |
| 74 | + </v-list-item-action> |
| 75 | + <v-list-item-content> |
| 76 | + <v-list-item-title> |
| 77 | + <nuxt-link :to="{ name: 'reviews' }">Reviews</nuxt-link> |
| 78 | + </v-list-item-title> |
| 79 | + </v-list-item-content> |
| 80 | + </v-list-item> |
| 81 | + </v-list> |
| 82 | + </v-navigation-drawer> |
| 83 | + <v-app-bar app color="indigo" dark> |
| 84 | + <v-app-bar-nav-icon @click.stop="drawer = !drawer"></v-app-bar-nav-icon> |
| 85 | + <v-toolbar-title>Application</v-toolbar-title> |
| 86 | + </v-app-bar> |
| 87 | + |
| 88 | + <v-main> |
| 89 | + <nuxt /> |
| 90 | + </v-main> |
| 91 | + <v-footer color="indigo" app> |
| 92 | + <span class="white--text">© {{ date }}</span> |
| 93 | + </v-footer> |
| 94 | + </v-app> |
| 95 | +</template> |
| 96 | + |
| 97 | +<script> |
| 98 | +import Alert from '../components/Alert'; |
| 99 | + |
| 100 | +export default { |
| 101 | + components: { |
| 102 | + Alert |
| 103 | + }, |
| 104 | + |
| 105 | + data: () => ({ |
| 106 | + date: new Date().getFullYear(), |
| 107 | + drawer: null |
| 108 | + }) |
| 109 | +}; |
| 110 | +</script> |
| 111 | +``` |
| 112 | + |
| 113 | +## Starting the Project |
| 114 | + |
| 115 | +You can launch the server with |
| 116 | + |
| 117 | + $ yarn dev |
| 118 | + |
| 119 | +Go to `https://localhost:3000/books/` to start using your app. |
| 120 | + |
| 121 | +## Screenshots |
| 122 | + |
| 123 | + |
| 124 | + |
0 commit comments