druxt-breadcrumb 0.14.0 → 0.15.1

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.
@@ -64,7 +64,7 @@ export default {
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 (this.path && path !== this.$route.path) {
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) {
@@ -147,11 +148,16 @@ export default {
147
148
  crumbs.push({ to, text: route.label })
148
149
  }
149
150
 
151
+ // If this route is the home path, prevent a duplicate home item.
152
+ if (route.isHomePath) {
153
+ addHome = false
154
+ }
155
+
150
156
  paths.pop()
151
157
  }
152
158
 
153
- // Home crumb.
154
- if (this.home) {
159
+ // Add Home item.
160
+ if (this.home && addHome) {
155
161
  crumbs.push({
156
162
  to: '/',
157
163
  text: 'Home'
@@ -228,11 +234,13 @@ export default {
228
234
  *
229
235
  * @example @lang js
230
236
  * [
237
+ * 'DruxtBreadcrumb[Default][Langcode]',
231
238
  * 'DruxtBreadcrumb[Default]',
232
239
  * ]
233
240
  *
234
241
  * @example @lang js
235
242
  * [
243
+ * 'DruxtBreadcrumbDefaultEn',
236
244
  * 'DruxtBreadcrumbDefault',
237
245
  * ]
238
246
  */
@@ -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.html|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.html|DruxtBlocksBlockMixin}
30
+ * @see {@link https://blocks.druxtjs.org/api/mixins/block|DruxtBlocksBlockMixin}
31
31
  */
32
32
  mixins: [DruxtBlocksBlockMixin],
33
33
  }
@@ -1,12 +1,17 @@
1
- import { join } from 'path';
1
+ import { join, resolve } from 'path';
2
2
 
3
3
  const DruxtBreadcrumbModule = function() {
4
4
  this.nuxt.hook("components:dirs", (dirs) => {
5
5
  dirs.push({ path: join(__dirname, "components") });
6
6
  dirs.push({ path: join(__dirname, "components/blocks") });
7
7
  });
8
+ const { addTemplate, options } = this;
8
9
  this.nuxt.hook("storybook:config", ({ stories }) => {
9
- stories.push("druxt-breadcrumb/dist/components/*.stories.mjs");
10
+ addTemplate({
11
+ src: resolve(__dirname, "../templates/druxt-breadcrumb.stories.js"),
12
+ fileName: "stories/druxt-breadcrumb.stories.js"
13
+ });
14
+ stories.push(resolve(options.buildDir, "./stories/druxt-breadcrumb.stories.js"));
10
15
  });
11
16
  };
12
17
  DruxtBreadcrumbModule.meta = require("../package.json");
@@ -16,9 +21,12 @@ const DruxtBreadcrumbMixin = {
16
21
  crumbs: {
17
22
  type: Array,
18
23
  require: true
24
+ },
25
+ langcode: {
26
+ type: String,
27
+ default: void 0
19
28
  }
20
29
  }
21
30
  };
22
31
 
23
- export default DruxtBreadcrumbModule;
24
- export { DruxtBreadcrumbMixin };
32
+ export { DruxtBreadcrumbMixin, DruxtBreadcrumbModule as default };
@@ -9,8 +9,13 @@ const DruxtBreadcrumbModule = function() {
9
9
  dirs.push({ path: path.join(__dirname, "components") });
10
10
  dirs.push({ path: path.join(__dirname, "components/blocks") });
11
11
  });
12
+ const { addTemplate, options } = this;
12
13
  this.nuxt.hook("storybook:config", ({ stories }) => {
13
- stories.push("druxt-breadcrumb/dist/components/*.stories.mjs");
14
+ addTemplate({
15
+ src: path.resolve(__dirname, "../templates/druxt-breadcrumb.stories.js"),
16
+ fileName: "stories/druxt-breadcrumb.stories.js"
17
+ });
18
+ stories.push(path.resolve(options.buildDir, "./stories/druxt-breadcrumb.stories.js"));
14
19
  });
15
20
  };
16
21
  DruxtBreadcrumbModule.meta = require("../package.json");
@@ -20,9 +25,13 @@ const DruxtBreadcrumbMixin = {
20
25
  crumbs: {
21
26
  type: Array,
22
27
  require: true
28
+ },
29
+ langcode: {
30
+ type: String,
31
+ default: void 0
23
32
  }
24
33
  }
25
34
  };
26
35
 
27
36
  exports.DruxtBreadcrumbMixin = DruxtBreadcrumbMixin;
28
- exports.default = DruxtBreadcrumbModule;
37
+ exports["default"] = DruxtBreadcrumbModule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "druxt-breadcrumb",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
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.17.0",
45
- "druxt-blocks": "^0.15.0",
46
- "druxt-router": "^0.26.0"
45
+ "druxt": "^0.19.3",
46
+ "druxt-blocks": "^0.16.2",
47
+ "druxt-router": "^0.27.4"
47
48
  },
48
49
  "optionalDependencies": {
49
50
  "vue": "^2.6.14",
@@ -1,4 +1,4 @@
1
- import DruxtBreadcrumb from './DruxtBreadcrumb.vue'
1
+ import DruxtBreadcrumb from 'druxt-breadcrumb/dist/components//DruxtBreadcrumb.vue'
2
2
 
3
3
  export default {
4
4
  title: 'Druxt/Breadcrumb/DruxtBreadcrumb',
@@ -41,7 +41,9 @@ export const Wrapper = (args, { argTypes }) => ({
41
41
  })
42
42
  Wrapper.parameters = {
43
43
  docs: {
44
- storyDescription: '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```',
44
+ description: {
45
+ 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```',
46
+ },
45
47
  source: { code }
46
48
  }
47
49
  }
@@ -60,7 +62,9 @@ export const TemplateInjection = (args, { argTypes }) => ({
60
62
  })
61
63
  TemplateInjection.parameters = {
62
64
  docs: {
63
- storyDescription: 'The DruxtBreadcrumb component can be themed by injecting the default template into the compomnent.\n\n```jsx\n' + code + '\n```',
65
+ description: {
66
+ story: 'The DruxtBreadcrumb component can be themed by injecting the default template into the compomnent.\n\n```jsx\n' + code + '\n```',
67
+ },
64
68
  source: { code }
65
69
  }
66
70
  }