11<template >
22 <div class =" breadcrumb-wrapper" >
3- <span class =" breadcrumb-title" >{{ siteTitle }}:</span >
4- <router-link class =" breadcrumb" v-for =" crumb in breadCrumbs" :key =" crumb.path" :to =" crumb.path" >
3+ <router-link
4+ v-for =" (crumb, index) in breadCrumbs"
5+ :key =" crumb.path"
6+ class =" breadcrumb"
7+ :to =" crumb.path"
8+ >
59 {{ crumb.title }}
610 </router-link >
711 </div >
812</template >
913
1014<script setup>
11- import {computed , inject } from " vue" ;
12- import {usePageData , useSiteData } from " @vuepress/client" ;
15+ import { computed } from " vue" ;
16+ import { usePageData , useSiteData } from " @vuepress/client" ;
17+
18+ const page = usePageData ();
19+ const site = useSiteData ();
20+
21+ const siteTitle = computed (() => site .value .title );
22+
23+ const titleMap = {
24+ ' /els-for-languages/' : ' ELS for Languages' ,
25+ ' /introduction/' : ' Introduction to Cloudlinux OS' ,
26+ ' /cloudlinuxos/' : ' CloudLinux OS' ,
27+ ' /cln/' : ' CLN - CloudLinux Licenses' ,
28+ ' /ubuntu/' : ' CloudLinux Subsystem For Ubuntu' ,
29+ ' /user-docs/' : ' End-user Documents' ,
30+ };
1331
14- const page = usePageData ()
15- const site = useSiteData ()
16- const { locales: {siteTitle }} = inject (" themeConfig" )
1732const breadCrumbs = computed (() => {
18- const crumbs = [];
19- if (page .value .path !== ' /' ) {
20- crumbs .push ({path: page .value .path , title: page .value .title });
33+ const segments = page .value .path .split (" /" ).filter (Boolean );
34+ const crumbs = [{ path: " /" , title: " Documentation" }];
35+ let cumulativePath = " " ;
36+
37+ for (let i = 0 ; i < segments .length ; i++ ) {
38+ cumulativePath += ` /${ segments[i]} ` ;
39+ const isLast = i === segments .length - 1 ;
40+ const fullPath = cumulativePath .endsWith (" .html" ) ? cumulativePath : ` ${ cumulativePath} /` ;
41+
42+ let title;
43+
44+ if (isLast) {
45+ title = page .value .title ;
46+ } else {
47+ title = titleMap[fullPath] || fullPath;
2148 }
49+
50+ crumbs .push ({ path: fullPath, title });
51+ }
52+
2253 return crumbs;
2354});
2455 </script >
@@ -28,17 +59,22 @@ const breadCrumbs = computed(() => {
2859
2960.breadcrumb
3061 color $breadcrumbColor
62+ text-decoration none
3163
32- & ::after
64+ & :not ( :last-child ) : :after
3365 content " > "
3466 font-family inherit
3567 font-size inherit
68+ color $breadcrumbColor
69+
70+ & :not (:last-child )
71+ cursor pointer
72+
73+ & :hover
74+ color #19 94 f9
3675
3776 & :last-child
3877 cursor default
78+ color $breadcrumbColor
3979
40- .breadcrumb-title
41- color $breadcrumbColor
42- font-weight 600
43- margin-right 2px
4480 </style >
0 commit comments