druxt-breadcrumb 0.14.1 → 0.16.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/DruxtBreadcrumb.vue +18 -9
- package/dist/components/blocks/DruxtBlockSystemBreadcrumbBlock.vue +3 -3
- package/dist/druxt-breadcrumb.esm.js +22 -5
- package/dist/druxt-breadcrumb.ssr.js +21 -3
- package/package.json +6 -5
- package/{dist/components/DruxtBreadcrumb.stories.mjs → templates/druxt-breadcrumb.stories.js} +13 -3
|
@@ -45,7 +45,7 @@ export default {
|
|
|
45
45
|
* @type {boolean}
|
|
46
46
|
* @default true
|
|
47
47
|
* @example @lang vue
|
|
48
|
-
* <
|
|
48
|
+
* <DruxtBreadcrumb :home="false" />
|
|
49
49
|
*/
|
|
50
50
|
home: {
|
|
51
51
|
type: Boolean,
|
|
@@ -60,11 +60,11 @@ export default {
|
|
|
60
60
|
* @type {string}
|
|
61
61
|
*
|
|
62
62
|
* @example @lang vue
|
|
63
|
-
* <
|
|
63
|
+
* <DruxtBreadcrumb path="/node/1" />
|
|
64
64
|
*/
|
|
65
65
|
path: {
|
|
66
66
|
type: String,
|
|
67
|
-
default:
|
|
67
|
+
default: undefined
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
|
|
@@ -106,7 +106,7 @@ export default {
|
|
|
106
106
|
async fetchCrumbs() {
|
|
107
107
|
const path = this.path || this.$route.path
|
|
108
108
|
let route = this.route
|
|
109
|
-
if (
|
|
109
|
+
if (path && path !== route.path) {
|
|
110
110
|
route = await this.getRoute(path)
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -116,7 +116,7 @@ export default {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
// If we are at the root and don't want a home crumb, stop here.
|
|
119
|
-
if (path === '/' && !this.home) return
|
|
119
|
+
if ((path === '/' || route.isHomePath) && !this.home) return
|
|
120
120
|
|
|
121
121
|
// Current route crumb.
|
|
122
122
|
const crumbs = []
|
|
@@ -125,12 +125,13 @@ export default {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
// If we are at the root of the site, stop here.
|
|
128
|
-
if (path === '/') {
|
|
128
|
+
if (path === '/' || route.isHomePath) {
|
|
129
129
|
this.model = crumbs
|
|
130
130
|
return
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// Add crumbs for route parents.
|
|
134
|
+
let addHome = true
|
|
134
135
|
const paths = path.split('/').filter(String)
|
|
135
136
|
paths.pop()
|
|
136
137
|
while (paths.length > 0) {
|
|
@@ -143,15 +144,21 @@ export default {
|
|
|
143
144
|
route = false
|
|
144
145
|
}
|
|
145
146
|
|
|
146
|
-
|
|
147
|
+
// If this route has a label and doesn't resolve to the current path, add to the crumbs.
|
|
148
|
+
if (route.label && route.resolvedPath !== path) {
|
|
147
149
|
crumbs.push({ to, text: route.label })
|
|
148
150
|
}
|
|
149
151
|
|
|
152
|
+
// If this route is the home path, prevent a duplicate home item.
|
|
153
|
+
if (route.isHomePath || to === ['/', (route.props || {}).langcode].filter((o) => o).join('')) {
|
|
154
|
+
addHome = false
|
|
155
|
+
}
|
|
156
|
+
|
|
150
157
|
paths.pop()
|
|
151
158
|
}
|
|
152
159
|
|
|
153
|
-
// Home
|
|
154
|
-
if (this.home) {
|
|
160
|
+
// Add Home item.
|
|
161
|
+
if (this.home && addHome) {
|
|
155
162
|
crumbs.push({
|
|
156
163
|
to: '/',
|
|
157
164
|
text: 'Home'
|
|
@@ -228,11 +235,13 @@ export default {
|
|
|
228
235
|
*
|
|
229
236
|
* @example @lang js
|
|
230
237
|
* [
|
|
238
|
+
* 'DruxtBreadcrumb[Default][Langcode]',
|
|
231
239
|
* 'DruxtBreadcrumb[Default]',
|
|
232
240
|
* ]
|
|
233
241
|
*
|
|
234
242
|
* @example @lang js
|
|
235
243
|
* [
|
|
244
|
+
* 'DruxtBreadcrumbDefaultEn',
|
|
236
245
|
* 'DruxtBreadcrumbDefault',
|
|
237
246
|
* ]
|
|
238
247
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<DruxtBreadcrumb />
|
|
2
|
+
<DruxtBreadcrumb :langcode="langcode" />
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script>
|
|
@@ -18,7 +18,7 @@ import { DruxtBlocksBlockMixin } from 'druxt-blocks'
|
|
|
18
18
|
* uuid="59121e44-e21b-4f53-b009-5225cd630145"
|
|
19
19
|
* />
|
|
20
20
|
*
|
|
21
|
-
* @see {@link https://blocks.druxtjs.org/api/components/DruxtBlock
|
|
21
|
+
* @see {@link https://blocks.druxtjs.org/api/components/DruxtBlock|DruxtBlock}
|
|
22
22
|
* @see {@link ../DruxtBreadcrumb|DruxtBreadcrumb}
|
|
23
23
|
*/
|
|
24
24
|
export default {
|
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
/**
|
|
28
28
|
* Vue.js Mixins.
|
|
29
29
|
*
|
|
30
|
-
* @see {@link https://blocks.druxtjs.org/api/mixins/block
|
|
30
|
+
* @see {@link https://blocks.druxtjs.org/api/mixins/block|DruxtBlocksBlockMixin}
|
|
31
31
|
*/
|
|
32
32
|
mixins: [DruxtBlocksBlockMixin],
|
|
33
33
|
}
|
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
1
|
+
import { join, resolve } from 'path';
|
|
2
2
|
|
|
3
|
-
const DruxtBreadcrumbModule = function() {
|
|
3
|
+
const DruxtBreadcrumbModule = async function(moduleOptions = {}) {
|
|
4
|
+
const options = {
|
|
5
|
+
baseUrl: moduleOptions.baseUrl,
|
|
6
|
+
...(this.options || {}).druxt || {},
|
|
7
|
+
breadcrumb: {
|
|
8
|
+
...((this.options || {}).druxt || {}).breadcrumb,
|
|
9
|
+
...moduleOptions
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
await this.addModule(["druxt", options]);
|
|
13
|
+
await this.addModule(["druxt-router/nuxt", options]);
|
|
4
14
|
this.nuxt.hook("components:dirs", (dirs) => {
|
|
5
15
|
dirs.push({ path: join(__dirname, "components") });
|
|
6
16
|
dirs.push({ path: join(__dirname, "components/blocks") });
|
|
7
17
|
});
|
|
8
18
|
this.nuxt.hook("storybook:config", ({ stories }) => {
|
|
9
|
-
|
|
19
|
+
this.addTemplate({
|
|
20
|
+
src: resolve(__dirname, "../templates/druxt-breadcrumb.stories.js"),
|
|
21
|
+
fileName: "stories/druxt-breadcrumb.stories.js"
|
|
22
|
+
});
|
|
23
|
+
stories.push(resolve(this.options.buildDir, "./stories/druxt-breadcrumb.stories.js"));
|
|
10
24
|
});
|
|
11
25
|
};
|
|
12
26
|
DruxtBreadcrumbModule.meta = require("../package.json");
|
|
@@ -16,9 +30,12 @@ const DruxtBreadcrumbMixin = {
|
|
|
16
30
|
crumbs: {
|
|
17
31
|
type: Array,
|
|
18
32
|
require: true
|
|
33
|
+
},
|
|
34
|
+
langcode: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: void 0
|
|
19
37
|
}
|
|
20
38
|
}
|
|
21
39
|
};
|
|
22
40
|
|
|
23
|
-
export default
|
|
24
|
-
export { DruxtBreadcrumbMixin };
|
|
41
|
+
export { DruxtBreadcrumbMixin, DruxtBreadcrumbModule as default };
|
|
@@ -4,13 +4,27 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
|
|
7
|
-
const DruxtBreadcrumbModule = function() {
|
|
7
|
+
const DruxtBreadcrumbModule = async function(moduleOptions = {}) {
|
|
8
|
+
const options = {
|
|
9
|
+
baseUrl: moduleOptions.baseUrl,
|
|
10
|
+
...(this.options || {}).druxt || {},
|
|
11
|
+
breadcrumb: {
|
|
12
|
+
...((this.options || {}).druxt || {}).breadcrumb,
|
|
13
|
+
...moduleOptions
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
await this.addModule(["druxt", options]);
|
|
17
|
+
await this.addModule(["druxt-router/nuxt", options]);
|
|
8
18
|
this.nuxt.hook("components:dirs", (dirs) => {
|
|
9
19
|
dirs.push({ path: path.join(__dirname, "components") });
|
|
10
20
|
dirs.push({ path: path.join(__dirname, "components/blocks") });
|
|
11
21
|
});
|
|
12
22
|
this.nuxt.hook("storybook:config", ({ stories }) => {
|
|
13
|
-
|
|
23
|
+
this.addTemplate({
|
|
24
|
+
src: path.resolve(__dirname, "../templates/druxt-breadcrumb.stories.js"),
|
|
25
|
+
fileName: "stories/druxt-breadcrumb.stories.js"
|
|
26
|
+
});
|
|
27
|
+
stories.push(path.resolve(this.options.buildDir, "./stories/druxt-breadcrumb.stories.js"));
|
|
14
28
|
});
|
|
15
29
|
};
|
|
16
30
|
DruxtBreadcrumbModule.meta = require("../package.json");
|
|
@@ -20,9 +34,13 @@ const DruxtBreadcrumbMixin = {
|
|
|
20
34
|
crumbs: {
|
|
21
35
|
type: Array,
|
|
22
36
|
require: true
|
|
37
|
+
},
|
|
38
|
+
langcode: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: void 0
|
|
23
41
|
}
|
|
24
42
|
}
|
|
25
43
|
};
|
|
26
44
|
|
|
27
45
|
exports.DruxtBreadcrumbMixin = DruxtBreadcrumbMixin;
|
|
28
|
-
exports
|
|
46
|
+
exports["default"] = DruxtBreadcrumbModule;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "druxt-breadcrumb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Decoupled Router based Breadcrumb Druxt component.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"breadcrumb",
|
|
@@ -38,12 +38,13 @@
|
|
|
38
38
|
"main": "dist/druxt-breadcrumb.ssr.js",
|
|
39
39
|
"module": "dist/druxt-breadcrumb.esm.js",
|
|
40
40
|
"files": [
|
|
41
|
-
"dist"
|
|
41
|
+
"dist",
|
|
42
|
+
"templates"
|
|
42
43
|
],
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"druxt": "^0.
|
|
45
|
-
"druxt-blocks": "^0.
|
|
46
|
-
"druxt-router": "^0.
|
|
45
|
+
"druxt": "^0.20.0",
|
|
46
|
+
"druxt-blocks": "^0.16.3",
|
|
47
|
+
"druxt-router": "^0.28.0"
|
|
47
48
|
},
|
|
48
49
|
"optionalDependencies": {
|
|
49
50
|
"vue": "^2.6.14",
|
package/{dist/components/DruxtBreadcrumb.stories.mjs → templates/druxt-breadcrumb.stories.js}
RENAMED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import DruxtBreadcrumb from '
|
|
1
|
+
import DruxtBreadcrumb from 'druxt-breadcrumb/dist/components/DruxtBreadcrumb.vue'
|
|
2
|
+
import DruxtModule from 'druxt/dist/components/DruxtModule.vue'
|
|
3
|
+
|
|
4
|
+
DruxtBreadcrumb.__docgenInfo.props = [
|
|
5
|
+
...DruxtModule.__docgenInfo.props,
|
|
6
|
+
...DruxtBreadcrumb.__docgenInfo.props,
|
|
7
|
+
].sort((a, b) => a.name < b.name ? -1 : 1).filter((o) => o.name !== 'v-model')
|
|
2
8
|
|
|
3
9
|
export default {
|
|
4
10
|
title: 'Druxt/Breadcrumb/DruxtBreadcrumb',
|
|
@@ -41,7 +47,9 @@ export const Wrapper = (args, { argTypes }) => ({
|
|
|
41
47
|
})
|
|
42
48
|
Wrapper.parameters = {
|
|
43
49
|
docs: {
|
|
44
|
-
|
|
50
|
+
description: {
|
|
51
|
+
story: 'The DruxtBreadcrumb 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```',
|
|
52
|
+
},
|
|
45
53
|
source: { code }
|
|
46
54
|
}
|
|
47
55
|
}
|
|
@@ -60,7 +68,9 @@ export const TemplateInjection = (args, { argTypes }) => ({
|
|
|
60
68
|
})
|
|
61
69
|
TemplateInjection.parameters = {
|
|
62
70
|
docs: {
|
|
63
|
-
|
|
71
|
+
description: {
|
|
72
|
+
story: 'The DruxtBreadcrumb component can be themed by injecting the default template into the compomnent.\n\n```jsx\n' + code + '\n```',
|
|
73
|
+
},
|
|
64
74
|
source: { code }
|
|
65
75
|
}
|
|
66
76
|
}
|