mirror of https://github.com/vuejs/vitepress
feat: add prev/next links (#56)
* feat: set Prev/Next to page data * feat: set links at the bottom of page * feat: hide next/prev links when themeConfig expressly set falsepull/77/head
parent
5419abdcc6
commit
f52b1d576b
@ -0,0 +1,22 @@
|
|||||||
|
import { defineComponent, computed } from 'vue'
|
||||||
|
import { usePageData } from 'vitepress'
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
setup() {
|
||||||
|
const pageData = usePageData()
|
||||||
|
const next = computed(() => {
|
||||||
|
return pageData.value.next
|
||||||
|
})
|
||||||
|
const prev = computed(() => {
|
||||||
|
return pageData.value.prev
|
||||||
|
})
|
||||||
|
const hasLinks = computed(() => {
|
||||||
|
return !!next || !!prev
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
next,
|
||||||
|
prev,
|
||||||
|
hasLinks
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,25 @@
|
|||||||
|
<template>
|
||||||
|
<div v-if="hasLinks" class="links-wrapper">
|
||||||
|
<div class="prev-link">
|
||||||
|
<div v-if="prev">
|
||||||
|
← <a :href="prev.link">{{prev.text}}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="next-link">
|
||||||
|
<div v-if="next">
|
||||||
|
<a :href="next.link">{{next.text}}</a> →
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./NextAndPrevLinks"></script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.links-wrapper {
|
||||||
|
padding-top: 1rem;
|
||||||
|
padding-bottom: 1rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in new issue