cec-nuxt-lib 0.0.9 → 0.1.1
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,12 +1,34 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { useState } from '#app';
|
|
3
|
-
|
|
3
|
+
import { useRoute } from 'vue-router';
|
|
4
|
+
|
|
5
|
+
const classicPath = useState('classicPath');
|
|
6
|
+
const route = useRoute();
|
|
7
|
+
let length = classicPath.value.split('/').length - 1;
|
|
8
|
+
|
|
9
|
+
const truePath =
|
|
10
|
+
route.path === '/' ? classicPath.value : classicPath.value + route.path;
|
|
11
|
+
let routes = route.path.split('/');
|
|
12
|
+
|
|
13
|
+
const makeLink = (i) => {
|
|
14
|
+
let diff = i - length;
|
|
15
|
+
if (!diff) {
|
|
16
|
+
return '/';
|
|
17
|
+
}
|
|
18
|
+
return routes.slice(0, diff + 1).join('/');
|
|
19
|
+
};
|
|
4
20
|
|
|
5
21
|
const toTitleCase = (str) => {
|
|
6
|
-
return
|
|
22
|
+
return (
|
|
23
|
+
str[0].toUpperCase() +
|
|
24
|
+
str
|
|
25
|
+
.slice(1)
|
|
26
|
+
.replace(/[-_]/g, ' ')
|
|
27
|
+
.replace(/\shmo\s/g, 'HMO')
|
|
28
|
+
);
|
|
7
29
|
};
|
|
8
30
|
|
|
9
|
-
let hrefs =
|
|
31
|
+
let hrefs = truePath === '/' ? [''] : truePath.split('/');
|
|
10
32
|
const links = hrefs.map((e, i) => (!e ? 'Home' : toTitleCase(e)));
|
|
11
33
|
</script>
|
|
12
34
|
<template>
|
|
@@ -18,6 +40,9 @@ const links = hrefs.map((e, i) => (!e ? 'Home' : toTitleCase(e)));
|
|
|
18
40
|
<ol class="breadcrumb cec-breadcrumb my-0 py-2">
|
|
19
41
|
<li class="breadcrumb-item" v-for="(l, i) in links" :key="i">
|
|
20
42
|
<span v-if="i === links.length - 1">{{ l }}</span>
|
|
43
|
+
<NuxtLink v-else-if="i >= length" :to="makeLink(i)">
|
|
44
|
+
{{ l }}</NuxtLink
|
|
45
|
+
>
|
|
21
46
|
<a v-else :href="'/' + hrefs.slice(1, i + 1).join('/')">
|
|
22
47
|
{{ l }}</a
|
|
23
48
|
>
|
package/package.json
CHANGED