@@ -4,25 +4,27 @@ Vuepal 3.0 comes with a lot of new features and improvements. This document
4
4
outlines the changes and how to upgrade your existing Vuepal setup to the latest
5
5
version.
6
6
7
- Vuepal 3.0 is meant to be used with Nuxt > 3.17 and with the following modules:
7
+ Version 3.0 is meant to be used with Nuxt > 3.17 and with the latest versions of
8
+ these modules:
8
9
9
- - [ Nuxt GraphQL Middleware] ( https://nuxt.com/modules/nuxt-graphql-middleware ) >
10
- 5.0.0
11
- - [ Nuxt Language Negotiation] ( https://github.com/dulnan/nuxt-language-negotiation ) >
12
- 2.0.0
13
- - [ Nuxt Easy Texts] ( https://github.com/dulnan/nuxt-easy-texts ) > 2.0.0
14
- - [ Nuxt SVG Icon Sprite] ( https://github.com/dulnan/nuxt-svg-icon-sprite ) > 2.0.0
15
- - [ NUxt Page Dependency] ( https://github.com/dulnan/nuxt-page-dependencies ) >
16
- 1.0.0
10
+ | Module | Version | Upgrade Guide |
11
+ | ------------------------- | ------- | -------------------------------------------------------------------------------- |
12
+ | nuxt-graphql-middleware | 5.1.0 | https://github.com/dulnan/nuxt-graphql-middleware/releases/tag/release%2F5.0.0 |
13
+ | nuxt-language-negotiation | 2.0.0 | https://github.com/dulnan/nuxt-language-negotiation/releases/tag/release%2F2.0.0 |
14
+
15
+ When using the "blökkli Starterkit", you may also update
16
+ [ nuxt-easy-texts] ( https://github.com/dulnan/nuxt-easy-texts ) and
17
+ [ nuxt-svg-icon-sprite] ( https://github.com/dulnan/nuxt-svg-icon-sprite ) , though
18
+ they don't have any dependency with Vuepal.
17
19
18
20
## Nuxt 4 compatibility
19
21
20
22
The Vuepal module is compatible with Nuxt 4. The module will automatically
21
23
detect the Nuxt version and work with the new file structure. We recommend
22
- already switching to the
24
+ already switching to this
23
25
[ new folder structure] ( https://nuxt.com/docs/getting-started/upgrade#new-directory-structure ) .
24
26
25
- ## Automatic Registering of fragments
27
+ ## Automatic Registration of Fragments
26
28
27
29
A new feature in nuxt-graphql-middleware allows other modules to automatically
28
30
register GraphQL documents. Vuepal also uses this for its fragments and queries.
@@ -68,14 +70,14 @@ exist. Based on that, it will dynamically add or remove certain features.
68
70
For example, if you enable the ` graphql_metatag_schema_org_schema ` Drupal module
69
71
and the ` metatags_schema_org ` GraphQL extension, Vuepal will automatically query
70
72
the ` schemaOrgMetatags ` field in route queries and set the schema.org metatags
71
- automatically.
73
+ automatically. This also applies for ` breadcrumb ` , ` languageSwitchLinks ` and
74
+ ` metatags ` .
72
75
73
76
## New ` useDrupalRouteQuery ` composable
74
77
75
78
This is the most important change in Vuepal 3.0. Instead of creating a GraphQL
76
- query for each route, you can now use the ` useDrupalRouteQuery() ` composable to
77
- automatically generate route queries. You can define the queries to generate and
78
- the related fragments in the Vuepal configuration in the ` nuxt.config.ts ` file.
79
+ query for each route, you can now let Vuepal create them for your. You can
80
+ define the route queries in the configuration in your ` nuxt.config.ts ` .
79
81
80
82
This new feature is optional; the "old way" still works.
81
83
@@ -123,8 +125,7 @@ await renderPageDependencies()
123
125
### After
124
126
125
127
Define the route queries in the ` nuxt.config.ts ` file. Here you need to specify
126
- the fragments that this route query will use. The` useDrupalRouteQuery() `
127
- composable will automatically generate the GraphQL query and extract the entity.
128
+ which entity fragments the query should contain:
128
129
129
130
``` ts
130
131
export default defineNuxtConfig ({
@@ -144,6 +145,9 @@ export default defineNuxtConfig({
144
145
})
145
146
```
146
147
148
+ Now you can use these three route queries using the new ` useDrupalRouteQuery `
149
+ composable:
150
+
147
151
File: ` pages/[...slug]/index.vue `
148
152
149
153
``` vue
@@ -213,12 +217,11 @@ introduced in `nuxt-language-negotiation`.
213
217
214
218
``` ts
215
219
definePageMeta ({
216
- name: ' static-page-example ' ,
220
+ name: ' contact ' ,
217
221
drupalFrontendRoute: true ,
218
222
languageMapping: {
219
- de: ' /de/statisch' ,
220
- fr: ' /fr/statique' ,
221
- en: ' /en/static' ,
223
+ de: ' /de/kontakt' ,
224
+ en: ' /en/contact' ,
222
225
},
223
226
})
224
227
```
@@ -237,42 +240,6 @@ definePageMeta({
237
240
})
238
241
```
239
242
240
- ## Removal of the ` pluginOrder ` module
241
-
242
- This module is no longer needed as Nuxt 3 now has a solution to properly order
243
- the plugins.
244
-
245
- Before:
246
-
247
- ``` ts [nuxt.config.ts]
248
- pluginOrder : {
249
- order : [
250
- // Match plugins by their file path.
251
- // Note that only a single plugin may match.
252
- // The match is performed as "plugin.src.includes(v.pathMatch)".
253
- { pathMatch: ' plugins/language.ts' },
254
- { pathMatch: ' myother/plugin.ts' },
255
- ],
256
- logSortedPlugins
257
- :
258
- false ,
259
- }
260
- ```
261
-
262
- After: Use the ` dependsOn ` feature of Nuxt 3 to define plugin order.
263
-
264
- ``` ts [app/plugins/initData.ts]
265
- export default defineNuxtPlugin ({
266
- name: ' starterkit:init-data' ,
267
- dependsOn: [
268
- ' nuxt-graphql-middleware-provide-state' ,
269
- ' starterkit:graphql-plugin' ,
270
- ' nuxt:router' ,
271
- ],
272
- async setup() {},
273
- })
274
- ```
275
-
276
243
## New types in ` vuepal.adapter.ts `
277
244
278
245
The ` defineVuepalAdapter ` method can now be imported directly from the package.
@@ -384,3 +351,70 @@ You can then access the breadcrumb links either using `useBreadcrumb()` or via
384
351
</div>
385
352
</template>
386
353
```
354
+
355
+ ## Hooking into ` useDrupalRoute `
356
+
357
+ If you want to alter some additional app state whenever ` useDrupalRoute ` or
358
+ ` useDrupalRouteQuery ` is called, you can do so by hooking into the
359
+ ` vuepal:drupal-route ` hook. This is in fact how the ` breadcrumb ` and
360
+ ` languageSwitchLinks ` feature also work:
361
+
362
+ ``` ts
363
+ import type { BreadcrumbFragment } from ' #graphql-operations'
364
+ import { getBreadcrumbFromRouteQuery } from ' #vuepal/helpers/breadcrumb'
365
+
366
+ /**
367
+ * Manages the breadcrumb state.
368
+ */
369
+ export default defineNuxtPlugin ({
370
+ name: ' vuepal:breadcrumb' ,
371
+ setup(app ) {
372
+ const state = useState <BreadcrumbFragment []>(' breadcrumbLinks' , () => [])
373
+
374
+ // Called by useDrupalRoute.
375
+ app .hooks .hook (' vuepal:drupal-route' , (data ) => {
376
+ state .value = getBreadcrumbFromRouteQuery (data .routeQuery )
377
+ })
378
+ },
379
+ })
380
+ ```
381
+
382
+ The hook is called after every non-error route query.
383
+
384
+ ## Optional (when using blökkli starterkit)
385
+
386
+ ### Removal of the ` pluginOrder ` module
387
+
388
+ This module is no longer needed as Nuxt 3 now has a solution to properly order
389
+ the plugins.
390
+
391
+ Before:
392
+
393
+ ``` ts [nuxt.config.ts]
394
+ pluginOrder : {
395
+ order : [
396
+ // Match plugins by their file path.
397
+ // Note that only a single plugin may match.
398
+ // The match is performed as "plugin.src.includes(v.pathMatch)".
399
+ { pathMatch: ' plugins/language.ts' },
400
+ { pathMatch: ' myother/plugin.ts' },
401
+ ],
402
+ logSortedPlugins
403
+ :
404
+ false ,
405
+ }
406
+ ```
407
+
408
+ After: Use the ` dependsOn ` feature of Nuxt 3 to define plugin order.
409
+
410
+ ``` ts [app/plugins/initData.ts]
411
+ export default defineNuxtPlugin ({
412
+ name: ' starterkit:init-data' ,
413
+ dependsOn: [
414
+ ' nuxt-graphql-middleware-provide-state' ,
415
+ ' starterkit:graphql-plugin' ,
416
+ ' nuxt:router' ,
417
+ ],
418
+ async setup() {},
419
+ })
420
+ ```
0 commit comments