Skip to content

Commit 0b3c4dd

Browse files
feat: update Nuxt generator docs (api-platform#1685)
1 parent 7a0f19f commit 0b3c4dd

11 files changed

+105
-155
lines changed
Loading
Loading
Loading
Loading
Binary file not shown.
Binary file not shown.

create-client/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and native mobile apps from APIs supporting the [Hydra](http://www.hydra-cg.com/
1010
It is able to generate apps using the following frontend stacks:
1111

1212
- [Next.js](nextjs.md)
13-
- [Nuxt.js](nuxtjs.md)
13+
- [Nuxt](nuxt.md)
1414
- [Quasar](quasar.md)
1515
- [Vuetify](vuetify.md)
1616
- [React](react.md)

create-client/nuxt.md

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Nuxt Generator
2+
3+
Bootstrap a [Nuxt 3](https://nuxt.com/) application:
4+
5+
```console
6+
npx nuxi init my-app
7+
cd my-app
8+
```
9+
10+
Install the required dependencies:
11+
12+
```console
13+
yarn add dayjs @pinia/nuxt qs @types/qs
14+
```
15+
16+
To generate the code you need for a given resource, run the following command:
17+
18+
```console
19+
yarn create @api-platform/client https://demo.api-platform.com . --generator nuxt --resource foo
20+
```
21+
22+
Replace the URL with the entrypoint of your Hydra-enabled API. You can also use an OpenAPI documentation with `https://demo.api-platform.com/docs.json` and `-f openapi3`.
23+
24+
Omit the resource flag to generate files for all resource types exposed by the API.
25+
26+
Add Pinia module in `nuxt.config.ts`:
27+
28+
```typescript
29+
// https://nuxt.com/docs/api/configuration/nuxt-config
30+
export default defineNuxtConfig({
31+
// ...
32+
modules: ["@pinia/nuxt"],
33+
// ...
34+
});
35+
```
36+
37+
Delete `app.vue` as it will prevent Nuxt router to work correctly.
38+
39+
Optionally, install Tailwind to get an app that looks good:
40+
41+
```console
42+
yarn add -D tailwindcss postcss autoprefixer
43+
yarn tailwindcss init -p
44+
```
45+
46+
Add this code in `nuxt.config.ts`:
47+
48+
```typescript
49+
// https://nuxt.com/docs/api/configuration/nuxt-config
50+
export default defineNuxtConfig({
51+
// ...
52+
css: ['~/assets/css/main.css'],
53+
postcss: {
54+
plugins: {
55+
tailwindcss: {},
56+
autoprefixer: {},
57+
},
58+
},
59+
// ...
60+
});
61+
```
62+
63+
And this code in `tailwind.config.js`:
64+
65+
```javascript
66+
/** @type {import('tailwindcss').Config} */
67+
module.exports = {
68+
content: [
69+
"./components/**/*.{js,vue,ts}",
70+
"./layouts/**/*.vue",
71+
"./pages/**/*.vue",
72+
"./plugins/**/*.{js,ts}",
73+
"./nuxt.config.{js,ts}",
74+
"./app.vue",
75+
],
76+
theme: {
77+
extend: {},
78+
},
79+
plugins: [],
80+
}
81+
```
82+
83+
Create the file `assets/css/main.css` and add this code in it:
84+
85+
```css
86+
@tailwind base;
87+
@tailwind components;
88+
@tailwind utilities;
89+
```
90+
91+
You can launch the server with:
92+
93+
```console
94+
yarn dev -o
95+
````
96+
97+
Go to `https://localhost:3000/books/` to start using your app.
98+
99+
## Screenshots
100+
101+
![List](images/nuxt/create-client-nuxt-list.png)
102+
![Edit](images/nuxt/create-client-nuxt-edit.png)

create-client/nuxtjs.md

-152
This file was deleted.

distribution/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The easiest and most powerful way to get started is [to download the API Platfor
2020

2121
* the API skeleton, including [the Core library](../core/index.md), [the Symfony framework](https://symfony.com/) ([optional](../core/bootstrap.md)) and [the Doctrine ORM](https://www.doctrine-project.org/projects/orm.html) ([optional](../core/extending.md))
2222
* [the client scaffolding tool](../create-client/) to generate [Next.js](../create-client/
23-
) web applications from the API documentation ([Nuxt.js](https://nuxtjs.org/), [Vue](https://vuejs.org/), [Create React App](https://reactjs.org), [React Native](https://facebook.github.io/react-native/), [Quasar](https://quasar.dev/) and [Vuetify](https://vuetifyjs.com/) are also supported)
23+
) web applications from the API documentation ([Nuxt](https://nuxt.com/), [Vue](https://vuejs.org/), [Create React App](https://reactjs.org), [React Native](https://facebook.github.io/react-native/), [Quasar](https://quasar.dev/) and [Vuetify](https://vuetifyjs.com/) are also supported)
2424
* [a beautiful admin interface](../admin/), built on top of React Admin, dynamically created by parsing the API documentation
2525
* all you need to [create real-time and async APIs using the Mercure protocol](../core/mercure.md)
2626
* a [Docker](../deployment/docker-compose.md) definition to start a working development environment in a single command, providing containers for the API and the Next.js web application

outline.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ chapters:
8282
items:
8383
- index
8484
- nextjs
85-
- nuxtjs
85+
- nuxt
8686
- vuetify
8787
- quasar
8888
- react

0 commit comments

Comments
 (0)