druxt-router 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,12 +6,9 @@ import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
|
|
|
6
6
|
* The DruxtRouter component renders a Drupal decoupled route, or path, using
|
|
7
7
|
* the appropriate Druxt component.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* For instance, using the path `/node/1` would render a DruxtEntity component.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* For instance, using the `/node/1` route would result in a DruxtRouter
|
|
14
|
-
* component for the content in Drupal with the Node ID of 1.
|
|
11
|
+
* The Vue router path will be used if not path is defined.
|
|
15
12
|
*
|
|
16
13
|
* @example <caption>Render using the Vue router path</caption> @lang vue
|
|
17
14
|
* <DruxtRouter />
|
|
@@ -22,10 +19,22 @@ import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
|
|
|
22
19
|
* @example <caption>Render the result of the model, bypasses Drupal backend</caption> @lang vue
|
|
23
20
|
* <DruxtRouter v-model="route" />
|
|
24
21
|
*
|
|
25
|
-
* @example <caption>
|
|
22
|
+
* @example <caption>DruxtRouter Wrapper component boilerplate</caption> @lang vue
|
|
23
|
+
* <template>
|
|
24
|
+
* <DruxtDebug :json="route" />
|
|
25
|
+
* </template>
|
|
26
|
+
*
|
|
27
|
+
* <script>
|
|
28
|
+
* import { DruxtRouterMixin } from 'druxt-router'
|
|
29
|
+
* export default {
|
|
30
|
+
* mixins: [DruxtRouterMixin]
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* @example <caption>DruxtRouter with template injection</caption> @lang vue
|
|
26
34
|
* <DruxtRouter>
|
|
27
35
|
* <template #default="{ route }">
|
|
28
|
-
*
|
|
36
|
+
* <!-- Do whatever you want here -->
|
|
37
|
+
* <DruxtDebug :json="route" open />
|
|
29
38
|
* </template>
|
|
30
39
|
* </DruxtRouter>
|
|
31
40
|
*/
|
|
@@ -99,6 +108,9 @@ export default {
|
|
|
99
108
|
* @property {object} model - The model object.
|
|
100
109
|
*/
|
|
101
110
|
data: ({ value }) => ({
|
|
111
|
+
debug: {
|
|
112
|
+
path: undefined,
|
|
113
|
+
},
|
|
102
114
|
model: value,
|
|
103
115
|
}),
|
|
104
116
|
|
|
@@ -197,7 +209,7 @@ export default {
|
|
|
197
209
|
// Get the route from the Drupal decoupled router module via the
|
|
198
210
|
// druxtRouter store.
|
|
199
211
|
// Use the Path prop or the Vue Router as the route to lookup.
|
|
200
|
-
const path = this.path || this.$route.fullPath
|
|
212
|
+
const path = this.debug.path || this.path || this.$route.fullPath
|
|
201
213
|
const route = await this.$store.dispatch('druxtRouter/getRoute', path)
|
|
202
214
|
this.model = route
|
|
203
215
|
|
|
@@ -219,7 +231,37 @@ export default {
|
|
|
219
231
|
propsData: ({ $route, path, model }) => ({
|
|
220
232
|
path: path || $route.fullPath,
|
|
221
233
|
route: model
|
|
222
|
-
})
|
|
234
|
+
}),
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Provides the scoped slots object for the Module render function.
|
|
238
|
+
*
|
|
239
|
+
* - **debug**: A Debug component with a Path override field.
|
|
240
|
+
* - **default**: Default error handling.
|
|
241
|
+
*
|
|
242
|
+
* @example <caption>DruxtRouter**Module**.vue</caption> @lang vue
|
|
243
|
+
* <template>
|
|
244
|
+
* <div>
|
|
245
|
+
* <slot name="debug" />
|
|
246
|
+
* {{ route.props }}
|
|
247
|
+
* </div>
|
|
248
|
+
* </template>
|
|
249
|
+
*
|
|
250
|
+
* @return {ScopedSlots} The Scoped slots object.
|
|
251
|
+
*/
|
|
252
|
+
slots(h) {
|
|
253
|
+
const scopedSlots = {}
|
|
254
|
+
|
|
255
|
+
// Provide defualt error message.
|
|
256
|
+
if (this.model.error) {
|
|
257
|
+
scopedSlots.default = () => h('div', [
|
|
258
|
+
h('h1', [`Error ${this.model.error.statusCode}`]),
|
|
259
|
+
h('p', [this.model.error.message]),
|
|
260
|
+
])
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return scopedSlots
|
|
264
|
+
}
|
|
223
265
|
}
|
|
224
266
|
}
|
|
225
267
|
|
|
@@ -267,4 +309,20 @@ export default {
|
|
|
267
309
|
* }
|
|
268
310
|
* }
|
|
269
311
|
*/
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Provides scoped slots for use in the Wrapper component.
|
|
315
|
+
*
|
|
316
|
+
* @typedef {object} ScopedSlots
|
|
317
|
+
* @param {function} debug - A Debug component with a Path override field.
|
|
318
|
+
* @param {function} default - Default error handling.
|
|
319
|
+
*
|
|
320
|
+
* @example <caption>DruxtRouter**Module**.vue</caption> @lang vue
|
|
321
|
+
* <template>
|
|
322
|
+
* <div>
|
|
323
|
+
* <slot name="debug" />
|
|
324
|
+
* {{ route.props }}
|
|
325
|
+
* </div>
|
|
326
|
+
* </template>
|
|
327
|
+
*/
|
|
270
328
|
</script>
|
package/nuxt/index.js
CHANGED
|
@@ -49,7 +49,12 @@ const DruxtRouterNuxtModule = async function(moduleOptions = {}) {
|
|
|
49
49
|
options
|
|
50
50
|
});
|
|
51
51
|
this.nuxt.hook("storybook:config", async ({ stories }) => {
|
|
52
|
-
|
|
52
|
+
this.addTemplate({
|
|
53
|
+
src: path.resolve(__dirname, "../templates/druxt-router.stories.js"),
|
|
54
|
+
fileName: "stories/druxt-router.stories.js",
|
|
55
|
+
options: {}
|
|
56
|
+
});
|
|
57
|
+
stories.push(path.resolve(this.options.buildDir, "./stories/druxt-router.stories.js"));
|
|
53
58
|
});
|
|
54
59
|
};
|
|
55
60
|
DruxtRouterNuxtModule.meta = require("../package.json");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "druxt-router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Drupal router for Nuxt, powered by the Drupal Decoupled Router module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"templates"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"druxt": "^0.
|
|
45
|
+
"druxt": "^0.17.0",
|
|
46
46
|
"url-parse": "^1.4.7"
|
|
47
47
|
},
|
|
48
48
|
"optionalDependencies": {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import DruxtRouter from 'druxt-router/dist/components/DruxtRouter.vue'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Druxt/Router/DruxtRouter',
|
|
5
|
+
component: DruxtRouter
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// Default story.
|
|
9
|
+
export const Default = (args, { argTypes }) => ({
|
|
10
|
+
components: { DruxtRouter },
|
|
11
|
+
props: Object.keys(argTypes),
|
|
12
|
+
template: `<DruxtRouter v-bind="$props" />`
|
|
13
|
+
})
|
|
14
|
+
Default.args = { path: '/' }
|
|
15
|
+
|
|
16
|
+
let code
|
|
17
|
+
|
|
18
|
+
// Wrapper story.
|
|
19
|
+
code = `<template>
|
|
20
|
+
<DruxtDebug :json="route" />
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script>
|
|
24
|
+
import { DruxtRouterMixin } from 'druxt-router'
|
|
25
|
+
export default {
|
|
26
|
+
mixins: [DruxtRouterMixin]
|
|
27
|
+
}
|
|
28
|
+
</script>`
|
|
29
|
+
export const Wrapper = (args, { argTypes }) => ({
|
|
30
|
+
components: { DruxtRouter },
|
|
31
|
+
props: Object.keys(argTypes),
|
|
32
|
+
template: `<DruxtRouter v-bind="$props" ref="module">
|
|
33
|
+
<template #default>
|
|
34
|
+
Component options:
|
|
35
|
+
<ul>
|
|
36
|
+
<li v-for="option of $refs.module.getModuleComponents()" :key="option.name">{{ option.name }}</li>
|
|
37
|
+
</ul>
|
|
38
|
+
</template>
|
|
39
|
+
</DruxtRouter>`
|
|
40
|
+
})
|
|
41
|
+
Wrapper.parameters = {
|
|
42
|
+
docs: {
|
|
43
|
+
storyDescription: 'The DruxtRouter component can be themed by using a Druxt Wrapper component.\n\nCreate an appropriately named component, using the relevant component option, with the following boilerplate:\n\n```jsx\n' + code + '\n```',
|
|
44
|
+
source: { code }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Template injection story.
|
|
49
|
+
code = `<DruxtRouter path="">
|
|
50
|
+
<template #default="{ route }">
|
|
51
|
+
<!-- Do whatever you want here -->
|
|
52
|
+
<DruxtDebug :json="route" open />
|
|
53
|
+
</template>
|
|
54
|
+
</DruxtRouter>`
|
|
55
|
+
export const TemplateInjection = (args, { argTypes }) => ({
|
|
56
|
+
components: { DruxtRouter },
|
|
57
|
+
props: Object.keys(argTypes),
|
|
58
|
+
template: code.replace('path=""', 'v-bind="$props"')
|
|
59
|
+
})
|
|
60
|
+
TemplateInjection.parameters = {
|
|
61
|
+
docs: {
|
|
62
|
+
storyDescription: 'The DruxtRouter component can be themed by injecting the default template into the compomnent.\n\n```jsx\n' + code + '\n```',
|
|
63
|
+
source: { code }
|
|
64
|
+
}
|
|
65
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
# druxt-router
|
|
2
|
-
|
|
3
|
-
## 0.25.0
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- 7b749bd: Added improved error handling.
|
|
8
|
-
|
|
9
|
-
### Patch Changes
|
|
10
|
-
|
|
11
|
-
- Updated dependencies [7b749bd]
|
|
12
|
-
- druxt@0.16.0
|
|
13
|
-
|
|
14
|
-
## 0.24.2
|
|
15
|
-
|
|
16
|
-
### Patch Changes
|
|
17
|
-
|
|
18
|
-
- Updated dependencies [2ae1d6d]
|
|
19
|
-
- druxt@0.15.0
|
|
20
|
-
|
|
21
|
-
## 0.24.1
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- Updated dependencies [45bc0b9]
|
|
26
|
-
- druxt@0.14.0
|
|
27
|
-
|
|
28
|
-
## 0.24.0
|
|
29
|
-
|
|
30
|
-
### Minor Changes
|
|
31
|
-
|
|
32
|
-
- 9161b38: Added Storybook integration for the DruxtRouter component.
|
|
33
|
-
- 9161b38: Added ability to render a specific route using the Path property.
|
|
34
|
-
|
|
35
|
-
```jsx
|
|
36
|
-
<DruxtRouter path="/node/1" />
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
- 9161b38: Added fetch hook to DruxtRouter component.
|
|
40
|
-
- 9161b38: Added option to disable the DruxtRouter page middleware.
|
|
41
|
-
|
|
42
|
-
```js
|
|
43
|
-
export default {
|
|
44
|
-
druxt: {
|
|
45
|
-
router: {
|
|
46
|
-
middleware: false
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Note: This is experimental and your results may vary.
|
|
53
|
-
|
|
54
|
-
## 0.23.0
|
|
55
|
-
|
|
56
|
-
### Minor Changes
|
|
57
|
-
|
|
58
|
-
- 77ab204: Added support for API Proxy
|
|
59
|
-
|
|
60
|
-
### Patch Changes
|
|
61
|
-
|
|
62
|
-
- Updated dependencies [77ab204]
|
|
63
|
-
- druxt@0.13.0
|
|
64
|
-
|
|
65
|
-
## 0.22.0
|
|
66
|
-
|
|
67
|
-
### Minor Changes
|
|
68
|
-
|
|
69
|
-
- c7b267a: Throw Error on router errors
|
|
70
|
-
|
|
71
|
-
### Patch Changes
|
|
72
|
-
|
|
73
|
-
- Updated dependencies [4504a2f]
|
|
74
|
-
- druxt@0.12.0
|
|
75
|
-
|
|
76
|
-
## 0.21.0
|
|
77
|
-
|
|
78
|
-
### Minor Changes
|
|
79
|
-
|
|
80
|
-
- 9d905e8: Set router `pages` option default based on presence of `pages/` directory.
|
|
81
|
-
- 9d905e8: Moved Nuxt module to `druxt-router/nuxt`
|
|
82
|
-
|
|
83
|
-
⚠ Potential breaking change
|
|
84
|
-
|
|
85
|
-
```diff
|
|
86
|
-
-modules: ['druxt-router']
|
|
87
|
-
+modules: ['druxt-router/nuxt']
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
- dae345e: Added module level options
|
|
91
|
-
|
|
92
|
-
### Patch Changes
|
|
93
|
-
|
|
94
|
-
- Updated dependencies [dae345e]
|
|
95
|
-
- druxt@0.11.0
|
|
96
|
-
|
|
97
|
-
## 0.20.0
|
|
98
|
-
|
|
99
|
-
### Minor Changes
|
|
100
|
-
|
|
101
|
-
- 1ab762c: Enabled Nuxt Vuex store by default
|
|
102
|
-
- ecefef5: Added option to disable wildcard route
|
|
103
|
-
- 715e5ef: Updated component registration method to use the Nuxt `components:dirs` hook
|
|
104
|
-
- cbc66cd: Added option to disable `pages/` routes
|
|
105
|
-
|
|
106
|
-
### Patch Changes
|
|
107
|
-
|
|
108
|
-
- Updated dependencies [715e5ef]
|
|
109
|
-
- druxt@0.10.0
|
|
110
|
-
|
|
111
|
-
## 0.19.1
|
|
112
|
-
|
|
113
|
-
### Patch Changes
|
|
114
|
-
|
|
115
|
-
- c4616df: Fixed dependencies
|
|
116
|
-
|
|
117
|
-
## 0.19.0
|
|
118
|
-
|
|
119
|
-
### Minor Changes
|
|
120
|
-
|
|
121
|
-
- 21170fb: Moved Vue components out of bundle
|
|
122
|
-
|
|
123
|
-
⚠ Potential breaking change
|
|
124
|
-
|
|
125
|
-
_**Note:** This only effects custom Druxt modules and implementations._
|
|
126
|
-
|
|
127
|
-
```diff
|
|
128
|
-
-import { DruxtRouter } from 'druxt-router'
|
|
129
|
-
+import DruxtRouter from 'druxt-router/dist/components/DruxtRouter.vue'
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### Patch Changes
|
|
133
|
-
|
|
134
|
-
- Updated dependencies [21170fb]
|
|
135
|
-
- druxt@0.9.0
|
|
136
|
-
|
|
137
|
-
## 0.18.1
|
|
138
|
-
|
|
139
|
-
### Patch Changes
|
|
140
|
-
|
|
141
|
-
- Added `hid` to canonical meta tag
|
|
142
|
-
- Fixed issue with metatags
|
|
143
|
-
|
|
144
|
-
## 0.18.0
|
|
145
|
-
|
|
146
|
-
### Minor Changes
|
|
147
|
-
|
|
148
|
-
- Deprecated client methods in favour of DruxtClient
|
|
149
|
-
|
|
150
|
-
## 0.17.3
|
|
151
|
-
|
|
152
|
-
### Patch Changes
|
|
153
|
-
|
|
154
|
-
- Fixed issue with querystring and getRedirect()
|
|
155
|
-
|
|
156
|
-
## 0.17.2
|
|
157
|
-
|
|
158
|
-
### Patch Changes
|
|
159
|
-
|
|
160
|
-
- Updated dependencies
|
|
161
|
-
|
|
162
|
-
## 0.17.1
|
|
163
|
-
|
|
164
|
-
### Patch Changes
|
|
165
|
-
|
|
166
|
-
- Fixed issue with permission check
|
|
167
|
-
|
|
168
|
-
## 0.17.0
|
|
169
|
-
|
|
170
|
-
### Minor Changes
|
|
171
|
-
|
|
172
|
-
- Added support for DruxtComponentMixin
|
|
173
|
-
|
|
174
|
-
## 0.16.1
|
|
175
|
-
|
|
176
|
-
### Patch Changes
|
|
177
|
-
|
|
178
|
-
- Updated Nuxt module
|
|
179
|
-
- Updated dependencies
|
|
180
|
-
|
|
181
|
-
## 0.16.0
|
|
182
|
-
|
|
183
|
-
### Minor Changes
|
|
184
|
-
|
|
185
|
-
- Added documentation
|
|
186
|
-
- Updated dependencies
|
|
187
|
-
|
|
188
|
-
## 0.15.0
|
|
189
|
-
|
|
190
|
-
### Minor Changes
|
|
191
|
-
|
|
192
|
-
- Added resolved path to router information
|
|
193
|
-
- Added `all` option to getResources
|
|
194
|
-
|
|
195
|
-
## 0.14.0
|
|
196
|
-
|
|
197
|
-
### Minor Changes
|
|
198
|
-
|
|
199
|
-
- Added support for Drupal JSON:API Params
|
|
200
|
-
- Added addHeaders() method
|
|
201
|
-
|
|
202
|
-
## 0.13.0
|
|
203
|
-
|
|
204
|
-
### Minor Changes
|
|
205
|
-
|
|
206
|
-
- Added resource index
|
|
207
|
-
- Added support for remapped resources
|
|
208
|
-
- Added getResources method
|
|
209
|
-
|
|
210
|
-
## 0.12.0
|
|
211
|
-
|
|
212
|
-
### Minor Changes
|
|
213
|
-
|
|
214
|
-
- Added support for customisable endpoint
|
|
215
|
-
- Added type and uuid data
|
|
216
|
-
- Fixed hydration issue
|
|
217
|
-
|
|
218
|
-
## 0.11.1
|
|
219
|
-
|
|
220
|
-
### Patch Changes
|
|
221
|
-
|
|
222
|
-
- Fixed hydration issue
|
|
223
|
-
|
|
224
|
-
## 0.11.0
|
|
225
|
-
|
|
226
|
-
### Minor Changes
|
|
227
|
-
|
|
228
|
-
- Added support for additional router types
|
|
229
|
-
- Added support for JSON:API Views routes
|
|
230
|
-
|
|
231
|
-
## 0.10.1
|
|
232
|
-
|
|
233
|
-
### Patch Changes
|
|
234
|
-
|
|
235
|
-
- Fixed router WSOD error
|
|
236
|
-
|
|
237
|
-
## 0.10.0
|
|
238
|
-
|
|
239
|
-
### Minor Changes
|
|
240
|
-
|
|
241
|
-
- Add configurable Router component
|
|
242
|
-
- Refactored DruxtRouterEntityMixin
|
|
243
|
-
- Removed support for JSON API Deserializer
|
|
244
|
-
|
|
245
|
-
## 0.9.0
|
|
246
|
-
|
|
247
|
-
### Minor Changes
|
|
248
|
-
|
|
249
|
-
- Updated module to use shared Druxt configruation
|
|
250
|
-
|
|
251
|
-
## 0.8.0
|
|
252
|
-
|
|
253
|
-
### Minor Changes
|
|
254
|
-
|
|
255
|
-
- Improved error handling for missing routes
|
|
256
|
-
|
|
257
|
-
## 0.7.0
|
|
258
|
-
|
|
259
|
-
### Minor Changes
|
|
260
|
-
|
|
261
|
-
- Added getRoute action to Vuex store
|
|
262
|
-
- Refactored Nuxt plugin
|
|
263
|
-
|
|
264
|
-
## 0.6.0
|
|
265
|
-
|
|
266
|
-
### Minor Changes
|
|
267
|
-
|
|
268
|
-
- Added Axios settings support
|
|
269
|
-
|
|
270
|
-
## 0.5.0
|
|
271
|
-
|
|
272
|
-
### Minor Changes
|
|
273
|
-
|
|
274
|
-
- Added support for redirects
|
|
275
|
-
- Added support for JSON API resourceName
|
|
276
|
-
|
|
277
|
-
## 0.4.2
|
|
278
|
-
|
|
279
|
-
### Patch Changes
|
|
280
|
-
|
|
281
|
-
- Fixed various issues
|
|
282
|
-
|
|
283
|
-
## 0.4.1
|
|
284
|
-
|
|
285
|
-
### Patch Changes
|
|
286
|
-
|
|
287
|
-
- Fixed various issues
|
|
288
|
-
|
|
289
|
-
## 0.4.0
|
|
290
|
-
|
|
291
|
-
### Minor Changes
|
|
292
|
-
|
|
293
|
-
## 0.3.0
|
|
294
|
-
|
|
295
|
-
### Minor Changes
|
|
296
|
-
|
|
297
|
-
## 0.2.2
|
|
298
|
-
|
|
299
|
-
### Patch Changes
|
|
300
|
-
|
|
301
|
-
## 0.2.1
|
|
302
|
-
|
|
303
|
-
### Patch Changes
|
|
304
|
-
|
|
305
|
-
## 0.2.0
|
|
306
|
-
|
|
307
|
-
### Minor Changes
|
|
308
|
-
|
|
309
|
-
## 0.1.0
|
|
310
|
-
|
|
311
|
-
### Initial release
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import DruxtRouter from './DruxtRouter.vue'
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
title: 'Druxt/Router/DruxtRouter',
|
|
5
|
-
component: DruxtRouter
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const Template = (args, { argTypes }) => ({
|
|
9
|
-
components: { DruxtRouter },
|
|
10
|
-
props: Object.keys(argTypes),
|
|
11
|
-
template: `<DruxtRouter v-bind="$props" />`
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
export const Default = Template.bind({})
|
|
15
|
-
Default.storyName = 'DruxtRouter'
|
|
16
|
-
Default.args = { path: '/' }
|