cec-nuxt-lib 0.1.4 → 0.1.6
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
|
@@ -5,20 +5,10 @@ import { useRoute } from 'vue-router';
|
|
|
5
5
|
|
|
6
6
|
const config = useRuntimeConfig();
|
|
7
7
|
const route = useRoute();
|
|
8
|
-
|
|
9
|
-
const baseUrl = config.app.baseURL;
|
|
10
8
|
const classicPath = useState('classicPath');
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
// Used to make the Nuxt links
|
|
14
|
-
let routes = route.path.split('/');
|
|
15
|
-
const length = path.value.split('/').length - 1;
|
|
16
|
-
|
|
17
|
-
let truePath = classicPath.value;
|
|
18
|
-
if (baseUrl && route.path !== '/') {
|
|
19
|
-
truePath += route.path;
|
|
20
|
-
}
|
|
9
|
+
const baseUrl = config.app.baseURL;
|
|
21
10
|
|
|
11
|
+
// Helper functions
|
|
22
12
|
const makeLink = (i) => {
|
|
23
13
|
let diff = i - length;
|
|
24
14
|
if (!diff) {
|
|
@@ -28,16 +18,28 @@ const makeLink = (i) => {
|
|
|
28
18
|
};
|
|
29
19
|
|
|
30
20
|
const toTitleCase = (str) => {
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
str
|
|
34
|
-
.slice(1)
|
|
35
|
-
.replace(/[-_]/g, ' ')
|
|
36
|
-
.replace(/\shmo\s/g, ' HMO ')
|
|
37
|
-
);
|
|
21
|
+
return !str.length
|
|
22
|
+
? ''
|
|
23
|
+
: `${str[0].toUpperCase()}${str.slice(1).replace(/[-_]/g, ' ')}`;
|
|
38
24
|
};
|
|
39
25
|
|
|
40
|
-
|
|
26
|
+
// Construct links and labels for breadcrumb
|
|
27
|
+
let rLength = route.path.split('/').length;
|
|
28
|
+
let cLength = classicPath.value.split('/').length;
|
|
29
|
+
let routes = route.path
|
|
30
|
+
.split('/')
|
|
31
|
+
.filter((e, i) => !(i === rLength - 1 && !e.length));
|
|
32
|
+
let classic = classicPath.value
|
|
33
|
+
.split('/')
|
|
34
|
+
.filter((e, i) => !(i === cLength - 1 && !e.length));
|
|
35
|
+
const length = classic.length - 1;
|
|
36
|
+
let hrefs =
|
|
37
|
+
baseUrl.length > 1 && route.path !== '/'
|
|
38
|
+
? `${classicPath.value}${route.path}`.split('/')
|
|
39
|
+
: routes.reduce((acc, e, i) => {
|
|
40
|
+
return classic[i] ? [...acc, classic[i]] : [...acc, e];
|
|
41
|
+
}, []);
|
|
42
|
+
|
|
41
43
|
const links = hrefs.map((e, i) => (!i ? 'Home' : toTitleCase(e)));
|
|
42
44
|
</script>
|
|
43
45
|
<template>
|
package/package.json
CHANGED