cec-nuxt-lib 0.1.5 → 0.1.7

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/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "cec-vue-lib",
3
3
  "configKey": "cec-vue-lib",
4
- "version": "0.1.5"
4
+ "version": "0.1.7"
5
5
  }
@@ -9,37 +9,33 @@ const classicPath = useState('classicPath');
9
9
  const baseUrl = config.app.baseURL;
10
10
 
11
11
  // Helper functions
12
- const makeLink = (i) => {
13
- let diff = i - length;
14
- if (!diff) {
15
- return '/';
16
- }
17
- return routes.slice(0, diff + 1).join('/');
12
+ const makeLink = (i, routes) => {
13
+ return routes.slice(0, i + 1).join('/');
18
14
  };
19
15
 
20
16
  const toTitleCase = (str) => {
21
- return (
22
- str[0].toUpperCase() +
23
- str
24
- .slice(1)
25
- .replace(/[-_]/g, ' ')
26
- .replace(/\shmo\s/g, ' HMO ')
27
- );
17
+ return !str.length
18
+ ? ''
19
+ : `${str[0].toUpperCase()}${str.slice(1).replace(/[-_]/g, ' ')}`;
28
20
  };
29
21
 
30
- // Used to make the Nuxt links
31
- let routes = route.path.split('/');
32
- let classic = classicPath.value.split('/');
33
- const length = classic.length - 1;
34
- let hrefs;
22
+ // Construct links and labels for breadcrumb
23
+ let rLength = route.path.split('/').length;
24
+ let cLength = classicPath.value.split('/').length;
25
+ let routes = route.path
26
+ .split('/')
27
+ .filter((e, i) => !(i === rLength - 1 && !e.length));
28
+ let classic = classicPath.value
29
+ .split('/')
30
+ .filter((e, i) => !(i === cLength - 1 && !e.length));
31
+ const length = classic.length;
32
+ let hrefs =
33
+ baseUrl.length > 1 && route.path !== '/'
34
+ ? `${classicPath.value}${route.path}`.split('/')
35
+ : routes.reduce((acc, e, i) => {
36
+ return classic[i] ? [...acc, classic[i]] : [...acc, e];
37
+ }, []);
35
38
 
36
- if (baseUrl.length > 1 && route.path !== '/') {
37
- hrefs = (classicPath.value + route.path).split('/');
38
- } else {
39
- hrefs = routes.reduce((acc, e, i) => {
40
- return classic[i] ? [...acc, classic[i]] : [...acc, e];
41
- }, []);
42
- }
43
39
  const links = hrefs.map((e, i) => (!i ? 'Home' : toTitleCase(e)));
44
40
  </script>
45
41
  <template>
@@ -51,9 +47,9 @@ const links = hrefs.map((e, i) => (!i ? 'Home' : toTitleCase(e)));
51
47
  <ol class="breadcrumb cec-breadcrumb my-0 py-2">
52
48
  <li class="breadcrumb-item" v-for="(l, i) in links" :key="i">
53
49
  <span v-if="i === links.length - 1">{{ l }}</span>
54
- <NuxtLink v-else-if="i >= length" :to="makeLink(i)">
55
- {{ l }}</NuxtLink
56
- >
50
+ <template v-else-if="i + 1 >= length">
51
+ <NuxtLink :to="makeLink(i, routes)">{{ l }} nuxt</NuxtLink>
52
+ </template>
57
53
  <a v-else :href="'/' + hrefs.slice(1, i + 1).join('/')">
58
54
  {{ l }}</a
59
55
  >
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.5",
2
+ "version": "0.1.7",
3
3
  "name": "cec-nuxt-lib",
4
4
  "description": "Nuxt components and assets",
5
5
  "license": "MIT",