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