@@ -4,25 +4,27 @@ Vuepal 3.0 comes with a lot of new features and improvements. This document
44outlines the changes and how to upgrade your existing Vuepal setup to the latest
55version.
66
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:
89
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.
1719
1820## Nuxt 4 compatibility
1921
2022The Vuepal module is compatible with Nuxt 4. The module will automatically
2123detect the Nuxt version and work with the new file structure. We recommend
22- already switching to the
24+ already switching to this
2325[ new folder structure] ( https://nuxt.com/docs/getting-started/upgrade#new-directory-structure ) .
2426
25- ## Automatic Registering of fragments
27+ ## Automatic Registration of Fragments
2628
2729A new feature in nuxt-graphql-middleware allows other modules to automatically
2830register 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.
6870For example, if you enable the ` graphql_metatag_schema_org_schema ` Drupal module
6971and the ` metatags_schema_org ` GraphQL extension, Vuepal will automatically query
7072the ` schemaOrgMetatags ` field in route queries and set the schema.org metatags
71- automatically.
73+ automatically. This also applies for ` breadcrumb ` , ` languageSwitchLinks ` and
74+ ` metatags ` .
7275
7376## New ` useDrupalRouteQuery ` composable
7477
7578This 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 ` .
7981
8082This new feature is optional; the "old way" still works.
8183
@@ -123,8 +125,7 @@ await renderPageDependencies()
123125### After
124126
125127Define 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:
128129
129130``` ts
130131export default defineNuxtConfig ({
@@ -144,6 +145,9 @@ export default defineNuxtConfig({
144145})
145146```
146147
148+ Now you can use these three route queries using the new ` useDrupalRouteQuery `
149+ composable:
150+
147151File: ` pages/[...slug]/index.vue `
148152
149153``` vue
@@ -213,12 +217,11 @@ introduced in `nuxt-language-negotiation`.
213217
214218``` ts
215219definePageMeta ({
216- name: ' static-page-example ' ,
220+ name: ' contact ' ,
217221 drupalFrontendRoute: true ,
218222 languageMapping: {
219- de: ' /de/statisch' ,
220- fr: ' /fr/statique' ,
221- en: ' /en/static' ,
223+ de: ' /de/kontakt' ,
224+ en: ' /en/contact' ,
222225 },
223226})
224227```
@@ -237,42 +240,6 @@ definePageMeta({
237240})
238241```
239242
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-
276243## New types in ` vuepal.adapter.ts `
277244
278245The ` 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
384351 </div>
385352</template>
386353```
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