cec-nuxt-lib 0.5.3 → 0.5.4

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-nuxt-lib",
3
3
  "configKey": "cec-nuxt-lib",
4
- "version": "0.5.3"
4
+ "version": "0.5.4"
5
5
  }
@@ -1,13 +1,10 @@
1
1
  <script setup lang="ts">
2
2
  import { useState, useRuntimeConfig } from '#app';
3
3
  import { useRoute } from 'vue-router';
4
-
5
4
  const config = useRuntimeConfig();
6
- const baseUrl = config.app.baseURL;
7
5
 
6
+ const baseUrl = config.app.baseURL;
8
7
  const classicPath = useState('classicPath');
9
- const path = useState('path');
10
- console.log(path.value);
11
8
  const route = useRoute();
12
9
 
13
10
  const trimPath = (str) => {
@@ -18,46 +15,44 @@ const trimPath = (str) => {
18
15
  };
19
16
 
20
17
  const makeLink = (i, routes) => {
21
- if (!i) {
22
- return path.value;
18
+ if (baseUrl !== '/') {
19
+ return i ? routes.slice(0, i + 1).join('/') : '/';
23
20
  }
24
- return path.value + routes.slice(0, i).join('/');
25
21
  };
26
22
 
27
23
  const toTitleCase = (str) => {
24
+ return str
25
+ .split(/\s/)
26
+ .map((e) => toSentenceCase(e))
27
+ .join(' ');
28
+ };
29
+
30
+ const toSentenceCase = (str) => {
28
31
  return !str.length
29
32
  ? ''
30
33
  : `${str[0].toUpperCase()}${str.slice(1).replace(/[-_]/g, ' ')}`;
31
34
  };
32
35
 
33
- const makeArr = (str) => {
34
- return str.split('/').reduce((acc, e) => {
35
- return [...acc, e];
36
- }, []);
37
- };
38
-
39
36
  // Make arrays of the items in the paths
40
37
  let routeTrim = trimPath(route.path);
41
- let routes = makeArr(routeTrim);
42
-
43
- // Get the classic path for legacy links
38
+ let routes = routeTrim.split('/');
44
39
  let classic = trimPath(classicPath.value).split('/');
45
40
  const length = classic.length;
46
- let hrefs = [];
47
- if (baseUrl !== '/') {
48
- hrefs = `${classicPath.value}${routeTrim === '/' ? '' : routeTrim}`.split(
49
- '/'
50
- );
51
- } else {
52
- hrefs = routes.reduce((acc, e, i) => {
53
- if (classic[i]) {
54
- return [...acc, classic[i]];
55
- } else {
56
- return [...acc, e];
57
- }
58
- }, []);
59
- }
60
- const links = hrefs.map((e, i) => (!i ? 'Home' : toTitleCase(e)));
41
+
42
+ // Build an array of hrefs
43
+ let hrefs =
44
+ baseUrl !== '/'
45
+ ? `${classicPath.value}${routeTrim === '/' ? '' : routeTrim}`.split('/')
46
+ : routes.reduce((acc, e, i) => {
47
+ if (classic[i]) {
48
+ return [...acc, classic[i]];
49
+ } else {
50
+ return [...acc, e];
51
+ }
52
+ }, []);
53
+
54
+ // Sentence case for the breadcrumb display
55
+ const links = hrefs.map((e, i) => (!i ? 'Home' : toSentenceCase(e)));
61
56
  </script>
62
57
  <template>
63
58
  <div class="cec-breadcrumb-bg">
@@ -68,12 +63,14 @@ const links = hrefs.map((e, i) => (!i ? 'Home' : toTitleCase(e)));
68
63
  <ol class="breadcrumb cec-breadcrumb my-0 py-2">
69
64
  <li class="breadcrumb-item" v-for="(l, i) in links" :key="i">
70
65
  <!-- Node we are on -->
71
- <span v-if="i === links.length - 1">{{ l }}</span>
66
+ <span v-if="i === links.length - 1">{{
67
+ links.includes('Parties') ? toTitleCase(l) : l
68
+ }}</span>
72
69
  <!-- Nuxt links -->
73
70
  <template v-else-if="i + 1 >= length">
74
- <NuxtLink :to="makeLink(i - length + 1, routes)">{{
75
- l
76
- }}</NuxtLink>
71
+ <NuxtLink :to="makeLink(i - length + 1, routes)"
72
+ >{{ l }}
73
+ </NuxtLink>
77
74
  </template>
78
75
  <!-- links back to classic site -->
79
76
  <a v-else :href="'/' + hrefs.slice(1, i + 1).join('/')">
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.3",
2
+ "version": "0.5.4",
3
3
  "name": "cec-nuxt-lib",
4
4
  "description": "Nuxt components and assets",
5
5
  "license": "MIT",