druxt-router 0.25.0 → 0.27.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.
- package/dist/components/DruxtRouter.vue +83 -12
- package/dist/components/index.mjs +1 -1
- package/dist/druxt-router.esm.js +16 -6
- package/dist/druxt-router.ssr.js +19 -8
- package/nuxt/index.d.ts +1 -1
- package/nuxt/index.js +30 -7
- package/package.json +9 -3
- package/templates/druxt-router.stories.js +65 -0
- package/CHANGELOG.md +0 -311
- package/dist/components/DruxtRouter.stories.mjs +0 -16
|
@@ -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
|
|
|
@@ -163,6 +175,13 @@ export default {
|
|
|
163
175
|
|
|
164
176
|
/** */
|
|
165
177
|
watch: {
|
|
178
|
+
$route() {
|
|
179
|
+
const path = this.$route.fullPath
|
|
180
|
+
if (this.$store.state.druxtRouter.routes[path] && this.$store.state.druxtRouter.route !== this.$store.state.druxtRouter.routes[path]) {
|
|
181
|
+
this.$store.commit('druxtRouter/setRoute', path)
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
|
|
166
185
|
/**
|
|
167
186
|
* Re-fetch on update to Path prop.
|
|
168
187
|
*/
|
|
@@ -197,7 +216,7 @@ export default {
|
|
|
197
216
|
// Get the route from the Drupal decoupled router module via the
|
|
198
217
|
// druxtRouter store.
|
|
199
218
|
// Use the Path prop or the Vue Router as the route to lookup.
|
|
200
|
-
const path = this.path || this.$route.fullPath
|
|
219
|
+
const path = this.debug.path || this.path || this.$route.fullPath
|
|
201
220
|
const route = await this.$store.dispatch('druxtRouter/getRoute', path)
|
|
202
221
|
this.model = route
|
|
203
222
|
|
|
@@ -219,7 +238,37 @@ export default {
|
|
|
219
238
|
propsData: ({ $route, path, model }) => ({
|
|
220
239
|
path: path || $route.fullPath,
|
|
221
240
|
route: model
|
|
222
|
-
})
|
|
241
|
+
}),
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Provides the scoped slots object for the Module render function.
|
|
245
|
+
*
|
|
246
|
+
* - **debug**: A Debug component with a Path override field.
|
|
247
|
+
* - **default**: Default error handling.
|
|
248
|
+
*
|
|
249
|
+
* @example <caption>DruxtRouter**Module**.vue</caption> @lang vue
|
|
250
|
+
* <template>
|
|
251
|
+
* <div>
|
|
252
|
+
* <slot name="debug" />
|
|
253
|
+
* {{ route.props }}
|
|
254
|
+
* </div>
|
|
255
|
+
* </template>
|
|
256
|
+
*
|
|
257
|
+
* @return {ScopedSlots} The Scoped slots object.
|
|
258
|
+
*/
|
|
259
|
+
slots(h) {
|
|
260
|
+
const scopedSlots = {}
|
|
261
|
+
|
|
262
|
+
// Provide defualt error message.
|
|
263
|
+
if (this.model.error) {
|
|
264
|
+
scopedSlots.default = () => h('div', [
|
|
265
|
+
h('h1', [`Error ${this.model.error.statusCode}`]),
|
|
266
|
+
h('p', [this.model.error.message]),
|
|
267
|
+
])
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return scopedSlots
|
|
271
|
+
}
|
|
223
272
|
}
|
|
224
273
|
}
|
|
225
274
|
|
|
@@ -230,16 +279,22 @@ export default {
|
|
|
230
279
|
*
|
|
231
280
|
* @example @lang js
|
|
232
281
|
* [
|
|
282
|
+
* 'DruxtRouter[Module][IsFront?][Langcode]',
|
|
233
283
|
* 'DruxtRouter[Module][IsFront?]',
|
|
234
|
-
* '
|
|
284
|
+
* 'DruxtRouter[Module][Langcode]',
|
|
285
|
+
* 'DruxtRouter[Module]',
|
|
286
|
+
* 'DruxtRouter[Default][Langcode]',
|
|
287
|
+
* 'DruxtRouter[Default]',
|
|
235
288
|
* ]
|
|
236
289
|
*
|
|
237
290
|
* @example <caption>Entity route</caption> @lang js
|
|
238
291
|
* [
|
|
292
|
+
* 'DruxtRouterEntityFrontEn',
|
|
239
293
|
* 'DruxtRouterEntityFront',
|
|
294
|
+
* 'DruxtRouterEntityEn',
|
|
240
295
|
* 'DruxtRouterEntity',
|
|
241
|
-
* '
|
|
242
|
-
* ''
|
|
296
|
+
* 'DruxtRouterDefaultEn',
|
|
297
|
+
* 'DruxtRouterDefault'
|
|
243
298
|
* ]
|
|
244
299
|
*/
|
|
245
300
|
|
|
@@ -267,4 +322,20 @@ export default {
|
|
|
267
322
|
* }
|
|
268
323
|
* }
|
|
269
324
|
*/
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Provides scoped slots for use in the Wrapper component.
|
|
328
|
+
*
|
|
329
|
+
* @typedef {object} ScopedSlots
|
|
330
|
+
* @param {function} debug - A Debug component with a Path override field.
|
|
331
|
+
* @param {function} default - Default error handling.
|
|
332
|
+
*
|
|
333
|
+
* @example <caption>DruxtRouter**Module**.vue</caption> @lang vue
|
|
334
|
+
* <template>
|
|
335
|
+
* <div>
|
|
336
|
+
* <slot name="debug" />
|
|
337
|
+
* {{ route.props }}
|
|
338
|
+
* </div>
|
|
339
|
+
* </template>
|
|
340
|
+
*/
|
|
270
341
|
</script>
|
package/dist/druxt-router.esm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DruxtClient } from 'druxt';
|
|
2
2
|
import Url from 'url-parse';
|
|
3
|
+
import Vue from 'vue';
|
|
3
4
|
import { mapState, mapActions } from 'vuex';
|
|
4
5
|
|
|
5
6
|
class DruxtRouter {
|
|
@@ -12,6 +13,7 @@ class DruxtRouter {
|
|
|
12
13
|
component: "druxt-entity",
|
|
13
14
|
property: "entity",
|
|
14
15
|
props: (route) => ({
|
|
16
|
+
langcode: route.entity.langcode,
|
|
15
17
|
type: route.jsonapi.resourceName,
|
|
16
18
|
uuid: route.entity.uuid
|
|
17
19
|
})
|
|
@@ -23,6 +25,7 @@ class DruxtRouter {
|
|
|
23
25
|
property: "view",
|
|
24
26
|
props: (route) => ({
|
|
25
27
|
displayId: route.view.display_id,
|
|
28
|
+
langcode: route.view.langcode || void 0,
|
|
26
29
|
type: route.jsonapi.resourceName,
|
|
27
30
|
uuid: route.view.uuid,
|
|
28
31
|
viewId: route.view.view_id
|
|
@@ -60,13 +63,15 @@ class DruxtRouter {
|
|
|
60
63
|
return this.index;
|
|
61
64
|
}
|
|
62
65
|
getRedirect(path, route = {}) {
|
|
66
|
+
const prefix = (route.props || {}).langcode || "";
|
|
63
67
|
if (((route.redirect || [])[0] || {}).to) {
|
|
64
68
|
return route.redirect[0].to;
|
|
65
69
|
}
|
|
66
70
|
const url = Url(path);
|
|
67
71
|
if (route.isHomePath) {
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
const homePath = prefix ? `/${prefix}` : "/";
|
|
73
|
+
if (!(url.pathname === homePath || url.pathname === `${homePath}/`)) {
|
|
74
|
+
return homePath;
|
|
70
75
|
}
|
|
71
76
|
return false;
|
|
72
77
|
}
|
|
@@ -99,10 +104,10 @@ class DruxtRouter {
|
|
|
99
104
|
return resources.data || false;
|
|
100
105
|
}
|
|
101
106
|
async getResourceByRoute(route) {
|
|
102
|
-
const resource = await this.druxt.getResource(route.jsonapi.resourceName, route.entity.uuid);
|
|
107
|
+
const resource = await this.druxt.getResource(route.jsonapi.resourceName, route.entity.uuid, route.prefix);
|
|
103
108
|
return resource.data || false;
|
|
104
109
|
}
|
|
105
|
-
async getRoute(path) {
|
|
110
|
+
async getRoute(path = "/") {
|
|
106
111
|
const url = `/router/translate-path?path=${path}`;
|
|
107
112
|
const response = await this.druxt.get(url, {
|
|
108
113
|
validateStatus: (status) => status < 500
|
|
@@ -124,7 +129,8 @@ class DruxtRouter {
|
|
|
124
129
|
label: data.label,
|
|
125
130
|
props: false,
|
|
126
131
|
redirect: data.redirect,
|
|
127
|
-
resolvedPath: Url(data.resolved).pathname
|
|
132
|
+
resolvedPath: Url(data.resolved).pathname,
|
|
133
|
+
entity: data.entity
|
|
128
134
|
};
|
|
129
135
|
for (const key in this.options.types) {
|
|
130
136
|
const type = {
|
|
@@ -190,7 +196,7 @@ const DruxtRouterStore = ({ store }) => {
|
|
|
190
196
|
if (typeof path !== "string" || typeof route === "undefined") {
|
|
191
197
|
return;
|
|
192
198
|
}
|
|
193
|
-
state.routes
|
|
199
|
+
Vue.set(state.routes, path, route);
|
|
194
200
|
},
|
|
195
201
|
setRoute(state, path) {
|
|
196
202
|
if (typeof path !== "string" || typeof state.routes[path] === "undefined") {
|
|
@@ -289,6 +295,10 @@ const DruxtRouterEntityMixin = {
|
|
|
289
295
|
|
|
290
296
|
const DruxtRouterMixin = {
|
|
291
297
|
props: {
|
|
298
|
+
langcode: {
|
|
299
|
+
type: String,
|
|
300
|
+
default: void 0
|
|
301
|
+
},
|
|
292
302
|
path: {
|
|
293
303
|
type: String,
|
|
294
304
|
default: void 0
|
package/dist/druxt-router.ssr.js
CHANGED
|
@@ -4,11 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const druxt = require('druxt');
|
|
6
6
|
const Url = require('url-parse');
|
|
7
|
+
const Vue = require('vue');
|
|
7
8
|
const vuex = require('vuex');
|
|
8
9
|
|
|
9
10
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
11
|
|
|
11
12
|
const Url__default = /*#__PURE__*/_interopDefaultLegacy(Url);
|
|
13
|
+
const Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
|
|
12
14
|
|
|
13
15
|
class DruxtRouter {
|
|
14
16
|
constructor(baseUrl, options = {}) {
|
|
@@ -20,6 +22,7 @@ class DruxtRouter {
|
|
|
20
22
|
component: "druxt-entity",
|
|
21
23
|
property: "entity",
|
|
22
24
|
props: (route) => ({
|
|
25
|
+
langcode: route.entity.langcode,
|
|
23
26
|
type: route.jsonapi.resourceName,
|
|
24
27
|
uuid: route.entity.uuid
|
|
25
28
|
})
|
|
@@ -31,6 +34,7 @@ class DruxtRouter {
|
|
|
31
34
|
property: "view",
|
|
32
35
|
props: (route) => ({
|
|
33
36
|
displayId: route.view.display_id,
|
|
37
|
+
langcode: route.view.langcode || void 0,
|
|
34
38
|
type: route.jsonapi.resourceName,
|
|
35
39
|
uuid: route.view.uuid,
|
|
36
40
|
viewId: route.view.view_id
|
|
@@ -68,18 +72,20 @@ class DruxtRouter {
|
|
|
68
72
|
return this.index;
|
|
69
73
|
}
|
|
70
74
|
getRedirect(path, route = {}) {
|
|
75
|
+
const prefix = (route.props || {}).langcode || "";
|
|
71
76
|
if (((route.redirect || [])[0] || {}).to) {
|
|
72
77
|
return route.redirect[0].to;
|
|
73
78
|
}
|
|
74
|
-
const url = Url__default[
|
|
79
|
+
const url = Url__default["default"](path);
|
|
75
80
|
if (route.isHomePath) {
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
const homePath = prefix ? `/${prefix}` : "/";
|
|
82
|
+
if (!(url.pathname === homePath || url.pathname === `${homePath}/`)) {
|
|
83
|
+
return homePath;
|
|
78
84
|
}
|
|
79
85
|
return false;
|
|
80
86
|
}
|
|
81
87
|
if (typeof route.canonical === "string") {
|
|
82
|
-
const canonicalUrl = new Url__default[
|
|
88
|
+
const canonicalUrl = new Url__default["default"](route.canonical);
|
|
83
89
|
if (url.pathname !== canonicalUrl.pathname) {
|
|
84
90
|
return canonicalUrl.pathname;
|
|
85
91
|
}
|
|
@@ -107,10 +113,10 @@ class DruxtRouter {
|
|
|
107
113
|
return resources.data || false;
|
|
108
114
|
}
|
|
109
115
|
async getResourceByRoute(route) {
|
|
110
|
-
const resource = await this.druxt.getResource(route.jsonapi.resourceName, route.entity.uuid);
|
|
116
|
+
const resource = await this.druxt.getResource(route.jsonapi.resourceName, route.entity.uuid, route.prefix);
|
|
111
117
|
return resource.data || false;
|
|
112
118
|
}
|
|
113
|
-
async getRoute(path) {
|
|
119
|
+
async getRoute(path = "/") {
|
|
114
120
|
const url = `/router/translate-path?path=${path}`;
|
|
115
121
|
const response = await this.druxt.get(url, {
|
|
116
122
|
validateStatus: (status) => status < 500
|
|
@@ -132,7 +138,8 @@ class DruxtRouter {
|
|
|
132
138
|
label: data.label,
|
|
133
139
|
props: false,
|
|
134
140
|
redirect: data.redirect,
|
|
135
|
-
resolvedPath: Url__default[
|
|
141
|
+
resolvedPath: Url__default["default"](data.resolved).pathname,
|
|
142
|
+
entity: data.entity
|
|
136
143
|
};
|
|
137
144
|
for (const key in this.options.types) {
|
|
138
145
|
const type = {
|
|
@@ -198,7 +205,7 @@ const DruxtRouterStore = ({ store }) => {
|
|
|
198
205
|
if (typeof path !== "string" || typeof route === "undefined") {
|
|
199
206
|
return;
|
|
200
207
|
}
|
|
201
|
-
state.routes
|
|
208
|
+
Vue__default["default"].set(state.routes, path, route);
|
|
202
209
|
},
|
|
203
210
|
setRoute(state, path) {
|
|
204
211
|
if (typeof path !== "string" || typeof state.routes[path] === "undefined") {
|
|
@@ -297,6 +304,10 @@ const DruxtRouterEntityMixin = {
|
|
|
297
304
|
|
|
298
305
|
const DruxtRouterMixin = {
|
|
299
306
|
props: {
|
|
307
|
+
langcode: {
|
|
308
|
+
type: String,
|
|
309
|
+
default: void 0
|
|
310
|
+
},
|
|
300
311
|
path: {
|
|
301
312
|
type: String,
|
|
302
313
|
default: void 0
|
package/nuxt/index.d.ts
CHANGED
package/nuxt/index.js
CHANGED
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
|
+
const drupalJsonapiParams = require('drupal-jsonapi-params');
|
|
8
|
+
const druxt = require('druxt');
|
|
7
9
|
|
|
8
10
|
const DruxtRouterNuxtModule = async function(moduleOptions = {}) {
|
|
9
11
|
const options = {
|
|
@@ -20,23 +22,39 @@ const DruxtRouterNuxtModule = async function(moduleOptions = {}) {
|
|
|
20
22
|
dirs.push({ path: path.join(__dirname, "../dist/components") });
|
|
21
23
|
});
|
|
22
24
|
if (options.router.wildcard) {
|
|
25
|
+
if (!options.router.pages) {
|
|
26
|
+
this.nuxt.hook("build:before", () => this.nuxt.options.build.createRoutes = () => []);
|
|
27
|
+
}
|
|
23
28
|
this.addTemplate({
|
|
24
29
|
src: path.resolve(__dirname, "../templates/component.js"),
|
|
25
30
|
fileName: "components/druxt-router.js",
|
|
26
31
|
options
|
|
27
32
|
});
|
|
28
|
-
|
|
33
|
+
const druxt$1 = new druxt.DruxtClient(options.baseUrl, {
|
|
34
|
+
...options,
|
|
35
|
+
proxy: { ...options.proxy || {}, api: false }
|
|
36
|
+
});
|
|
37
|
+
const resourceType = "configurable_language--configurable_language";
|
|
38
|
+
const query = new drupalJsonapiParams.DrupalJsonApiParams().addFields(resourceType, ["drupal_internal__id"]);
|
|
39
|
+
const languages = (await druxt$1.getCollectionAll(resourceType, query) || []).map((o) => o.data).flat().filter((o) => !["und", "zxx"].includes(o.attributes.drupal_internal__id));
|
|
40
|
+
this.extendRoutes((routes) => {
|
|
41
|
+
languages.forEach((o) => {
|
|
42
|
+
routes.push({
|
|
43
|
+
name: `druxt-router__${o.attributes.drupal_internal__id}`,
|
|
44
|
+
path: `/${o.attributes.drupal_internal__id}*`,
|
|
45
|
+
component: path.resolve(this.options.buildDir, "components/druxt-router.js"),
|
|
46
|
+
chunkName: "druxt-router",
|
|
47
|
+
meta: { langcode: o.attributes.drupal_internal__id }
|
|
48
|
+
});
|
|
49
|
+
});
|
|
29
50
|
routes.push({
|
|
30
51
|
name: "druxt-router",
|
|
31
52
|
path: "*",
|
|
32
|
-
component:
|
|
53
|
+
component: path.resolve(this.options.buildDir, "components/druxt-router.js"),
|
|
33
54
|
chunkName: "druxt-router"
|
|
34
55
|
});
|
|
35
56
|
});
|
|
36
57
|
}
|
|
37
|
-
if (options.router.wildcard && !options.router.pages) {
|
|
38
|
-
this.nuxt.hook("build:before", () => this.nuxt.options.build.createRoutes = () => []);
|
|
39
|
-
}
|
|
40
58
|
this.addPlugin({
|
|
41
59
|
src: path.resolve(__dirname, "../templates/plugin.js"),
|
|
42
60
|
fileName: "druxt-router.js",
|
|
@@ -49,9 +67,14 @@ const DruxtRouterNuxtModule = async function(moduleOptions = {}) {
|
|
|
49
67
|
options
|
|
50
68
|
});
|
|
51
69
|
this.nuxt.hook("storybook:config", async ({ stories }) => {
|
|
52
|
-
|
|
70
|
+
this.addTemplate({
|
|
71
|
+
src: path.resolve(__dirname, "../templates/druxt-router.stories.js"),
|
|
72
|
+
fileName: "stories/druxt-router.stories.js",
|
|
73
|
+
options: {}
|
|
74
|
+
});
|
|
75
|
+
stories.push(path.resolve(this.options.buildDir, "./stories/druxt-router.stories.js"));
|
|
53
76
|
});
|
|
54
77
|
};
|
|
55
78
|
DruxtRouterNuxtModule.meta = require("../package.json");
|
|
56
79
|
|
|
57
|
-
exports
|
|
80
|
+
exports["default"] = DruxtRouterNuxtModule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "druxt-router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Drupal router for Nuxt, powered by the Drupal Decoupled Router module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -42,8 +42,14 @@
|
|
|
42
42
|
"templates"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"druxt": "^0.
|
|
46
|
-
"url-parse": "^1.
|
|
45
|
+
"druxt": "^0.19.0",
|
|
46
|
+
"url-parse": "^1.5.10"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"vue-router": "^3.5.4"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"drupal-jsonapi-params": "*"
|
|
47
53
|
},
|
|
48
54
|
"optionalDependencies": {
|
|
49
55
|
"vue": "^2.6.14",
|
|
@@ -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: '/' }
|