This repository was archived by the owner on Sep 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +52
-5
lines changed Expand file tree Collapse file tree 3 files changed +52
-5
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
- <div />
2
+ <div >
3
+ <CFlex justify =" space-between" >
4
+ <CLink as =" router-link" :v-show =" prev !== ''" :to =" prev" >
5
+ Prev
6
+ </CLink >
7
+
8
+ <CLink as =" router-link" :v-show =" next !== ''" :to =" next" >
9
+ Next
10
+ </CLink >
11
+ </CFlex >
12
+ </div >
3
13
</template >
4
14
5
15
<script >
6
- export default {}
16
+ import { CLink , CFlex } from ' @chakra-ui/vue'
17
+ import { findNextAndPrevRoute } from ' ../utils'
18
+
19
+ export default {
20
+ components: {
21
+ CLink,
22
+ CFlex
23
+ },
24
+ data : () => ({
25
+ prev: ' ' ,
26
+ next: ' '
27
+ }),
28
+ watch: {
29
+ $route (to, from) {
30
+ const { prev , next } = findNextAndPrevRoute (to .path , this .$router .options .routes )
31
+
32
+ this .prev = prev
33
+ this .next = next
34
+ }
35
+ },
36
+ created () {
37
+ const { prev , next } = findNextAndPrevRoute (this .$route .path , this .$router .options .routes )
38
+
39
+ this .prev = prev
40
+ this .next = next
41
+ }
42
+ }
7
43
</script >
8
44
9
- <style >
10
- </style >
45
+ <style ></style >
Original file line number Diff line number Diff line change 28
28
</keep-alive >
29
29
<Footer v-if =" $route.path === '/'" />
30
30
<FileContributors />
31
+ <BottomNavigationLink v-if =" $route.path !== '/'" />
31
32
</CBox >
32
33
</CFlex >
33
34
</CBox >
@@ -53,6 +54,7 @@ import Navbar from '../components/Navbar'
53
54
import Sidebar from ' ../components/Sidebar'
54
55
import Footer from ' ../components/Footer'
55
56
import FileContributors from ' ../components/FileContributors'
57
+ import BottomNavigationLink from ' ../components/BottomNavigationLink'
56
58
57
59
// import { stringToUrl } from '../utils'
58
60
@@ -68,7 +70,8 @@ export default {
68
70
Sidebar,
69
71
Footer,
70
72
CReset,
71
- CFlex
73
+ CFlex,
74
+ BottomNavigationLink
72
75
},
73
76
data () {
74
77
return {
Original file line number Diff line number Diff line change @@ -17,3 +17,12 @@ export const removeHyphenFromString = (hyphenatedString) => {
17
17
const str = hyphenatedString . split ( '-' )
18
18
return str . join ( ' ' )
19
19
}
20
+
21
+ export const findNextAndPrevRoute = ( path , routes ) => {
22
+ const currentRouteIndex = routes . map ( route => route . path ) . indexOf ( path )
23
+
24
+ const nextPageLink = routes [ currentRouteIndex + 1 ]
25
+ const prevPageLink = routes [ currentRouteIndex - 1 ]
26
+
27
+ return { prev : prevPageLink . path , next : nextPageLink . path }
28
+ }
You can’t perform that action at this time.
0 commit comments