1
- import { provide } from "vue" ;
2
- import { defineClientConfig } from "@vuepress/client" ;
1
+ import { provide , onMounted , onBeforeUnmount , nextTick } from "vue" ;
2
+ import { defineClientConfig } from "@vuepress/client" ;
3
3
import mitt from 'mitt' ;
4
-
5
4
import Layout from "./theme/layouts/Layout.vue" ;
6
5
import HomeLayout from "./theme/layouts/HomeLayout.vue" ;
7
6
import NotFound from "./theme/layouts/NotFound.vue" ;
8
-
9
7
import bottomLinks from "./config-client/bottomLinks" ;
10
8
import navbarLinks from "./config-client/navbarLinks" ;
11
9
import documents from "./config-client/documents" ;
12
10
import sidebar from "./config-client/sidebar" ;
13
11
import social from "./config-client/social" ;
14
12
import Chat from "./components/Chat.vue" ;
15
13
14
+ declare const __VUEPRESS_DEV__ : boolean ;
15
+
16
16
export default defineClientConfig ( {
17
- rootComponents : [
17
+ rootComponents : [
18
18
Chat ,
19
19
] ,
20
- async enhance ( { app } ) {
20
+ async enhance ( { app, router } ) {
21
+ // Existing event bus setup
21
22
app . config . globalProperties . $eventBus = mitt ( ) ;
23
+
24
+ // Add anchor navigation handling
25
+ if ( ! __VUEPRESS_DEV__ ) {
26
+ const handleAnchorClick = ( event : MouseEvent ) => {
27
+ const target = event . target as HTMLElement ;
28
+ const anchor = target . closest ( 'a' ) ;
29
+
30
+ if ( anchor ?. hash && anchor . origin === window . location . origin ) {
31
+ event . preventDefault ( ) ;
32
+
33
+ const hash = anchor . hash ;
34
+ nextTick ( ( ) => {
35
+ const element = document . querySelector ( hash ) ;
36
+ if ( element ) {
37
+ // Add offset for fixed header if needed
38
+ const headerOffset = 80 ; // Adjust based on your header height
39
+ const elementPosition = element . getBoundingClientRect ( ) . top ;
40
+ const offsetPosition = elementPosition + window . pageYOffset - headerOffset ;
41
+
42
+ window . scrollTo ( {
43
+ top : offsetPosition ,
44
+ behavior : 'smooth'
45
+ } ) ;
46
+
47
+ // Update URL without full page reload
48
+ window . history . pushState ( null , '' , hash ) ;
49
+ }
50
+ } ) ;
51
+ }
52
+ } ;
53
+
54
+ // Handle initial hash on page load
55
+ router . afterEach ( ( ) => {
56
+ if ( window . location . hash ) {
57
+ nextTick ( ( ) => {
58
+ const element = document . querySelector ( window . location . hash ) ;
59
+ if ( element ) {
60
+ const headerOffset = 80 ; // Adjust based on your header height
61
+ const elementPosition = element . getBoundingClientRect ( ) . top ;
62
+ const offsetPosition = elementPosition + window . pageYOffset - headerOffset ;
63
+
64
+ window . scrollTo ( {
65
+ top : offsetPosition ,
66
+ behavior : 'smooth'
67
+ } ) ;
68
+ }
69
+ } ) ;
70
+ }
71
+ } ) ;
72
+
73
+ // Add event listeners
74
+ onMounted ( ( ) => {
75
+ document . addEventListener ( 'click' , handleAnchorClick ) ;
76
+ } ) ;
77
+
78
+ onBeforeUnmount ( ( ) => {
79
+ document . removeEventListener ( 'click' , handleAnchorClick ) ;
80
+ } ) ;
81
+ }
22
82
} ,
23
83
layouts : {
24
84
Layout,
@@ -35,10 +95,8 @@ export default defineClientConfig({
35
95
githubMainDir : "docs" ,
36
96
githubRepository : "cloudlinux/imunify360-documentation" ,
37
97
MOBILE_BREAKPOINT : 767 ,
38
-
39
98
//docs cards
40
99
documents,
41
-
42
100
// icons
43
101
arrowDownIcon : "arrows/arrow-down.svg" ,
44
102
githubEditIcon : 'global/pen.svg' ,
@@ -47,11 +105,9 @@ export default defineClientConfig({
47
105
siteLogo : "global/logo.svg" ,
48
106
searchSelectIcon : 'arrows/select-down.svg' ,
49
107
headerSearchIcon : 'global/header-search.svg' ,
50
-
51
108
// Header
52
109
headerSearch : "Imunify360 Product Documentation" ,
53
110
headerSearchPlaceholder : "Search across all Imunify360 product documentation" ,
54
-
55
111
//locales
56
112
locales : {
57
113
bottomLinks,
@@ -61,22 +117,18 @@ export default defineClientConfig({
61
117
stayInTouch : "Stay in touch" ,
62
118
navbarLinks : navbarLinks ,
63
119
} ,
64
-
65
120
// Products
66
121
productsList : [ 'Cloudlinux' , 'Imunify' , 'TuxCare' ] ,
67
122
productsTitle : 'Products' ,
68
123
productsURLs : [ 'https://docs.cloudlinux.com' , 'https://docs.imunify360.com' , 'https://docs.tuxcare.com' ] ,
69
-
70
124
//social links for footer
71
125
social,
72
-
73
126
// Algolia
74
127
algoliaOptions : {
75
128
apiKey : "e6b9d79daf71aa98e2e2a51d4556f9d4" ,
76
129
indexName : "imunify360-unified" ,
77
130
appId : "0TCNL6CGX8" ,
78
131
} ,
79
-
80
132
MAX_VISIBLE_RESULT : 12 ,
81
133
MAX_VISIBLE_ROWS : 12 ,
82
134
MAX_HITS_PER_PAGE : 12 ,
0 commit comments