add page navigation
This commit is contained in:
58
docs/src/components/PageNavigation/index.vue
Normal file
58
docs/src/components/PageNavigation/index.vue
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<template>
|
||||||
|
<nav class="page-navigation">
|
||||||
|
<div class="page-navigation__previous">
|
||||||
|
<g-link
|
||||||
|
class="page-navigation__link"
|
||||||
|
exact
|
||||||
|
:to="previousPage.link"
|
||||||
|
v-if="previousPage"
|
||||||
|
>
|
||||||
|
← {{ previousPage.title }}
|
||||||
|
</g-link>
|
||||||
|
</div>
|
||||||
|
<div class="page-navigation__next">
|
||||||
|
<g-link
|
||||||
|
class="page-navigation__link"
|
||||||
|
exact
|
||||||
|
:to="nextPage.link"
|
||||||
|
v-if="nextPage"
|
||||||
|
>
|
||||||
|
{{ nextPage.title }} →
|
||||||
|
</g-link>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import linkGroups from '@/data/links.yaml'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
linkGroups,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
items() {
|
||||||
|
return this.linkGroups.reduce((acc, group) => (acc.push(...group.items), acc), [])
|
||||||
|
},
|
||||||
|
|
||||||
|
currentIndex() {
|
||||||
|
return this.items.findIndex(item => {
|
||||||
|
return item.link.replace(/\/$/, '') === this.$route.path.replace(/\/$/, '')
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
nextPage() {
|
||||||
|
return this.items[this.currentIndex + 1]
|
||||||
|
},
|
||||||
|
|
||||||
|
previousPage() {
|
||||||
|
return this.items[this.currentIndex - 1]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" src="./style.scss" scoped></style>
|
||||||
5
docs/src/components/PageNavigation/style.scss
Normal file
5
docs/src/components/PageNavigation/style.scss
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.page-navigation {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 3rem 0;
|
||||||
|
}
|
||||||
@@ -72,10 +72,6 @@ a {
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.is-active {
|
.is-active {
|
||||||
background: black;
|
background: black;
|
||||||
color: white;
|
color: white;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
<main class="app__main">
|
<main class="app__main">
|
||||||
<slot/>
|
<slot/>
|
||||||
|
<page-navigation />
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -43,13 +44,18 @@ query {
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import linkGroups from '@/data/links.yaml'
|
import linkGroups from '@/data/links.yaml'
|
||||||
|
import PageNavigation from '@/components/PageNavigation'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
PageNavigation,
|
||||||
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
linkGroups
|
linkGroups,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user