cec-nuxt-lib 0.3.12 → 0.4.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/module.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { useState } from '#app';
|
|
3
|
-
import { useRuntimeConfig } from '#app';
|
|
4
3
|
import { useRoute } from 'vue-router';
|
|
5
4
|
|
|
6
5
|
const classicPath = useState('classicPath');
|
|
7
|
-
const config = useRuntimeConfig();
|
|
8
|
-
const path = useState('path');
|
|
9
6
|
const route = useRoute();
|
|
10
|
-
const baseUrl = config.app.baseURL;
|
|
11
7
|
|
|
12
|
-
const trimPath = (str) =>
|
|
13
|
-
|
|
8
|
+
const trimPath = (str) => {
|
|
9
|
+
if (str === '/' || !str) {
|
|
10
|
+
return str;
|
|
11
|
+
}
|
|
12
|
+
return str.replace(/\/$/, '');
|
|
13
|
+
};
|
|
14
14
|
|
|
15
|
-
// Helper functions
|
|
16
15
|
const makeLink = (i, routes) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
if (!i) {
|
|
17
|
+
return '/';
|
|
18
|
+
}
|
|
19
|
+
return '/' + routes.slice(0, i).join('/');
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
const toTitleCase = (str) => {
|
|
@@ -26,8 +26,8 @@ const toTitleCase = (str) => {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
const makeArr = (str) => {
|
|
29
|
-
return str.split('/').reduce((acc, e
|
|
30
|
-
if (
|
|
29
|
+
return str.split('/').reduce((acc, e) => {
|
|
30
|
+
if (e.length) {
|
|
31
31
|
return [...acc, e];
|
|
32
32
|
}
|
|
33
33
|
return acc;
|
|
@@ -36,25 +36,15 @@ const makeArr = (str) => {
|
|
|
36
36
|
|
|
37
37
|
// Make arrays of the items in the paths
|
|
38
38
|
let routeTrim = trimPath(route.path);
|
|
39
|
-
let pathTrim = trimPath(path.value);
|
|
40
39
|
let routes = makeArr(routeTrim);
|
|
41
|
-
let paths = makeArr(pathTrim);
|
|
42
|
-
//console.log(routes)
|
|
43
|
-
|
|
44
|
-
// Use the route path if it includes the node's path
|
|
45
|
-
if (!routeTrim.toLowerCase().startsWith(pathTrim.toLowerCase())) {
|
|
46
|
-
routes = [...paths, ...routes.filter((e) => e.length)];
|
|
47
|
-
}
|
|
48
40
|
|
|
49
41
|
// Get the classic path for legacy links
|
|
50
42
|
let classic = trimPath(classicPath.value).split('/');
|
|
51
43
|
const length = classic.length;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return classic[i] ? [...acc, classic[i]] : [...acc, e];
|
|
57
|
-
}, []);
|
|
44
|
+
|
|
45
|
+
let hrefs = `${classicPath.value}${routeTrim === '/' ? '' : routeTrim}`.split(
|
|
46
|
+
'/'
|
|
47
|
+
);
|
|
58
48
|
const links = hrefs.map((e, i) => (!i ? 'Home' : toTitleCase(e)));
|
|
59
49
|
</script>
|
|
60
50
|
<template>
|
|
@@ -67,7 +57,9 @@ const links = hrefs.map((e, i) => (!i ? 'Home' : toTitleCase(e)));
|
|
|
67
57
|
<li class="breadcrumb-item" v-for="(l, i) in links" :key="i">
|
|
68
58
|
<span v-if="i === links.length - 1">{{ l }}</span>
|
|
69
59
|
<template v-else-if="i + 1 >= length">
|
|
70
|
-
<NuxtLink :to="makeLink(i, routes)">{{
|
|
60
|
+
<NuxtLink :to="makeLink(i - length + 1, routes)">{{
|
|
61
|
+
l
|
|
62
|
+
}}</NuxtLink>
|
|
71
63
|
</template>
|
|
72
64
|
<a v-else :href="'/' + hrefs.slice(1, i + 1).join('/')">
|
|
73
65
|
{{ l }}</a
|
package/package.json
CHANGED