|
| 1 | +# VuePal |
| 2 | + |
| 3 | +VuePal provides a bridge between Drupal and Vue. It comes with a set of components and |
| 4 | +composables to make your life easier when working with Drupal. |
| 5 | + |
| 6 | +## Frontend Routing |
| 7 | + |
| 8 | +```ts [nuxt.config.ts] |
| 9 | +export default defineNuxtConfig({ |
| 10 | + vuepal: { |
| 11 | + frontendRouting: { |
| 12 | + enabled: true, |
| 13 | + langcodes: ['de', 'fr', 'en'], |
| 14 | + outputPath: './../drupal/config/default/frontend_routing.settings.yml', |
| 15 | + }, |
| 16 | + }, |
| 17 | +}) |
| 18 | +``` |
| 19 | + |
| 20 | +With this feature enabled, you can create a static frontend page in Nuxt and still use all the routing features of |
| 21 | +Drupal in your frontend application. You can define your aliases in the frontend page using `definePageMeta`. The module |
| 22 | +will automatically create a Drupal configuration file that can be imported and processed by the |
| 23 | +[Drupal frontend_routing](https://www.drupal.org/project/frontend_routing) module. |
| 24 | + |
| 25 | +```ts [pages/static-page/example.vue] |
| 26 | +definePageMeta({ |
| 27 | + name: 'static-page-example', |
| 28 | + drupalFrontendRoute: true, |
| 29 | + languageMapping: { |
| 30 | + de: '/de/statisch', |
| 31 | + fr: '/fr/statique', |
| 32 | + en: '/en/static', |
| 33 | + }, |
| 34 | +}) |
| 35 | +``` |
| 36 | + |
| 37 | +## Drupal Route |
| 38 | + |
| 39 | +```ts [nuxt.config.ts] |
| 40 | +export default defineNuxtConfig({ |
| 41 | + vuepal: { |
| 42 | + drupalRoute: { |
| 43 | + enabled: true, |
| 44 | + }, |
| 45 | + }, |
| 46 | +}) |
| 47 | +``` |
| 48 | + |
| 49 | +This option enables the `useDrupalRoute()` composable. |
| 50 | +This composable provides the necessary GraphQL fragment and query to fetch the route data and metatags of a Drupal page. |
| 51 | + |
| 52 | +## Admin Toolbar |
| 53 | + |
| 54 | +```ts [nuxt.config.ts] |
| 55 | +export default defineNuxtConfig({ |
| 56 | + vuepal: { |
| 57 | + adminToolbar: { |
| 58 | + enabled: true, |
| 59 | + }, |
| 60 | + }, |
| 61 | +}) |
| 62 | +``` |
| 63 | + |
| 64 | +The admin toolbar component fetches the Drupal administration menu and displays it in your frontend application. |
| 65 | + |
| 66 | + |
| 67 | +### Usage |
| 68 | + |
| 69 | +```vue |
| 70 | +
|
| 71 | +<template> |
| 72 | + <ClientOnly> |
| 73 | + <div v-if="drupalUser.accessToolbar && !isEditing"> |
| 74 | + <VuepalAdminToolbar :key="language" /> |
| 75 | + </div> |
| 76 | + </ClientOnly> |
| 77 | +</template> |
| 78 | +
|
| 79 | +
|
| 80 | +<script setup lang="ts"> |
| 81 | + const route = useRoute() |
| 82 | + const drupalUser = useDrupalUser() |
| 83 | + const language = useCurrentLanguage() |
| 84 | + const isEditing = computed( |
| 85 | + () => |
| 86 | + !!(route.query.blokkliEditing || route.query.blokkliPreview) && |
| 87 | + drupalUser.value.accessToolbar, |
| 88 | + ) |
| 89 | +</script> |
| 90 | +``` |
| 91 | + |
| 92 | +## LocalTasks |
| 93 | + |
| 94 | +```ts [nuxt.config.ts] |
| 95 | +export default defineNuxtConfig({ |
| 96 | + vuepal: { |
| 97 | + localTasks: { |
| 98 | + enabled: true, |
| 99 | + }, |
| 100 | + }, |
| 101 | +}) |
| 102 | +``` |
| 103 | + |
| 104 | +The local tasks component fetches the local tasks of a Drupal page and displays them in your frontend application. |
| 105 | + |
| 106 | + |
| 107 | +```vue |
| 108 | +
|
| 109 | +<template> |
| 110 | + <ClientOnly> |
| 111 | + <div class="flex"> |
| 112 | + <div class="mx-auto w-auto bg-white py-8 xl:min-w-[1174px]"> |
| 113 | + <VuepalLocalTasks /> |
| 114 | + </div> |
| 115 | + </div> |
| 116 | + </ClientOnly> |
| 117 | +</template> |
| 118 | +``` |
| 119 | + |
| 120 | +## Full Configuration |
| 121 | + |
| 122 | +Example of a full VuePal configuration in the `nuxt.config.ts` file. |
| 123 | + |
| 124 | +```ts |
| 125 | +export default defineNuxtConfig({ |
| 126 | + vuepal: { |
| 127 | + adminToolbar: { |
| 128 | + enabled: true, |
| 129 | + }, |
| 130 | + localTasks: { |
| 131 | + enabled: true, |
| 132 | + }, |
| 133 | + drupalRoute: { |
| 134 | + enabled: true, |
| 135 | + }, |
| 136 | + frontendRouting: { |
| 137 | + enabled: true, |
| 138 | + langcodes: ['de', 'fr', 'en'], |
| 139 | + outputPath: './../drupal/config/default/frontend_routing.settings.yml', |
| 140 | + }, |
| 141 | + devMode: { |
| 142 | + enabled: true, |
| 143 | + url: `https://${NUXT_REQUEST_HOST}`, |
| 144 | + forceHttps: true, |
| 145 | + }, |
| 146 | + }, |
| 147 | +}) |
| 148 | +``` |
0 commit comments