Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit d5d53fd

Browse files
committed
feat: add conditional rendering for links
1 parent 74f4934 commit d5d53fd

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

packages/chakra-ui-docs/components/BottomNavigationLink.vue renamed to packages/chakra-ui-docs/components/BottomLink.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<template>
22
<div>
33
<CFlex justify="space-between">
4-
<CLink as="router-link" :v-show="prev !== ''" :to="prev">
5-
Prev
6-
</CLink>
4+
<div>
5+
<CLink as="router-link" :to="prev">
6+
{{ prev == '' ? "" : "Prev" }}
7+
</CLink>
8+
</div>
79

8-
<CLink as="router-link" :v-show="next !== ''" :to="next">
9-
Next
10+
<CLink as="router-link" :to="next">
11+
{{ next == '' ? "": "Next" }}
1012
</CLink>
1113
</CFlex>
1214
</div>

packages/chakra-ui-docs/layouts/default.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</keep-alive>
2929
<Footer v-if="$route.path === '/'" />
3030
<FileContributors />
31-
<BottomNavigationLink v-if="$route.path !== '/'" />
31+
<BottomLink v-if="$route.path !== '/'" />
3232
</CBox>
3333
</CFlex>
3434
</CBox>
@@ -54,7 +54,7 @@ import Navbar from '../components/Navbar'
5454
import Sidebar from '../components/Sidebar'
5555
import Footer from '../components/Footer'
5656
import FileContributors from '../components/FileContributors'
57-
import BottomNavigationLink from '../components/BottomNavigationLink'
57+
import BottomLink from '../components/BottomLink'
5858
5959
// import { stringToUrl } from '../utils'
6060
@@ -71,7 +71,7 @@ export default {
7171
Footer,
7272
CReset,
7373
CFlex,
74-
BottomNavigationLink
74+
BottomLink
7575
},
7676
data () {
7777
return {

packages/chakra-ui-docs/utils/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ export const findNextAndPrevRoute = (path, routes) => {
2424
const nextPageLink = routes[currentRouteIndex + 1]
2525
const prevPageLink = routes[currentRouteIndex - 1]
2626

27-
return { prev: prevPageLink.path, next: nextPageLink.path }
27+
return { prev: prevPageLink ? prevPageLink.path : '', next: nextPageLink ? nextPageLink.path : '' }
2828
}

0 commit comments

Comments
 (0)