cec-nuxt-lib 0.0.9 → 0.1.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,5 +1,5 @@
1
1
  {
2
2
  "name": "cec-vue-lib",
3
3
  "configKey": "cec-vue-lib",
4
- "version": "0.0.9"
4
+ "version": "0.1.0"
5
5
  }
@@ -1,12 +1,28 @@
1
1
  <script setup lang="ts">
2
2
  import { useState } from '#app';
3
- const path = useState('path');
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 str[0].toUpperCase() + str.slice(1).replace(/-/g, ' ');
22
+ return str[0].toUpperCase() + str.slice(1).replace(/[-_]/g, ' ');
7
23
  };
8
24
 
9
- let hrefs = path.value === '/' ? [''] : path.value.split('/');
25
+ let hrefs = truePath === '/' ? [''] : truePath.split('/');
10
26
  const links = hrefs.map((e, i) => (!e ? 'Home' : toTitleCase(e)));
11
27
  </script>
12
28
  <template>
@@ -18,6 +34,9 @@ const links = hrefs.map((e, i) => (!e ? 'Home' : toTitleCase(e)));
18
34
  <ol class="breadcrumb cec-breadcrumb my-0 py-2">
19
35
  <li class="breadcrumb-item" v-for="(l, i) in links" :key="i">
20
36
  <span v-if="i === links.length - 1">{{ l }}</span>
37
+ <NuxtLink v-else-if="i >= length" :to="makeLink(i)">
38
+ {{ l }}</NuxtLink
39
+ >
21
40
  <a v-else :href="'/' + hrefs.slice(1, i + 1).join('/')">
22
41
  {{ l }}</a
23
42
  >
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.9",
2
+ "version": "0.1.0",
3
3
  "name": "cec-nuxt-lib",
4
4
  "description": "Nuxt components and assets",
5
5
  "license": "MIT",